4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static enum rte_cryptodev_type gbl_cryptodev_type;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_cryptodev_config conf;
71 struct rte_cryptodev_qp_conf qp_conf;
73 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
74 uint8_t valid_dev_count;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
80 struct rte_crypto_sym_xform aead_xform;
82 struct rte_cryptodev_sym_session *sess;
84 struct rte_crypto_op *op;
86 struct rte_mbuf *obuf, *ibuf;
91 #define ALIGN_POW2_ROUNDUP(num, align) \
92 (((num) + (align) - 1) & ~((align) - 1))
95 * Forward declarations.
98 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
99 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
103 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
104 struct crypto_unittest_params *ut_params,
105 struct crypto_testsuite_params *ts_param,
106 const uint8_t *cipher,
107 const uint8_t *digest,
110 static struct rte_mbuf *
111 setup_test_string(struct rte_mempool *mpool,
112 const char *string, size_t len, uint8_t blocksize)
114 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
115 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
117 memset(m->buf_addr, 0, m->buf_len);
119 char *dst = rte_pktmbuf_append(m, t_len);
126 rte_memcpy(dst, string, t_len);
128 memset(dst, 0, t_len);
134 /* Get number of bytes in X bits (rounding up) */
136 ceil_byte_length(uint32_t num_bits)
139 return ((num_bits >> 3) + 1);
141 return (num_bits >> 3);
144 static struct rte_crypto_op *
145 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
147 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
148 printf("Error sending packet for encryption");
154 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
160 static struct crypto_testsuite_params testsuite_params = { NULL };
161 static struct crypto_unittest_params unittest_params;
164 testsuite_setup(void)
166 struct crypto_testsuite_params *ts_params = &testsuite_params;
167 struct rte_cryptodev_info info;
168 uint32_t i = 0, nb_devs, dev_id;
172 memset(ts_params, 0, sizeof(*ts_params));
174 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
175 if (ts_params->mbuf_pool == NULL) {
176 /* Not already created so create */
177 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
179 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
181 if (ts_params->mbuf_pool == NULL) {
182 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
187 ts_params->large_mbuf_pool = rte_mempool_lookup(
188 "CRYPTO_LARGE_MBUFPOOL");
189 if (ts_params->large_mbuf_pool == NULL) {
190 /* Not already created so create */
191 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
192 "CRYPTO_LARGE_MBUFPOOL",
195 if (ts_params->large_mbuf_pool == NULL) {
197 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
202 ts_params->op_mpool = rte_crypto_op_pool_create(
203 "MBUF_CRYPTO_SYM_OP_POOL",
204 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
205 NUM_MBUFS, MBUF_CACHE_SIZE,
207 sizeof(struct rte_crypto_sym_xform) +
210 if (ts_params->op_mpool == NULL) {
211 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
215 /* Create an AESNI MB device if required */
216 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
217 #ifndef RTE_LIBRTE_PMD_AESNI_MB
218 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
219 " enabled in config file to run this testsuite.\n");
222 nb_devs = rte_cryptodev_count_devtype(
223 RTE_CRYPTODEV_AESNI_MB_PMD);
226 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
228 TEST_ASSERT(ret == 0,
229 "Failed to create instance of"
231 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
235 /* Create an AESNI GCM device if required */
236 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
237 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
238 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
239 " enabled in config file to run this testsuite.\n");
242 nb_devs = rte_cryptodev_count_devtype(
243 RTE_CRYPTODEV_AESNI_GCM_PMD);
245 TEST_ASSERT_SUCCESS(rte_vdev_init(
246 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
247 "Failed to create instance of"
249 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
253 /* Create a SNOW 3G device if required */
254 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
255 #ifndef RTE_LIBRTE_PMD_SNOW3G
256 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
257 " enabled in config file to run this testsuite.\n");
260 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
262 TEST_ASSERT_SUCCESS(rte_vdev_init(
263 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
264 "Failed to create instance of"
266 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
270 /* Create a KASUMI device if required */
271 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
272 #ifndef RTE_LIBRTE_PMD_KASUMI
273 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
274 " enabled in config file to run this testsuite.\n");
277 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
279 TEST_ASSERT_SUCCESS(rte_vdev_init(
280 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
281 "Failed to create instance of"
283 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
287 /* Create a ZUC device if required */
288 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
289 #ifndef RTE_LIBRTE_PMD_ZUC
290 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
291 " enabled in config file to run this testsuite.\n");
294 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
296 TEST_ASSERT_SUCCESS(rte_vdev_init(
297 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
298 "Failed to create instance of"
300 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
304 /* Create a NULL device if required */
305 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
306 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
307 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
308 " enabled in config file to run this testsuite.\n");
311 nb_devs = rte_cryptodev_count_devtype(
312 RTE_CRYPTODEV_NULL_PMD);
315 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
317 TEST_ASSERT(ret == 0,
318 "Failed to create instance of"
320 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
324 /* Create an OPENSSL device if required */
325 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
326 #ifndef RTE_LIBRTE_PMD_OPENSSL
327 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
328 " enabled in config file to run this testsuite.\n");
331 nb_devs = rte_cryptodev_count_devtype(
332 RTE_CRYPTODEV_OPENSSL_PMD);
335 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
338 TEST_ASSERT(ret == 0, "Failed to create "
339 "instance of pmd : %s",
340 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
344 /* Create a ARMv8 device if required */
345 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
346 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
347 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
348 " enabled in config file to run this testsuite.\n");
351 nb_devs = rte_cryptodev_count_devtype(
352 RTE_CRYPTODEV_ARMV8_PMD);
355 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
358 TEST_ASSERT(ret == 0, "Failed to create "
359 "instance of pmd : %s",
360 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
364 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
365 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
367 #ifndef RTE_LIBRTE_PMD_AESNI_MB
368 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
369 " enabled in config file to run this testsuite.\n");
372 nb_devs = rte_cryptodev_count_devtype(
373 RTE_CRYPTODEV_SCHEDULER_PMD);
376 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
379 TEST_ASSERT(ret == 0,
380 "Failed to create instance %u of"
382 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
385 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
387 #ifndef RTE_LIBRTE_PMD_QAT
388 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
389 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
390 "in config file to run this testsuite.\n");
395 nb_devs = rte_cryptodev_count();
397 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
401 /* Create list of valid crypto devs */
402 for (i = 0; i < nb_devs; i++) {
403 rte_cryptodev_info_get(i, &info);
404 if (info.dev_type == gbl_cryptodev_type)
405 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
408 if (ts_params->valid_dev_count < 1)
411 /* Set up all the qps on the first of the valid devices found */
413 dev_id = ts_params->valid_devs[0];
415 rte_cryptodev_info_get(dev_id, &info);
417 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
418 ts_params->conf.socket_id = SOCKET_ID_ANY;
419 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
421 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
423 "Failed to configure cryptodev %u with %u qps",
424 dev_id, ts_params->conf.nb_queue_pairs);
426 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
428 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
429 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
430 dev_id, qp_id, &ts_params->qp_conf,
431 rte_cryptodev_socket_id(dev_id)),
432 "Failed to setup queue pair %u on cryptodev %u",
440 testsuite_teardown(void)
442 struct crypto_testsuite_params *ts_params = &testsuite_params;
444 if (ts_params->mbuf_pool != NULL) {
445 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
446 rte_mempool_avail_count(ts_params->mbuf_pool));
449 if (ts_params->op_mpool != NULL) {
450 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
451 rte_mempool_avail_count(ts_params->op_mpool));
459 struct crypto_testsuite_params *ts_params = &testsuite_params;
460 struct crypto_unittest_params *ut_params = &unittest_params;
464 /* Clear unit test parameters before running test */
465 memset(ut_params, 0, sizeof(*ut_params));
467 /* Reconfigure device to default parameters */
468 ts_params->conf.socket_id = SOCKET_ID_ANY;
469 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
471 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
473 "Failed to configure cryptodev %u",
474 ts_params->valid_devs[0]);
476 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
477 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
478 ts_params->valid_devs[0], qp_id,
480 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
481 "Failed to setup queue pair %u on cryptodev %u",
482 qp_id, ts_params->valid_devs[0]);
486 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
488 /* Start the device */
489 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
490 "Failed to start cryptodev %u",
491 ts_params->valid_devs[0]);
499 struct crypto_testsuite_params *ts_params = &testsuite_params;
500 struct crypto_unittest_params *ut_params = &unittest_params;
501 struct rte_cryptodev_stats stats;
503 /* free crypto session structure */
504 if (ut_params->sess) {
505 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
507 ut_params->sess = NULL;
510 /* free crypto operation structure */
512 rte_crypto_op_free(ut_params->op);
515 * free mbuf - both obuf and ibuf are usually the same,
516 * so check if they point at the same address is necessary,
517 * to avoid freeing the mbuf twice.
519 if (ut_params->obuf) {
520 rte_pktmbuf_free(ut_params->obuf);
521 if (ut_params->ibuf == ut_params->obuf)
525 if (ut_params->ibuf) {
526 rte_pktmbuf_free(ut_params->ibuf);
530 if (ts_params->mbuf_pool != NULL)
531 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
532 rte_mempool_avail_count(ts_params->mbuf_pool));
534 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
536 /* Stop the device */
537 rte_cryptodev_stop(ts_params->valid_devs[0]);
541 test_device_configure_invalid_dev_id(void)
543 struct crypto_testsuite_params *ts_params = &testsuite_params;
544 uint16_t dev_id, num_devs = 0;
546 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
547 "Need at least %d devices for test", 1);
549 /* valid dev_id values */
550 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
552 /* Stop the device in case it's started so it can be configured */
553 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
555 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
556 "Failed test for rte_cryptodev_configure: "
557 "invalid dev_num %u", dev_id);
559 /* invalid dev_id values */
562 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
563 "Failed test for rte_cryptodev_configure: "
564 "invalid dev_num %u", dev_id);
568 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
569 "Failed test for rte_cryptodev_configure:"
570 "invalid dev_num %u", dev_id);
576 test_device_configure_invalid_queue_pair_ids(void)
578 struct crypto_testsuite_params *ts_params = &testsuite_params;
579 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
581 /* Stop the device in case it's started so it can be configured */
582 rte_cryptodev_stop(ts_params->valid_devs[0]);
584 /* valid - one queue pairs */
585 ts_params->conf.nb_queue_pairs = 1;
587 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
589 "Failed to configure cryptodev: dev_id %u, qp_id %u",
590 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
593 /* valid - max value queue pairs */
594 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
596 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
598 "Failed to configure cryptodev: dev_id %u, qp_id %u",
599 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
602 /* invalid - zero queue pairs */
603 ts_params->conf.nb_queue_pairs = 0;
605 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
607 "Failed test for rte_cryptodev_configure, dev_id %u,"
609 ts_params->valid_devs[0],
610 ts_params->conf.nb_queue_pairs);
613 /* invalid - max value supported by field queue pairs */
614 ts_params->conf.nb_queue_pairs = UINT16_MAX;
616 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
618 "Failed test for rte_cryptodev_configure, dev_id %u,"
620 ts_params->valid_devs[0],
621 ts_params->conf.nb_queue_pairs);
624 /* invalid - max value + 1 queue pairs */
625 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
627 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
629 "Failed test for rte_cryptodev_configure, dev_id %u,"
631 ts_params->valid_devs[0],
632 ts_params->conf.nb_queue_pairs);
634 /* revert to original testsuite value */
635 ts_params->conf.nb_queue_pairs = orig_nb_qps;
641 test_queue_pair_descriptor_setup(void)
643 struct crypto_testsuite_params *ts_params = &testsuite_params;
644 struct rte_cryptodev_info dev_info;
645 struct rte_cryptodev_qp_conf qp_conf = {
646 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
651 /* Stop the device in case it's started so it can be configured */
652 rte_cryptodev_stop(ts_params->valid_devs[0]);
655 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
657 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
659 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
660 &ts_params->conf), "Failed to configure cryptodev %u",
661 ts_params->valid_devs[0]);
665 * Test various ring sizes on this device. memzones can't be
666 * freed so are re-used if ring is released and re-created.
668 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
670 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
671 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
672 ts_params->valid_devs[0], qp_id, &qp_conf,
673 rte_cryptodev_socket_id(
674 ts_params->valid_devs[0])),
676 "rte_cryptodev_queue_pair_setup: num_inflights "
677 "%u on qp %u on cryptodev %u",
678 qp_conf.nb_descriptors, qp_id,
679 ts_params->valid_devs[0]);
682 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
684 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
685 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
686 ts_params->valid_devs[0], qp_id, &qp_conf,
687 rte_cryptodev_socket_id(
688 ts_params->valid_devs[0])),
690 " rte_cryptodev_queue_pair_setup: num_inflights"
691 " %u on qp %u on cryptodev %u",
692 qp_conf.nb_descriptors, qp_id,
693 ts_params->valid_devs[0]);
696 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
698 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
699 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
700 ts_params->valid_devs[0], qp_id, &qp_conf,
701 rte_cryptodev_socket_id(
702 ts_params->valid_devs[0])),
704 "rte_cryptodev_queue_pair_setup: num_inflights"
705 " %u on qp %u on cryptodev %u",
706 qp_conf.nb_descriptors, qp_id,
707 ts_params->valid_devs[0]);
710 /* invalid number of descriptors - max supported + 2 */
711 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
713 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
714 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
715 ts_params->valid_devs[0], qp_id, &qp_conf,
716 rte_cryptodev_socket_id(
717 ts_params->valid_devs[0])),
718 "Unexpectedly passed test for "
719 "rte_cryptodev_queue_pair_setup:"
720 "num_inflights %u on qp %u on cryptodev %u",
721 qp_conf.nb_descriptors, qp_id,
722 ts_params->valid_devs[0]);
725 /* invalid number of descriptors - max value of parameter */
726 qp_conf.nb_descriptors = UINT32_MAX-1;
728 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
729 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
730 ts_params->valid_devs[0], qp_id, &qp_conf,
731 rte_cryptodev_socket_id(
732 ts_params->valid_devs[0])),
733 "Unexpectedly passed test for "
734 "rte_cryptodev_queue_pair_setup:"
735 "num_inflights %u on qp %u on cryptodev %u",
736 qp_conf.nb_descriptors, qp_id,
737 ts_params->valid_devs[0]);
740 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
742 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
743 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
744 ts_params->valid_devs[0], qp_id, &qp_conf,
745 rte_cryptodev_socket_id(
746 ts_params->valid_devs[0])),
748 " rte_cryptodev_queue_pair_setup:"
749 "num_inflights %u on qp %u on cryptodev %u",
750 qp_conf.nb_descriptors, qp_id,
751 ts_params->valid_devs[0]);
754 /* invalid number of descriptors - max supported + 1 */
755 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
757 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
758 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
759 ts_params->valid_devs[0], qp_id, &qp_conf,
760 rte_cryptodev_socket_id(
761 ts_params->valid_devs[0])),
762 "Unexpectedly passed test for "
763 "rte_cryptodev_queue_pair_setup:"
764 "num_inflights %u on qp %u on cryptodev %u",
765 qp_conf.nb_descriptors, qp_id,
766 ts_params->valid_devs[0]);
769 /* test invalid queue pair id */
770 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
772 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
774 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
775 ts_params->valid_devs[0],
777 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
778 "Failed test for rte_cryptodev_queue_pair_setup:"
779 "invalid qp %u on cryptodev %u",
780 qp_id, ts_params->valid_devs[0]);
782 qp_id = 0xffff; /*invalid*/
784 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
785 ts_params->valid_devs[0],
787 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
788 "Failed test for rte_cryptodev_queue_pair_setup:"
789 "invalid qp %u on cryptodev %u",
790 qp_id, ts_params->valid_devs[0]);
795 /* ***** Plaintext data for tests ***** */
797 const char catch_22_quote_1[] =
798 "There was only one catch and that was Catch-22, which "
799 "specified that a concern for one's safety in the face of "
800 "dangers that were real and immediate was the process of a "
801 "rational mind. Orr was crazy and could be grounded. All he "
802 "had to do was ask; and as soon as he did, he would no longer "
803 "be crazy and would have to fly more missions. Orr would be "
804 "crazy to fly more missions and sane if he didn't, but if he "
805 "was sane he had to fly them. If he flew them he was crazy "
806 "and didn't have to; but if he didn't want to he was sane and "
807 "had to. Yossarian was moved very deeply by the absolute "
808 "simplicity of this clause of Catch-22 and let out a "
809 "respectful whistle. \"That's some catch, that Catch-22\", he "
810 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
812 const char catch_22_quote[] =
813 "What a lousy earth! He wondered how many people were "
814 "destitute that same night even in his own prosperous country, "
815 "how many homes were shanties, how many husbands were drunk "
816 "and wives socked, and how many children were bullied, abused, "
817 "or abandoned. How many families hungered for food they could "
818 "not afford to buy? How many hearts were broken? How many "
819 "suicides would take place that same night, how many people "
820 "would go insane? How many cockroaches and landlords would "
821 "triumph? How many winners were losers, successes failures, "
822 "and rich men poor men? How many wise guys were stupid? How "
823 "many happy endings were unhappy endings? How many honest men "
824 "were liars, brave men cowards, loyal men traitors, how many "
825 "sainted men were corrupt, how many people in positions of "
826 "trust had sold their souls to bodyguards, how many had never "
827 "had souls? How many straight-and-narrow paths were crooked "
828 "paths? How many best families were worst families and how "
829 "many good people were bad people? When you added them all up "
830 "and then subtracted, you might be left with only the children, "
831 "and perhaps with Albert Einstein and an old violinist or "
832 "sculptor somewhere.";
834 #define QUOTE_480_BYTES (480)
835 #define QUOTE_512_BYTES (512)
836 #define QUOTE_768_BYTES (768)
837 #define QUOTE_1024_BYTES (1024)
841 /* ***** SHA1 Hash Tests ***** */
843 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
845 static uint8_t hmac_sha1_key[] = {
846 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
847 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
848 0xDE, 0xF4, 0xDE, 0xAD };
850 /* ***** SHA224 Hash Tests ***** */
852 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
855 /* ***** AES-CBC Cipher Tests ***** */
857 #define CIPHER_KEY_LENGTH_AES_CBC (16)
858 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
860 static uint8_t aes_cbc_key[] = {
861 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
862 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
864 static uint8_t aes_cbc_iv[] = {
865 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
866 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
869 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
871 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
872 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
873 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
874 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
875 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
876 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
877 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
878 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
879 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
880 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
881 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
882 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
883 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
884 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
885 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
886 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
887 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
888 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
889 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
890 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
891 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
892 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
893 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
894 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
895 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
896 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
897 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
898 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
899 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
900 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
901 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
902 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
903 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
904 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
905 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
906 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
907 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
908 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
909 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
910 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
911 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
912 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
913 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
914 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
915 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
916 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
917 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
918 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
919 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
920 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
921 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
922 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
923 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
924 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
925 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
926 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
927 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
928 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
929 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
930 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
931 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
932 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
933 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
934 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
935 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
938 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
939 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
940 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
941 0x18, 0x8c, 0x1d, 0x32
945 /* Multisession Vector context Test */
947 static uint8_t ms_aes_cbc_key0[] = {
948 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
949 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
952 static uint8_t ms_aes_cbc_iv0[] = {
953 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
954 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
957 static const uint8_t ms_aes_cbc_cipher0[] = {
958 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
959 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
960 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
961 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
962 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
963 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
964 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
965 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
966 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
967 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
968 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
969 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
970 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
971 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
972 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
973 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
974 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
975 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
976 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
977 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
978 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
979 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
980 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
981 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
982 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
983 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
984 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
985 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
986 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
987 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
988 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
989 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
990 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
991 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
992 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
993 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
994 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
995 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
996 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
997 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
998 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
999 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1000 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1001 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1002 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1003 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1004 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1005 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1006 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1007 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1008 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1009 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1010 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1011 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1012 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1013 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1014 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1015 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1016 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1017 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1018 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1019 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1020 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1021 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1025 static uint8_t ms_hmac_key0[] = {
1026 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1027 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1028 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1029 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1030 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1031 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1032 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1033 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1036 static const uint8_t ms_hmac_digest0[] = {
1037 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1038 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1039 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1040 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1041 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1042 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1043 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1044 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1048 /* Begin session 1 */
1050 static uint8_t ms_aes_cbc_key1[] = {
1051 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1052 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1055 static uint8_t ms_aes_cbc_iv1[] = {
1056 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1057 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1060 static const uint8_t ms_aes_cbc_cipher1[] = {
1061 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1062 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1063 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1064 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1065 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1066 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1067 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1068 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1069 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1070 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1071 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1072 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1073 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1074 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1075 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1076 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1077 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1078 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1079 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1080 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1081 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1082 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1083 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1084 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1085 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1086 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1087 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1088 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1089 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1090 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1091 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1092 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1093 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1094 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1095 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1096 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1097 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1098 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1099 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1100 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1101 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1102 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1103 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1104 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1105 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1106 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1107 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1108 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1109 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1110 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1111 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1112 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1113 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1114 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1115 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1116 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1117 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1118 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1119 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1120 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1121 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1122 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1123 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1124 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1128 static uint8_t ms_hmac_key1[] = {
1129 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1130 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1131 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1132 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1133 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1134 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1135 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1136 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1139 static const uint8_t ms_hmac_digest1[] = {
1140 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1141 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1142 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1143 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1144 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1145 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1146 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1147 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1150 /* Begin Session 2 */
1151 static uint8_t ms_aes_cbc_key2[] = {
1152 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1153 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1156 static uint8_t ms_aes_cbc_iv2[] = {
1157 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1158 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1161 static const uint8_t ms_aes_cbc_cipher2[] = {
1162 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1163 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1164 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1165 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1166 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1167 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1168 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1169 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1170 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1171 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1172 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1173 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1174 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1175 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1176 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1177 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1178 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1179 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1180 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1181 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1182 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1183 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1184 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1185 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1186 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1187 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1188 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1189 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1190 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1191 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1192 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1193 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1194 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1195 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1196 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1197 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1198 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1199 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1200 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1201 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1202 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1203 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1204 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1205 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1206 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1207 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1208 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1209 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1210 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1211 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1212 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1213 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1214 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1215 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1216 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1217 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1218 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1219 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1220 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1221 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1222 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1223 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1224 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1225 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1228 static uint8_t ms_hmac_key2[] = {
1229 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1230 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1231 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1232 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1233 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1234 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1235 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1236 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1239 static const uint8_t ms_hmac_digest2[] = {
1240 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1241 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1242 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1243 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1244 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1245 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1246 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1247 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1254 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1256 struct crypto_testsuite_params *ts_params = &testsuite_params;
1257 struct crypto_unittest_params *ut_params = &unittest_params;
1259 /* Generate test mbuf data and space for digest */
1260 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1261 catch_22_quote, QUOTE_512_BYTES, 0);
1263 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1264 DIGEST_BYTE_LENGTH_SHA1);
1265 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1267 /* Setup Cipher Parameters */
1268 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1269 ut_params->cipher_xform.next = &ut_params->auth_xform;
1271 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1272 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1273 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1274 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1275 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1276 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1278 /* Setup HMAC Parameters */
1279 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1281 ut_params->auth_xform.next = NULL;
1283 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1284 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1285 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1286 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1287 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1289 /* Create crypto session*/
1290 ut_params->sess = rte_cryptodev_sym_session_create(
1291 ts_params->valid_devs[0],
1292 &ut_params->cipher_xform);
1293 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1295 /* Generate crypto op data structure */
1296 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1297 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1298 TEST_ASSERT_NOT_NULL(ut_params->op,
1299 "Failed to allocate symmetric crypto operation struct");
1301 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1303 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1305 /* set crypto operation source mbuf */
1306 sym_op->m_src = ut_params->ibuf;
1308 /* Set crypto operation authentication parameters */
1309 sym_op->auth.digest.data = ut_params->digest;
1310 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1311 ut_params->ibuf, QUOTE_512_BYTES);
1313 sym_op->auth.data.offset = 0;
1314 sym_op->auth.data.length = QUOTE_512_BYTES;
1316 /* Copy IV at the end of the crypto operation */
1317 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1318 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1320 /* Set crypto operation cipher parameters */
1321 sym_op->cipher.data.offset = 0;
1322 sym_op->cipher.data.length = QUOTE_512_BYTES;
1324 /* Process crypto operation */
1325 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1326 ut_params->op), "failed to process sym crypto op");
1328 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1329 "crypto op processing failed");
1332 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1335 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1336 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1338 "ciphertext data not as expected");
1340 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1342 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1343 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1344 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1345 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1346 DIGEST_BYTE_LENGTH_SHA1,
1347 "Generated digest data not as expected");
1349 return TEST_SUCCESS;
1352 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1354 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1356 static uint8_t hmac_sha512_key[] = {
1357 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1358 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1359 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1360 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1361 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1362 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1363 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1364 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1366 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1367 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1368 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1369 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1370 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1371 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1372 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1373 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1374 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1379 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1380 struct crypto_unittest_params *ut_params,
1381 uint8_t *cipher_key,
1385 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1386 struct crypto_unittest_params *ut_params,
1387 struct crypto_testsuite_params *ts_params,
1388 const uint8_t *cipher,
1389 const uint8_t *digest,
1394 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1395 struct crypto_unittest_params *ut_params,
1396 uint8_t *cipher_key,
1400 /* Setup Cipher Parameters */
1401 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1402 ut_params->cipher_xform.next = NULL;
1404 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1405 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1406 ut_params->cipher_xform.cipher.key.data = cipher_key;
1407 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1408 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1409 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1411 /* Setup HMAC Parameters */
1412 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1413 ut_params->auth_xform.next = &ut_params->cipher_xform;
1415 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1416 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1417 ut_params->auth_xform.auth.key.data = hmac_key;
1418 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1419 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1421 return TEST_SUCCESS;
1426 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1427 struct crypto_unittest_params *ut_params,
1428 struct crypto_testsuite_params *ts_params,
1429 const uint8_t *cipher,
1430 const uint8_t *digest,
1433 /* Generate test mbuf data and digest */
1434 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1437 QUOTE_512_BYTES, 0);
1439 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1440 DIGEST_BYTE_LENGTH_SHA512);
1441 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1443 rte_memcpy(ut_params->digest,
1445 DIGEST_BYTE_LENGTH_SHA512);
1447 /* Generate Crypto op data structure */
1448 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1449 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1450 TEST_ASSERT_NOT_NULL(ut_params->op,
1451 "Failed to allocate symmetric crypto operation struct");
1453 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1455 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1457 /* set crypto operation source mbuf */
1458 sym_op->m_src = ut_params->ibuf;
1460 sym_op->auth.digest.data = ut_params->digest;
1461 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1462 ut_params->ibuf, QUOTE_512_BYTES);
1464 sym_op->auth.data.offset = 0;
1465 sym_op->auth.data.length = QUOTE_512_BYTES;
1467 /* Copy IV at the end of the crypto operation */
1468 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1469 iv, CIPHER_IV_LENGTH_AES_CBC);
1471 sym_op->cipher.data.offset = 0;
1472 sym_op->cipher.data.length = QUOTE_512_BYTES;
1474 /* Process crypto operation */
1475 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1476 ut_params->op), "failed to process sym crypto op");
1478 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1479 "crypto op processing failed");
1481 ut_params->obuf = ut_params->op->sym->m_src;
1484 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1485 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1488 "Plaintext data not as expected");
1491 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1492 "Digest verification failed");
1494 return TEST_SUCCESS;
1498 test_AES_cipheronly_mb_all(void)
1500 struct crypto_testsuite_params *ts_params = &testsuite_params;
1503 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1504 ts_params->op_mpool, ts_params->valid_devs[0],
1505 RTE_CRYPTODEV_AESNI_MB_PMD,
1506 BLKCIPHER_AES_CIPHERONLY_TYPE);
1508 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1510 return TEST_SUCCESS;
1514 test_AES_docsis_mb_all(void)
1516 struct crypto_testsuite_params *ts_params = &testsuite_params;
1519 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1520 ts_params->op_mpool, ts_params->valid_devs[0],
1521 RTE_CRYPTODEV_AESNI_MB_PMD,
1522 BLKCIPHER_AES_DOCSIS_TYPE);
1524 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1526 return TEST_SUCCESS;
1530 test_AES_docsis_qat_all(void)
1532 struct crypto_testsuite_params *ts_params = &testsuite_params;
1535 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1536 ts_params->op_mpool, ts_params->valid_devs[0],
1537 RTE_CRYPTODEV_QAT_SYM_PMD,
1538 BLKCIPHER_AES_DOCSIS_TYPE);
1540 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1542 return TEST_SUCCESS;
1546 test_DES_docsis_qat_all(void)
1548 struct crypto_testsuite_params *ts_params = &testsuite_params;
1551 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1552 ts_params->op_mpool, ts_params->valid_devs[0],
1553 RTE_CRYPTODEV_QAT_SYM_PMD,
1554 BLKCIPHER_DES_DOCSIS_TYPE);
1556 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1558 return TEST_SUCCESS;
1562 test_authonly_mb_all(void)
1564 struct crypto_testsuite_params *ts_params = &testsuite_params;
1567 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1568 ts_params->op_mpool, ts_params->valid_devs[0],
1569 RTE_CRYPTODEV_AESNI_MB_PMD,
1570 BLKCIPHER_AUTHONLY_TYPE);
1572 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1574 return TEST_SUCCESS;
1578 test_AES_chain_mb_all(void)
1580 struct crypto_testsuite_params *ts_params = &testsuite_params;
1583 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1584 ts_params->op_mpool, ts_params->valid_devs[0],
1585 RTE_CRYPTODEV_AESNI_MB_PMD,
1586 BLKCIPHER_AES_CHAIN_TYPE);
1588 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1590 return TEST_SUCCESS;
1593 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1596 test_AES_cipheronly_scheduler_all(void)
1598 struct crypto_testsuite_params *ts_params = &testsuite_params;
1601 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1602 ts_params->op_mpool, ts_params->valid_devs[0],
1603 RTE_CRYPTODEV_SCHEDULER_PMD,
1604 BLKCIPHER_AES_CIPHERONLY_TYPE);
1606 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1608 return TEST_SUCCESS;
1612 test_AES_chain_scheduler_all(void)
1614 struct crypto_testsuite_params *ts_params = &testsuite_params;
1617 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1618 ts_params->op_mpool, ts_params->valid_devs[0],
1619 RTE_CRYPTODEV_SCHEDULER_PMD,
1620 BLKCIPHER_AES_CHAIN_TYPE);
1622 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1624 return TEST_SUCCESS;
1628 test_authonly_scheduler_all(void)
1630 struct crypto_testsuite_params *ts_params = &testsuite_params;
1633 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1634 ts_params->op_mpool, ts_params->valid_devs[0],
1635 RTE_CRYPTODEV_SCHEDULER_PMD,
1636 BLKCIPHER_AUTHONLY_TYPE);
1638 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1640 return TEST_SUCCESS;
1643 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1646 test_AES_chain_openssl_all(void)
1648 struct crypto_testsuite_params *ts_params = &testsuite_params;
1651 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1652 ts_params->op_mpool, ts_params->valid_devs[0],
1653 RTE_CRYPTODEV_OPENSSL_PMD,
1654 BLKCIPHER_AES_CHAIN_TYPE);
1656 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1658 return TEST_SUCCESS;
1662 test_AES_cipheronly_openssl_all(void)
1664 struct crypto_testsuite_params *ts_params = &testsuite_params;
1667 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1668 ts_params->op_mpool, ts_params->valid_devs[0],
1669 RTE_CRYPTODEV_OPENSSL_PMD,
1670 BLKCIPHER_AES_CIPHERONLY_TYPE);
1672 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1674 return TEST_SUCCESS;
1678 test_AES_chain_qat_all(void)
1680 struct crypto_testsuite_params *ts_params = &testsuite_params;
1683 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1684 ts_params->op_mpool, ts_params->valid_devs[0],
1685 RTE_CRYPTODEV_QAT_SYM_PMD,
1686 BLKCIPHER_AES_CHAIN_TYPE);
1688 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1690 return TEST_SUCCESS;
1694 test_AES_cipheronly_qat_all(void)
1696 struct crypto_testsuite_params *ts_params = &testsuite_params;
1699 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1700 ts_params->op_mpool, ts_params->valid_devs[0],
1701 RTE_CRYPTODEV_QAT_SYM_PMD,
1702 BLKCIPHER_AES_CIPHERONLY_TYPE);
1704 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1706 return TEST_SUCCESS;
1710 test_AES_chain_dpaa2_sec_all(void)
1712 struct crypto_testsuite_params *ts_params = &testsuite_params;
1715 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1716 ts_params->op_mpool, ts_params->valid_devs[0],
1717 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1718 BLKCIPHER_AES_CHAIN_TYPE);
1720 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1722 return TEST_SUCCESS;
1726 test_AES_cipheronly_dpaa2_sec_all(void)
1728 struct crypto_testsuite_params *ts_params = &testsuite_params;
1731 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1732 ts_params->op_mpool, ts_params->valid_devs[0],
1733 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1734 BLKCIPHER_AES_CIPHERONLY_TYPE);
1736 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1738 return TEST_SUCCESS;
1742 test_authonly_dpaa2_sec_all(void)
1744 struct crypto_testsuite_params *ts_params = &testsuite_params;
1747 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1748 ts_params->op_mpool, ts_params->valid_devs[0],
1749 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1750 BLKCIPHER_AUTHONLY_TYPE);
1752 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1754 return TEST_SUCCESS;
1758 test_authonly_openssl_all(void)
1760 struct crypto_testsuite_params *ts_params = &testsuite_params;
1763 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1764 ts_params->op_mpool, ts_params->valid_devs[0],
1765 RTE_CRYPTODEV_OPENSSL_PMD,
1766 BLKCIPHER_AUTHONLY_TYPE);
1768 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1770 return TEST_SUCCESS;
1774 test_AES_chain_armv8_all(void)
1776 struct crypto_testsuite_params *ts_params = &testsuite_params;
1779 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1780 ts_params->op_mpool, ts_params->valid_devs[0],
1781 RTE_CRYPTODEV_ARMV8_PMD,
1782 BLKCIPHER_AES_CHAIN_TYPE);
1784 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1786 return TEST_SUCCESS;
1789 /* ***** SNOW 3G Tests ***** */
1791 create_wireless_algo_hash_session(uint8_t dev_id,
1792 const uint8_t *key, const uint8_t key_len,
1793 const uint8_t iv_len, const uint8_t auth_len,
1794 enum rte_crypto_auth_operation op,
1795 enum rte_crypto_auth_algorithm algo)
1797 uint8_t hash_key[key_len];
1799 struct crypto_unittest_params *ut_params = &unittest_params;
1801 memcpy(hash_key, key, key_len);
1803 TEST_HEXDUMP(stdout, "key:", key, key_len);
1805 /* Setup Authentication Parameters */
1806 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1807 ut_params->auth_xform.next = NULL;
1809 ut_params->auth_xform.auth.op = op;
1810 ut_params->auth_xform.auth.algo = algo;
1811 ut_params->auth_xform.auth.key.length = key_len;
1812 ut_params->auth_xform.auth.key.data = hash_key;
1813 ut_params->auth_xform.auth.digest_length = auth_len;
1814 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1815 ut_params->auth_xform.auth.iv.length = iv_len;
1816 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1817 &ut_params->auth_xform);
1818 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1823 create_wireless_algo_cipher_session(uint8_t dev_id,
1824 enum rte_crypto_cipher_operation op,
1825 enum rte_crypto_cipher_algorithm algo,
1826 const uint8_t *key, const uint8_t key_len,
1829 uint8_t cipher_key[key_len];
1831 struct crypto_unittest_params *ut_params = &unittest_params;
1833 memcpy(cipher_key, key, key_len);
1835 /* Setup Cipher Parameters */
1836 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1837 ut_params->cipher_xform.next = NULL;
1839 ut_params->cipher_xform.cipher.algo = algo;
1840 ut_params->cipher_xform.cipher.op = op;
1841 ut_params->cipher_xform.cipher.key.data = cipher_key;
1842 ut_params->cipher_xform.cipher.key.length = key_len;
1843 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1844 ut_params->cipher_xform.cipher.iv.length = iv_len;
1846 TEST_HEXDUMP(stdout, "key:", key, key_len);
1848 /* Create Crypto session */
1849 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1852 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1857 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1858 unsigned int cipher_len,
1859 unsigned int cipher_offset)
1861 struct crypto_testsuite_params *ts_params = &testsuite_params;
1862 struct crypto_unittest_params *ut_params = &unittest_params;
1864 /* Generate Crypto op data structure */
1865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1867 TEST_ASSERT_NOT_NULL(ut_params->op,
1868 "Failed to allocate pktmbuf offload");
1870 /* Set crypto operation data parameters */
1871 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1873 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1875 /* set crypto operation source mbuf */
1876 sym_op->m_src = ut_params->ibuf;
1879 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1881 sym_op->cipher.data.length = cipher_len;
1882 sym_op->cipher.data.offset = cipher_offset;
1887 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1888 unsigned int cipher_len,
1889 unsigned int cipher_offset)
1891 struct crypto_testsuite_params *ts_params = &testsuite_params;
1892 struct crypto_unittest_params *ut_params = &unittest_params;
1894 /* Generate Crypto op data structure */
1895 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1896 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1897 TEST_ASSERT_NOT_NULL(ut_params->op,
1898 "Failed to allocate pktmbuf offload");
1900 /* Set crypto operation data parameters */
1901 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1903 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1905 /* set crypto operation source mbuf */
1906 sym_op->m_src = ut_params->ibuf;
1907 sym_op->m_dst = ut_params->obuf;
1910 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1912 sym_op->cipher.data.length = cipher_len;
1913 sym_op->cipher.data.offset = cipher_offset;
1918 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1919 enum rte_crypto_cipher_operation cipher_op,
1920 enum rte_crypto_auth_operation auth_op,
1921 enum rte_crypto_auth_algorithm auth_algo,
1922 enum rte_crypto_cipher_algorithm cipher_algo,
1923 const uint8_t *key, uint8_t key_len,
1924 uint8_t auth_iv_len, uint8_t auth_len,
1925 uint8_t cipher_iv_len)
1928 uint8_t cipher_auth_key[key_len];
1930 struct crypto_unittest_params *ut_params = &unittest_params;
1932 memcpy(cipher_auth_key, key, key_len);
1934 /* Setup Authentication Parameters */
1935 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1936 ut_params->auth_xform.next = NULL;
1938 ut_params->auth_xform.auth.op = auth_op;
1939 ut_params->auth_xform.auth.algo = auth_algo;
1940 ut_params->auth_xform.auth.key.length = key_len;
1941 /* Hash key = cipher key */
1942 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1943 ut_params->auth_xform.auth.digest_length = auth_len;
1944 /* Auth IV will be after cipher IV */
1945 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1946 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1948 /* Setup Cipher Parameters */
1949 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1950 ut_params->cipher_xform.next = &ut_params->auth_xform;
1952 ut_params->cipher_xform.cipher.algo = cipher_algo;
1953 ut_params->cipher_xform.cipher.op = cipher_op;
1954 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1955 ut_params->cipher_xform.cipher.key.length = key_len;
1956 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1957 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1959 TEST_HEXDUMP(stdout, "key:", key, key_len);
1961 /* Create Crypto session*/
1962 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1963 &ut_params->cipher_xform);
1965 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1970 create_wireless_cipher_auth_session(uint8_t dev_id,
1971 enum rte_crypto_cipher_operation cipher_op,
1972 enum rte_crypto_auth_operation auth_op,
1973 enum rte_crypto_auth_algorithm auth_algo,
1974 enum rte_crypto_cipher_algorithm cipher_algo,
1975 const struct wireless_test_data *tdata)
1977 const uint8_t key_len = tdata->key.len;
1978 uint8_t cipher_auth_key[key_len];
1980 struct crypto_unittest_params *ut_params = &unittest_params;
1981 const uint8_t *key = tdata->key.data;
1982 const uint8_t auth_len = tdata->digest.len;
1983 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1984 uint8_t auth_iv_len = tdata->auth_iv.len;
1986 memcpy(cipher_auth_key, key, key_len);
1988 /* Setup Authentication Parameters */
1989 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1990 ut_params->auth_xform.next = NULL;
1992 ut_params->auth_xform.auth.op = auth_op;
1993 ut_params->auth_xform.auth.algo = auth_algo;
1994 ut_params->auth_xform.auth.key.length = key_len;
1995 /* Hash key = cipher key */
1996 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1997 ut_params->auth_xform.auth.digest_length = auth_len;
1998 /* Auth IV will be after cipher IV */
1999 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2000 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2002 /* Setup Cipher Parameters */
2003 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2004 ut_params->cipher_xform.next = &ut_params->auth_xform;
2006 ut_params->cipher_xform.cipher.algo = cipher_algo;
2007 ut_params->cipher_xform.cipher.op = cipher_op;
2008 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2009 ut_params->cipher_xform.cipher.key.length = key_len;
2010 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2011 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2014 TEST_HEXDUMP(stdout, "key:", key, key_len);
2016 /* Create Crypto session*/
2017 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2018 &ut_params->cipher_xform);
2020 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2025 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2026 const struct wireless_test_data *tdata)
2028 return create_wireless_cipher_auth_session(dev_id,
2029 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2030 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2031 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2035 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2036 enum rte_crypto_cipher_operation cipher_op,
2037 enum rte_crypto_auth_operation auth_op,
2038 enum rte_crypto_auth_algorithm auth_algo,
2039 enum rte_crypto_cipher_algorithm cipher_algo,
2040 const uint8_t *key, const uint8_t key_len,
2041 uint8_t auth_iv_len, uint8_t auth_len,
2042 uint8_t cipher_iv_len)
2044 uint8_t auth_cipher_key[key_len];
2046 struct crypto_unittest_params *ut_params = &unittest_params;
2048 memcpy(auth_cipher_key, key, key_len);
2050 /* Setup Authentication Parameters */
2051 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2052 ut_params->auth_xform.auth.op = auth_op;
2053 ut_params->auth_xform.next = &ut_params->cipher_xform;
2054 ut_params->auth_xform.auth.algo = auth_algo;
2055 ut_params->auth_xform.auth.key.length = key_len;
2056 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2057 ut_params->auth_xform.auth.digest_length = auth_len;
2058 /* Auth IV will be after cipher IV */
2059 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2060 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2062 /* Setup Cipher Parameters */
2063 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2064 ut_params->cipher_xform.next = NULL;
2065 ut_params->cipher_xform.cipher.algo = cipher_algo;
2066 ut_params->cipher_xform.cipher.op = cipher_op;
2067 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2068 ut_params->cipher_xform.cipher.key.length = key_len;
2069 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2070 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2072 TEST_HEXDUMP(stdout, "key:", key, key_len);
2074 /* Create Crypto session*/
2075 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2076 &ut_params->auth_xform);
2078 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2084 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2085 unsigned int auth_tag_len,
2086 const uint8_t *iv, unsigned int iv_len,
2087 unsigned int data_pad_len,
2088 enum rte_crypto_auth_operation op,
2089 unsigned int auth_len, unsigned int auth_offset)
2091 struct crypto_testsuite_params *ts_params = &testsuite_params;
2093 struct crypto_unittest_params *ut_params = &unittest_params;
2095 /* Generate Crypto op data structure */
2096 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2097 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2098 TEST_ASSERT_NOT_NULL(ut_params->op,
2099 "Failed to allocate pktmbuf offload");
2101 /* Set crypto operation data parameters */
2102 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2104 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2106 /* set crypto operation source mbuf */
2107 sym_op->m_src = ut_params->ibuf;
2110 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2113 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2114 ut_params->ibuf, auth_tag_len);
2116 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2117 "no room to append auth tag");
2118 ut_params->digest = sym_op->auth.digest.data;
2119 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2120 ut_params->ibuf, data_pad_len);
2121 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2122 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2124 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2126 TEST_HEXDUMP(stdout, "digest:",
2127 sym_op->auth.digest.data,
2130 sym_op->auth.data.length = auth_len;
2131 sym_op->auth.data.offset = auth_offset;
2137 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2138 enum rte_crypto_auth_operation op)
2140 struct crypto_testsuite_params *ts_params = &testsuite_params;
2141 struct crypto_unittest_params *ut_params = &unittest_params;
2143 const uint8_t *auth_tag = tdata->digest.data;
2144 const unsigned int auth_tag_len = tdata->digest.len;
2145 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2146 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2148 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2149 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2150 const uint8_t *auth_iv = tdata->auth_iv.data;
2151 const uint8_t auth_iv_len = tdata->auth_iv.len;
2152 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2153 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2155 /* Generate Crypto op data structure */
2156 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2157 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2158 TEST_ASSERT_NOT_NULL(ut_params->op,
2159 "Failed to allocate pktmbuf offload");
2160 /* Set crypto operation data parameters */
2161 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2163 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2165 /* set crypto operation source mbuf */
2166 sym_op->m_src = ut_params->ibuf;
2169 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2170 ut_params->ibuf, auth_tag_len);
2172 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2173 "no room to append auth tag");
2174 ut_params->digest = sym_op->auth.digest.data;
2175 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2176 ut_params->ibuf, data_pad_len);
2177 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2178 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2180 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2182 TEST_HEXDUMP(stdout, "digest:",
2183 sym_op->auth.digest.data,
2186 /* Copy cipher and auth IVs at the end of the crypto operation */
2187 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2189 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2190 iv_ptr += cipher_iv_len;
2191 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2193 sym_op->cipher.data.length = cipher_len;
2194 sym_op->cipher.data.offset = 0;
2195 sym_op->auth.data.length = auth_len;
2196 sym_op->auth.data.offset = 0;
2202 create_zuc_cipher_hash_generate_operation(
2203 const struct wireless_test_data *tdata)
2205 return create_wireless_cipher_hash_operation(tdata,
2206 RTE_CRYPTO_AUTH_OP_GENERATE);
2210 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2211 const unsigned auth_tag_len,
2212 const uint8_t *auth_iv, uint8_t auth_iv_len,
2213 unsigned data_pad_len,
2214 enum rte_crypto_auth_operation op,
2215 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2216 const unsigned cipher_len, const unsigned cipher_offset,
2217 const unsigned auth_len, const unsigned auth_offset)
2219 struct crypto_testsuite_params *ts_params = &testsuite_params;
2220 struct crypto_unittest_params *ut_params = &unittest_params;
2222 /* Generate Crypto op data structure */
2223 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2224 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2225 TEST_ASSERT_NOT_NULL(ut_params->op,
2226 "Failed to allocate pktmbuf offload");
2227 /* Set crypto operation data parameters */
2228 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2230 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2232 /* set crypto operation source mbuf */
2233 sym_op->m_src = ut_params->ibuf;
2236 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2237 ut_params->ibuf, auth_tag_len);
2239 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2240 "no room to append auth tag");
2241 ut_params->digest = sym_op->auth.digest.data;
2242 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2243 ut_params->ibuf, data_pad_len);
2244 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2245 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2247 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2249 TEST_HEXDUMP(stdout, "digest:",
2250 sym_op->auth.digest.data,
2253 /* Copy cipher and auth IVs at the end of the crypto operation */
2254 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2256 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2257 iv_ptr += cipher_iv_len;
2258 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2260 sym_op->cipher.data.length = cipher_len;
2261 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2262 sym_op->auth.data.length = auth_len;
2263 sym_op->auth.data.offset = auth_offset + cipher_offset;
2269 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2270 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2271 const uint8_t *auth_iv, uint8_t auth_iv_len,
2272 unsigned int data_pad_len,
2273 unsigned int cipher_len, unsigned int cipher_offset,
2274 unsigned int auth_len, unsigned int auth_offset)
2276 struct crypto_testsuite_params *ts_params = &testsuite_params;
2277 struct crypto_unittest_params *ut_params = &unittest_params;
2279 /* Generate Crypto op data structure */
2280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2282 TEST_ASSERT_NOT_NULL(ut_params->op,
2283 "Failed to allocate pktmbuf offload");
2285 /* Set crypto operation data parameters */
2286 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2288 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2290 /* set crypto operation source mbuf */
2291 sym_op->m_src = ut_params->ibuf;
2294 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2295 ut_params->ibuf, auth_tag_len);
2297 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2298 "no room to append auth tag");
2300 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2301 ut_params->ibuf, data_pad_len);
2303 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2305 TEST_HEXDUMP(stdout, "digest:",
2306 sym_op->auth.digest.data,
2309 /* Copy cipher and auth IVs at the end of the crypto operation */
2310 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2312 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2313 iv_ptr += cipher_iv_len;
2314 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2316 sym_op->cipher.data.length = cipher_len;
2317 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2319 sym_op->auth.data.length = auth_len;
2320 sym_op->auth.data.offset = auth_offset + cipher_offset;
2326 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2328 struct crypto_testsuite_params *ts_params = &testsuite_params;
2329 struct crypto_unittest_params *ut_params = &unittest_params;
2332 unsigned plaintext_pad_len;
2333 unsigned plaintext_len;
2336 /* Create SNOW 3G session */
2337 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2338 tdata->key.data, tdata->key.len,
2339 tdata->auth_iv.len, tdata->digest.len,
2340 RTE_CRYPTO_AUTH_OP_GENERATE,
2341 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2345 /* alloc mbuf and set payload */
2346 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2348 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2349 rte_pktmbuf_tailroom(ut_params->ibuf));
2351 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2352 /* Append data which is padded to a multiple of */
2353 /* the algorithms block size */
2354 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2355 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2357 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2359 /* Create SNOW 3G operation */
2360 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2361 tdata->auth_iv.data, tdata->auth_iv.len,
2362 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2363 tdata->validAuthLenInBits.len,
2368 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2370 ut_params->obuf = ut_params->op->sym->m_src;
2371 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2372 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2373 + plaintext_pad_len;
2376 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2379 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2380 "SNOW 3G Generated auth tag not as expected");
2386 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2388 struct crypto_testsuite_params *ts_params = &testsuite_params;
2389 struct crypto_unittest_params *ut_params = &unittest_params;
2392 unsigned plaintext_pad_len;
2393 unsigned plaintext_len;
2396 /* Create SNOW 3G session */
2397 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2398 tdata->key.data, tdata->key.len,
2399 tdata->auth_iv.len, tdata->digest.len,
2400 RTE_CRYPTO_AUTH_OP_VERIFY,
2401 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2404 /* alloc mbuf and set payload */
2405 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2407 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2408 rte_pktmbuf_tailroom(ut_params->ibuf));
2410 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2411 /* Append data which is padded to a multiple of */
2412 /* the algorithms block size */
2413 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2414 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2416 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2418 /* Create SNOW 3G operation */
2419 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2421 tdata->auth_iv.data, tdata->auth_iv.len,
2423 RTE_CRYPTO_AUTH_OP_VERIFY,
2424 tdata->validAuthLenInBits.len,
2429 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2431 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2432 ut_params->obuf = ut_params->op->sym->m_src;
2433 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2434 + plaintext_pad_len;
2437 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2446 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2448 struct crypto_testsuite_params *ts_params = &testsuite_params;
2449 struct crypto_unittest_params *ut_params = &unittest_params;
2452 unsigned plaintext_pad_len;
2453 unsigned plaintext_len;
2456 /* Create KASUMI session */
2457 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2458 tdata->key.data, tdata->key.len,
2459 tdata->auth_iv.len, tdata->digest.len,
2460 RTE_CRYPTO_AUTH_OP_GENERATE,
2461 RTE_CRYPTO_AUTH_KASUMI_F9);
2465 /* alloc mbuf and set payload */
2466 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2468 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2469 rte_pktmbuf_tailroom(ut_params->ibuf));
2471 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2472 /* Append data which is padded to a multiple of */
2473 /* the algorithms block size */
2474 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2475 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2477 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2479 /* Create KASUMI operation */
2480 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2481 tdata->auth_iv.data, tdata->auth_iv.len,
2482 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2483 tdata->validAuthLenInBits.len,
2488 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2490 ut_params->obuf = ut_params->op->sym->m_src;
2491 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2492 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2493 + plaintext_pad_len;
2496 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2499 DIGEST_BYTE_LENGTH_KASUMI_F9,
2500 "KASUMI Generated auth tag not as expected");
2506 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2508 struct crypto_testsuite_params *ts_params = &testsuite_params;
2509 struct crypto_unittest_params *ut_params = &unittest_params;
2512 unsigned plaintext_pad_len;
2513 unsigned plaintext_len;
2516 /* Create KASUMI session */
2517 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2518 tdata->key.data, tdata->key.len,
2519 tdata->auth_iv.len, tdata->digest.len,
2520 RTE_CRYPTO_AUTH_OP_VERIFY,
2521 RTE_CRYPTO_AUTH_KASUMI_F9);
2524 /* alloc mbuf and set payload */
2525 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2527 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2528 rte_pktmbuf_tailroom(ut_params->ibuf));
2530 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2531 /* Append data which is padded to a multiple */
2532 /* of the algorithms block size */
2533 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2534 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2536 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2538 /* Create KASUMI operation */
2539 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2541 tdata->auth_iv.data, tdata->auth_iv.len,
2543 RTE_CRYPTO_AUTH_OP_VERIFY,
2544 tdata->validAuthLenInBits.len,
2549 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2551 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2552 ut_params->obuf = ut_params->op->sym->m_src;
2553 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2554 + plaintext_pad_len;
2557 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2566 test_snow3g_hash_generate_test_case_1(void)
2568 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2572 test_snow3g_hash_generate_test_case_2(void)
2574 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2578 test_snow3g_hash_generate_test_case_3(void)
2580 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2584 test_snow3g_hash_generate_test_case_4(void)
2586 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2590 test_snow3g_hash_generate_test_case_5(void)
2592 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2596 test_snow3g_hash_generate_test_case_6(void)
2598 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2602 test_snow3g_hash_verify_test_case_1(void)
2604 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2609 test_snow3g_hash_verify_test_case_2(void)
2611 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2615 test_snow3g_hash_verify_test_case_3(void)
2617 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2621 test_snow3g_hash_verify_test_case_4(void)
2623 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2627 test_snow3g_hash_verify_test_case_5(void)
2629 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2633 test_snow3g_hash_verify_test_case_6(void)
2635 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2639 test_kasumi_hash_generate_test_case_1(void)
2641 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2645 test_kasumi_hash_generate_test_case_2(void)
2647 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2651 test_kasumi_hash_generate_test_case_3(void)
2653 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2657 test_kasumi_hash_generate_test_case_4(void)
2659 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2663 test_kasumi_hash_generate_test_case_5(void)
2665 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2669 test_kasumi_hash_generate_test_case_6(void)
2671 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2675 test_kasumi_hash_verify_test_case_1(void)
2677 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2681 test_kasumi_hash_verify_test_case_2(void)
2683 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2687 test_kasumi_hash_verify_test_case_3(void)
2689 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2693 test_kasumi_hash_verify_test_case_4(void)
2695 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2699 test_kasumi_hash_verify_test_case_5(void)
2701 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2705 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2707 struct crypto_testsuite_params *ts_params = &testsuite_params;
2708 struct crypto_unittest_params *ut_params = &unittest_params;
2711 uint8_t *plaintext, *ciphertext;
2712 unsigned plaintext_pad_len;
2713 unsigned plaintext_len;
2715 /* Create KASUMI session */
2716 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2717 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2718 RTE_CRYPTO_CIPHER_KASUMI_F8,
2719 tdata->key.data, tdata->key.len,
2720 tdata->cipher_iv.len);
2724 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2726 /* Clear mbuf payload */
2727 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2728 rte_pktmbuf_tailroom(ut_params->ibuf));
2730 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2731 /* Append data which is padded to a multiple */
2732 /* of the algorithms block size */
2733 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2734 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2736 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2738 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2740 /* Create KASUMI operation */
2741 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2742 tdata->cipher_iv.len,
2743 tdata->plaintext.len,
2748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2752 ut_params->obuf = ut_params->op->sym->m_dst;
2753 if (ut_params->obuf)
2754 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2756 ciphertext = plaintext;
2758 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2761 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2763 tdata->ciphertext.data,
2764 tdata->validCipherLenInBits.len,
2765 "KASUMI Ciphertext data not as expected");
2770 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2772 struct crypto_testsuite_params *ts_params = &testsuite_params;
2773 struct crypto_unittest_params *ut_params = &unittest_params;
2777 unsigned int plaintext_pad_len;
2778 unsigned int plaintext_len;
2780 uint8_t buffer[10000];
2781 const uint8_t *ciphertext;
2783 struct rte_cryptodev_info dev_info;
2785 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2786 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2787 printf("Device doesn't support scatter-gather. "
2792 /* Create KASUMI session */
2793 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2794 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2795 RTE_CRYPTO_CIPHER_KASUMI_F8,
2796 tdata->key.data, tdata->key.len,
2797 tdata->cipher_iv.len);
2801 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2804 /* Append data which is padded to a multiple */
2805 /* of the algorithms block size */
2806 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2808 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2809 plaintext_pad_len, 10, 0);
2811 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2813 /* Create KASUMI operation */
2814 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2815 tdata->cipher_iv.len,
2816 tdata->plaintext.len,
2821 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2825 ut_params->obuf = ut_params->op->sym->m_dst;
2827 if (ut_params->obuf)
2828 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2829 plaintext_len, buffer);
2831 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2832 plaintext_len, buffer);
2835 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2838 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2840 tdata->ciphertext.data,
2841 tdata->validCipherLenInBits.len,
2842 "KASUMI Ciphertext data not as expected");
2847 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2849 struct crypto_testsuite_params *ts_params = &testsuite_params;
2850 struct crypto_unittest_params *ut_params = &unittest_params;
2853 uint8_t *plaintext, *ciphertext;
2854 unsigned plaintext_pad_len;
2855 unsigned plaintext_len;
2857 /* Create KASUMI session */
2858 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2859 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2860 RTE_CRYPTO_CIPHER_KASUMI_F8,
2861 tdata->key.data, tdata->key.len,
2862 tdata->cipher_iv.len);
2866 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2867 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2869 /* Clear mbuf payload */
2870 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2871 rte_pktmbuf_tailroom(ut_params->ibuf));
2873 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2874 /* Append data which is padded to a multiple */
2875 /* of the algorithms block size */
2876 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2877 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2879 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2880 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2882 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2884 /* Create KASUMI operation */
2885 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2886 tdata->cipher_iv.len,
2887 tdata->plaintext.len,
2892 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2896 ut_params->obuf = ut_params->op->sym->m_dst;
2897 if (ut_params->obuf)
2898 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2900 ciphertext = plaintext;
2902 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2905 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2907 tdata->ciphertext.data,
2908 tdata->validCipherLenInBits.len,
2909 "KASUMI Ciphertext data not as expected");
2914 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2916 struct crypto_testsuite_params *ts_params = &testsuite_params;
2917 struct crypto_unittest_params *ut_params = &unittest_params;
2920 unsigned int plaintext_pad_len;
2921 unsigned int plaintext_len;
2923 const uint8_t *ciphertext;
2924 uint8_t buffer[2048];
2926 struct rte_cryptodev_info dev_info;
2928 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2929 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2930 printf("Device doesn't support scatter-gather. "
2935 /* Create KASUMI session */
2936 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2937 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2938 RTE_CRYPTO_CIPHER_KASUMI_F8,
2939 tdata->key.data, tdata->key.len,
2940 tdata->cipher_iv.len);
2944 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2945 /* Append data which is padded to a multiple */
2946 /* of the algorithms block size */
2947 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2949 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2950 plaintext_pad_len, 10, 0);
2951 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2952 plaintext_pad_len, 3, 0);
2954 /* Append data which is padded to a multiple */
2955 /* of the algorithms block size */
2956 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2958 /* Create KASUMI operation */
2959 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2960 tdata->cipher_iv.len,
2961 tdata->plaintext.len,
2966 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2968 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2970 ut_params->obuf = ut_params->op->sym->m_dst;
2971 if (ut_params->obuf)
2972 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2973 plaintext_pad_len, buffer);
2975 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2976 plaintext_pad_len, buffer);
2979 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2981 tdata->ciphertext.data,
2982 tdata->validCipherLenInBits.len,
2983 "KASUMI Ciphertext data not as expected");
2989 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2991 struct crypto_testsuite_params *ts_params = &testsuite_params;
2992 struct crypto_unittest_params *ut_params = &unittest_params;
2995 uint8_t *ciphertext, *plaintext;
2996 unsigned ciphertext_pad_len;
2997 unsigned ciphertext_len;
2999 /* Create KASUMI session */
3000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3001 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3002 RTE_CRYPTO_CIPHER_KASUMI_F8,
3003 tdata->key.data, tdata->key.len,
3004 tdata->cipher_iv.len);
3008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3009 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3011 /* Clear mbuf payload */
3012 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3013 rte_pktmbuf_tailroom(ut_params->ibuf));
3015 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3016 /* Append data which is padded to a multiple */
3017 /* of the algorithms block size */
3018 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3019 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3020 ciphertext_pad_len);
3021 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3022 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3024 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3026 /* Create KASUMI operation */
3027 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3028 tdata->cipher_iv.len,
3029 tdata->ciphertext.len,
3034 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3036 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3038 ut_params->obuf = ut_params->op->sym->m_dst;
3039 if (ut_params->obuf)
3040 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3042 plaintext = ciphertext;
3044 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3047 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3049 tdata->plaintext.data,
3050 tdata->validCipherLenInBits.len,
3051 "KASUMI Plaintext data not as expected");
3056 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3058 struct crypto_testsuite_params *ts_params = &testsuite_params;
3059 struct crypto_unittest_params *ut_params = &unittest_params;
3062 uint8_t *ciphertext, *plaintext;
3063 unsigned ciphertext_pad_len;
3064 unsigned ciphertext_len;
3066 /* Create KASUMI session */
3067 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3068 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3069 RTE_CRYPTO_CIPHER_KASUMI_F8,
3070 tdata->key.data, tdata->key.len,
3071 tdata->cipher_iv.len);
3075 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3077 /* Clear mbuf payload */
3078 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3079 rte_pktmbuf_tailroom(ut_params->ibuf));
3081 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3082 /* Append data which is padded to a multiple */
3083 /* of the algorithms block size */
3084 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3085 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3086 ciphertext_pad_len);
3087 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3089 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3091 /* Create KASUMI operation */
3092 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3093 tdata->cipher_iv.len,
3094 tdata->ciphertext.len,
3099 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3101 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3103 ut_params->obuf = ut_params->op->sym->m_dst;
3104 if (ut_params->obuf)
3105 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3107 plaintext = ciphertext;
3109 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3112 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3114 tdata->plaintext.data,
3115 tdata->validCipherLenInBits.len,
3116 "KASUMI Plaintext data not as expected");
3121 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3123 struct crypto_testsuite_params *ts_params = &testsuite_params;
3124 struct crypto_unittest_params *ut_params = &unittest_params;
3127 uint8_t *plaintext, *ciphertext;
3128 unsigned plaintext_pad_len;
3129 unsigned plaintext_len;
3131 /* Create SNOW 3G session */
3132 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3133 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3134 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3135 tdata->key.data, tdata->key.len,
3136 tdata->cipher_iv.len);
3140 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3142 /* Clear mbuf payload */
3143 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3144 rte_pktmbuf_tailroom(ut_params->ibuf));
3146 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3147 /* Append data which is padded to a multiple of */
3148 /* the algorithms block size */
3149 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3150 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3152 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3154 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3156 /* Create SNOW 3G operation */
3157 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3158 tdata->cipher_iv.len,
3159 tdata->validCipherLenInBits.len,
3164 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3166 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3168 ut_params->obuf = ut_params->op->sym->m_dst;
3169 if (ut_params->obuf)
3170 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3172 ciphertext = plaintext;
3174 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3177 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3179 tdata->ciphertext.data,
3180 tdata->validDataLenInBits.len,
3181 "SNOW 3G Ciphertext data not as expected");
3187 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3189 struct crypto_testsuite_params *ts_params = &testsuite_params;
3190 struct crypto_unittest_params *ut_params = &unittest_params;
3191 uint8_t *plaintext, *ciphertext;
3194 unsigned plaintext_pad_len;
3195 unsigned plaintext_len;
3197 /* Create SNOW 3G session */
3198 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3199 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3200 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3201 tdata->key.data, tdata->key.len,
3202 tdata->cipher_iv.len);
3206 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3207 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3209 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3210 "Failed to allocate input buffer in mempool");
3211 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3212 "Failed to allocate output buffer in mempool");
3214 /* Clear mbuf payload */
3215 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3216 rte_pktmbuf_tailroom(ut_params->ibuf));
3218 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3219 /* Append data which is padded to a multiple of */
3220 /* the algorithms block size */
3221 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3222 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3224 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3225 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3227 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3229 /* Create SNOW 3G operation */
3230 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3231 tdata->cipher_iv.len,
3232 tdata->validCipherLenInBits.len,
3237 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3239 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3241 ut_params->obuf = ut_params->op->sym->m_dst;
3242 if (ut_params->obuf)
3243 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3245 ciphertext = plaintext;
3247 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3250 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3252 tdata->ciphertext.data,
3253 tdata->validDataLenInBits.len,
3254 "SNOW 3G Ciphertext data not as expected");
3259 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3261 struct crypto_testsuite_params *ts_params = &testsuite_params;
3262 struct crypto_unittest_params *ut_params = &unittest_params;
3265 unsigned int plaintext_pad_len;
3266 unsigned int plaintext_len;
3267 uint8_t buffer[10000];
3268 const uint8_t *ciphertext;
3270 struct rte_cryptodev_info dev_info;
3272 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3273 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3274 printf("Device doesn't support scatter-gather. "
3279 /* Create SNOW 3G session */
3280 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3281 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3282 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3283 tdata->key.data, tdata->key.len,
3284 tdata->cipher_iv.len);
3288 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3289 /* Append data which is padded to a multiple of */
3290 /* the algorithms block size */
3291 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3293 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3294 plaintext_pad_len, 10, 0);
3295 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3296 plaintext_pad_len, 3, 0);
3298 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3299 "Failed to allocate input buffer in mempool");
3300 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3301 "Failed to allocate output buffer in mempool");
3303 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3305 /* Create SNOW 3G operation */
3306 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3307 tdata->cipher_iv.len,
3308 tdata->validCipherLenInBits.len,
3313 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3315 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3317 ut_params->obuf = ut_params->op->sym->m_dst;
3318 if (ut_params->obuf)
3319 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3320 plaintext_len, buffer);
3322 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3323 plaintext_len, buffer);
3325 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3328 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3330 tdata->ciphertext.data,
3331 tdata->validDataLenInBits.len,
3332 "SNOW 3G Ciphertext data not as expected");
3337 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3339 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3341 uint8_t curr_byte, prev_byte;
3342 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3343 uint8_t lower_byte_mask = (1 << offset) - 1;
3346 prev_byte = buffer[0];
3347 buffer[0] >>= offset;
3349 for (i = 1; i < length_in_bytes; i++) {
3350 curr_byte = buffer[i];
3351 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3352 (curr_byte >> offset);
3353 prev_byte = curr_byte;
3358 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3360 struct crypto_testsuite_params *ts_params = &testsuite_params;
3361 struct crypto_unittest_params *ut_params = &unittest_params;
3362 uint8_t *plaintext, *ciphertext;
3364 uint32_t plaintext_len;
3365 uint32_t plaintext_pad_len;
3366 uint8_t extra_offset = 4;
3367 uint8_t *expected_ciphertext_shifted;
3369 /* Create SNOW 3G session */
3370 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3371 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3372 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3373 tdata->key.data, tdata->key.len,
3374 tdata->cipher_iv.len);
3378 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3379 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3381 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3382 "Failed to allocate input buffer in mempool");
3383 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3384 "Failed to allocate output buffer in mempool");
3386 /* Clear mbuf payload */
3387 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3388 rte_pktmbuf_tailroom(ut_params->ibuf));
3390 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3392 * Append data which is padded to a
3393 * multiple of the algorithms block size
3395 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3397 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3400 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3402 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3403 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3405 #ifdef RTE_APP_TEST_DEBUG
3406 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3408 /* Create SNOW 3G operation */
3409 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3410 tdata->cipher_iv.len,
3411 tdata->validCipherLenInBits.len,
3416 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3420 ut_params->obuf = ut_params->op->sym->m_dst;
3421 if (ut_params->obuf)
3422 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3424 ciphertext = plaintext;
3426 #ifdef RTE_APP_TEST_DEBUG
3427 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3430 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3432 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3433 "failed to reserve memory for ciphertext shifted\n");
3435 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3436 ceil_byte_length(tdata->ciphertext.len));
3437 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3440 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3442 expected_ciphertext_shifted,
3443 tdata->validDataLenInBits.len,
3445 "SNOW 3G Ciphertext data not as expected");
3449 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3451 struct crypto_testsuite_params *ts_params = &testsuite_params;
3452 struct crypto_unittest_params *ut_params = &unittest_params;
3456 uint8_t *plaintext, *ciphertext;
3457 unsigned ciphertext_pad_len;
3458 unsigned ciphertext_len;
3460 /* Create SNOW 3G session */
3461 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3462 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3463 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3464 tdata->key.data, tdata->key.len,
3465 tdata->cipher_iv.len);
3469 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3471 /* Clear mbuf payload */
3472 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3473 rte_pktmbuf_tailroom(ut_params->ibuf));
3475 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3476 /* Append data which is padded to a multiple of */
3477 /* the algorithms block size */
3478 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3479 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3480 ciphertext_pad_len);
3481 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3483 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3485 /* Create SNOW 3G operation */
3486 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3487 tdata->cipher_iv.len,
3488 tdata->validCipherLenInBits.len,
3493 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3495 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3496 ut_params->obuf = ut_params->op->sym->m_dst;
3497 if (ut_params->obuf)
3498 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3500 plaintext = ciphertext;
3502 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3505 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3506 tdata->plaintext.data,
3507 tdata->validDataLenInBits.len,
3508 "SNOW 3G Plaintext data not as expected");
3512 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3514 struct crypto_testsuite_params *ts_params = &testsuite_params;
3515 struct crypto_unittest_params *ut_params = &unittest_params;
3519 uint8_t *plaintext, *ciphertext;
3520 unsigned ciphertext_pad_len;
3521 unsigned ciphertext_len;
3523 /* Create SNOW 3G session */
3524 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3525 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3526 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3527 tdata->key.data, tdata->key.len,
3528 tdata->cipher_iv.len);
3532 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3533 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3535 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3536 "Failed to allocate input buffer");
3537 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3538 "Failed to allocate output buffer");
3540 /* Clear mbuf payload */
3541 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3542 rte_pktmbuf_tailroom(ut_params->ibuf));
3544 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3545 rte_pktmbuf_tailroom(ut_params->obuf));
3547 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3548 /* Append data which is padded to a multiple of */
3549 /* the algorithms block size */
3550 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3551 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3552 ciphertext_pad_len);
3553 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3554 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3556 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3558 /* Create SNOW 3G operation */
3559 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3560 tdata->cipher_iv.len,
3561 tdata->validCipherLenInBits.len,
3566 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3568 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3569 ut_params->obuf = ut_params->op->sym->m_dst;
3570 if (ut_params->obuf)
3571 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3573 plaintext = ciphertext;
3575 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3578 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3579 tdata->plaintext.data,
3580 tdata->validDataLenInBits.len,
3581 "SNOW 3G Plaintext data not as expected");
3586 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3588 struct crypto_testsuite_params *ts_params = &testsuite_params;
3589 struct crypto_unittest_params *ut_params = &unittest_params;
3593 uint8_t *plaintext, *ciphertext;
3594 unsigned int plaintext_pad_len;
3595 unsigned int plaintext_len;
3597 struct rte_cryptodev_sym_capability_idx cap_idx;
3599 /* Check if device supports ZUC EEA3 */
3600 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3601 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3603 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3607 /* Check if device supports ZUC EIA3 */
3608 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3609 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3611 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3615 /* Create ZUC session */
3616 retval = create_zuc_cipher_auth_encrypt_generate_session(
3617 ts_params->valid_devs[0],
3621 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3623 /* clear mbuf payload */
3624 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3625 rte_pktmbuf_tailroom(ut_params->ibuf));
3627 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3628 /* Append data which is padded to a multiple of */
3629 /* the algorithms block size */
3630 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3631 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3633 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3635 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3637 /* Create ZUC operation */
3638 retval = create_zuc_cipher_hash_generate_operation(tdata);
3642 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3644 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3645 ut_params->obuf = ut_params->op->sym->m_src;
3646 if (ut_params->obuf)
3647 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3649 ciphertext = plaintext;
3651 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3653 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3655 tdata->ciphertext.data,
3656 tdata->validDataLenInBits.len,
3657 "ZUC Ciphertext data not as expected");
3659 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3660 + plaintext_pad_len;
3663 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3667 "ZUC Generated auth tag not as expected");
3672 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3674 struct crypto_testsuite_params *ts_params = &testsuite_params;
3675 struct crypto_unittest_params *ut_params = &unittest_params;
3679 uint8_t *plaintext, *ciphertext;
3680 unsigned plaintext_pad_len;
3681 unsigned plaintext_len;
3683 /* Create SNOW 3G session */
3684 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3685 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3686 RTE_CRYPTO_AUTH_OP_GENERATE,
3687 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3688 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3689 tdata->key.data, tdata->key.len,
3690 tdata->auth_iv.len, tdata->digest.len,
3691 tdata->cipher_iv.len);
3694 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3696 /* clear mbuf payload */
3697 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3698 rte_pktmbuf_tailroom(ut_params->ibuf));
3700 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3701 /* Append data which is padded to a multiple of */
3702 /* the algorithms block size */
3703 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3704 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3706 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3708 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3710 /* Create SNOW 3G operation */
3711 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3712 tdata->digest.len, tdata->auth_iv.data,
3714 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3715 tdata->cipher_iv.data, tdata->cipher_iv.len,
3716 tdata->validCipherLenInBits.len,
3718 tdata->validAuthLenInBits.len,
3724 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3726 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3727 ut_params->obuf = ut_params->op->sym->m_src;
3728 if (ut_params->obuf)
3729 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3731 ciphertext = plaintext;
3733 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3735 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3737 tdata->ciphertext.data,
3738 tdata->validDataLenInBits.len,
3739 "SNOW 3G Ciphertext data not as expected");
3741 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3742 + plaintext_pad_len;
3745 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3748 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3749 "SNOW 3G Generated auth tag not as expected");
3753 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3755 struct crypto_testsuite_params *ts_params = &testsuite_params;
3756 struct crypto_unittest_params *ut_params = &unittest_params;
3760 uint8_t *plaintext, *ciphertext;
3761 unsigned plaintext_pad_len;
3762 unsigned plaintext_len;
3764 /* Create SNOW 3G session */
3765 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3766 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3767 RTE_CRYPTO_AUTH_OP_GENERATE,
3768 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3769 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3770 tdata->key.data, tdata->key.len,
3771 tdata->auth_iv.len, tdata->digest.len,
3772 tdata->cipher_iv.len);
3776 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3778 /* clear mbuf payload */
3779 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3780 rte_pktmbuf_tailroom(ut_params->ibuf));
3782 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3783 /* Append data which is padded to a multiple of */
3784 /* the algorithms block size */
3785 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3786 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3788 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3790 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3792 /* Create SNOW 3G operation */
3793 retval = create_wireless_algo_auth_cipher_operation(
3795 tdata->cipher_iv.data, tdata->cipher_iv.len,
3796 tdata->auth_iv.data, tdata->auth_iv.len,
3798 tdata->validCipherLenInBits.len,
3800 tdata->validAuthLenInBits.len,
3806 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3808 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3809 ut_params->obuf = ut_params->op->sym->m_src;
3810 if (ut_params->obuf)
3811 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3813 ciphertext = plaintext;
3815 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3816 + plaintext_pad_len;
3817 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3820 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3822 tdata->ciphertext.data,
3823 tdata->validDataLenInBits.len,
3824 "SNOW 3G Ciphertext data not as expected");
3827 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3830 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3831 "SNOW 3G Generated auth tag not as expected");
3836 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3838 struct crypto_testsuite_params *ts_params = &testsuite_params;
3839 struct crypto_unittest_params *ut_params = &unittest_params;
3843 uint8_t *plaintext, *ciphertext;
3844 unsigned plaintext_pad_len;
3845 unsigned plaintext_len;
3847 /* Create KASUMI session */
3848 retval = create_wireless_algo_auth_cipher_session(
3849 ts_params->valid_devs[0],
3850 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3851 RTE_CRYPTO_AUTH_OP_GENERATE,
3852 RTE_CRYPTO_AUTH_KASUMI_F9,
3853 RTE_CRYPTO_CIPHER_KASUMI_F8,
3854 tdata->key.data, tdata->key.len,
3855 tdata->auth_iv.len, tdata->digest.len,
3856 tdata->cipher_iv.len);
3859 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3861 /* clear mbuf payload */
3862 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3863 rte_pktmbuf_tailroom(ut_params->ibuf));
3865 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3866 /* Append data which is padded to a multiple of */
3867 /* the algorithms block size */
3868 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3869 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3871 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3873 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3875 /* Create KASUMI operation */
3876 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3877 tdata->cipher_iv.data, tdata->cipher_iv.len,
3878 tdata->auth_iv.data, tdata->auth_iv.len,
3880 tdata->validCipherLenInBits.len,
3882 tdata->validAuthLenInBits.len,
3889 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3891 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3892 ut_params->obuf = ut_params->op->sym->m_src;
3893 if (ut_params->obuf)
3894 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3896 ciphertext = plaintext;
3899 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3901 tdata->ciphertext.data,
3902 tdata->validCipherLenInBits.len,
3903 "KASUMI Ciphertext data not as expected");
3904 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3905 + plaintext_pad_len;
3908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3911 DIGEST_BYTE_LENGTH_KASUMI_F9,
3912 "KASUMI Generated auth tag not as expected");
3917 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3919 struct crypto_testsuite_params *ts_params = &testsuite_params;
3920 struct crypto_unittest_params *ut_params = &unittest_params;
3924 uint8_t *plaintext, *ciphertext;
3925 unsigned plaintext_pad_len;
3926 unsigned plaintext_len;
3928 /* Create KASUMI session */
3929 retval = create_wireless_algo_cipher_auth_session(
3930 ts_params->valid_devs[0],
3931 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3932 RTE_CRYPTO_AUTH_OP_GENERATE,
3933 RTE_CRYPTO_AUTH_KASUMI_F9,
3934 RTE_CRYPTO_CIPHER_KASUMI_F8,
3935 tdata->key.data, tdata->key.len,
3936 tdata->auth_iv.len, tdata->digest.len,
3937 tdata->cipher_iv.len);
3941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3943 /* clear mbuf payload */
3944 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3945 rte_pktmbuf_tailroom(ut_params->ibuf));
3947 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3948 /* Append data which is padded to a multiple of */
3949 /* the algorithms block size */
3950 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3951 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3953 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3955 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3957 /* Create KASUMI operation */
3958 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3959 tdata->digest.len, tdata->auth_iv.data,
3961 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3962 tdata->cipher_iv.data, tdata->cipher_iv.len,
3963 tdata->validCipherLenInBits.len,
3965 tdata->validAuthLenInBits.len,
3971 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3973 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3974 ut_params->obuf = ut_params->op->sym->m_src;
3975 if (ut_params->obuf)
3976 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3978 ciphertext = plaintext;
3980 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3981 + plaintext_pad_len;
3984 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3986 tdata->ciphertext.data,
3987 tdata->validCipherLenInBits.len,
3988 "KASUMI Ciphertext data not as expected");
3991 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3994 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3995 "KASUMI Generated auth tag not as expected");
4000 test_zuc_encryption(const struct wireless_test_data *tdata)
4002 struct crypto_testsuite_params *ts_params = &testsuite_params;
4003 struct crypto_unittest_params *ut_params = &unittest_params;
4006 uint8_t *plaintext, *ciphertext;
4007 unsigned plaintext_pad_len;
4008 unsigned plaintext_len;
4010 struct rte_cryptodev_sym_capability_idx cap_idx;
4012 /* Check if device supports ZUC EEA3 */
4013 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4014 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4016 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4020 /* Create ZUC session */
4021 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4022 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4023 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4024 tdata->key.data, tdata->key.len,
4025 tdata->cipher_iv.len);
4029 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4031 /* Clear mbuf payload */
4032 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4033 rte_pktmbuf_tailroom(ut_params->ibuf));
4035 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4036 /* Append data which is padded to a multiple */
4037 /* of the algorithms block size */
4038 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4039 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4041 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4043 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4045 /* Create ZUC operation */
4046 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4047 tdata->cipher_iv.len,
4048 tdata->plaintext.len,
4053 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4055 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4057 ut_params->obuf = ut_params->op->sym->m_dst;
4058 if (ut_params->obuf)
4059 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4061 ciphertext = plaintext;
4063 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4066 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4068 tdata->ciphertext.data,
4069 tdata->validCipherLenInBits.len,
4070 "ZUC Ciphertext data not as expected");
4075 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4077 struct crypto_testsuite_params *ts_params = &testsuite_params;
4078 struct crypto_unittest_params *ut_params = &unittest_params;
4082 unsigned int plaintext_pad_len;
4083 unsigned int plaintext_len;
4084 const uint8_t *ciphertext;
4085 uint8_t ciphertext_buffer[2048];
4086 struct rte_cryptodev_info dev_info;
4088 struct rte_cryptodev_sym_capability_idx cap_idx;
4090 /* Check if device supports ZUC EEA3 */
4091 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4092 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4094 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4098 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4099 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4100 printf("Device doesn't support scatter-gather. "
4105 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4107 /* Append data which is padded to a multiple */
4108 /* of the algorithms block size */
4109 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4111 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4112 plaintext_pad_len, 10, 0);
4114 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4115 tdata->plaintext.data);
4117 /* Create ZUC session */
4118 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4119 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4120 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4121 tdata->key.data, tdata->key.len,
4122 tdata->cipher_iv.len);
4126 /* Clear mbuf payload */
4128 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4130 /* Create ZUC operation */
4131 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4132 tdata->cipher_iv.len, tdata->plaintext.len,
4137 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4139 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4141 ut_params->obuf = ut_params->op->sym->m_dst;
4142 if (ut_params->obuf)
4143 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4144 0, plaintext_len, ciphertext_buffer);
4146 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4147 0, plaintext_len, ciphertext_buffer);
4150 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4153 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4155 tdata->ciphertext.data,
4156 tdata->validCipherLenInBits.len,
4157 "ZUC Ciphertext data not as expected");
4163 test_zuc_authentication(const struct wireless_test_data *tdata)
4165 struct crypto_testsuite_params *ts_params = &testsuite_params;
4166 struct crypto_unittest_params *ut_params = &unittest_params;
4169 unsigned plaintext_pad_len;
4170 unsigned plaintext_len;
4173 struct rte_cryptodev_sym_capability_idx cap_idx;
4175 /* Check if device supports ZUC EIA3 */
4176 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4177 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4179 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4183 /* Create ZUC session */
4184 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4185 tdata->key.data, tdata->key.len,
4186 tdata->auth_iv.len, tdata->digest.len,
4187 RTE_CRYPTO_AUTH_OP_GENERATE,
4188 RTE_CRYPTO_AUTH_ZUC_EIA3);
4192 /* alloc mbuf and set payload */
4193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4195 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4196 rte_pktmbuf_tailroom(ut_params->ibuf));
4198 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4199 /* Append data which is padded to a multiple of */
4200 /* the algorithms block size */
4201 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4202 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4204 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4206 /* Create ZUC operation */
4207 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4208 tdata->auth_iv.data, tdata->auth_iv.len,
4209 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4210 tdata->validAuthLenInBits.len,
4215 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4217 ut_params->obuf = ut_params->op->sym->m_src;
4218 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4219 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4220 + plaintext_pad_len;
4223 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4226 DIGEST_BYTE_LENGTH_KASUMI_F9,
4227 "ZUC Generated auth tag not as expected");
4233 test_kasumi_encryption_test_case_1(void)
4235 return test_kasumi_encryption(&kasumi_test_case_1);
4239 test_kasumi_encryption_test_case_1_sgl(void)
4241 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4245 test_kasumi_encryption_test_case_1_oop(void)
4247 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4251 test_kasumi_encryption_test_case_1_oop_sgl(void)
4253 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4257 test_kasumi_encryption_test_case_2(void)
4259 return test_kasumi_encryption(&kasumi_test_case_2);
4263 test_kasumi_encryption_test_case_3(void)
4265 return test_kasumi_encryption(&kasumi_test_case_3);
4269 test_kasumi_encryption_test_case_4(void)
4271 return test_kasumi_encryption(&kasumi_test_case_4);
4275 test_kasumi_encryption_test_case_5(void)
4277 return test_kasumi_encryption(&kasumi_test_case_5);
4281 test_kasumi_decryption_test_case_1(void)
4283 return test_kasumi_decryption(&kasumi_test_case_1);
4287 test_kasumi_decryption_test_case_1_oop(void)
4289 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4293 test_kasumi_decryption_test_case_2(void)
4295 return test_kasumi_decryption(&kasumi_test_case_2);
4299 test_kasumi_decryption_test_case_3(void)
4301 return test_kasumi_decryption(&kasumi_test_case_3);
4305 test_kasumi_decryption_test_case_4(void)
4307 return test_kasumi_decryption(&kasumi_test_case_4);
4311 test_kasumi_decryption_test_case_5(void)
4313 return test_kasumi_decryption(&kasumi_test_case_5);
4316 test_snow3g_encryption_test_case_1(void)
4318 return test_snow3g_encryption(&snow3g_test_case_1);
4322 test_snow3g_encryption_test_case_1_oop(void)
4324 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4328 test_snow3g_encryption_test_case_1_oop_sgl(void)
4330 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4335 test_snow3g_encryption_test_case_1_offset_oop(void)
4337 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4341 test_snow3g_encryption_test_case_2(void)
4343 return test_snow3g_encryption(&snow3g_test_case_2);
4347 test_snow3g_encryption_test_case_3(void)
4349 return test_snow3g_encryption(&snow3g_test_case_3);
4353 test_snow3g_encryption_test_case_4(void)
4355 return test_snow3g_encryption(&snow3g_test_case_4);
4359 test_snow3g_encryption_test_case_5(void)
4361 return test_snow3g_encryption(&snow3g_test_case_5);
4365 test_snow3g_decryption_test_case_1(void)
4367 return test_snow3g_decryption(&snow3g_test_case_1);
4371 test_snow3g_decryption_test_case_1_oop(void)
4373 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4377 test_snow3g_decryption_test_case_2(void)
4379 return test_snow3g_decryption(&snow3g_test_case_2);
4383 test_snow3g_decryption_test_case_3(void)
4385 return test_snow3g_decryption(&snow3g_test_case_3);
4389 test_snow3g_decryption_test_case_4(void)
4391 return test_snow3g_decryption(&snow3g_test_case_4);
4395 test_snow3g_decryption_test_case_5(void)
4397 return test_snow3g_decryption(&snow3g_test_case_5);
4400 test_snow3g_cipher_auth_test_case_1(void)
4402 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4406 test_snow3g_auth_cipher_test_case_1(void)
4408 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4412 test_kasumi_auth_cipher_test_case_1(void)
4414 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4418 test_kasumi_cipher_auth_test_case_1(void)
4420 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4424 test_zuc_encryption_test_case_1(void)
4426 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4430 test_zuc_encryption_test_case_2(void)
4432 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4436 test_zuc_encryption_test_case_3(void)
4438 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4442 test_zuc_encryption_test_case_4(void)
4444 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4448 test_zuc_encryption_test_case_5(void)
4450 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4454 test_zuc_encryption_test_case_6_sgl(void)
4456 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4460 test_zuc_hash_generate_test_case_1(void)
4462 return test_zuc_authentication(&zuc_test_case_auth_1b);
4466 test_zuc_hash_generate_test_case_2(void)
4468 return test_zuc_authentication(&zuc_test_case_auth_90b);
4472 test_zuc_hash_generate_test_case_3(void)
4474 return test_zuc_authentication(&zuc_test_case_auth_577b);
4478 test_zuc_hash_generate_test_case_4(void)
4480 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4484 test_zuc_hash_generate_test_case_5(void)
4486 return test_zuc_authentication(&zuc_test_auth_5670b);
4490 test_zuc_hash_generate_test_case_6(void)
4492 return test_zuc_authentication(&zuc_test_case_auth_128b);
4496 test_zuc_hash_generate_test_case_7(void)
4498 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4502 test_zuc_hash_generate_test_case_8(void)
4504 return test_zuc_authentication(&zuc_test_case_auth_584b);
4508 test_zuc_cipher_auth_test_case_1(void)
4510 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4514 test_zuc_cipher_auth_test_case_2(void)
4516 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4520 test_3DES_chain_qat_all(void)
4522 struct crypto_testsuite_params *ts_params = &testsuite_params;
4525 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4526 ts_params->op_mpool, ts_params->valid_devs[0],
4527 RTE_CRYPTODEV_QAT_SYM_PMD,
4528 BLKCIPHER_3DES_CHAIN_TYPE);
4530 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4532 return TEST_SUCCESS;
4536 test_DES_cipheronly_qat_all(void)
4538 struct crypto_testsuite_params *ts_params = &testsuite_params;
4541 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4542 ts_params->op_mpool, ts_params->valid_devs[0],
4543 RTE_CRYPTODEV_QAT_SYM_PMD,
4544 BLKCIPHER_DES_CIPHERONLY_TYPE);
4546 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4548 return TEST_SUCCESS;
4552 test_DES_docsis_openssl_all(void)
4554 struct crypto_testsuite_params *ts_params = &testsuite_params;
4557 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4558 ts_params->op_mpool, ts_params->valid_devs[0],
4559 RTE_CRYPTODEV_OPENSSL_PMD,
4560 BLKCIPHER_DES_DOCSIS_TYPE);
4562 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4564 return TEST_SUCCESS;
4568 test_3DES_chain_dpaa2_sec_all(void)
4570 struct crypto_testsuite_params *ts_params = &testsuite_params;
4573 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4574 ts_params->op_mpool, ts_params->valid_devs[0],
4575 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4576 BLKCIPHER_3DES_CHAIN_TYPE);
4578 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4580 return TEST_SUCCESS;
4584 test_3DES_cipheronly_dpaa2_sec_all(void)
4586 struct crypto_testsuite_params *ts_params = &testsuite_params;
4589 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4590 ts_params->op_mpool, ts_params->valid_devs[0],
4591 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4592 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4594 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4596 return TEST_SUCCESS;
4600 test_3DES_cipheronly_qat_all(void)
4602 struct crypto_testsuite_params *ts_params = &testsuite_params;
4605 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4606 ts_params->op_mpool, ts_params->valid_devs[0],
4607 RTE_CRYPTODEV_QAT_SYM_PMD,
4608 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4610 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4612 return TEST_SUCCESS;
4616 test_3DES_chain_openssl_all(void)
4618 struct crypto_testsuite_params *ts_params = &testsuite_params;
4621 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4622 ts_params->op_mpool, ts_params->valid_devs[0],
4623 RTE_CRYPTODEV_OPENSSL_PMD,
4624 BLKCIPHER_3DES_CHAIN_TYPE);
4626 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4628 return TEST_SUCCESS;
4632 test_3DES_cipheronly_openssl_all(void)
4634 struct crypto_testsuite_params *ts_params = &testsuite_params;
4637 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4638 ts_params->op_mpool, ts_params->valid_devs[0],
4639 RTE_CRYPTODEV_OPENSSL_PMD,
4640 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4642 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4644 return TEST_SUCCESS;
4647 /* ***** AES-GCM Tests ***** */
4650 create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
4651 const uint8_t *key, const uint8_t key_len,
4652 const uint16_t aad_len, const uint8_t auth_len,
4655 uint8_t aead_key[key_len];
4657 struct crypto_unittest_params *ut_params = &unittest_params;
4659 memcpy(aead_key, key, key_len);
4661 /* Setup AEAD Parameters */
4662 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4663 ut_params->aead_xform.next = NULL;
4664 ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4665 ut_params->aead_xform.aead.op = op;
4666 ut_params->aead_xform.aead.key.data = aead_key;
4667 ut_params->aead_xform.aead.key.length = key_len;
4668 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4669 ut_params->aead_xform.aead.iv.length = iv_len;
4670 ut_params->aead_xform.aead.digest_length = auth_len;
4671 ut_params->aead_xform.aead.add_auth_data_length = aad_len;
4673 TEST_HEXDUMP(stdout, "key:", key, key_len);
4675 /* Create Crypto session*/
4676 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4677 &ut_params->aead_xform);
4679 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4685 create_gcm_xforms(struct rte_crypto_op *op,
4686 enum rte_crypto_aead_operation aead_op,
4687 uint8_t *key, const uint8_t key_len,
4688 const uint8_t aad_len, const uint8_t auth_len,
4691 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4692 "failed to allocate space for crypto transform");
4694 struct rte_crypto_sym_op *sym_op = op->sym;
4696 /* Setup AEAD Parameters */
4697 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4698 sym_op->xform->next = NULL;
4699 sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4700 sym_op->xform->aead.op = aead_op;
4701 sym_op->xform->aead.key.data = key;
4702 sym_op->xform->aead.key.length = key_len;
4703 sym_op->xform->aead.iv.offset = IV_OFFSET;
4704 sym_op->xform->aead.iv.length = iv_len;
4705 sym_op->xform->aead.digest_length = auth_len;
4706 sym_op->xform->aead.add_auth_data_length = aad_len;
4708 TEST_HEXDUMP(stdout, "key:", key, key_len);
4714 create_gcm_operation(enum rte_crypto_aead_operation op,
4715 const struct gcm_test_data *tdata)
4717 struct crypto_testsuite_params *ts_params = &testsuite_params;
4718 struct crypto_unittest_params *ut_params = &unittest_params;
4720 uint8_t *plaintext, *ciphertext;
4721 unsigned int aad_pad_len, plaintext_pad_len;
4723 /* Generate Crypto op data structure */
4724 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4725 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4726 TEST_ASSERT_NOT_NULL(ut_params->op,
4727 "Failed to allocate symmetric crypto operation struct");
4729 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4731 /* Append aad data */
4732 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4733 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4735 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
4736 "no room to append aad");
4738 sym_op->aead.aad.phys_addr =
4739 rte_pktmbuf_mtophys(ut_params->ibuf);
4740 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
4741 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
4744 /* Append IV at the end of the crypto operation*/
4745 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4746 uint8_t *, IV_OFFSET);
4748 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4749 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4752 /* Append plaintext/ciphertext */
4753 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4754 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4755 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4757 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4759 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4760 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4761 tdata->plaintext.len);
4763 if (ut_params->obuf) {
4764 ciphertext = (uint8_t *)rte_pktmbuf_append(
4766 plaintext_pad_len + aad_pad_len);
4767 TEST_ASSERT_NOT_NULL(ciphertext,
4768 "no room to append ciphertext");
4770 memset(ciphertext + aad_pad_len, 0,
4771 tdata->ciphertext.len);
4774 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4775 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4777 TEST_ASSERT_NOT_NULL(ciphertext,
4778 "no room to append ciphertext");
4780 memcpy(ciphertext, tdata->ciphertext.data,
4781 tdata->ciphertext.len);
4782 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4783 tdata->ciphertext.len);
4785 if (ut_params->obuf) {
4786 plaintext = (uint8_t *)rte_pktmbuf_append(
4788 plaintext_pad_len + aad_pad_len);
4789 TEST_ASSERT_NOT_NULL(plaintext,
4790 "no room to append plaintext");
4792 memset(plaintext + aad_pad_len, 0,
4793 tdata->plaintext.len);
4797 /* Append digest data */
4798 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4799 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4800 ut_params->obuf ? ut_params->obuf :
4802 tdata->auth_tag.len);
4803 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4804 "no room to append digest");
4805 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
4806 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4807 ut_params->obuf ? ut_params->obuf :
4812 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4813 ut_params->ibuf, tdata->auth_tag.len);
4814 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4815 "no room to append digest");
4816 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4818 plaintext_pad_len + aad_pad_len);
4820 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
4821 tdata->auth_tag.len);
4822 TEST_HEXDUMP(stdout, "digest:",
4823 sym_op->aead.digest.data,
4824 tdata->auth_tag.len);
4827 sym_op->aead.data.length = tdata->plaintext.len;
4828 sym_op->aead.data.offset = aad_pad_len;
4834 test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4836 struct crypto_testsuite_params *ts_params = &testsuite_params;
4837 struct crypto_unittest_params *ut_params = &unittest_params;
4840 uint8_t *ciphertext, *auth_tag;
4841 uint16_t plaintext_pad_len;
4844 /* Create GCM session */
4845 retval = create_gcm_session(ts_params->valid_devs[0],
4846 RTE_CRYPTO_AEAD_OP_ENCRYPT,
4847 tdata->key.data, tdata->key.len,
4848 tdata->aad.len, tdata->auth_tag.len,
4853 if (tdata->aad.len > MBUF_SIZE) {
4854 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4855 /* Populate full size of add data */
4856 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4857 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4859 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4861 /* clear mbuf payload */
4862 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4863 rte_pktmbuf_tailroom(ut_params->ibuf));
4865 /* Create GCM operation */
4866 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
4870 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4872 ut_params->op->sym->m_src = ut_params->ibuf;
4874 /* Process crypto operation */
4875 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4876 ut_params->op), "failed to process sym crypto op");
4878 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4879 "crypto op processing failed");
4881 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4883 if (ut_params->op->sym->m_dst) {
4884 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4886 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4887 uint8_t *, plaintext_pad_len);
4889 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4891 ut_params->op->sym->cipher.data.offset);
4892 auth_tag = ciphertext + plaintext_pad_len;
4895 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4896 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4899 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4901 tdata->ciphertext.data,
4902 tdata->ciphertext.len,
4903 "GCM Ciphertext data not as expected");
4905 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4907 tdata->auth_tag.data,
4908 tdata->auth_tag.len,
4909 "GCM Generated auth tag not as expected");
4916 test_AES_GCM_authenticated_encryption_test_case_1(void)
4918 return test_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4922 test_AES_GCM_authenticated_encryption_test_case_2(void)
4924 return test_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4928 test_AES_GCM_authenticated_encryption_test_case_3(void)
4930 return test_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4934 test_AES_GCM_authenticated_encryption_test_case_4(void)
4936 return test_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4940 test_AES_GCM_authenticated_encryption_test_case_5(void)
4942 return test_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4946 test_AES_GCM_authenticated_encryption_test_case_6(void)
4948 return test_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4952 test_AES_GCM_authenticated_encryption_test_case_7(void)
4954 return test_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4958 test_AES_GCM_auth_encryption_test_case_256_1(void)
4960 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4964 test_AES_GCM_auth_encryption_test_case_256_2(void)
4966 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4970 test_AES_GCM_auth_encryption_test_case_256_3(void)
4972 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4976 test_AES_GCM_auth_encryption_test_case_256_4(void)
4978 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
4982 test_AES_GCM_auth_encryption_test_case_256_5(void)
4984 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
4988 test_AES_GCM_auth_encryption_test_case_256_6(void)
4990 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
4994 test_AES_GCM_auth_encryption_test_case_256_7(void)
4996 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5000 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5002 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5006 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5008 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5012 test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5014 struct crypto_testsuite_params *ts_params = &testsuite_params;
5015 struct crypto_unittest_params *ut_params = &unittest_params;
5021 /* Create GCM session */
5022 retval = create_gcm_session(ts_params->valid_devs[0],
5023 RTE_CRYPTO_AEAD_OP_DECRYPT,
5024 tdata->key.data, tdata->key.len,
5025 tdata->aad.len, tdata->auth_tag.len,
5030 /* alloc mbuf and set payload */
5031 if (tdata->aad.len > MBUF_SIZE) {
5032 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5033 /* Populate full size of add data */
5034 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5035 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5037 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5039 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5040 rte_pktmbuf_tailroom(ut_params->ibuf));
5042 /* Create GCM operation */
5043 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5047 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5049 ut_params->op->sym->m_src = ut_params->ibuf;
5051 /* Process crypto operation */
5052 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5053 ut_params->op), "failed to process sym crypto op");
5055 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5056 "crypto op processing failed");
5058 if (ut_params->op->sym->m_dst)
5059 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5062 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5064 ut_params->op->sym->cipher.data.offset);
5066 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5069 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5071 tdata->plaintext.data,
5072 tdata->plaintext.len,
5073 "GCM plaintext data not as expected");
5075 TEST_ASSERT_EQUAL(ut_params->op->status,
5076 RTE_CRYPTO_OP_STATUS_SUCCESS,
5077 "GCM authentication failed");
5082 test_AES_GCM_authenticated_decryption_test_case_1(void)
5084 return test_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5088 test_AES_GCM_authenticated_decryption_test_case_2(void)
5090 return test_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5094 test_AES_GCM_authenticated_decryption_test_case_3(void)
5096 return test_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5100 test_AES_GCM_authenticated_decryption_test_case_4(void)
5102 return test_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5106 test_AES_GCM_authenticated_decryption_test_case_5(void)
5108 return test_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5112 test_AES_GCM_authenticated_decryption_test_case_6(void)
5114 return test_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5118 test_AES_GCM_authenticated_decryption_test_case_7(void)
5120 return test_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5124 test_AES_GCM_auth_decryption_test_case_256_1(void)
5126 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5130 test_AES_GCM_auth_decryption_test_case_256_2(void)
5132 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5136 test_AES_GCM_auth_decryption_test_case_256_3(void)
5138 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5142 test_AES_GCM_auth_decryption_test_case_256_4(void)
5144 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5148 test_AES_GCM_auth_decryption_test_case_256_5(void)
5150 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5154 test_AES_GCM_auth_decryption_test_case_256_6(void)
5156 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5160 test_AES_GCM_auth_decryption_test_case_256_7(void)
5162 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5166 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5168 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5172 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5174 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5178 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5180 struct crypto_testsuite_params *ts_params = &testsuite_params;
5181 struct crypto_unittest_params *ut_params = &unittest_params;
5184 uint8_t *ciphertext, *auth_tag;
5185 uint16_t plaintext_pad_len;
5187 /* Create GCM session */
5188 retval = create_gcm_session(ts_params->valid_devs[0],
5189 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5190 tdata->key.data, tdata->key.len,
5191 tdata->aad.len, tdata->auth_tag.len,
5196 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5197 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5199 /* clear mbuf payload */
5200 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5201 rte_pktmbuf_tailroom(ut_params->ibuf));
5202 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5203 rte_pktmbuf_tailroom(ut_params->obuf));
5205 /* Create GCM operation */
5206 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5210 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5212 ut_params->op->sym->m_src = ut_params->ibuf;
5213 ut_params->op->sym->m_dst = ut_params->obuf;
5215 /* Process crypto operation */
5216 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5217 ut_params->op), "failed to process sym crypto op");
5219 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5220 "crypto op processing failed");
5222 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5224 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5225 ut_params->op->sym->cipher.data.offset);
5226 auth_tag = ciphertext + plaintext_pad_len;
5228 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5229 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5232 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5234 tdata->ciphertext.data,
5235 tdata->ciphertext.len,
5236 "GCM Ciphertext data not as expected");
5238 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5240 tdata->auth_tag.data,
5241 tdata->auth_tag.len,
5242 "GCM Generated auth tag not as expected");
5249 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5251 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5255 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5257 struct crypto_testsuite_params *ts_params = &testsuite_params;
5258 struct crypto_unittest_params *ut_params = &unittest_params;
5263 /* Create GCM session */
5264 retval = create_gcm_session(ts_params->valid_devs[0],
5265 RTE_CRYPTO_AEAD_OP_DECRYPT,
5266 tdata->key.data, tdata->key.len,
5267 tdata->aad.len, tdata->auth_tag.len,
5272 /* alloc mbuf and set payload */
5273 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5274 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5276 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5277 rte_pktmbuf_tailroom(ut_params->ibuf));
5278 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5279 rte_pktmbuf_tailroom(ut_params->obuf));
5281 /* Create GCM operation */
5282 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5286 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5288 ut_params->op->sym->m_src = ut_params->ibuf;
5289 ut_params->op->sym->m_dst = ut_params->obuf;
5291 /* Process crypto operation */
5292 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5293 ut_params->op), "failed to process sym crypto op");
5295 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5296 "crypto op processing failed");
5298 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5299 ut_params->op->sym->cipher.data.offset);
5301 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5304 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5306 tdata->plaintext.data,
5307 tdata->plaintext.len,
5308 "GCM plaintext data not as expected");
5310 TEST_ASSERT_EQUAL(ut_params->op->status,
5311 RTE_CRYPTO_OP_STATUS_SUCCESS,
5312 "GCM authentication failed");
5317 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5319 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5323 test_AES_GCM_authenticated_encryption_sessionless(
5324 const struct gcm_test_data *tdata)
5326 struct crypto_testsuite_params *ts_params = &testsuite_params;
5327 struct crypto_unittest_params *ut_params = &unittest_params;
5330 uint8_t *ciphertext, *auth_tag;
5331 uint16_t plaintext_pad_len;
5332 uint8_t key[tdata->key.len + 1];
5334 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5336 /* clear mbuf payload */
5337 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5338 rte_pktmbuf_tailroom(ut_params->ibuf));
5340 /* Create GCM operation */
5341 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5345 /* Create GCM xforms */
5346 memcpy(key, tdata->key.data, tdata->key.len);
5347 retval = create_gcm_xforms(ut_params->op,
5348 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5349 key, tdata->key.len,
5350 tdata->aad.len, tdata->auth_tag.len,
5355 ut_params->op->sym->m_src = ut_params->ibuf;
5357 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5358 RTE_CRYPTO_OP_SESSIONLESS,
5359 "crypto op session type not sessionless");
5361 /* Process crypto operation */
5362 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5363 ut_params->op), "failed to process sym crypto op");
5365 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5367 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5368 "crypto op status not success");
5370 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5372 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5373 ut_params->op->sym->cipher.data.offset);
5374 auth_tag = ciphertext + plaintext_pad_len;
5376 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5377 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5380 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5382 tdata->ciphertext.data,
5383 tdata->ciphertext.len,
5384 "GCM Ciphertext data not as expected");
5386 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5388 tdata->auth_tag.data,
5389 tdata->auth_tag.len,
5390 "GCM Generated auth tag not as expected");
5397 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5399 return test_AES_GCM_authenticated_encryption_sessionless(
5404 test_AES_GCM_authenticated_decryption_sessionless(
5405 const struct gcm_test_data *tdata)
5407 struct crypto_testsuite_params *ts_params = &testsuite_params;
5408 struct crypto_unittest_params *ut_params = &unittest_params;
5412 uint8_t key[tdata->key.len + 1];
5414 /* alloc mbuf and set payload */
5415 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5417 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5418 rte_pktmbuf_tailroom(ut_params->ibuf));
5420 /* Create GCM operation */
5421 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5425 /* Create GCM xforms */
5426 memcpy(key, tdata->key.data, tdata->key.len);
5427 retval = create_gcm_xforms(ut_params->op,
5428 RTE_CRYPTO_AEAD_OP_DECRYPT,
5429 key, tdata->key.len,
5430 tdata->aad.len, tdata->auth_tag.len,
5435 ut_params->op->sym->m_src = ut_params->ibuf;
5437 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5438 RTE_CRYPTO_OP_SESSIONLESS,
5439 "crypto op session type not sessionless");
5441 /* Process crypto operation */
5442 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5443 ut_params->op), "failed to process sym crypto op");
5445 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5447 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5448 "crypto op status not success");
5450 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5451 ut_params->op->sym->cipher.data.offset);
5453 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5456 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5458 tdata->plaintext.data,
5459 tdata->plaintext.len,
5460 "GCM plaintext data not as expected");
5462 TEST_ASSERT_EQUAL(ut_params->op->status,
5463 RTE_CRYPTO_OP_STATUS_SUCCESS,
5464 "GCM authentication failed");
5469 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5471 return test_AES_GCM_authenticated_decryption_sessionless(
5478 struct crypto_testsuite_params *ts_params = &testsuite_params;
5479 struct rte_cryptodev_stats stats;
5480 struct rte_cryptodev *dev;
5481 cryptodev_stats_get_t temp_pfn;
5483 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5484 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5485 &stats) == -ENODEV),
5486 "rte_cryptodev_stats_get invalid dev failed");
5487 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5488 "rte_cryptodev_stats_get invalid Param failed");
5489 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5490 temp_pfn = dev->dev_ops->stats_get;
5491 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5492 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5494 "rte_cryptodev_stats_get invalid Param failed");
5495 dev->dev_ops->stats_get = temp_pfn;
5497 /* Test expected values */
5499 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5501 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5503 "rte_cryptodev_stats_get failed");
5504 TEST_ASSERT((stats.enqueued_count == 1),
5505 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5506 TEST_ASSERT((stats.dequeued_count == 1),
5507 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5508 TEST_ASSERT((stats.enqueue_err_count == 0),
5509 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5510 TEST_ASSERT((stats.dequeue_err_count == 0),
5511 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5513 /* invalid device but should ignore and not reset device stats*/
5514 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5515 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5517 "rte_cryptodev_stats_get failed");
5518 TEST_ASSERT((stats.enqueued_count == 1),
5519 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5521 /* check that a valid reset clears stats */
5522 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5523 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5525 "rte_cryptodev_stats_get failed");
5526 TEST_ASSERT((stats.enqueued_count == 0),
5527 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5528 TEST_ASSERT((stats.dequeued_count == 0),
5529 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5531 return TEST_SUCCESS;
5534 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5535 struct crypto_unittest_params *ut_params,
5536 enum rte_crypto_auth_operation op,
5537 const struct HMAC_MD5_vector *test_case)
5541 memcpy(key, test_case->key.data, test_case->key.len);
5543 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5544 ut_params->auth_xform.next = NULL;
5545 ut_params->auth_xform.auth.op = op;
5547 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5549 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5550 ut_params->auth_xform.auth.key.length = test_case->key.len;
5551 ut_params->auth_xform.auth.key.data = key;
5553 ut_params->sess = rte_cryptodev_sym_session_create(
5554 ts_params->valid_devs[0], &ut_params->auth_xform);
5556 if (ut_params->sess == NULL)
5559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5561 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5562 rte_pktmbuf_tailroom(ut_params->ibuf));
5567 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5568 const struct HMAC_MD5_vector *test_case,
5569 uint8_t **plaintext)
5571 uint16_t plaintext_pad_len;
5573 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5575 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5578 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5580 memcpy(*plaintext, test_case->plaintext.data,
5581 test_case->plaintext.len);
5583 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5584 ut_params->ibuf, MD5_DIGEST_LEN);
5585 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5586 "no room to append digest");
5587 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5588 ut_params->ibuf, plaintext_pad_len);
5590 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5591 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5592 test_case->auth_tag.len);
5595 sym_op->auth.data.offset = 0;
5596 sym_op->auth.data.length = test_case->plaintext.len;
5598 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5599 ut_params->op->sym->m_src = ut_params->ibuf;
5605 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5607 uint16_t plaintext_pad_len;
5608 uint8_t *plaintext, *auth_tag;
5610 struct crypto_testsuite_params *ts_params = &testsuite_params;
5611 struct crypto_unittest_params *ut_params = &unittest_params;
5613 if (MD5_HMAC_create_session(ts_params, ut_params,
5614 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5617 /* Generate Crypto op data structure */
5618 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5619 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5620 TEST_ASSERT_NOT_NULL(ut_params->op,
5621 "Failed to allocate symmetric crypto operation struct");
5623 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5626 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5629 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5630 ut_params->op), "failed to process sym crypto op");
5632 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5633 "crypto op processing failed");
5635 if (ut_params->op->sym->m_dst) {
5636 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5637 uint8_t *, plaintext_pad_len);
5639 auth_tag = plaintext + plaintext_pad_len;
5642 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5644 test_case->auth_tag.data,
5645 test_case->auth_tag.len,
5646 "HMAC_MD5 generated tag not as expected");
5648 return TEST_SUCCESS;
5652 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5656 struct crypto_testsuite_params *ts_params = &testsuite_params;
5657 struct crypto_unittest_params *ut_params = &unittest_params;
5659 if (MD5_HMAC_create_session(ts_params, ut_params,
5660 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5664 /* Generate Crypto op data structure */
5665 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5666 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5667 TEST_ASSERT_NOT_NULL(ut_params->op,
5668 "Failed to allocate symmetric crypto operation struct");
5670 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5673 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5674 ut_params->op), "failed to process sym crypto op");
5676 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5677 "HMAC_MD5 crypto op processing failed");
5679 return TEST_SUCCESS;
5683 test_MD5_HMAC_generate_case_1(void)
5685 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5689 test_MD5_HMAC_verify_case_1(void)
5691 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5695 test_MD5_HMAC_generate_case_2(void)
5697 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5701 test_MD5_HMAC_verify_case_2(void)
5703 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5707 test_multi_session(void)
5709 struct crypto_testsuite_params *ts_params = &testsuite_params;
5710 struct crypto_unittest_params *ut_params = &unittest_params;
5712 struct rte_cryptodev_info dev_info;
5713 struct rte_cryptodev_sym_session **sessions;
5717 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5718 aes_cbc_key, hmac_sha512_key);
5721 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5723 sessions = rte_malloc(NULL,
5724 (sizeof(struct rte_cryptodev_sym_session *) *
5725 dev_info.sym.max_nb_sessions) + 1, 0);
5727 /* Create multiple crypto sessions*/
5728 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5729 sessions[i] = rte_cryptodev_sym_session_create(
5730 ts_params->valid_devs[0],
5731 &ut_params->auth_xform);
5732 TEST_ASSERT_NOT_NULL(sessions[i],
5733 "Session creation failed at session number %u",
5736 /* Attempt to send a request on each session */
5737 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5741 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5742 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5744 "Failed to perform decrypt on request number %u.", i);
5745 /* free crypto operation structure */
5747 rte_crypto_op_free(ut_params->op);
5750 * free mbuf - both obuf and ibuf are usually the same,
5751 * so check if they point at the same address is necessary,
5752 * to avoid freeing the mbuf twice.
5754 if (ut_params->obuf) {
5755 rte_pktmbuf_free(ut_params->obuf);
5756 if (ut_params->ibuf == ut_params->obuf)
5757 ut_params->ibuf = 0;
5758 ut_params->obuf = 0;
5760 if (ut_params->ibuf) {
5761 rte_pktmbuf_free(ut_params->ibuf);
5762 ut_params->ibuf = 0;
5766 /* Next session create should fail */
5767 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5768 &ut_params->auth_xform);
5769 TEST_ASSERT_NULL(sessions[i],
5770 "Session creation succeeded unexpectedly!");
5772 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5773 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5778 return TEST_SUCCESS;
5781 struct multi_session_params {
5782 struct crypto_unittest_params ut_params;
5783 uint8_t *cipher_key;
5785 const uint8_t *cipher;
5786 const uint8_t *digest;
5790 #define MB_SESSION_NUMBER 3
5793 test_multi_session_random_usage(void)
5795 struct crypto_testsuite_params *ts_params = &testsuite_params;
5796 struct rte_cryptodev_info dev_info;
5797 struct rte_cryptodev_sym_session **sessions;
5799 struct multi_session_params ut_paramz[] = {
5802 .cipher_key = ms_aes_cbc_key0,
5803 .hmac_key = ms_hmac_key0,
5804 .cipher = ms_aes_cbc_cipher0,
5805 .digest = ms_hmac_digest0,
5806 .iv = ms_aes_cbc_iv0
5809 .cipher_key = ms_aes_cbc_key1,
5810 .hmac_key = ms_hmac_key1,
5811 .cipher = ms_aes_cbc_cipher1,
5812 .digest = ms_hmac_digest1,
5813 .iv = ms_aes_cbc_iv1
5816 .cipher_key = ms_aes_cbc_key2,
5817 .hmac_key = ms_hmac_key2,
5818 .cipher = ms_aes_cbc_cipher2,
5819 .digest = ms_hmac_digest2,
5820 .iv = ms_aes_cbc_iv2
5825 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5827 sessions = rte_malloc(NULL,
5828 (sizeof(struct rte_cryptodev_sym_session *)
5829 * dev_info.sym.max_nb_sessions) + 1, 0);
5831 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5832 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5833 sizeof(struct crypto_unittest_params));
5835 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5836 &ut_paramz[i].ut_params,
5837 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5839 /* Create multiple crypto sessions*/
5840 sessions[i] = rte_cryptodev_sym_session_create(
5841 ts_params->valid_devs[0],
5842 &ut_paramz[i].ut_params.auth_xform);
5844 TEST_ASSERT_NOT_NULL(sessions[i],
5845 "Session creation failed at session number %u",
5851 for (i = 0; i < 40000; i++) {
5853 j = rand() % MB_SESSION_NUMBER;
5855 TEST_ASSERT_SUCCESS(
5856 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5858 &ut_paramz[j].ut_params,
5859 ts_params, ut_paramz[j].cipher,
5860 ut_paramz[j].digest,
5862 "Failed to perform decrypt on request number %u.", i);
5864 if (ut_paramz[j].ut_params.op)
5865 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5868 * free mbuf - both obuf and ibuf are usually the same,
5869 * so check if they point at the same address is necessary,
5870 * to avoid freeing the mbuf twice.
5872 if (ut_paramz[j].ut_params.obuf) {
5873 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5874 if (ut_paramz[j].ut_params.ibuf
5875 == ut_paramz[j].ut_params.obuf)
5876 ut_paramz[j].ut_params.ibuf = 0;
5877 ut_paramz[j].ut_params.obuf = 0;
5879 if (ut_paramz[j].ut_params.ibuf) {
5880 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5881 ut_paramz[j].ut_params.ibuf = 0;
5885 for (i = 0; i < MB_SESSION_NUMBER; i++)
5886 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5891 return TEST_SUCCESS;
5895 test_null_cipher_only_operation(void)
5897 struct crypto_testsuite_params *ts_params = &testsuite_params;
5898 struct crypto_unittest_params *ut_params = &unittest_params;
5900 /* Generate test mbuf data and space for digest */
5901 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5902 catch_22_quote, QUOTE_512_BYTES, 0);
5904 /* Setup Cipher Parameters */
5905 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5906 ut_params->cipher_xform.next = NULL;
5908 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5909 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5911 /* Create Crypto session*/
5912 ut_params->sess = rte_cryptodev_sym_session_create(
5913 ts_params->valid_devs[0], &ut_params->cipher_xform);
5914 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5916 /* Generate Crypto op data structure */
5917 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5918 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5919 TEST_ASSERT_NOT_NULL(ut_params->op,
5920 "Failed to allocate symmetric crypto operation struct");
5922 /* Set crypto operation data parameters */
5923 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5925 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5927 /* set crypto operation source mbuf */
5928 sym_op->m_src = ut_params->ibuf;
5930 sym_op->cipher.data.offset = 0;
5931 sym_op->cipher.data.length = QUOTE_512_BYTES;
5933 /* Process crypto operation */
5934 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5936 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5938 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5939 "crypto operation processing failed");
5942 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5943 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5946 "Ciphertext data not as expected");
5948 return TEST_SUCCESS;
5952 test_null_auth_only_operation(void)
5954 struct crypto_testsuite_params *ts_params = &testsuite_params;
5955 struct crypto_unittest_params *ut_params = &unittest_params;
5957 /* Generate test mbuf data and space for digest */
5958 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5959 catch_22_quote, QUOTE_512_BYTES, 0);
5961 /* Setup HMAC Parameters */
5962 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5963 ut_params->auth_xform.next = NULL;
5965 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5966 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5968 /* Create Crypto session*/
5969 ut_params->sess = rte_cryptodev_sym_session_create(
5970 ts_params->valid_devs[0], &ut_params->auth_xform);
5971 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5973 /* Generate Crypto op data structure */
5974 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5975 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5976 TEST_ASSERT_NOT_NULL(ut_params->op,
5977 "Failed to allocate symmetric crypto operation struct");
5979 /* Set crypto operation data parameters */
5980 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5982 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5984 sym_op->m_src = ut_params->ibuf;
5986 sym_op->auth.data.offset = 0;
5987 sym_op->auth.data.length = QUOTE_512_BYTES;
5989 /* Process crypto operation */
5990 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5992 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5994 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5995 "crypto operation processing failed");
5997 return TEST_SUCCESS;
6001 test_null_cipher_auth_operation(void)
6003 struct crypto_testsuite_params *ts_params = &testsuite_params;
6004 struct crypto_unittest_params *ut_params = &unittest_params;
6006 /* Generate test mbuf data and space for digest */
6007 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6008 catch_22_quote, QUOTE_512_BYTES, 0);
6010 /* Setup Cipher Parameters */
6011 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6012 ut_params->cipher_xform.next = &ut_params->auth_xform;
6014 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6015 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6017 /* Setup HMAC Parameters */
6018 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6019 ut_params->auth_xform.next = NULL;
6021 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6022 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6024 /* Create Crypto session*/
6025 ut_params->sess = rte_cryptodev_sym_session_create(
6026 ts_params->valid_devs[0], &ut_params->cipher_xform);
6027 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6029 /* Generate Crypto op data structure */
6030 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6031 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6032 TEST_ASSERT_NOT_NULL(ut_params->op,
6033 "Failed to allocate symmetric crypto operation struct");
6035 /* Set crypto operation data parameters */
6036 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6038 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6040 sym_op->m_src = ut_params->ibuf;
6042 sym_op->cipher.data.offset = 0;
6043 sym_op->cipher.data.length = QUOTE_512_BYTES;
6045 sym_op->auth.data.offset = 0;
6046 sym_op->auth.data.length = QUOTE_512_BYTES;
6048 /* Process crypto operation */
6049 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6051 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6053 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6054 "crypto operation processing failed");
6057 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6058 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6061 "Ciphertext data not as expected");
6063 return TEST_SUCCESS;
6067 test_null_auth_cipher_operation(void)
6069 struct crypto_testsuite_params *ts_params = &testsuite_params;
6070 struct crypto_unittest_params *ut_params = &unittest_params;
6072 /* Generate test mbuf data and space for digest */
6073 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6074 catch_22_quote, QUOTE_512_BYTES, 0);
6076 /* Setup Cipher Parameters */
6077 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6078 ut_params->cipher_xform.next = NULL;
6080 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6081 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6083 /* Setup HMAC Parameters */
6084 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6085 ut_params->auth_xform.next = &ut_params->cipher_xform;
6087 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6088 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6090 /* Create Crypto session*/
6091 ut_params->sess = rte_cryptodev_sym_session_create(
6092 ts_params->valid_devs[0], &ut_params->cipher_xform);
6093 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6095 /* Generate Crypto op data structure */
6096 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6097 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6098 TEST_ASSERT_NOT_NULL(ut_params->op,
6099 "Failed to allocate symmetric crypto operation struct");
6101 /* Set crypto operation data parameters */
6102 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6104 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6106 sym_op->m_src = ut_params->ibuf;
6108 sym_op->cipher.data.offset = 0;
6109 sym_op->cipher.data.length = QUOTE_512_BYTES;
6111 sym_op->auth.data.offset = 0;
6112 sym_op->auth.data.length = QUOTE_512_BYTES;
6114 /* Process crypto operation */
6115 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6117 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6119 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6120 "crypto operation processing failed");
6123 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6124 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6127 "Ciphertext data not as expected");
6129 return TEST_SUCCESS;
6134 test_null_invalid_operation(void)
6136 struct crypto_testsuite_params *ts_params = &testsuite_params;
6137 struct crypto_unittest_params *ut_params = &unittest_params;
6139 /* Setup Cipher Parameters */
6140 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6141 ut_params->cipher_xform.next = NULL;
6143 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6144 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6146 /* Create Crypto session*/
6147 ut_params->sess = rte_cryptodev_sym_session_create(
6148 ts_params->valid_devs[0], &ut_params->cipher_xform);
6149 TEST_ASSERT_NULL(ut_params->sess,
6150 "Session creation succeeded unexpectedly");
6153 /* Setup HMAC Parameters */
6154 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6155 ut_params->auth_xform.next = NULL;
6157 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6158 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6160 /* Create Crypto session*/
6161 ut_params->sess = rte_cryptodev_sym_session_create(
6162 ts_params->valid_devs[0], &ut_params->auth_xform);
6163 TEST_ASSERT_NULL(ut_params->sess,
6164 "Session creation succeeded unexpectedly");
6166 return TEST_SUCCESS;
6170 #define NULL_BURST_LENGTH (32)
6173 test_null_burst_operation(void)
6175 struct crypto_testsuite_params *ts_params = &testsuite_params;
6176 struct crypto_unittest_params *ut_params = &unittest_params;
6178 unsigned i, burst_len = NULL_BURST_LENGTH;
6180 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6181 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6183 /* Setup Cipher Parameters */
6184 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6185 ut_params->cipher_xform.next = &ut_params->auth_xform;
6187 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6188 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6190 /* Setup HMAC Parameters */
6191 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6192 ut_params->auth_xform.next = NULL;
6194 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6195 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6197 /* Create Crypto session*/
6198 ut_params->sess = rte_cryptodev_sym_session_create(
6199 ts_params->valid_devs[0], &ut_params->cipher_xform);
6200 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6202 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6203 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6204 burst_len, "failed to generate burst of crypto ops");
6206 /* Generate an operation for each mbuf in burst */
6207 for (i = 0; i < burst_len; i++) {
6208 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6210 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6212 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6216 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6218 burst[i]->sym->m_src = m;
6221 /* Process crypto operation */
6222 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6223 0, burst, burst_len),
6225 "Error enqueuing burst");
6227 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6228 0, burst_dequeued, burst_len),
6230 "Error dequeuing burst");
6233 for (i = 0; i < burst_len; i++) {
6235 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6236 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6238 "data not as expected");
6240 rte_pktmbuf_free(burst[i]->sym->m_src);
6241 rte_crypto_op_free(burst[i]);
6244 return TEST_SUCCESS;
6248 generate_gmac_large_plaintext(uint8_t *data)
6252 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6253 memcpy(&data[i], &data[0], 32);
6257 create_gmac_operation(enum rte_crypto_auth_operation op,
6258 const struct gmac_test_data *tdata)
6260 struct crypto_testsuite_params *ts_params = &testsuite_params;
6261 struct crypto_unittest_params *ut_params = &unittest_params;
6262 struct rte_crypto_sym_op *sym_op;
6264 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6266 /* Generate Crypto op data structure */
6267 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6268 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6269 TEST_ASSERT_NOT_NULL(ut_params->op,
6270 "Failed to allocate symmetric crypto operation struct");
6272 sym_op = ut_params->op->sym;
6274 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6275 ut_params->ibuf, tdata->gmac_tag.len);
6276 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6277 "no room to append digest");
6279 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6280 ut_params->ibuf, plaintext_pad_len);
6282 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6283 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6284 tdata->gmac_tag.len);
6285 TEST_HEXDUMP(stdout, "digest:",
6286 sym_op->auth.digest.data,
6287 tdata->gmac_tag.len);
6290 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6291 uint8_t *, IV_OFFSET);
6293 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6295 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6297 sym_op->cipher.data.length = 0;
6298 sym_op->cipher.data.offset = 0;
6300 sym_op->auth.data.offset = 0;
6301 sym_op->auth.data.length = tdata->plaintext.len;
6306 static int create_gmac_session(uint8_t dev_id,
6307 const struct gmac_test_data *tdata,
6308 enum rte_crypto_auth_operation auth_op)
6310 uint8_t auth_key[tdata->key.len];
6312 struct crypto_unittest_params *ut_params = &unittest_params;
6314 memcpy(auth_key, tdata->key.data, tdata->key.len);
6316 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6317 ut_params->auth_xform.next = NULL;
6319 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6320 ut_params->auth_xform.auth.op = auth_op;
6321 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6322 ut_params->auth_xform.auth.key.length = tdata->key.len;
6323 ut_params->auth_xform.auth.key.data = auth_key;
6324 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6325 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6328 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6329 &ut_params->auth_xform);
6331 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6337 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6339 struct crypto_testsuite_params *ts_params = &testsuite_params;
6340 struct crypto_unittest_params *ut_params = &unittest_params;
6344 uint8_t *auth_tag, *plaintext;
6345 uint16_t plaintext_pad_len;
6347 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6348 "No GMAC length in the source data");
6350 retval = create_gmac_session(ts_params->valid_devs[0],
6351 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6356 if (tdata->plaintext.len > MBUF_SIZE)
6357 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6359 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6360 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6361 "Failed to allocate input buffer in mempool");
6363 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6364 rte_pktmbuf_tailroom(ut_params->ibuf));
6366 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6368 * Runtime generate the large plain text instead of use hard code
6369 * plain text vector. It is done to avoid create huge source file
6370 * with the test vector.
6372 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6373 generate_gmac_large_plaintext(tdata->plaintext.data);
6375 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6377 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6379 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6380 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6381 tdata->plaintext.len);
6383 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6389 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6391 ut_params->op->sym->m_src = ut_params->ibuf;
6393 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6394 ut_params->op), "failed to process sym crypto op");
6396 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6397 "crypto op processing failed");
6399 if (ut_params->op->sym->m_dst) {
6400 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6401 uint8_t *, plaintext_pad_len);
6403 auth_tag = plaintext + plaintext_pad_len;
6406 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6408 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6410 tdata->gmac_tag.data,
6411 tdata->gmac_tag.len,
6412 "GMAC Generated auth tag not as expected");
6418 test_AES_GMAC_authentication_test_case_1(void)
6420 return test_AES_GMAC_authentication(&gmac_test_case_1);
6424 test_AES_GMAC_authentication_test_case_2(void)
6426 return test_AES_GMAC_authentication(&gmac_test_case_2);
6430 test_AES_GMAC_authentication_test_case_3(void)
6432 return test_AES_GMAC_authentication(&gmac_test_case_3);
6436 test_AES_GMAC_authentication_test_case_4(void)
6438 return test_AES_GMAC_authentication(&gmac_test_case_4);
6442 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6444 struct crypto_testsuite_params *ts_params = &testsuite_params;
6445 struct crypto_unittest_params *ut_params = &unittest_params;
6447 uint32_t plaintext_pad_len;
6450 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6451 "No GMAC length in the source data");
6453 retval = create_gmac_session(ts_params->valid_devs[0],
6454 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6459 if (tdata->plaintext.len > MBUF_SIZE)
6460 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6462 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6463 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6464 "Failed to allocate input buffer in mempool");
6466 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6467 rte_pktmbuf_tailroom(ut_params->ibuf));
6469 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6472 * Runtime generate the large plain text instead of use hard code
6473 * plain text vector. It is done to avoid create huge source file
6474 * with the test vector.
6476 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6477 generate_gmac_large_plaintext(tdata->plaintext.data);
6479 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6481 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6483 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6484 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6485 tdata->plaintext.len);
6487 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6493 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6495 ut_params->op->sym->m_src = ut_params->ibuf;
6497 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6498 ut_params->op), "failed to process sym crypto op");
6500 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6501 "crypto op processing failed");
6508 test_AES_GMAC_authentication_verify_test_case_1(void)
6510 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6514 test_AES_GMAC_authentication_verify_test_case_2(void)
6516 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6520 test_AES_GMAC_authentication_verify_test_case_3(void)
6522 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6526 test_AES_GMAC_authentication_verify_test_case_4(void)
6528 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6531 struct test_crypto_vector {
6532 enum rte_crypto_cipher_algorithm crypto_algo;
6545 const uint8_t *data;
6550 const uint8_t *data;
6554 enum rte_crypto_auth_algorithm auth_algo;
6562 const uint8_t *data;
6572 static const struct test_crypto_vector
6573 hmac_sha1_test_crypto_vector = {
6574 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6576 .data = plaintext_hash,
6581 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6582 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6583 0xDE, 0xF4, 0xDE, 0xAD
6589 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6590 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6591 0x3F, 0x91, 0x64, 0x59
6597 static const struct test_crypto_vector
6598 aes128_gmac_test_vector = {
6599 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6601 .data = plaintext_hash,
6606 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6607 0x08, 0x09, 0x0A, 0x0B
6613 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6614 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6620 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6621 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6627 static const struct test_crypto_vector
6628 aes128cbc_hmac_sha1_test_vector = {
6629 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6632 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6633 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6639 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6640 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6645 .data = plaintext_hash,
6649 .data = ciphertext512_aes128cbc,
6652 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6655 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6656 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6657 0xDE, 0xF4, 0xDE, 0xAD
6663 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6664 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6665 0x18, 0x8C, 0x1D, 0x32
6672 data_corruption(uint8_t *data)
6678 tag_corruption(uint8_t *data, unsigned int tag_offset)
6680 data[tag_offset] += 1;
6684 create_auth_session(struct crypto_unittest_params *ut_params,
6686 const struct test_crypto_vector *reference,
6687 enum rte_crypto_auth_operation auth_op)
6689 uint8_t auth_key[reference->auth_key.len + 1];
6691 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6693 /* Setup Authentication Parameters */
6694 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6695 ut_params->auth_xform.auth.op = auth_op;
6696 ut_params->auth_xform.next = NULL;
6697 ut_params->auth_xform.auth.algo = reference->auth_algo;
6698 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6699 ut_params->auth_xform.auth.key.data = auth_key;
6700 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6702 /* Create Crypto session*/
6703 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6704 &ut_params->auth_xform);
6706 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6712 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6714 const struct test_crypto_vector *reference,
6715 enum rte_crypto_auth_operation auth_op,
6716 enum rte_crypto_cipher_operation cipher_op)
6718 uint8_t cipher_key[reference->cipher_key.len + 1];
6719 uint8_t auth_key[reference->auth_key.len + 1];
6721 memcpy(cipher_key, reference->cipher_key.data,
6722 reference->cipher_key.len);
6723 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6725 /* Setup Authentication Parameters */
6726 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6727 ut_params->auth_xform.auth.op = auth_op;
6728 ut_params->auth_xform.auth.algo = reference->auth_algo;
6729 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6730 ut_params->auth_xform.auth.key.data = auth_key;
6731 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6733 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
6734 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6735 ut_params->auth_xform.auth.iv.length = reference->iv.len;
6737 ut_params->auth_xform.next = &ut_params->cipher_xform;
6739 /* Setup Cipher Parameters */
6740 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6741 ut_params->cipher_xform.next = NULL;
6742 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6743 ut_params->cipher_xform.cipher.op = cipher_op;
6744 ut_params->cipher_xform.cipher.key.data = cipher_key;
6745 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6746 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6747 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6750 /* Create Crypto session*/
6751 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6752 &ut_params->auth_xform);
6754 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6760 create_auth_operation(struct crypto_testsuite_params *ts_params,
6761 struct crypto_unittest_params *ut_params,
6762 const struct test_crypto_vector *reference,
6763 unsigned int auth_generate)
6765 /* Generate Crypto op data structure */
6766 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6767 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6768 TEST_ASSERT_NOT_NULL(ut_params->op,
6769 "Failed to allocate pktmbuf offload");
6771 /* Set crypto operation data parameters */
6772 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6774 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6776 /* set crypto operation source mbuf */
6777 sym_op->m_src = ut_params->ibuf;
6780 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6781 ut_params->ibuf, reference->digest.len);
6783 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6784 "no room to append auth tag");
6786 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6787 ut_params->ibuf, reference->plaintext.len);
6790 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6792 memcpy(sym_op->auth.digest.data,
6793 reference->digest.data,
6794 reference->digest.len);
6796 TEST_HEXDUMP(stdout, "digest:",
6797 sym_op->auth.digest.data,
6798 reference->digest.len);
6800 sym_op->auth.data.length = reference->plaintext.len;
6801 sym_op->auth.data.offset = 0;
6807 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6808 struct crypto_unittest_params *ut_params,
6809 const struct test_crypto_vector *reference,
6810 unsigned int auth_generate)
6812 /* Generate Crypto op data structure */
6813 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6814 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6815 TEST_ASSERT_NOT_NULL(ut_params->op,
6816 "Failed to allocate pktmbuf offload");
6818 /* Set crypto operation data parameters */
6819 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6821 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6823 /* set crypto operation source mbuf */
6824 sym_op->m_src = ut_params->ibuf;
6827 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6828 ut_params->ibuf, reference->digest.len);
6830 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6831 "no room to append auth tag");
6833 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6834 ut_params->ibuf, reference->ciphertext.len);
6837 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6839 memcpy(sym_op->auth.digest.data,
6840 reference->digest.data,
6841 reference->digest.len);
6843 TEST_HEXDUMP(stdout, "digest:",
6844 sym_op->auth.digest.data,
6845 reference->digest.len);
6847 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6848 reference->iv.data, reference->iv.len);
6850 sym_op->cipher.data.length = 0;
6851 sym_op->cipher.data.offset = 0;
6853 sym_op->auth.data.length = reference->plaintext.len;
6854 sym_op->auth.data.offset = 0;
6860 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6861 struct crypto_unittest_params *ut_params,
6862 const struct test_crypto_vector *reference,
6863 unsigned int auth_generate)
6865 /* Generate Crypto op data structure */
6866 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6867 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6868 TEST_ASSERT_NOT_NULL(ut_params->op,
6869 "Failed to allocate pktmbuf offload");
6871 /* Set crypto operation data parameters */
6872 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6874 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6876 /* set crypto operation source mbuf */
6877 sym_op->m_src = ut_params->ibuf;
6880 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6881 ut_params->ibuf, reference->digest.len);
6883 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6884 "no room to append auth tag");
6886 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6887 ut_params->ibuf, reference->ciphertext.len);
6890 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6892 memcpy(sym_op->auth.digest.data,
6893 reference->digest.data,
6894 reference->digest.len);
6896 TEST_HEXDUMP(stdout, "digest:",
6897 sym_op->auth.digest.data,
6898 reference->digest.len);
6900 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6901 reference->iv.data, reference->iv.len);
6903 sym_op->cipher.data.length = reference->ciphertext.len;
6904 sym_op->cipher.data.offset = 0;
6906 sym_op->auth.data.length = reference->ciphertext.len;
6907 sym_op->auth.data.offset = 0;
6913 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6914 struct crypto_unittest_params *ut_params,
6915 const struct test_crypto_vector *reference)
6917 return create_auth_operation(ts_params, ut_params, reference, 0);
6921 create_auth_verify_GMAC_operation(
6922 struct crypto_testsuite_params *ts_params,
6923 struct crypto_unittest_params *ut_params,
6924 const struct test_crypto_vector *reference)
6926 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6930 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6931 struct crypto_unittest_params *ut_params,
6932 const struct test_crypto_vector *reference)
6934 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6938 test_authentication_verify_fail_when_data_corruption(
6939 struct crypto_testsuite_params *ts_params,
6940 struct crypto_unittest_params *ut_params,
6941 const struct test_crypto_vector *reference,
6942 unsigned int data_corrupted)
6948 /* Create session */
6949 retval = create_auth_session(ut_params,
6950 ts_params->valid_devs[0],
6952 RTE_CRYPTO_AUTH_OP_VERIFY);
6956 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6957 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6958 "Failed to allocate input buffer in mempool");
6960 /* clear mbuf payload */
6961 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6962 rte_pktmbuf_tailroom(ut_params->ibuf));
6964 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6965 reference->plaintext.len);
6966 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6967 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6969 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6971 /* Create operation */
6972 retval = create_auth_verify_operation(ts_params, ut_params, reference);
6978 data_corruption(plaintext);
6980 tag_corruption(plaintext, reference->plaintext.len);
6982 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6984 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6985 TEST_ASSERT_EQUAL(ut_params->op->status,
6986 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6987 "authentication not failed");
6989 ut_params->obuf = ut_params->op->sym->m_src;
6990 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6996 test_authentication_verify_GMAC_fail_when_corruption(
6997 struct crypto_testsuite_params *ts_params,
6998 struct crypto_unittest_params *ut_params,
6999 const struct test_crypto_vector *reference,
7000 unsigned int data_corrupted)
7005 /* Create session */
7006 retval = create_auth_cipher_session(ut_params,
7007 ts_params->valid_devs[0],
7009 RTE_CRYPTO_AUTH_OP_VERIFY,
7010 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7014 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7015 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7016 "Failed to allocate input buffer in mempool");
7018 /* clear mbuf payload */
7019 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7020 rte_pktmbuf_tailroom(ut_params->ibuf));
7022 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7023 reference->plaintext.len);
7024 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7025 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7027 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7029 /* Create operation */
7030 retval = create_auth_verify_GMAC_operation(ts_params,
7038 data_corruption(plaintext);
7040 tag_corruption(plaintext, reference->aad.len);
7042 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7044 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7045 TEST_ASSERT_EQUAL(ut_params->op->status,
7046 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7047 "authentication not failed");
7049 ut_params->obuf = ut_params->op->sym->m_src;
7050 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7056 test_authenticated_decryption_fail_when_corruption(
7057 struct crypto_testsuite_params *ts_params,
7058 struct crypto_unittest_params *ut_params,
7059 const struct test_crypto_vector *reference,
7060 unsigned int data_corrupted)
7064 uint8_t *ciphertext;
7066 /* Create session */
7067 retval = create_auth_cipher_session(ut_params,
7068 ts_params->valid_devs[0],
7070 RTE_CRYPTO_AUTH_OP_VERIFY,
7071 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7075 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7076 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7077 "Failed to allocate input buffer in mempool");
7079 /* clear mbuf payload */
7080 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7081 rte_pktmbuf_tailroom(ut_params->ibuf));
7083 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7084 reference->ciphertext.len);
7085 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7086 memcpy(ciphertext, reference->ciphertext.data,
7087 reference->ciphertext.len);
7089 /* Create operation */
7090 retval = create_cipher_auth_verify_operation(ts_params,
7098 data_corruption(ciphertext);
7100 tag_corruption(ciphertext, reference->ciphertext.len);
7102 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7105 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7106 TEST_ASSERT_EQUAL(ut_params->op->status,
7107 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7108 "authentication not failed");
7110 ut_params->obuf = ut_params->op->sym->m_src;
7111 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7117 create_gcm_operation_SGL(enum rte_crypto_aead_operation op,
7118 const struct gcm_test_data *tdata,
7119 void *digest_mem, uint64_t digest_phys)
7121 struct crypto_testsuite_params *ts_params = &testsuite_params;
7122 struct crypto_unittest_params *ut_params = &unittest_params;
7124 const unsigned int auth_tag_len = tdata->auth_tag.len;
7125 const unsigned int iv_len = tdata->iv.len;
7126 const unsigned int aad_len = tdata->aad.len;
7128 /* Generate Crypto op data structure */
7129 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7130 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7131 TEST_ASSERT_NOT_NULL(ut_params->op,
7132 "Failed to allocate symmetric crypto operation struct");
7134 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7136 sym_op->aead.digest.data = digest_mem;
7138 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7139 "no room to append digest");
7141 sym_op->aead.digest.phys_addr = digest_phys;
7143 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7144 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7146 TEST_HEXDUMP(stdout, "digest:",
7147 sym_op->aead.digest.data,
7151 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7152 uint8_t *, IV_OFFSET);
7154 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7156 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7157 ut_params->ibuf, aad_len);
7158 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7159 "no room to prepend aad");
7160 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7163 memset(sym_op->aead.aad.data, 0, aad_len);
7164 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7166 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7167 TEST_HEXDUMP(stdout, "aad:",
7168 sym_op->aead.aad.data, aad_len);
7170 sym_op->aead.data.length = tdata->plaintext.len;
7171 sym_op->aead.data.offset = aad_len;
7176 #define SGL_MAX_NO 16
7179 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7180 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7182 struct crypto_testsuite_params *ts_params = &testsuite_params;
7183 struct crypto_unittest_params *ut_params = &unittest_params;
7184 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7187 int to_trn_tbl[SGL_MAX_NO];
7189 unsigned int trn_data = 0;
7190 uint8_t *plaintext, *ciphertext, *auth_tag;
7192 if (fragsz > tdata->plaintext.len)
7193 fragsz = tdata->plaintext.len;
7195 uint16_t plaintext_len = fragsz;
7196 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7198 if (fragsz_oop > tdata->plaintext.len)
7199 frag_size_oop = tdata->plaintext.len;
7202 void *digest_mem = NULL;
7204 uint32_t prepend_len = tdata->aad.len;
7206 if (tdata->plaintext.len % fragsz != 0) {
7207 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7210 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7215 * For out-op-place we need to alloc another mbuf
7218 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7219 rte_pktmbuf_append(ut_params->obuf,
7220 frag_size_oop + prepend_len);
7221 buf_oop = ut_params->obuf;
7224 /* Create GCM session */
7225 retval = create_gcm_session(ts_params->valid_devs[0],
7226 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7227 tdata->key.data, tdata->key.len,
7228 tdata->aad.len, tdata->auth_tag.len,
7233 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7235 /* clear mbuf payload */
7236 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7237 rte_pktmbuf_tailroom(ut_params->ibuf));
7239 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7242 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7244 trn_data += plaintext_len;
7246 buf = ut_params->ibuf;
7249 * Loop until no more fragments
7252 while (trn_data < tdata->plaintext.len) {
7254 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7255 (tdata->plaintext.len - trn_data) : fragsz;
7257 to_trn_tbl[ecx++] = to_trn;
7259 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7262 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7263 rte_pktmbuf_tailroom(buf));
7266 if (oop && !fragsz_oop) {
7267 buf_last_oop = buf_oop->next =
7268 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7269 buf_oop = buf_oop->next;
7270 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7271 0, rte_pktmbuf_tailroom(buf_oop));
7272 rte_pktmbuf_append(buf_oop, to_trn);
7275 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7278 memcpy(plaintext, tdata->plaintext.data + trn_data,
7281 if (trn_data == tdata->plaintext.len) {
7284 digest_mem = rte_pktmbuf_append(buf_oop,
7285 tdata->auth_tag.len);
7287 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7288 tdata->auth_tag.len);
7292 uint64_t digest_phys = 0;
7294 ut_params->ibuf->nb_segs = segs;
7297 if (fragsz_oop && oop) {
7301 if (frag_size_oop == tdata->plaintext.len) {
7302 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7303 tdata->auth_tag.len);
7305 digest_phys = rte_pktmbuf_mtophys_offset(
7307 tdata->plaintext.len + prepend_len);
7310 trn_data = frag_size_oop;
7311 while (trn_data < tdata->plaintext.len) {
7314 (tdata->plaintext.len - trn_data <
7316 (tdata->plaintext.len - trn_data) :
7319 to_trn_tbl[ecx++] = to_trn;
7321 buf_last_oop = buf_oop->next =
7322 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7323 buf_oop = buf_oop->next;
7324 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7325 0, rte_pktmbuf_tailroom(buf_oop));
7326 rte_pktmbuf_append(buf_oop, to_trn);
7330 if (trn_data == tdata->plaintext.len) {
7331 digest_mem = rte_pktmbuf_append(buf_oop,
7332 tdata->auth_tag.len);
7336 ut_params->obuf->nb_segs = segs;
7340 * Place digest at the end of the last buffer
7343 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7344 if (oop && buf_last_oop)
7345 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7347 if (!digest_mem && !oop) {
7348 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7349 + tdata->auth_tag.len);
7350 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7351 tdata->plaintext.len);
7354 /* Create GCM opertaion */
7355 retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7356 tdata, digest_mem, digest_phys);
7361 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7363 ut_params->op->sym->m_src = ut_params->ibuf;
7365 ut_params->op->sym->m_dst = ut_params->obuf;
7367 /* Process crypto operation */
7368 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7369 ut_params->op), "failed to process sym crypto op");
7371 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7372 "crypto op processing failed");
7375 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7376 uint8_t *, prepend_len);
7378 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7379 uint8_t *, prepend_len);
7383 fragsz = fragsz_oop;
7385 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7387 tdata->ciphertext.data,
7389 "GCM Ciphertext data not as expected");
7391 buf = ut_params->op->sym->m_src->next;
7393 buf = ut_params->op->sym->m_dst->next;
7395 unsigned int off = fragsz;
7399 ciphertext = rte_pktmbuf_mtod(buf,
7402 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7404 tdata->ciphertext.data + off,
7406 "GCM Ciphertext data not as expected");
7408 off += to_trn_tbl[ecx++];
7412 auth_tag = digest_mem;
7413 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7415 tdata->auth_tag.data,
7416 tdata->auth_tag.len,
7417 "GCM Generated auth tag not as expected");
7423 #define OUT_OF_PLACE 1
7426 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7428 return test_AES_GCM_authenticated_encryption_SGL(
7429 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7433 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7435 return test_AES_GCM_authenticated_encryption_SGL(
7436 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7440 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7442 return test_AES_GCM_authenticated_encryption_SGL(
7443 &gcm_test_case_8, OUT_OF_PLACE, 400,
7444 gcm_test_case_8.plaintext.len);
7448 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7451 return test_AES_GCM_authenticated_encryption_SGL(
7452 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7456 test_authentication_verify_fail_when_data_corrupted(
7457 struct crypto_testsuite_params *ts_params,
7458 struct crypto_unittest_params *ut_params,
7459 const struct test_crypto_vector *reference)
7461 return test_authentication_verify_fail_when_data_corruption(
7462 ts_params, ut_params, reference, 1);
7466 test_authentication_verify_fail_when_tag_corrupted(
7467 struct crypto_testsuite_params *ts_params,
7468 struct crypto_unittest_params *ut_params,
7469 const struct test_crypto_vector *reference)
7471 return test_authentication_verify_fail_when_data_corruption(
7472 ts_params, ut_params, reference, 0);
7476 test_authentication_verify_GMAC_fail_when_data_corrupted(
7477 struct crypto_testsuite_params *ts_params,
7478 struct crypto_unittest_params *ut_params,
7479 const struct test_crypto_vector *reference)
7481 return test_authentication_verify_GMAC_fail_when_corruption(
7482 ts_params, ut_params, reference, 1);
7486 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7487 struct crypto_testsuite_params *ts_params,
7488 struct crypto_unittest_params *ut_params,
7489 const struct test_crypto_vector *reference)
7491 return test_authentication_verify_GMAC_fail_when_corruption(
7492 ts_params, ut_params, reference, 0);
7496 test_authenticated_decryption_fail_when_data_corrupted(
7497 struct crypto_testsuite_params *ts_params,
7498 struct crypto_unittest_params *ut_params,
7499 const struct test_crypto_vector *reference)
7501 return test_authenticated_decryption_fail_when_corruption(
7502 ts_params, ut_params, reference, 1);
7506 test_authenticated_decryption_fail_when_tag_corrupted(
7507 struct crypto_testsuite_params *ts_params,
7508 struct crypto_unittest_params *ut_params,
7509 const struct test_crypto_vector *reference)
7511 return test_authenticated_decryption_fail_when_corruption(
7512 ts_params, ut_params, reference, 0);
7516 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7518 return test_authentication_verify_fail_when_data_corrupted(
7519 &testsuite_params, &unittest_params,
7520 &hmac_sha1_test_crypto_vector);
7524 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7526 return test_authentication_verify_fail_when_tag_corrupted(
7527 &testsuite_params, &unittest_params,
7528 &hmac_sha1_test_crypto_vector);
7532 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7534 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7535 &testsuite_params, &unittest_params,
7536 &aes128_gmac_test_vector);
7540 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7542 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7543 &testsuite_params, &unittest_params,
7544 &aes128_gmac_test_vector);
7548 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7550 return test_authenticated_decryption_fail_when_data_corrupted(
7553 &aes128cbc_hmac_sha1_test_vector);
7557 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7559 return test_authenticated_decryption_fail_when_tag_corrupted(
7562 &aes128cbc_hmac_sha1_test_vector);
7565 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7567 /* global AESNI slave IDs for the scheduler test */
7568 uint8_t aesni_ids[2];
7571 test_scheduler_attach_slave_op(void)
7573 struct crypto_testsuite_params *ts_params = &testsuite_params;
7574 uint8_t sched_id = ts_params->valid_devs[0];
7575 uint32_t nb_devs, i, nb_devs_attached = 0;
7579 /* create 2 AESNI_MB if necessary */
7580 nb_devs = rte_cryptodev_count_devtype(
7581 RTE_CRYPTODEV_AESNI_MB_PMD);
7583 for (i = nb_devs; i < 2; i++) {
7584 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7585 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7587 ret = rte_vdev_init(vdev_name, NULL);
7589 TEST_ASSERT(ret == 0,
7590 "Failed to create instance %u of"
7592 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7596 /* attach 2 AESNI_MB cdevs */
7597 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7599 struct rte_cryptodev_info info;
7601 rte_cryptodev_info_get(i, &info);
7602 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7605 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7608 TEST_ASSERT(ret == 0,
7609 "Failed to attach device %u of pmd : %s", i,
7610 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7612 aesni_ids[nb_devs_attached] = (uint8_t)i;
7621 test_scheduler_detach_slave_op(void)
7623 struct crypto_testsuite_params *ts_params = &testsuite_params;
7624 uint8_t sched_id = ts_params->valid_devs[0];
7628 for (i = 0; i < 2; i++) {
7629 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7631 TEST_ASSERT(ret == 0,
7632 "Failed to detach device %u", aesni_ids[i]);
7639 test_scheduler_mode_op(void)
7641 struct crypto_testsuite_params *ts_params = &testsuite_params;
7642 uint8_t sched_id = ts_params->valid_devs[0];
7643 struct rte_cryptodev_scheduler_ops op = {0};
7644 struct rte_cryptodev_scheduler dummy_scheduler = {
7645 .description = "dummy scheduler to test mode",
7646 .name = "dummy scheduler",
7647 .mode = CDEV_SCHED_MODE_USERDEFINED,
7652 /* set user defined mode */
7653 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7655 TEST_ASSERT(ret == 0,
7656 "Failed to set cdev %u to user defined mode", sched_id);
7658 /* set round robin mode */
7659 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7660 CDEV_SCHED_MODE_ROUNDROBIN);
7661 TEST_ASSERT(ret == 0,
7662 "Failed to set cdev %u to round-robin mode", sched_id);
7663 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7664 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7670 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7671 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7672 .setup = testsuite_setup,
7673 .teardown = testsuite_teardown,
7674 .unit_test_cases = {
7675 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7676 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7677 TEST_CASE_ST(ut_setup, ut_teardown,
7678 test_AES_chain_scheduler_all),
7679 TEST_CASE_ST(ut_setup, ut_teardown,
7680 test_AES_cipheronly_scheduler_all),
7681 TEST_CASE_ST(ut_setup, ut_teardown,
7682 test_authonly_scheduler_all),
7683 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7684 TEST_CASES_END() /**< NULL terminate unit test array */
7688 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7690 static struct unit_test_suite cryptodev_qat_testsuite = {
7691 .suite_name = "Crypto QAT Unit Test Suite",
7692 .setup = testsuite_setup,
7693 .teardown = testsuite_teardown,
7694 .unit_test_cases = {
7695 TEST_CASE_ST(ut_setup, ut_teardown,
7696 test_device_configure_invalid_dev_id),
7697 TEST_CASE_ST(ut_setup, ut_teardown,
7698 test_device_configure_invalid_queue_pair_ids),
7699 TEST_CASE_ST(ut_setup, ut_teardown,
7700 test_queue_pair_descriptor_setup),
7701 TEST_CASE_ST(ut_setup, ut_teardown,
7702 test_multi_session),
7704 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7705 TEST_CASE_ST(ut_setup, ut_teardown,
7706 test_AES_cipheronly_qat_all),
7707 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7708 TEST_CASE_ST(ut_setup, ut_teardown,
7709 test_3DES_cipheronly_qat_all),
7710 TEST_CASE_ST(ut_setup, ut_teardown,
7711 test_DES_cipheronly_qat_all),
7712 TEST_CASE_ST(ut_setup, ut_teardown,
7713 test_AES_docsis_qat_all),
7714 TEST_CASE_ST(ut_setup, ut_teardown,
7715 test_DES_docsis_qat_all),
7716 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7718 /** AES GCM Authenticated Encryption */
7719 TEST_CASE_ST(ut_setup, ut_teardown,
7720 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7721 TEST_CASE_ST(ut_setup, ut_teardown,
7722 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7723 TEST_CASE_ST(ut_setup, ut_teardown,
7724 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7725 TEST_CASE_ST(ut_setup, ut_teardown,
7726 test_AES_GCM_authenticated_encryption_test_case_1),
7727 TEST_CASE_ST(ut_setup, ut_teardown,
7728 test_AES_GCM_authenticated_encryption_test_case_2),
7729 TEST_CASE_ST(ut_setup, ut_teardown,
7730 test_AES_GCM_authenticated_encryption_test_case_3),
7731 TEST_CASE_ST(ut_setup, ut_teardown,
7732 test_AES_GCM_authenticated_encryption_test_case_4),
7733 TEST_CASE_ST(ut_setup, ut_teardown,
7734 test_AES_GCM_authenticated_encryption_test_case_5),
7735 TEST_CASE_ST(ut_setup, ut_teardown,
7736 test_AES_GCM_authenticated_encryption_test_case_6),
7737 TEST_CASE_ST(ut_setup, ut_teardown,
7738 test_AES_GCM_authenticated_encryption_test_case_7),
7740 /** AES GCM Authenticated Decryption */
7741 TEST_CASE_ST(ut_setup, ut_teardown,
7742 test_AES_GCM_authenticated_decryption_test_case_1),
7743 TEST_CASE_ST(ut_setup, ut_teardown,
7744 test_AES_GCM_authenticated_decryption_test_case_2),
7745 TEST_CASE_ST(ut_setup, ut_teardown,
7746 test_AES_GCM_authenticated_decryption_test_case_3),
7747 TEST_CASE_ST(ut_setup, ut_teardown,
7748 test_AES_GCM_authenticated_decryption_test_case_4),
7749 TEST_CASE_ST(ut_setup, ut_teardown,
7750 test_AES_GCM_authenticated_decryption_test_case_5),
7751 TEST_CASE_ST(ut_setup, ut_teardown,
7752 test_AES_GCM_authenticated_decryption_test_case_6),
7753 TEST_CASE_ST(ut_setup, ut_teardown,
7754 test_AES_GCM_authenticated_decryption_test_case_7),
7756 /** AES GMAC Authentication */
7757 TEST_CASE_ST(ut_setup, ut_teardown,
7758 test_AES_GMAC_authentication_test_case_1),
7759 TEST_CASE_ST(ut_setup, ut_teardown,
7760 test_AES_GMAC_authentication_verify_test_case_1),
7761 TEST_CASE_ST(ut_setup, ut_teardown,
7762 test_AES_GMAC_authentication_test_case_2),
7763 TEST_CASE_ST(ut_setup, ut_teardown,
7764 test_AES_GMAC_authentication_verify_test_case_2),
7765 TEST_CASE_ST(ut_setup, ut_teardown,
7766 test_AES_GMAC_authentication_test_case_3),
7767 TEST_CASE_ST(ut_setup, ut_teardown,
7768 test_AES_GMAC_authentication_verify_test_case_3),
7770 /** SNOW 3G encrypt only (UEA2) */
7771 TEST_CASE_ST(ut_setup, ut_teardown,
7772 test_snow3g_encryption_test_case_1),
7773 TEST_CASE_ST(ut_setup, ut_teardown,
7774 test_snow3g_encryption_test_case_2),
7775 TEST_CASE_ST(ut_setup, ut_teardown,
7776 test_snow3g_encryption_test_case_3),
7777 TEST_CASE_ST(ut_setup, ut_teardown,
7778 test_snow3g_encryption_test_case_4),
7779 TEST_CASE_ST(ut_setup, ut_teardown,
7780 test_snow3g_encryption_test_case_5),
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 test_snow3g_encryption_test_case_1_oop),
7784 TEST_CASE_ST(ut_setup, ut_teardown,
7785 test_snow3g_decryption_test_case_1_oop),
7787 /** SNOW 3G decrypt only (UEA2) */
7788 TEST_CASE_ST(ut_setup, ut_teardown,
7789 test_snow3g_decryption_test_case_1),
7790 TEST_CASE_ST(ut_setup, ut_teardown,
7791 test_snow3g_decryption_test_case_2),
7792 TEST_CASE_ST(ut_setup, ut_teardown,
7793 test_snow3g_decryption_test_case_3),
7794 TEST_CASE_ST(ut_setup, ut_teardown,
7795 test_snow3g_decryption_test_case_4),
7796 TEST_CASE_ST(ut_setup, ut_teardown,
7797 test_snow3g_decryption_test_case_5),
7798 TEST_CASE_ST(ut_setup, ut_teardown,
7799 test_snow3g_hash_generate_test_case_1),
7800 TEST_CASE_ST(ut_setup, ut_teardown,
7801 test_snow3g_hash_generate_test_case_2),
7802 TEST_CASE_ST(ut_setup, ut_teardown,
7803 test_snow3g_hash_generate_test_case_3),
7804 TEST_CASE_ST(ut_setup, ut_teardown,
7805 test_snow3g_hash_verify_test_case_1),
7806 TEST_CASE_ST(ut_setup, ut_teardown,
7807 test_snow3g_hash_verify_test_case_2),
7808 TEST_CASE_ST(ut_setup, ut_teardown,
7809 test_snow3g_hash_verify_test_case_3),
7810 TEST_CASE_ST(ut_setup, ut_teardown,
7811 test_snow3g_cipher_auth_test_case_1),
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_snow3g_auth_cipher_test_case_1),
7815 /** ZUC encrypt only (EEA3) */
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_zuc_encryption_test_case_1),
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_zuc_encryption_test_case_2),
7820 TEST_CASE_ST(ut_setup, ut_teardown,
7821 test_zuc_encryption_test_case_3),
7822 TEST_CASE_ST(ut_setup, ut_teardown,
7823 test_zuc_encryption_test_case_4),
7824 TEST_CASE_ST(ut_setup, ut_teardown,
7825 test_zuc_encryption_test_case_5),
7827 /** ZUC authenticate (EIA3) */
7828 TEST_CASE_ST(ut_setup, ut_teardown,
7829 test_zuc_hash_generate_test_case_6),
7830 TEST_CASE_ST(ut_setup, ut_teardown,
7831 test_zuc_hash_generate_test_case_7),
7832 TEST_CASE_ST(ut_setup, ut_teardown,
7833 test_zuc_hash_generate_test_case_8),
7835 /** ZUC alg-chain (EEA3/EIA3) */
7836 TEST_CASE_ST(ut_setup, ut_teardown,
7837 test_zuc_cipher_auth_test_case_1),
7838 TEST_CASE_ST(ut_setup, ut_teardown,
7839 test_zuc_cipher_auth_test_case_2),
7841 /** HMAC_MD5 Authentication */
7842 TEST_CASE_ST(ut_setup, ut_teardown,
7843 test_MD5_HMAC_generate_case_1),
7844 TEST_CASE_ST(ut_setup, ut_teardown,
7845 test_MD5_HMAC_verify_case_1),
7846 TEST_CASE_ST(ut_setup, ut_teardown,
7847 test_MD5_HMAC_generate_case_2),
7848 TEST_CASE_ST(ut_setup, ut_teardown,
7849 test_MD5_HMAC_verify_case_2),
7852 TEST_CASE_ST(ut_setup, ut_teardown,
7853 test_null_auth_only_operation),
7854 TEST_CASE_ST(ut_setup, ut_teardown,
7855 test_null_cipher_only_operation),
7856 TEST_CASE_ST(ut_setup, ut_teardown,
7857 test_null_cipher_auth_operation),
7858 TEST_CASE_ST(ut_setup, ut_teardown,
7859 test_null_auth_cipher_operation),
7861 TEST_CASE_ST(ut_setup, ut_teardown,
7862 test_kasumi_hash_generate_test_case_6),
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 test_kasumi_encryption_test_case_1),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 test_kasumi_encryption_test_case_3),
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_kasumi_auth_cipher_test_case_1),
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_kasumi_cipher_auth_test_case_1),
7874 /** Negative tests */
7875 TEST_CASE_ST(ut_setup, ut_teardown,
7876 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7877 TEST_CASE_ST(ut_setup, ut_teardown,
7878 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 authentication_verify_AES128_GMAC_fail_data_corrupt),
7881 TEST_CASE_ST(ut_setup, ut_teardown,
7882 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7883 TEST_CASE_ST(ut_setup, ut_teardown,
7884 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7885 TEST_CASE_ST(ut_setup, ut_teardown,
7886 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7888 TEST_CASES_END() /**< NULL terminate unit test array */
7892 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7893 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7894 .setup = testsuite_setup,
7895 .teardown = testsuite_teardown,
7896 .unit_test_cases = {
7897 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7898 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7899 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7900 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7902 TEST_CASES_END() /**< NULL terminate unit test array */
7906 static struct unit_test_suite cryptodev_openssl_testsuite = {
7907 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7908 .setup = testsuite_setup,
7909 .teardown = testsuite_teardown,
7910 .unit_test_cases = {
7911 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7912 TEST_CASE_ST(ut_setup, ut_teardown,
7913 test_multi_session_random_usage),
7914 TEST_CASE_ST(ut_setup, ut_teardown,
7915 test_AES_chain_openssl_all),
7916 TEST_CASE_ST(ut_setup, ut_teardown,
7917 test_AES_cipheronly_openssl_all),
7918 TEST_CASE_ST(ut_setup, ut_teardown,
7919 test_3DES_chain_openssl_all),
7920 TEST_CASE_ST(ut_setup, ut_teardown,
7921 test_3DES_cipheronly_openssl_all),
7922 TEST_CASE_ST(ut_setup, ut_teardown,
7923 test_DES_docsis_openssl_all),
7924 TEST_CASE_ST(ut_setup, ut_teardown,
7925 test_authonly_openssl_all),
7927 /** AES GCM Authenticated Encryption */
7928 TEST_CASE_ST(ut_setup, ut_teardown,
7929 test_AES_GCM_authenticated_encryption_test_case_1),
7930 TEST_CASE_ST(ut_setup, ut_teardown,
7931 test_AES_GCM_authenticated_encryption_test_case_2),
7932 TEST_CASE_ST(ut_setup, ut_teardown,
7933 test_AES_GCM_authenticated_encryption_test_case_3),
7934 TEST_CASE_ST(ut_setup, ut_teardown,
7935 test_AES_GCM_authenticated_encryption_test_case_4),
7936 TEST_CASE_ST(ut_setup, ut_teardown,
7937 test_AES_GCM_authenticated_encryption_test_case_5),
7938 TEST_CASE_ST(ut_setup, ut_teardown,
7939 test_AES_GCM_authenticated_encryption_test_case_6),
7940 TEST_CASE_ST(ut_setup, ut_teardown,
7941 test_AES_GCM_authenticated_encryption_test_case_7),
7943 /** AES GCM Authenticated Decryption */
7944 TEST_CASE_ST(ut_setup, ut_teardown,
7945 test_AES_GCM_authenticated_decryption_test_case_1),
7946 TEST_CASE_ST(ut_setup, ut_teardown,
7947 test_AES_GCM_authenticated_decryption_test_case_2),
7948 TEST_CASE_ST(ut_setup, ut_teardown,
7949 test_AES_GCM_authenticated_decryption_test_case_3),
7950 TEST_CASE_ST(ut_setup, ut_teardown,
7951 test_AES_GCM_authenticated_decryption_test_case_4),
7952 TEST_CASE_ST(ut_setup, ut_teardown,
7953 test_AES_GCM_authenticated_decryption_test_case_5),
7954 TEST_CASE_ST(ut_setup, ut_teardown,
7955 test_AES_GCM_authenticated_decryption_test_case_6),
7956 TEST_CASE_ST(ut_setup, ut_teardown,
7957 test_AES_GCM_authenticated_decryption_test_case_7),
7959 /** AES GMAC Authentication */
7960 TEST_CASE_ST(ut_setup, ut_teardown,
7961 test_AES_GMAC_authentication_test_case_1),
7962 TEST_CASE_ST(ut_setup, ut_teardown,
7963 test_AES_GMAC_authentication_verify_test_case_1),
7964 TEST_CASE_ST(ut_setup, ut_teardown,
7965 test_AES_GMAC_authentication_test_case_2),
7966 TEST_CASE_ST(ut_setup, ut_teardown,
7967 test_AES_GMAC_authentication_verify_test_case_2),
7968 TEST_CASE_ST(ut_setup, ut_teardown,
7969 test_AES_GMAC_authentication_test_case_3),
7970 TEST_CASE_ST(ut_setup, ut_teardown,
7971 test_AES_GMAC_authentication_verify_test_case_3),
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_AES_GMAC_authentication_test_case_4),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_AES_GMAC_authentication_verify_test_case_4),
7977 /** Scatter-Gather */
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7981 /** Negative tests */
7982 TEST_CASE_ST(ut_setup, ut_teardown,
7983 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7984 TEST_CASE_ST(ut_setup, ut_teardown,
7985 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7986 TEST_CASE_ST(ut_setup, ut_teardown,
7987 authentication_verify_AES128_GMAC_fail_data_corrupt),
7988 TEST_CASE_ST(ut_setup, ut_teardown,
7989 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7990 TEST_CASE_ST(ut_setup, ut_teardown,
7991 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7992 TEST_CASE_ST(ut_setup, ut_teardown,
7993 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7995 TEST_CASES_END() /**< NULL terminate unit test array */
7999 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8000 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8001 .setup = testsuite_setup,
8002 .teardown = testsuite_teardown,
8003 .unit_test_cases = {
8004 /** AES GCM Authenticated Encryption */
8005 TEST_CASE_ST(ut_setup, ut_teardown,
8006 test_AES_GCM_authenticated_encryption_test_case_1),
8007 TEST_CASE_ST(ut_setup, ut_teardown,
8008 test_AES_GCM_authenticated_encryption_test_case_2),
8009 TEST_CASE_ST(ut_setup, ut_teardown,
8010 test_AES_GCM_authenticated_encryption_test_case_3),
8011 TEST_CASE_ST(ut_setup, ut_teardown,
8012 test_AES_GCM_authenticated_encryption_test_case_4),
8013 TEST_CASE_ST(ut_setup, ut_teardown,
8014 test_AES_GCM_authenticated_encryption_test_case_5),
8015 TEST_CASE_ST(ut_setup, ut_teardown,
8016 test_AES_GCM_authenticated_encryption_test_case_6),
8017 TEST_CASE_ST(ut_setup, ut_teardown,
8018 test_AES_GCM_authenticated_encryption_test_case_7),
8020 /** AES GCM Authenticated Decryption */
8021 TEST_CASE_ST(ut_setup, ut_teardown,
8022 test_AES_GCM_authenticated_decryption_test_case_1),
8023 TEST_CASE_ST(ut_setup, ut_teardown,
8024 test_AES_GCM_authenticated_decryption_test_case_2),
8025 TEST_CASE_ST(ut_setup, ut_teardown,
8026 test_AES_GCM_authenticated_decryption_test_case_3),
8027 TEST_CASE_ST(ut_setup, ut_teardown,
8028 test_AES_GCM_authenticated_decryption_test_case_4),
8029 TEST_CASE_ST(ut_setup, ut_teardown,
8030 test_AES_GCM_authenticated_decryption_test_case_5),
8031 TEST_CASE_ST(ut_setup, ut_teardown,
8032 test_AES_GCM_authenticated_decryption_test_case_6),
8033 TEST_CASE_ST(ut_setup, ut_teardown,
8034 test_AES_GCM_authenticated_decryption_test_case_7),
8036 /** AES GCM Authenticated Encryption 256 bits key */
8037 TEST_CASE_ST(ut_setup, ut_teardown,
8038 test_AES_GCM_auth_encryption_test_case_256_1),
8039 TEST_CASE_ST(ut_setup, ut_teardown,
8040 test_AES_GCM_auth_encryption_test_case_256_2),
8041 TEST_CASE_ST(ut_setup, ut_teardown,
8042 test_AES_GCM_auth_encryption_test_case_256_3),
8043 TEST_CASE_ST(ut_setup, ut_teardown,
8044 test_AES_GCM_auth_encryption_test_case_256_4),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_AES_GCM_auth_encryption_test_case_256_5),
8047 TEST_CASE_ST(ut_setup, ut_teardown,
8048 test_AES_GCM_auth_encryption_test_case_256_6),
8049 TEST_CASE_ST(ut_setup, ut_teardown,
8050 test_AES_GCM_auth_encryption_test_case_256_7),
8052 /** AES GCM Authenticated Decryption 256 bits key */
8053 TEST_CASE_ST(ut_setup, ut_teardown,
8054 test_AES_GCM_auth_decryption_test_case_256_1),
8055 TEST_CASE_ST(ut_setup, ut_teardown,
8056 test_AES_GCM_auth_decryption_test_case_256_2),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_AES_GCM_auth_decryption_test_case_256_3),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 test_AES_GCM_auth_decryption_test_case_256_4),
8061 TEST_CASE_ST(ut_setup, ut_teardown,
8062 test_AES_GCM_auth_decryption_test_case_256_5),
8063 TEST_CASE_ST(ut_setup, ut_teardown,
8064 test_AES_GCM_auth_decryption_test_case_256_6),
8065 TEST_CASE_ST(ut_setup, ut_teardown,
8066 test_AES_GCM_auth_decryption_test_case_256_7),
8068 /** AES GCM Authenticated Encryption big aad size */
8069 TEST_CASE_ST(ut_setup, ut_teardown,
8070 test_AES_GCM_auth_encryption_test_case_aad_1),
8071 TEST_CASE_ST(ut_setup, ut_teardown,
8072 test_AES_GCM_auth_encryption_test_case_aad_2),
8074 /** AES GCM Authenticated Decryption big aad size */
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 test_AES_GCM_auth_decryption_test_case_aad_1),
8077 TEST_CASE_ST(ut_setup, ut_teardown,
8078 test_AES_GCM_auth_decryption_test_case_aad_2),
8080 /** AES GMAC Authentication */
8081 TEST_CASE_ST(ut_setup, ut_teardown,
8082 test_AES_GMAC_authentication_test_case_1),
8083 TEST_CASE_ST(ut_setup, ut_teardown,
8084 test_AES_GMAC_authentication_verify_test_case_1),
8085 TEST_CASE_ST(ut_setup, ut_teardown,
8086 test_AES_GMAC_authentication_test_case_3),
8087 TEST_CASE_ST(ut_setup, ut_teardown,
8088 test_AES_GMAC_authentication_verify_test_case_3),
8089 TEST_CASE_ST(ut_setup, ut_teardown,
8090 test_AES_GMAC_authentication_test_case_4),
8091 TEST_CASE_ST(ut_setup, ut_teardown,
8092 test_AES_GMAC_authentication_verify_test_case_4),
8094 /** Negative tests */
8095 TEST_CASE_ST(ut_setup, ut_teardown,
8096 authentication_verify_AES128_GMAC_fail_data_corrupt),
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8100 /** Out of place tests */
8101 TEST_CASE_ST(ut_setup, ut_teardown,
8102 test_AES_GCM_authenticated_encryption_oop_test_case_1),
8103 TEST_CASE_ST(ut_setup, ut_teardown,
8104 test_AES_GCM_authenticated_decryption_oop_test_case_1),
8106 /** Session-less tests */
8107 TEST_CASE_ST(ut_setup, ut_teardown,
8108 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
8109 TEST_CASE_ST(ut_setup, ut_teardown,
8110 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
8112 /** Scatter-Gather */
8113 TEST_CASE_ST(ut_setup, ut_teardown,
8114 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8116 TEST_CASES_END() /**< NULL terminate unit test array */
8120 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8121 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8122 .setup = testsuite_setup,
8123 .teardown = testsuite_teardown,
8124 .unit_test_cases = {
8125 /** KASUMI encrypt only (UEA1) */
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_kasumi_encryption_test_case_1),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_kasumi_encryption_test_case_1_sgl),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_kasumi_encryption_test_case_2),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 test_kasumi_encryption_test_case_3),
8134 TEST_CASE_ST(ut_setup, ut_teardown,
8135 test_kasumi_encryption_test_case_4),
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 test_kasumi_encryption_test_case_5),
8138 /** KASUMI decrypt only (UEA1) */
8139 TEST_CASE_ST(ut_setup, ut_teardown,
8140 test_kasumi_decryption_test_case_1),
8141 TEST_CASE_ST(ut_setup, ut_teardown,
8142 test_kasumi_decryption_test_case_2),
8143 TEST_CASE_ST(ut_setup, ut_teardown,
8144 test_kasumi_decryption_test_case_3),
8145 TEST_CASE_ST(ut_setup, ut_teardown,
8146 test_kasumi_decryption_test_case_4),
8147 TEST_CASE_ST(ut_setup, ut_teardown,
8148 test_kasumi_decryption_test_case_5),
8150 TEST_CASE_ST(ut_setup, ut_teardown,
8151 test_kasumi_encryption_test_case_1_oop),
8152 TEST_CASE_ST(ut_setup, ut_teardown,
8153 test_kasumi_encryption_test_case_1_oop_sgl),
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 test_kasumi_decryption_test_case_1_oop),
8159 /** KASUMI hash only (UIA1) */
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 test_kasumi_hash_generate_test_case_1),
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 test_kasumi_hash_generate_test_case_2),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_kasumi_hash_generate_test_case_3),
8166 TEST_CASE_ST(ut_setup, ut_teardown,
8167 test_kasumi_hash_generate_test_case_4),
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 test_kasumi_hash_generate_test_case_5),
8170 TEST_CASE_ST(ut_setup, ut_teardown,
8171 test_kasumi_hash_generate_test_case_6),
8172 TEST_CASE_ST(ut_setup, ut_teardown,
8173 test_kasumi_hash_verify_test_case_1),
8174 TEST_CASE_ST(ut_setup, ut_teardown,
8175 test_kasumi_hash_verify_test_case_2),
8176 TEST_CASE_ST(ut_setup, ut_teardown,
8177 test_kasumi_hash_verify_test_case_3),
8178 TEST_CASE_ST(ut_setup, ut_teardown,
8179 test_kasumi_hash_verify_test_case_4),
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 test_kasumi_hash_verify_test_case_5),
8182 TEST_CASE_ST(ut_setup, ut_teardown,
8183 test_kasumi_auth_cipher_test_case_1),
8184 TEST_CASE_ST(ut_setup, ut_teardown,
8185 test_kasumi_cipher_auth_test_case_1),
8186 TEST_CASES_END() /**< NULL terminate unit test array */
8189 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8190 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8191 .setup = testsuite_setup,
8192 .teardown = testsuite_teardown,
8193 .unit_test_cases = {
8194 /** SNOW 3G encrypt only (UEA2) */
8195 TEST_CASE_ST(ut_setup, ut_teardown,
8196 test_snow3g_encryption_test_case_1),
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_snow3g_encryption_test_case_2),
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_snow3g_encryption_test_case_3),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_snow3g_encryption_test_case_4),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_snow3g_encryption_test_case_5),
8206 TEST_CASE_ST(ut_setup, ut_teardown,
8207 test_snow3g_encryption_test_case_1_oop),
8208 TEST_CASE_ST(ut_setup, ut_teardown,
8209 test_snow3g_encryption_test_case_1_oop_sgl),
8210 TEST_CASE_ST(ut_setup, ut_teardown,
8211 test_snow3g_decryption_test_case_1_oop),
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 test_snow3g_encryption_test_case_1_offset_oop),
8216 /** SNOW 3G decrypt only (UEA2) */
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_snow3g_decryption_test_case_1),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_snow3g_decryption_test_case_2),
8221 TEST_CASE_ST(ut_setup, ut_teardown,
8222 test_snow3g_decryption_test_case_3),
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_snow3g_decryption_test_case_4),
8225 TEST_CASE_ST(ut_setup, ut_teardown,
8226 test_snow3g_decryption_test_case_5),
8227 TEST_CASE_ST(ut_setup, ut_teardown,
8228 test_snow3g_hash_generate_test_case_1),
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 test_snow3g_hash_generate_test_case_2),
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 test_snow3g_hash_generate_test_case_3),
8233 /* Tests with buffers which length is not byte-aligned */
8234 TEST_CASE_ST(ut_setup, ut_teardown,
8235 test_snow3g_hash_generate_test_case_4),
8236 TEST_CASE_ST(ut_setup, ut_teardown,
8237 test_snow3g_hash_generate_test_case_5),
8238 TEST_CASE_ST(ut_setup, ut_teardown,
8239 test_snow3g_hash_generate_test_case_6),
8240 TEST_CASE_ST(ut_setup, ut_teardown,
8241 test_snow3g_hash_verify_test_case_1),
8242 TEST_CASE_ST(ut_setup, ut_teardown,
8243 test_snow3g_hash_verify_test_case_2),
8244 TEST_CASE_ST(ut_setup, ut_teardown,
8245 test_snow3g_hash_verify_test_case_3),
8246 /* Tests with buffers which length is not byte-aligned */
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_snow3g_hash_verify_test_case_4),
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_snow3g_hash_verify_test_case_5),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_snow3g_hash_verify_test_case_6),
8253 TEST_CASE_ST(ut_setup, ut_teardown,
8254 test_snow3g_cipher_auth_test_case_1),
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_snow3g_auth_cipher_test_case_1),
8258 TEST_CASES_END() /**< NULL terminate unit test array */
8262 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8263 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8264 .setup = testsuite_setup,
8265 .teardown = testsuite_teardown,
8266 .unit_test_cases = {
8267 /** ZUC encrypt only (EEA3) */
8268 TEST_CASE_ST(ut_setup, ut_teardown,
8269 test_zuc_encryption_test_case_1),
8270 TEST_CASE_ST(ut_setup, ut_teardown,
8271 test_zuc_encryption_test_case_2),
8272 TEST_CASE_ST(ut_setup, ut_teardown,
8273 test_zuc_encryption_test_case_3),
8274 TEST_CASE_ST(ut_setup, ut_teardown,
8275 test_zuc_encryption_test_case_4),
8276 TEST_CASE_ST(ut_setup, ut_teardown,
8277 test_zuc_encryption_test_case_5),
8278 TEST_CASE_ST(ut_setup, ut_teardown,
8279 test_zuc_hash_generate_test_case_1),
8280 TEST_CASE_ST(ut_setup, ut_teardown,
8281 test_zuc_hash_generate_test_case_2),
8282 TEST_CASE_ST(ut_setup, ut_teardown,
8283 test_zuc_hash_generate_test_case_3),
8284 TEST_CASE_ST(ut_setup, ut_teardown,
8285 test_zuc_hash_generate_test_case_4),
8286 TEST_CASE_ST(ut_setup, ut_teardown,
8287 test_zuc_hash_generate_test_case_5),
8288 TEST_CASE_ST(ut_setup, ut_teardown,
8289 test_zuc_encryption_test_case_6_sgl),
8290 TEST_CASES_END() /**< NULL terminate unit test array */
8294 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8295 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8296 .setup = testsuite_setup,
8297 .teardown = testsuite_teardown,
8298 .unit_test_cases = {
8299 TEST_CASE_ST(ut_setup, ut_teardown,
8300 test_device_configure_invalid_dev_id),
8301 TEST_CASE_ST(ut_setup, ut_teardown,
8302 test_multi_session),
8304 TEST_CASE_ST(ut_setup, ut_teardown,
8305 test_AES_chain_dpaa2_sec_all),
8306 TEST_CASE_ST(ut_setup, ut_teardown,
8307 test_3DES_chain_dpaa2_sec_all),
8308 TEST_CASE_ST(ut_setup, ut_teardown,
8309 test_AES_cipheronly_dpaa2_sec_all),
8310 TEST_CASE_ST(ut_setup, ut_teardown,
8311 test_3DES_cipheronly_dpaa2_sec_all),
8312 TEST_CASE_ST(ut_setup, ut_teardown,
8313 test_authonly_dpaa2_sec_all),
8315 /** AES GCM Authenticated Encryption */
8316 TEST_CASE_ST(ut_setup, ut_teardown,
8317 test_AES_GCM_authenticated_encryption_test_case_1),
8318 TEST_CASE_ST(ut_setup, ut_teardown,
8319 test_AES_GCM_authenticated_encryption_test_case_2),
8320 TEST_CASE_ST(ut_setup, ut_teardown,
8321 test_AES_GCM_authenticated_encryption_test_case_3),
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_AES_GCM_authenticated_encryption_test_case_4),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_AES_GCM_authenticated_encryption_test_case_5),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_AES_GCM_authenticated_encryption_test_case_6),
8328 TEST_CASE_ST(ut_setup, ut_teardown,
8329 test_AES_GCM_authenticated_encryption_test_case_7),
8331 /** AES GCM Authenticated Decryption */
8332 TEST_CASE_ST(ut_setup, ut_teardown,
8333 test_AES_GCM_authenticated_decryption_test_case_1),
8334 TEST_CASE_ST(ut_setup, ut_teardown,
8335 test_AES_GCM_authenticated_decryption_test_case_2),
8336 TEST_CASE_ST(ut_setup, ut_teardown,
8337 test_AES_GCM_authenticated_decryption_test_case_3),
8338 TEST_CASE_ST(ut_setup, ut_teardown,
8339 test_AES_GCM_authenticated_decryption_test_case_4),
8340 TEST_CASE_ST(ut_setup, ut_teardown,
8341 test_AES_GCM_authenticated_decryption_test_case_5),
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_AES_GCM_authenticated_decryption_test_case_6),
8344 TEST_CASE_ST(ut_setup, ut_teardown,
8345 test_AES_GCM_authenticated_decryption_test_case_7),
8347 /** AES GCM Authenticated Encryption 256 bits key */
8348 TEST_CASE_ST(ut_setup, ut_teardown,
8349 test_AES_GCM_auth_encryption_test_case_256_1),
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_AES_GCM_auth_encryption_test_case_256_2),
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_AES_GCM_auth_encryption_test_case_256_3),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_AES_GCM_auth_encryption_test_case_256_4),
8356 TEST_CASE_ST(ut_setup, ut_teardown,
8357 test_AES_GCM_auth_encryption_test_case_256_5),
8358 TEST_CASE_ST(ut_setup, ut_teardown,
8359 test_AES_GCM_auth_encryption_test_case_256_6),
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_AES_GCM_auth_encryption_test_case_256_7),
8363 /** AES GCM Authenticated Decryption 256 bits key */
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_AES_GCM_auth_decryption_test_case_256_1),
8366 TEST_CASE_ST(ut_setup, ut_teardown,
8367 test_AES_GCM_auth_decryption_test_case_256_2),
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 test_AES_GCM_auth_decryption_test_case_256_3),
8370 TEST_CASE_ST(ut_setup, ut_teardown,
8371 test_AES_GCM_auth_decryption_test_case_256_4),
8372 TEST_CASE_ST(ut_setup, ut_teardown,
8373 test_AES_GCM_auth_decryption_test_case_256_5),
8374 TEST_CASE_ST(ut_setup, ut_teardown,
8375 test_AES_GCM_auth_decryption_test_case_256_6),
8376 TEST_CASE_ST(ut_setup, ut_teardown,
8377 test_AES_GCM_auth_decryption_test_case_256_7),
8379 TEST_CASES_END() /**< NULL terminate unit test array */
8383 static struct unit_test_suite cryptodev_null_testsuite = {
8384 .suite_name = "Crypto Device NULL Unit Test Suite",
8385 .setup = testsuite_setup,
8386 .teardown = testsuite_teardown,
8387 .unit_test_cases = {
8388 TEST_CASE_ST(ut_setup, ut_teardown,
8389 test_null_auth_only_operation),
8390 TEST_CASE_ST(ut_setup, ut_teardown,
8391 test_null_cipher_only_operation),
8392 TEST_CASE_ST(ut_setup, ut_teardown,
8393 test_null_cipher_auth_operation),
8394 TEST_CASE_ST(ut_setup, ut_teardown,
8395 test_null_auth_cipher_operation),
8396 TEST_CASE_ST(ut_setup, ut_teardown,
8397 test_null_invalid_operation),
8398 TEST_CASE_ST(ut_setup, ut_teardown,
8399 test_null_burst_operation),
8401 TEST_CASES_END() /**< NULL terminate unit test array */
8405 static struct unit_test_suite cryptodev_armv8_testsuite = {
8406 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8407 .setup = testsuite_setup,
8408 .teardown = testsuite_teardown,
8409 .unit_test_cases = {
8410 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8412 /** Negative tests */
8413 TEST_CASE_ST(ut_setup, ut_teardown,
8414 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8415 TEST_CASE_ST(ut_setup, ut_teardown,
8416 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8418 TEST_CASES_END() /**< NULL terminate unit test array */
8423 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8425 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8426 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8430 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8432 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8434 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8438 test_cryptodev_openssl(void)
8440 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8442 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8446 test_cryptodev_aesni_gcm(void)
8448 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8450 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8454 test_cryptodev_null(void)
8456 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8458 return unit_test_suite_runner(&cryptodev_null_testsuite);
8462 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8464 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8466 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8470 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8472 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8474 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8478 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8480 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8482 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8486 test_cryptodev_armv8(void)
8488 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8490 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8493 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8496 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8498 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8499 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8502 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8507 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8509 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8510 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8513 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8514 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8515 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8516 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8517 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8518 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8519 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8520 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8521 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8522 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);