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>
39 #include <rte_crypto.h>
40 #include <rte_cryptodev.h>
41 #include <rte_cryptodev_pmd.h>
43 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
44 #include <rte_cryptodev_scheduler.h>
45 #include <rte_cryptodev_scheduler_operations.h>
49 #include "test_cryptodev.h"
51 #include "test_cryptodev_blockcipher.h"
52 #include "test_cryptodev_aes_test_vectors.h"
53 #include "test_cryptodev_des_test_vectors.h"
54 #include "test_cryptodev_hash_test_vectors.h"
55 #include "test_cryptodev_kasumi_test_vectors.h"
56 #include "test_cryptodev_kasumi_hash_test_vectors.h"
57 #include "test_cryptodev_snow3g_test_vectors.h"
58 #include "test_cryptodev_snow3g_hash_test_vectors.h"
59 #include "test_cryptodev_zuc_test_vectors.h"
60 #include "test_cryptodev_gcm_test_vectors.h"
61 #include "test_cryptodev_hmac_test_vectors.h"
63 static enum rte_cryptodev_type gbl_cryptodev_type;
65 struct crypto_testsuite_params {
66 struct rte_mempool *mbuf_pool;
67 struct rte_mempool *large_mbuf_pool;
68 struct rte_mempool *op_mpool;
69 struct rte_cryptodev_config conf;
70 struct rte_cryptodev_qp_conf qp_conf;
72 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
73 uint8_t valid_dev_count;
76 struct crypto_unittest_params {
77 struct rte_crypto_sym_xform cipher_xform;
78 struct rte_crypto_sym_xform auth_xform;
80 struct rte_cryptodev_sym_session *sess;
82 struct rte_crypto_op *op;
84 struct rte_mbuf *obuf, *ibuf;
89 #define ALIGN_POW2_ROUNDUP(num, align) \
90 (((num) + (align) - 1) & ~((align) - 1))
93 * Forward declarations.
96 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
97 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
101 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
102 struct crypto_unittest_params *ut_params,
103 struct crypto_testsuite_params *ts_param,
104 const uint8_t *cipher,
105 const uint8_t *digest,
108 static struct rte_mbuf *
109 setup_test_string(struct rte_mempool *mpool,
110 const char *string, size_t len, uint8_t blocksize)
112 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
113 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
115 memset(m->buf_addr, 0, m->buf_len);
117 char *dst = rte_pktmbuf_append(m, t_len);
124 rte_memcpy(dst, string, t_len);
126 memset(dst, 0, t_len);
132 /* Get number of bytes in X bits (rounding up) */
134 ceil_byte_length(uint32_t num_bits)
137 return ((num_bits >> 3) + 1);
139 return (num_bits >> 3);
142 static struct rte_crypto_op *
143 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
145 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
146 printf("Error sending packet for encryption");
152 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
158 static struct crypto_testsuite_params testsuite_params = { NULL };
159 static struct crypto_unittest_params unittest_params;
162 testsuite_setup(void)
164 struct crypto_testsuite_params *ts_params = &testsuite_params;
165 struct rte_cryptodev_info info;
166 uint32_t i = 0, nb_devs, dev_id;
170 memset(ts_params, 0, sizeof(*ts_params));
172 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
173 if (ts_params->mbuf_pool == NULL) {
174 /* Not already created so create */
175 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
177 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
179 if (ts_params->mbuf_pool == NULL) {
180 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
185 ts_params->large_mbuf_pool = rte_mempool_lookup(
186 "CRYPTO_LARGE_MBUFPOOL");
187 if (ts_params->large_mbuf_pool == NULL) {
188 /* Not already created so create */
189 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
190 "CRYPTO_LARGE_MBUFPOOL",
193 if (ts_params->large_mbuf_pool == NULL) {
195 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
200 ts_params->op_mpool = rte_crypto_op_pool_create(
201 "MBUF_CRYPTO_SYM_OP_POOL",
202 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
203 NUM_MBUFS, MBUF_CACHE_SIZE,
205 sizeof(struct rte_crypto_sym_xform),
207 if (ts_params->op_mpool == NULL) {
208 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
212 /* Create an AESNI MB device if required */
213 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
214 #ifndef RTE_LIBRTE_PMD_AESNI_MB
215 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
216 " enabled in config file to run this testsuite.\n");
219 nb_devs = rte_cryptodev_count_devtype(
220 RTE_CRYPTODEV_AESNI_MB_PMD);
222 ret = rte_eal_vdev_init(
223 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
225 TEST_ASSERT(ret == 0,
226 "Failed to create instance of"
228 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
232 /* Create an AESNI GCM device if required */
233 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
234 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
235 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
236 " enabled in config file to run this testsuite.\n");
239 nb_devs = rte_cryptodev_count_devtype(
240 RTE_CRYPTODEV_AESNI_GCM_PMD);
242 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
243 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
244 "Failed to create instance of"
246 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
250 /* Create a SNOW 3G device if required */
251 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
252 #ifndef RTE_LIBRTE_PMD_SNOW3G
253 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
254 " enabled in config file to run this testsuite.\n");
257 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
259 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
260 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
261 "Failed to create instance of"
263 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
267 /* Create a KASUMI device if required */
268 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
269 #ifndef RTE_LIBRTE_PMD_KASUMI
270 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
271 " enabled in config file to run this testsuite.\n");
274 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
276 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
277 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
278 "Failed to create instance of"
280 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
284 /* Create a ZUC device if required */
285 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
286 #ifndef RTE_LIBRTE_PMD_ZUC
287 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
288 " enabled in config file to run this testsuite.\n");
291 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
293 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
294 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
295 "Failed to create instance of"
297 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
301 /* Create a NULL device if required */
302 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
303 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
304 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
305 " enabled in config file to run this testsuite.\n");
308 nb_devs = rte_cryptodev_count_devtype(
309 RTE_CRYPTODEV_NULL_PMD);
311 ret = rte_eal_vdev_init(
312 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
314 TEST_ASSERT(ret == 0,
315 "Failed to create instance of"
317 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
321 /* Create an OPENSSL device if required */
322 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
323 #ifndef RTE_LIBRTE_PMD_OPENSSL
324 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
325 " enabled in config file to run this testsuite.\n");
328 nb_devs = rte_cryptodev_count_devtype(
329 RTE_CRYPTODEV_OPENSSL_PMD);
331 ret = rte_eal_vdev_init(
332 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
335 TEST_ASSERT(ret == 0, "Failed to create "
336 "instance of pmd : %s",
337 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
341 /* Create a ARMv8 device if required */
342 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
343 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
344 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
345 " enabled in config file to run this testsuite.\n");
348 nb_devs = rte_cryptodev_count_devtype(
349 RTE_CRYPTODEV_ARMV8_PMD);
351 ret = rte_eal_vdev_init(
352 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
355 TEST_ASSERT(ret == 0, "Failed to create "
356 "instance of pmd : %s",
357 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
361 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
362 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
364 #ifndef RTE_LIBRTE_PMD_AESNI_MB
365 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
366 " enabled in config file to run this testsuite.\n");
369 nb_devs = rte_cryptodev_count_devtype(
370 RTE_CRYPTODEV_SCHEDULER_PMD);
372 ret = rte_eal_vdev_init(
373 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
376 TEST_ASSERT(ret == 0,
377 "Failed to create instance %u of"
379 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
382 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
384 #ifndef RTE_LIBRTE_PMD_QAT
385 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
386 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
387 "in config file to run this testsuite.\n");
392 nb_devs = rte_cryptodev_count();
394 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
398 /* Create list of valid crypto devs */
399 for (i = 0; i < nb_devs; i++) {
400 rte_cryptodev_info_get(i, &info);
401 if (info.dev_type == gbl_cryptodev_type)
402 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
405 if (ts_params->valid_dev_count < 1)
408 /* Set up all the qps on the first of the valid devices found */
410 dev_id = ts_params->valid_devs[0];
412 rte_cryptodev_info_get(dev_id, &info);
414 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
415 ts_params->conf.socket_id = SOCKET_ID_ANY;
416 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
418 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
420 "Failed to configure cryptodev %u with %u qps",
421 dev_id, ts_params->conf.nb_queue_pairs);
423 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
425 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
426 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
427 dev_id, qp_id, &ts_params->qp_conf,
428 rte_cryptodev_socket_id(dev_id)),
429 "Failed to setup queue pair %u on cryptodev %u",
437 testsuite_teardown(void)
439 struct crypto_testsuite_params *ts_params = &testsuite_params;
441 if (ts_params->mbuf_pool != NULL) {
442 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
443 rte_mempool_avail_count(ts_params->mbuf_pool));
446 if (ts_params->op_mpool != NULL) {
447 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
448 rte_mempool_avail_count(ts_params->op_mpool));
456 struct crypto_testsuite_params *ts_params = &testsuite_params;
457 struct crypto_unittest_params *ut_params = &unittest_params;
461 /* Clear unit test parameters before running test */
462 memset(ut_params, 0, sizeof(*ut_params));
464 /* Reconfigure device to default parameters */
465 ts_params->conf.socket_id = SOCKET_ID_ANY;
466 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
468 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
470 "Failed to configure cryptodev %u",
471 ts_params->valid_devs[0]);
473 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
474 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
475 ts_params->valid_devs[0], qp_id,
477 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
478 "Failed to setup queue pair %u on cryptodev %u",
479 qp_id, ts_params->valid_devs[0]);
483 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
485 /* Start the device */
486 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
487 "Failed to start cryptodev %u",
488 ts_params->valid_devs[0]);
496 struct crypto_testsuite_params *ts_params = &testsuite_params;
497 struct crypto_unittest_params *ut_params = &unittest_params;
498 struct rte_cryptodev_stats stats;
500 /* free crypto session structure */
501 if (ut_params->sess) {
502 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
504 ut_params->sess = NULL;
507 /* free crypto operation structure */
509 rte_crypto_op_free(ut_params->op);
512 * free mbuf - both obuf and ibuf are usually the same,
513 * so check if they point at the same address is necessary,
514 * to avoid freeing the mbuf twice.
516 if (ut_params->obuf) {
517 rte_pktmbuf_free(ut_params->obuf);
518 if (ut_params->ibuf == ut_params->obuf)
522 if (ut_params->ibuf) {
523 rte_pktmbuf_free(ut_params->ibuf);
527 if (ts_params->mbuf_pool != NULL)
528 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
529 rte_mempool_avail_count(ts_params->mbuf_pool));
531 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
533 /* Stop the device */
534 rte_cryptodev_stop(ts_params->valid_devs[0]);
538 test_device_configure_invalid_dev_id(void)
540 struct crypto_testsuite_params *ts_params = &testsuite_params;
541 uint16_t dev_id, num_devs = 0;
543 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
544 "Need at least %d devices for test", 1);
546 /* valid dev_id values */
547 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
549 /* Stop the device in case it's started so it can be configured */
550 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
552 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
553 "Failed test for rte_cryptodev_configure: "
554 "invalid dev_num %u", dev_id);
556 /* invalid dev_id values */
559 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
560 "Failed test for rte_cryptodev_configure: "
561 "invalid dev_num %u", dev_id);
565 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
566 "Failed test for rte_cryptodev_configure:"
567 "invalid dev_num %u", dev_id);
573 test_device_configure_invalid_queue_pair_ids(void)
575 struct crypto_testsuite_params *ts_params = &testsuite_params;
576 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
578 /* Stop the device in case it's started so it can be configured */
579 rte_cryptodev_stop(ts_params->valid_devs[0]);
581 /* valid - one queue pairs */
582 ts_params->conf.nb_queue_pairs = 1;
584 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
586 "Failed to configure cryptodev: dev_id %u, qp_id %u",
587 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
590 /* valid - max value queue pairs */
591 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
593 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
595 "Failed to configure cryptodev: dev_id %u, qp_id %u",
596 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
599 /* invalid - zero queue pairs */
600 ts_params->conf.nb_queue_pairs = 0;
602 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
604 "Failed test for rte_cryptodev_configure, dev_id %u,"
606 ts_params->valid_devs[0],
607 ts_params->conf.nb_queue_pairs);
610 /* invalid - max value supported by field queue pairs */
611 ts_params->conf.nb_queue_pairs = UINT16_MAX;
613 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
615 "Failed test for rte_cryptodev_configure, dev_id %u,"
617 ts_params->valid_devs[0],
618 ts_params->conf.nb_queue_pairs);
621 /* invalid - max value + 1 queue pairs */
622 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
624 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
626 "Failed test for rte_cryptodev_configure, dev_id %u,"
628 ts_params->valid_devs[0],
629 ts_params->conf.nb_queue_pairs);
631 /* revert to original testsuite value */
632 ts_params->conf.nb_queue_pairs = orig_nb_qps;
638 test_queue_pair_descriptor_setup(void)
640 struct crypto_testsuite_params *ts_params = &testsuite_params;
641 struct rte_cryptodev_info dev_info;
642 struct rte_cryptodev_qp_conf qp_conf = {
643 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
648 /* Stop the device in case it's started so it can be configured */
649 rte_cryptodev_stop(ts_params->valid_devs[0]);
652 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
654 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
656 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
657 &ts_params->conf), "Failed to configure cryptodev %u",
658 ts_params->valid_devs[0]);
662 * Test various ring sizes on this device. memzones can't be
663 * freed so are re-used if ring is released and re-created.
665 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
667 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
668 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
669 ts_params->valid_devs[0], qp_id, &qp_conf,
670 rte_cryptodev_socket_id(
671 ts_params->valid_devs[0])),
673 "rte_cryptodev_queue_pair_setup: num_inflights "
674 "%u on qp %u on cryptodev %u",
675 qp_conf.nb_descriptors, qp_id,
676 ts_params->valid_devs[0]);
679 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
681 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
682 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
683 ts_params->valid_devs[0], qp_id, &qp_conf,
684 rte_cryptodev_socket_id(
685 ts_params->valid_devs[0])),
687 " rte_cryptodev_queue_pair_setup: num_inflights"
688 " %u on qp %u on cryptodev %u",
689 qp_conf.nb_descriptors, qp_id,
690 ts_params->valid_devs[0]);
693 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
695 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
696 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
697 ts_params->valid_devs[0], qp_id, &qp_conf,
698 rte_cryptodev_socket_id(
699 ts_params->valid_devs[0])),
701 "rte_cryptodev_queue_pair_setup: num_inflights"
702 " %u on qp %u on cryptodev %u",
703 qp_conf.nb_descriptors, qp_id,
704 ts_params->valid_devs[0]);
707 /* invalid number of descriptors - max supported + 2 */
708 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
710 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
711 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
712 ts_params->valid_devs[0], qp_id, &qp_conf,
713 rte_cryptodev_socket_id(
714 ts_params->valid_devs[0])),
715 "Unexpectedly passed test for "
716 "rte_cryptodev_queue_pair_setup:"
717 "num_inflights %u on qp %u on cryptodev %u",
718 qp_conf.nb_descriptors, qp_id,
719 ts_params->valid_devs[0]);
722 /* invalid number of descriptors - max value of parameter */
723 qp_conf.nb_descriptors = UINT32_MAX-1;
725 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
726 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
727 ts_params->valid_devs[0], qp_id, &qp_conf,
728 rte_cryptodev_socket_id(
729 ts_params->valid_devs[0])),
730 "Unexpectedly passed test for "
731 "rte_cryptodev_queue_pair_setup:"
732 "num_inflights %u on qp %u on cryptodev %u",
733 qp_conf.nb_descriptors, qp_id,
734 ts_params->valid_devs[0]);
737 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
739 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
740 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
741 ts_params->valid_devs[0], qp_id, &qp_conf,
742 rte_cryptodev_socket_id(
743 ts_params->valid_devs[0])),
745 " rte_cryptodev_queue_pair_setup:"
746 "num_inflights %u on qp %u on cryptodev %u",
747 qp_conf.nb_descriptors, qp_id,
748 ts_params->valid_devs[0]);
751 /* invalid number of descriptors - max supported + 1 */
752 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
754 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
755 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
756 ts_params->valid_devs[0], qp_id, &qp_conf,
757 rte_cryptodev_socket_id(
758 ts_params->valid_devs[0])),
759 "Unexpectedly passed test for "
760 "rte_cryptodev_queue_pair_setup:"
761 "num_inflights %u on qp %u on cryptodev %u",
762 qp_conf.nb_descriptors, qp_id,
763 ts_params->valid_devs[0]);
766 /* test invalid queue pair id */
767 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
769 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
771 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
772 ts_params->valid_devs[0],
774 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
775 "Failed test for rte_cryptodev_queue_pair_setup:"
776 "invalid qp %u on cryptodev %u",
777 qp_id, ts_params->valid_devs[0]);
779 qp_id = 0xffff; /*invalid*/
781 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
782 ts_params->valid_devs[0],
784 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
785 "Failed test for rte_cryptodev_queue_pair_setup:"
786 "invalid qp %u on cryptodev %u",
787 qp_id, ts_params->valid_devs[0]);
792 /* ***** Plaintext data for tests ***** */
794 const char catch_22_quote_1[] =
795 "There was only one catch and that was Catch-22, which "
796 "specified that a concern for one's safety in the face of "
797 "dangers that were real and immediate was the process of a "
798 "rational mind. Orr was crazy and could be grounded. All he "
799 "had to do was ask; and as soon as he did, he would no longer "
800 "be crazy and would have to fly more missions. Orr would be "
801 "crazy to fly more missions and sane if he didn't, but if he "
802 "was sane he had to fly them. If he flew them he was crazy "
803 "and didn't have to; but if he didn't want to he was sane and "
804 "had to. Yossarian was moved very deeply by the absolute "
805 "simplicity of this clause of Catch-22 and let out a "
806 "respectful whistle. \"That's some catch, that Catch-22\", he "
807 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
809 const char catch_22_quote[] =
810 "What a lousy earth! He wondered how many people were "
811 "destitute that same night even in his own prosperous country, "
812 "how many homes were shanties, how many husbands were drunk "
813 "and wives socked, and how many children were bullied, abused, "
814 "or abandoned. How many families hungered for food they could "
815 "not afford to buy? How many hearts were broken? How many "
816 "suicides would take place that same night, how many people "
817 "would go insane? How many cockroaches and landlords would "
818 "triumph? How many winners were losers, successes failures, "
819 "and rich men poor men? How many wise guys were stupid? How "
820 "many happy endings were unhappy endings? How many honest men "
821 "were liars, brave men cowards, loyal men traitors, how many "
822 "sainted men were corrupt, how many people in positions of "
823 "trust had sold their souls to bodyguards, how many had never "
824 "had souls? How many straight-and-narrow paths were crooked "
825 "paths? How many best families were worst families and how "
826 "many good people were bad people? When you added them all up "
827 "and then subtracted, you might be left with only the children, "
828 "and perhaps with Albert Einstein and an old violinist or "
829 "sculptor somewhere.";
831 #define QUOTE_480_BYTES (480)
832 #define QUOTE_512_BYTES (512)
833 #define QUOTE_768_BYTES (768)
834 #define QUOTE_1024_BYTES (1024)
838 /* ***** SHA1 Hash Tests ***** */
840 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
842 static uint8_t hmac_sha1_key[] = {
843 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
844 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
845 0xDE, 0xF4, 0xDE, 0xAD };
847 /* ***** SHA224 Hash Tests ***** */
849 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
852 /* ***** AES-CBC Cipher Tests ***** */
854 #define CIPHER_KEY_LENGTH_AES_CBC (16)
855 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
857 static uint8_t aes_cbc_key[] = {
858 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
859 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
861 static uint8_t aes_cbc_iv[] = {
862 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
863 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
866 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
868 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
869 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
870 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
871 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
872 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
873 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
874 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
875 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
876 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
877 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
878 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
879 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
880 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
881 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
882 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
883 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
884 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
885 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
886 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
887 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
888 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
889 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
890 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
891 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
892 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
893 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
894 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
895 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
896 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
897 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
898 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
899 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
900 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
901 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
902 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
903 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
904 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
905 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
906 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
907 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
908 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
909 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
910 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
911 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
912 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
913 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
914 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
915 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
916 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
917 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
918 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
919 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
920 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
921 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
922 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
923 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
924 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
925 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
926 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
927 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
928 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
929 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
930 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
931 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
932 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
935 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
936 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
937 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
938 0x18, 0x8c, 0x1d, 0x32
942 /* Multisession Vector context Test */
944 static uint8_t ms_aes_cbc_key0[] = {
945 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
946 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
949 static uint8_t ms_aes_cbc_iv0[] = {
950 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
951 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
954 static const uint8_t ms_aes_cbc_cipher0[] = {
955 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
956 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
957 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
958 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
959 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
960 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
961 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
962 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
963 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
964 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
965 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
966 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
967 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
968 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
969 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
970 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
971 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
972 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
973 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
974 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
975 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
976 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
977 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
978 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
979 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
980 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
981 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
982 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
983 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
984 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
985 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
986 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
987 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
988 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
989 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
990 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
991 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
992 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
993 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
994 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
995 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
996 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
997 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
998 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
999 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1000 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1001 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1002 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1003 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1004 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1005 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1006 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1007 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1008 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1009 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1010 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1011 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1012 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1013 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1014 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1015 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1016 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1017 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1018 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1022 static uint8_t ms_hmac_key0[] = {
1023 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1024 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1025 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1026 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1027 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1028 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1029 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1030 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1033 static const uint8_t ms_hmac_digest0[] = {
1034 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1035 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1036 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1037 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1038 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1039 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1040 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1041 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1045 /* Begin session 1 */
1047 static uint8_t ms_aes_cbc_key1[] = {
1048 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1049 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1052 static uint8_t ms_aes_cbc_iv1[] = {
1053 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1054 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1057 static const uint8_t ms_aes_cbc_cipher1[] = {
1058 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1059 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1060 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1061 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1062 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1063 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1064 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1065 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1066 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1067 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1068 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1069 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1070 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1071 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1072 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1073 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1074 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1075 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1076 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1077 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1078 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1079 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1080 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1081 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1082 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1083 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1084 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1085 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1086 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1087 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1088 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1089 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1090 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1091 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1092 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1093 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1094 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1095 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1096 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1097 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1098 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1099 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1100 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1101 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1102 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1103 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1104 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1105 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1106 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1107 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1108 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1109 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1110 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1111 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1112 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1113 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1114 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1115 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1116 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1117 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1118 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1119 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1120 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1121 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1125 static uint8_t ms_hmac_key1[] = {
1126 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1127 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1128 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1129 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1130 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1131 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1132 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1133 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1136 static const uint8_t ms_hmac_digest1[] = {
1137 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1138 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1139 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1140 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1141 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1142 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1143 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1144 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1147 /* Begin Session 2 */
1148 static uint8_t ms_aes_cbc_key2[] = {
1149 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1150 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1153 static uint8_t ms_aes_cbc_iv2[] = {
1154 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1155 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1158 static const uint8_t ms_aes_cbc_cipher2[] = {
1159 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1160 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1161 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1162 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1163 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1164 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1165 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1166 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1167 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1168 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1169 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1170 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1171 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1172 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1173 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1174 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1175 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1176 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1177 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1178 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1179 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1180 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1181 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1182 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1183 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1184 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1185 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1186 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1187 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1188 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1189 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1190 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1191 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1192 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1193 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1194 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1195 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1196 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1197 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1198 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1199 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1200 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1201 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1202 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1203 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1204 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1205 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1206 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1207 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1208 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1209 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1210 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1211 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1212 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1213 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1214 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1215 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1216 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1217 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1218 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1219 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1220 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1221 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1222 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1225 static uint8_t ms_hmac_key2[] = {
1226 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1227 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1228 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1229 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1230 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1231 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1232 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1233 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1236 static const uint8_t ms_hmac_digest2[] = {
1237 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1238 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1239 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1240 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1241 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1242 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1243 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1244 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1251 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1253 struct crypto_testsuite_params *ts_params = &testsuite_params;
1254 struct crypto_unittest_params *ut_params = &unittest_params;
1256 /* Generate test mbuf data and space for digest */
1257 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1258 catch_22_quote, QUOTE_512_BYTES, 0);
1260 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1261 DIGEST_BYTE_LENGTH_SHA1);
1262 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1264 /* Setup Cipher Parameters */
1265 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1266 ut_params->cipher_xform.next = &ut_params->auth_xform;
1268 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1269 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1270 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1271 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1273 /* Setup HMAC Parameters */
1274 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1276 ut_params->auth_xform.next = NULL;
1278 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1279 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1280 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1281 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1282 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1284 /* Create crypto session*/
1285 ut_params->sess = rte_cryptodev_sym_session_create(
1286 ts_params->valid_devs[0],
1287 &ut_params->cipher_xform);
1288 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1290 /* Generate crypto op data structure */
1291 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1292 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1293 TEST_ASSERT_NOT_NULL(ut_params->op,
1294 "Failed to allocate symmetric crypto operation struct");
1296 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1298 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1300 /* set crypto operation source mbuf */
1301 sym_op->m_src = ut_params->ibuf;
1303 /* Set crypto operation authentication parameters */
1304 sym_op->auth.digest.data = ut_params->digest;
1305 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1306 ut_params->ibuf, QUOTE_512_BYTES);
1307 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1309 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1310 sym_op->auth.data.length = QUOTE_512_BYTES;
1312 /* Set crypto operation cipher parameters */
1313 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1314 CIPHER_IV_LENGTH_AES_CBC);
1315 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1316 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1318 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1319 CIPHER_IV_LENGTH_AES_CBC);
1321 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
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_offset(ut_params->op->sym->m_src,
1333 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
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;
1409 /* Setup HMAC Parameters */
1410 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1411 ut_params->auth_xform.next = &ut_params->cipher_xform;
1413 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1414 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1415 ut_params->auth_xform.auth.key.data = hmac_key;
1416 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1417 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1419 return TEST_SUCCESS;
1424 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1425 struct crypto_unittest_params *ut_params,
1426 struct crypto_testsuite_params *ts_params,
1427 const uint8_t *cipher,
1428 const uint8_t *digest,
1431 /* Generate test mbuf data and digest */
1432 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1435 QUOTE_512_BYTES, 0);
1437 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1438 DIGEST_BYTE_LENGTH_SHA512);
1439 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1441 rte_memcpy(ut_params->digest,
1443 DIGEST_BYTE_LENGTH_SHA512);
1445 /* Generate Crypto op data structure */
1446 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1447 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1448 TEST_ASSERT_NOT_NULL(ut_params->op,
1449 "Failed to allocate symmetric crypto operation struct");
1451 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1453 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1455 /* set crypto operation source mbuf */
1456 sym_op->m_src = ut_params->ibuf;
1458 sym_op->auth.digest.data = ut_params->digest;
1459 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1460 ut_params->ibuf, QUOTE_512_BYTES);
1461 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1463 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1464 sym_op->auth.data.length = QUOTE_512_BYTES;
1466 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1467 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1468 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1469 ut_params->ibuf, 0);
1470 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1472 rte_memcpy(sym_op->cipher.iv.data, iv,
1473 CIPHER_IV_LENGTH_AES_CBC);
1475 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1476 sym_op->cipher.data.length = QUOTE_512_BYTES;
1478 /* Process crypto operation */
1479 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1480 ut_params->op), "failed to process sym crypto op");
1482 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1483 "crypto op processing failed");
1485 ut_params->obuf = ut_params->op->sym->m_src;
1488 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1489 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1490 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1492 "Plaintext data not as expected");
1495 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1496 "Digest verification failed");
1498 return TEST_SUCCESS;
1502 test_AES_cipheronly_mb_all(void)
1504 struct crypto_testsuite_params *ts_params = &testsuite_params;
1507 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1508 ts_params->op_mpool, ts_params->valid_devs[0],
1509 RTE_CRYPTODEV_AESNI_MB_PMD,
1510 BLKCIPHER_AES_CIPHERONLY_TYPE);
1512 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1514 return TEST_SUCCESS;
1518 test_AES_docsis_mb_all(void)
1520 struct crypto_testsuite_params *ts_params = &testsuite_params;
1523 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1524 ts_params->op_mpool, ts_params->valid_devs[0],
1525 RTE_CRYPTODEV_AESNI_MB_PMD,
1526 BLKCIPHER_AES_DOCSIS_TYPE);
1528 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1530 return TEST_SUCCESS;
1534 test_AES_docsis_qat_all(void)
1536 struct crypto_testsuite_params *ts_params = &testsuite_params;
1539 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1540 ts_params->op_mpool, ts_params->valid_devs[0],
1541 RTE_CRYPTODEV_QAT_SYM_PMD,
1542 BLKCIPHER_AES_DOCSIS_TYPE);
1544 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1546 return TEST_SUCCESS;
1550 test_DES_docsis_qat_all(void)
1552 struct crypto_testsuite_params *ts_params = &testsuite_params;
1555 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1556 ts_params->op_mpool, ts_params->valid_devs[0],
1557 RTE_CRYPTODEV_QAT_SYM_PMD,
1558 BLKCIPHER_DES_DOCSIS_TYPE);
1560 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1562 return TEST_SUCCESS;
1566 test_authonly_mb_all(void)
1568 struct crypto_testsuite_params *ts_params = &testsuite_params;
1571 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1572 ts_params->op_mpool, ts_params->valid_devs[0],
1573 RTE_CRYPTODEV_AESNI_MB_PMD,
1574 BLKCIPHER_AUTHONLY_TYPE);
1576 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1578 return TEST_SUCCESS;
1582 test_AES_chain_mb_all(void)
1584 struct crypto_testsuite_params *ts_params = &testsuite_params;
1587 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1588 ts_params->op_mpool, ts_params->valid_devs[0],
1589 RTE_CRYPTODEV_AESNI_MB_PMD,
1590 BLKCIPHER_AES_CHAIN_TYPE);
1592 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1594 return TEST_SUCCESS;
1597 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1600 test_AES_cipheronly_scheduler_all(void)
1602 struct crypto_testsuite_params *ts_params = &testsuite_params;
1605 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1606 ts_params->op_mpool, ts_params->valid_devs[0],
1607 RTE_CRYPTODEV_SCHEDULER_PMD,
1608 BLKCIPHER_AES_CIPHERONLY_TYPE);
1610 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1612 return TEST_SUCCESS;
1616 test_AES_chain_scheduler_all(void)
1618 struct crypto_testsuite_params *ts_params = &testsuite_params;
1621 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1622 ts_params->op_mpool, ts_params->valid_devs[0],
1623 RTE_CRYPTODEV_SCHEDULER_PMD,
1624 BLKCIPHER_AES_CHAIN_TYPE);
1626 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1628 return TEST_SUCCESS;
1632 test_authonly_scheduler_all(void)
1634 struct crypto_testsuite_params *ts_params = &testsuite_params;
1637 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1638 ts_params->op_mpool, ts_params->valid_devs[0],
1639 RTE_CRYPTODEV_SCHEDULER_PMD,
1640 BLKCIPHER_AUTHONLY_TYPE);
1642 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1644 return TEST_SUCCESS;
1647 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1650 test_AES_chain_openssl_all(void)
1652 struct crypto_testsuite_params *ts_params = &testsuite_params;
1655 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1656 ts_params->op_mpool, ts_params->valid_devs[0],
1657 RTE_CRYPTODEV_OPENSSL_PMD,
1658 BLKCIPHER_AES_CHAIN_TYPE);
1660 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1662 return TEST_SUCCESS;
1666 test_AES_cipheronly_openssl_all(void)
1668 struct crypto_testsuite_params *ts_params = &testsuite_params;
1671 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1672 ts_params->op_mpool, ts_params->valid_devs[0],
1673 RTE_CRYPTODEV_OPENSSL_PMD,
1674 BLKCIPHER_AES_CIPHERONLY_TYPE);
1676 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1678 return TEST_SUCCESS;
1682 test_AES_chain_qat_all(void)
1684 struct crypto_testsuite_params *ts_params = &testsuite_params;
1687 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1688 ts_params->op_mpool, ts_params->valid_devs[0],
1689 RTE_CRYPTODEV_QAT_SYM_PMD,
1690 BLKCIPHER_AES_CHAIN_TYPE);
1692 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1694 return TEST_SUCCESS;
1698 test_AES_cipheronly_qat_all(void)
1700 struct crypto_testsuite_params *ts_params = &testsuite_params;
1703 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1704 ts_params->op_mpool, ts_params->valid_devs[0],
1705 RTE_CRYPTODEV_QAT_SYM_PMD,
1706 BLKCIPHER_AES_CIPHERONLY_TYPE);
1708 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1710 return TEST_SUCCESS;
1714 test_authonly_openssl_all(void)
1716 struct crypto_testsuite_params *ts_params = &testsuite_params;
1719 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1720 ts_params->op_mpool, ts_params->valid_devs[0],
1721 RTE_CRYPTODEV_OPENSSL_PMD,
1722 BLKCIPHER_AUTHONLY_TYPE);
1724 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1726 return TEST_SUCCESS;
1730 test_AES_chain_armv8_all(void)
1732 struct crypto_testsuite_params *ts_params = &testsuite_params;
1735 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1736 ts_params->op_mpool, ts_params->valid_devs[0],
1737 RTE_CRYPTODEV_ARMV8_PMD,
1738 BLKCIPHER_AES_CHAIN_TYPE);
1740 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1742 return TEST_SUCCESS;
1745 /* ***** SNOW 3G Tests ***** */
1747 create_wireless_algo_hash_session(uint8_t dev_id,
1748 const uint8_t *key, const uint8_t key_len,
1749 const uint8_t aad_len, const uint8_t auth_len,
1750 enum rte_crypto_auth_operation op,
1751 enum rte_crypto_auth_algorithm algo)
1753 uint8_t hash_key[key_len];
1755 struct crypto_unittest_params *ut_params = &unittest_params;
1757 memcpy(hash_key, key, key_len);
1759 TEST_HEXDUMP(stdout, "key:", key, key_len);
1761 /* Setup Authentication Parameters */
1762 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1763 ut_params->auth_xform.next = NULL;
1765 ut_params->auth_xform.auth.op = op;
1766 ut_params->auth_xform.auth.algo = algo;
1767 ut_params->auth_xform.auth.key.length = key_len;
1768 ut_params->auth_xform.auth.key.data = hash_key;
1769 ut_params->auth_xform.auth.digest_length = auth_len;
1770 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1771 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1772 &ut_params->auth_xform);
1773 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1778 create_wireless_algo_cipher_session(uint8_t dev_id,
1779 enum rte_crypto_cipher_operation op,
1780 enum rte_crypto_cipher_algorithm algo,
1781 const uint8_t *key, const uint8_t key_len)
1783 uint8_t cipher_key[key_len];
1785 struct crypto_unittest_params *ut_params = &unittest_params;
1787 memcpy(cipher_key, key, key_len);
1789 /* Setup Cipher Parameters */
1790 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1791 ut_params->cipher_xform.next = NULL;
1793 ut_params->cipher_xform.cipher.algo = algo;
1794 ut_params->cipher_xform.cipher.op = op;
1795 ut_params->cipher_xform.cipher.key.data = cipher_key;
1796 ut_params->cipher_xform.cipher.key.length = key_len;
1798 TEST_HEXDUMP(stdout, "key:", key, key_len);
1800 /* Create Crypto session */
1801 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1804 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1809 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1810 const unsigned cipher_len,
1811 const unsigned cipher_offset,
1812 enum rte_crypto_cipher_algorithm algo)
1814 struct crypto_testsuite_params *ts_params = &testsuite_params;
1815 struct crypto_unittest_params *ut_params = &unittest_params;
1816 unsigned iv_pad_len = 0;
1818 /* Generate Crypto op data structure */
1819 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1820 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1821 TEST_ASSERT_NOT_NULL(ut_params->op,
1822 "Failed to allocate pktmbuf offload");
1824 /* Set crypto operation data parameters */
1825 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1827 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1829 /* set crypto operation source mbuf */
1830 sym_op->m_src = ut_params->ibuf;
1833 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1834 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1836 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1838 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1841 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1843 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1844 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1845 sym_op->cipher.iv.length = iv_pad_len;
1847 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1848 sym_op->cipher.data.length = cipher_len;
1849 sym_op->cipher.data.offset = cipher_offset;
1854 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1855 const unsigned cipher_len,
1856 const unsigned cipher_offset,
1857 enum rte_crypto_cipher_algorithm algo)
1859 struct crypto_testsuite_params *ts_params = &testsuite_params;
1860 struct crypto_unittest_params *ut_params = &unittest_params;
1861 unsigned iv_pad_len = 0;
1863 /* Generate Crypto op data structure */
1864 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1865 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1866 TEST_ASSERT_NOT_NULL(ut_params->op,
1867 "Failed to allocate pktmbuf offload");
1869 /* Set crypto operation data parameters */
1870 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1872 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1874 /* set crypto operation source mbuf */
1875 sym_op->m_src = ut_params->ibuf;
1876 sym_op->m_dst = ut_params->obuf;
1879 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1880 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1882 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1883 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1886 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1888 /* For OOP operation both buffers must have the same size */
1889 if (ut_params->obuf)
1890 rte_pktmbuf_prepend(ut_params->obuf, iv_pad_len);
1892 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1893 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1894 sym_op->cipher.iv.length = iv_pad_len;
1896 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1897 sym_op->cipher.data.length = cipher_len;
1898 sym_op->cipher.data.offset = cipher_offset;
1903 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1904 enum rte_crypto_cipher_operation cipher_op,
1905 enum rte_crypto_auth_operation auth_op,
1906 enum rte_crypto_auth_algorithm auth_algo,
1907 enum rte_crypto_cipher_algorithm cipher_algo,
1908 const uint8_t *key, const uint8_t key_len,
1909 const uint8_t aad_len, const uint8_t auth_len)
1912 uint8_t cipher_auth_key[key_len];
1914 struct crypto_unittest_params *ut_params = &unittest_params;
1916 memcpy(cipher_auth_key, key, key_len);
1918 /* Setup Authentication Parameters */
1919 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1920 ut_params->auth_xform.next = NULL;
1922 ut_params->auth_xform.auth.op = auth_op;
1923 ut_params->auth_xform.auth.algo = auth_algo;
1924 ut_params->auth_xform.auth.key.length = key_len;
1925 /* Hash key = cipher key */
1926 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1927 ut_params->auth_xform.auth.digest_length = auth_len;
1928 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1930 /* Setup Cipher Parameters */
1931 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1932 ut_params->cipher_xform.next = &ut_params->auth_xform;
1934 ut_params->cipher_xform.cipher.algo = cipher_algo;
1935 ut_params->cipher_xform.cipher.op = cipher_op;
1936 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1937 ut_params->cipher_xform.cipher.key.length = key_len;
1939 TEST_HEXDUMP(stdout, "key:", key, key_len);
1941 /* Create Crypto session*/
1942 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1943 &ut_params->cipher_xform);
1945 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1950 create_wireless_cipher_auth_session(uint8_t dev_id,
1951 enum rte_crypto_cipher_operation cipher_op,
1952 enum rte_crypto_auth_operation auth_op,
1953 enum rte_crypto_auth_algorithm auth_algo,
1954 enum rte_crypto_cipher_algorithm cipher_algo,
1955 const struct wireless_test_data *tdata)
1957 const uint8_t key_len = tdata->key.len;
1958 uint8_t cipher_auth_key[key_len];
1960 struct crypto_unittest_params *ut_params = &unittest_params;
1961 const uint8_t *key = tdata->key.data;
1962 const uint8_t aad_len = tdata->aad.len;
1963 const uint8_t auth_len = tdata->digest.len;
1965 memcpy(cipher_auth_key, key, key_len);
1967 /* Setup Authentication Parameters */
1968 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1969 ut_params->auth_xform.next = NULL;
1971 ut_params->auth_xform.auth.op = auth_op;
1972 ut_params->auth_xform.auth.algo = auth_algo;
1973 ut_params->auth_xform.auth.key.length = key_len;
1974 /* Hash key = cipher key */
1975 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1976 ut_params->auth_xform.auth.digest_length = auth_len;
1977 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1979 /* Setup Cipher Parameters */
1980 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1981 ut_params->cipher_xform.next = &ut_params->auth_xform;
1983 ut_params->cipher_xform.cipher.algo = cipher_algo;
1984 ut_params->cipher_xform.cipher.op = cipher_op;
1985 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1986 ut_params->cipher_xform.cipher.key.length = key_len;
1988 TEST_HEXDUMP(stdout, "key:", key, key_len);
1990 /* Create Crypto session*/
1991 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1992 &ut_params->cipher_xform);
1994 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1999 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2000 const struct wireless_test_data *tdata)
2002 return create_wireless_cipher_auth_session(dev_id,
2003 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2004 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2005 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2009 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2010 enum rte_crypto_cipher_operation cipher_op,
2011 enum rte_crypto_auth_operation auth_op,
2012 enum rte_crypto_auth_algorithm auth_algo,
2013 enum rte_crypto_cipher_algorithm cipher_algo,
2014 const uint8_t *key, const uint8_t key_len,
2015 const uint8_t aad_len, const uint8_t auth_len)
2017 uint8_t auth_cipher_key[key_len];
2019 struct crypto_unittest_params *ut_params = &unittest_params;
2021 memcpy(auth_cipher_key, key, key_len);
2023 /* Setup Authentication Parameters */
2024 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2025 ut_params->auth_xform.auth.op = auth_op;
2026 ut_params->auth_xform.next = &ut_params->cipher_xform;
2027 ut_params->auth_xform.auth.algo = auth_algo;
2028 ut_params->auth_xform.auth.key.length = key_len;
2029 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2030 ut_params->auth_xform.auth.digest_length = auth_len;
2031 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
2033 /* Setup Cipher Parameters */
2034 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2035 ut_params->cipher_xform.next = NULL;
2036 ut_params->cipher_xform.cipher.algo = cipher_algo;
2037 ut_params->cipher_xform.cipher.op = cipher_op;
2038 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2039 ut_params->cipher_xform.cipher.key.length = key_len;
2041 TEST_HEXDUMP(stdout, "key:", key, key_len);
2043 /* Create Crypto session*/
2044 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2045 &ut_params->auth_xform);
2047 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2053 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2054 const unsigned auth_tag_len,
2055 const uint8_t *aad, const unsigned aad_len,
2056 unsigned data_pad_len,
2057 enum rte_crypto_auth_operation op,
2058 enum rte_crypto_auth_algorithm algo,
2059 const unsigned auth_len, const unsigned auth_offset)
2061 struct crypto_testsuite_params *ts_params = &testsuite_params;
2063 struct crypto_unittest_params *ut_params = &unittest_params;
2065 unsigned aad_buffer_len;
2067 /* Generate Crypto op data structure */
2068 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2069 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2070 TEST_ASSERT_NOT_NULL(ut_params->op,
2071 "Failed to allocate pktmbuf offload");
2073 /* Set crypto operation data parameters */
2074 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2076 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2078 /* set crypto operation source mbuf */
2079 sym_op->m_src = ut_params->ibuf;
2083 * Always allocate the aad up to the block size.
2084 * The cryptodev API calls out -
2085 * - the array must be big enough to hold the AAD, plus any
2086 * space to round this up to the nearest multiple of the
2087 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2089 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2090 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2092 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2093 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2094 ut_params->ibuf, aad_buffer_len);
2095 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2096 "no room to prepend aad");
2097 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2099 sym_op->auth.aad.length = aad_len;
2101 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2102 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2104 TEST_HEXDUMP(stdout, "aad:",
2105 sym_op->auth.aad.data, aad_len);
2108 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2109 ut_params->ibuf, auth_tag_len);
2111 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2112 "no room to append auth tag");
2113 ut_params->digest = sym_op->auth.digest.data;
2114 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2115 ut_params->ibuf, data_pad_len + aad_len);
2116 sym_op->auth.digest.length = auth_tag_len;
2117 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2118 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2120 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2122 TEST_HEXDUMP(stdout, "digest:",
2123 sym_op->auth.digest.data,
2124 sym_op->auth.digest.length);
2126 sym_op->auth.data.length = auth_len;
2127 sym_op->auth.data.offset = auth_offset;
2133 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2134 enum rte_crypto_auth_operation op,
2135 enum rte_crypto_auth_algorithm auth_algo,
2136 enum rte_crypto_cipher_algorithm cipher_algo)
2138 struct crypto_testsuite_params *ts_params = &testsuite_params;
2139 struct crypto_unittest_params *ut_params = &unittest_params;
2141 const uint8_t *auth_tag = tdata->digest.data;
2142 const unsigned int auth_tag_len = tdata->digest.len;
2143 const uint8_t *aad = tdata->aad.data;
2144 const uint8_t aad_len = tdata->aad.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 *iv = tdata->iv.data;
2149 const uint8_t iv_len = tdata->iv.len;
2150 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2151 const unsigned int cipher_offset =
2152 tdata->validCipherOffsetLenInBits.len;
2153 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2154 const unsigned int auth_offset = tdata->validAuthOffsetLenInBits.len;
2156 unsigned int iv_pad_len = 0;
2157 unsigned int aad_buffer_len;
2159 /* Generate Crypto op data structure */
2160 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2161 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2162 TEST_ASSERT_NOT_NULL(ut_params->op,
2163 "Failed to allocate pktmbuf offload");
2164 /* Set crypto operation data parameters */
2165 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2167 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2169 /* set crypto operation source mbuf */
2170 sym_op->m_src = ut_params->ibuf;
2173 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2174 ut_params->ibuf, auth_tag_len);
2176 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2177 "no room to append auth tag");
2178 ut_params->digest = sym_op->auth.digest.data;
2179 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2180 ut_params->ibuf, data_pad_len);
2181 sym_op->auth.digest.length = auth_tag_len;
2182 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2183 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2185 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2187 TEST_HEXDUMP(stdout, "digest:",
2188 sym_op->auth.digest.data,
2189 sym_op->auth.digest.length);
2193 * Always allocate the aad up to the block size.
2194 * The cryptodev API calls out -
2195 * - the array must be big enough to hold the AAD, plus any
2196 * space to round this up to the nearest multiple of the
2197 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2199 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2200 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2202 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2203 sym_op->auth.aad.data =
2204 (uint8_t *)rte_pktmbuf_prepend(
2205 ut_params->ibuf, aad_buffer_len);
2206 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2207 "no room to prepend aad");
2208 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2210 sym_op->auth.aad.length = aad_len;
2211 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2212 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2213 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2216 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2217 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2219 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2220 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2221 ut_params->ibuf, iv_pad_len);
2223 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2224 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2225 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2226 sym_op->cipher.iv.length = iv_pad_len;
2227 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2228 sym_op->cipher.data.length = cipher_len;
2229 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2230 sym_op->auth.data.length = auth_len;
2231 sym_op->auth.data.offset = auth_offset + cipher_offset;
2237 create_zuc_cipher_hash_generate_operation(
2238 const struct wireless_test_data *tdata)
2240 return create_wireless_cipher_hash_operation(tdata,
2241 RTE_CRYPTO_AUTH_OP_GENERATE,
2242 RTE_CRYPTO_AUTH_ZUC_EIA3,
2243 RTE_CRYPTO_CIPHER_ZUC_EEA3);
2247 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2248 const unsigned auth_tag_len,
2249 const uint8_t *aad, const uint8_t aad_len,
2250 unsigned data_pad_len,
2251 enum rte_crypto_auth_operation op,
2252 enum rte_crypto_auth_algorithm auth_algo,
2253 enum rte_crypto_cipher_algorithm cipher_algo,
2254 const uint8_t *iv, const uint8_t iv_len,
2255 const unsigned cipher_len, const unsigned cipher_offset,
2256 const unsigned auth_len, const unsigned auth_offset)
2258 struct crypto_testsuite_params *ts_params = &testsuite_params;
2259 struct crypto_unittest_params *ut_params = &unittest_params;
2261 unsigned iv_pad_len = 0;
2262 unsigned aad_buffer_len;
2264 /* Generate Crypto op data structure */
2265 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2266 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2267 TEST_ASSERT_NOT_NULL(ut_params->op,
2268 "Failed to allocate pktmbuf offload");
2269 /* Set crypto operation data parameters */
2270 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2272 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2274 /* set crypto operation source mbuf */
2275 sym_op->m_src = ut_params->ibuf;
2278 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2279 ut_params->ibuf, auth_tag_len);
2281 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2282 "no room to append auth tag");
2283 ut_params->digest = sym_op->auth.digest.data;
2284 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2285 ut_params->ibuf, data_pad_len);
2286 sym_op->auth.digest.length = auth_tag_len;
2287 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2288 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2290 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2292 TEST_HEXDUMP(stdout, "digest:",
2293 sym_op->auth.digest.data,
2294 sym_op->auth.digest.length);
2298 * Always allocate the aad up to the block size.
2299 * The cryptodev API calls out -
2300 * - the array must be big enough to hold the AAD, plus any
2301 * space to round this up to the nearest multiple of the
2302 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2304 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2305 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2307 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2308 sym_op->auth.aad.data =
2309 (uint8_t *)rte_pktmbuf_prepend(
2310 ut_params->ibuf, aad_buffer_len);
2311 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2312 "no room to prepend aad");
2313 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2315 sym_op->auth.aad.length = aad_len;
2316 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2317 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2318 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2321 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2322 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2324 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2325 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2326 ut_params->ibuf, iv_pad_len);
2328 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2329 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2330 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2331 sym_op->cipher.iv.length = iv_pad_len;
2332 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2333 sym_op->cipher.data.length = cipher_len;
2334 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2335 sym_op->auth.data.length = auth_len;
2336 sym_op->auth.data.offset = auth_offset + cipher_offset;
2342 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2343 const uint8_t *iv, const uint8_t iv_len,
2344 const uint8_t *aad, const uint8_t aad_len,
2345 unsigned data_pad_len,
2346 const unsigned cipher_len, const unsigned cipher_offset,
2347 const unsigned auth_len, const unsigned auth_offset,
2348 enum rte_crypto_auth_algorithm auth_algo,
2349 enum rte_crypto_cipher_algorithm cipher_algo)
2351 struct crypto_testsuite_params *ts_params = &testsuite_params;
2352 struct crypto_unittest_params *ut_params = &unittest_params;
2354 unsigned iv_pad_len = 0;
2355 unsigned aad_buffer_len = 0;
2357 /* Generate Crypto op data structure */
2358 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2359 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2360 TEST_ASSERT_NOT_NULL(ut_params->op,
2361 "Failed to allocate pktmbuf offload");
2363 /* Set crypto operation data parameters */
2364 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2366 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2368 /* set crypto operation source mbuf */
2369 sym_op->m_src = ut_params->ibuf;
2372 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2373 ut_params->ibuf, auth_tag_len);
2375 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2376 "no room to append auth tag");
2378 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2379 ut_params->ibuf, data_pad_len);
2380 sym_op->auth.digest.length = auth_tag_len;
2382 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2384 TEST_HEXDUMP(stdout, "digest:",
2385 sym_op->auth.digest.data,
2386 sym_op->auth.digest.length);
2390 * Always allocate the aad up to the block size.
2391 * The cryptodev API calls out -
2392 * - the array must be big enough to hold the AAD, plus any
2393 * space to round this up to the nearest multiple of the
2394 * block size (8 bytes for KASUMI 16 bytes).
2396 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2397 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2399 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2400 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2401 ut_params->ibuf, aad_buffer_len);
2402 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2403 "no room to prepend aad");
2404 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2406 sym_op->auth.aad.length = aad_len;
2407 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2408 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2409 TEST_HEXDUMP(stdout, "aad:",
2410 sym_op->auth.aad.data, aad_len);
2413 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2414 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2416 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2418 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2419 ut_params->ibuf, iv_pad_len);
2420 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2422 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2423 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2424 sym_op->cipher.iv.length = iv_pad_len;
2426 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2428 sym_op->cipher.data.length = cipher_len;
2429 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2431 sym_op->auth.data.length = auth_len;
2432 sym_op->auth.data.offset = auth_offset + cipher_offset;
2438 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2440 struct crypto_testsuite_params *ts_params = &testsuite_params;
2441 struct crypto_unittest_params *ut_params = &unittest_params;
2444 unsigned plaintext_pad_len;
2445 unsigned plaintext_len;
2448 /* Create SNOW 3G session */
2449 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2450 tdata->key.data, tdata->key.len,
2451 tdata->aad.len, tdata->digest.len,
2452 RTE_CRYPTO_AUTH_OP_GENERATE,
2453 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2457 /* alloc mbuf and set payload */
2458 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2460 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2461 rte_pktmbuf_tailroom(ut_params->ibuf));
2463 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2464 /* Append data which is padded to a multiple of */
2465 /* the algorithms block size */
2466 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2467 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2469 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2471 /* Create SNOW 3G operation */
2472 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2473 tdata->aad.data, tdata->aad.len,
2474 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2475 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2476 tdata->validAuthLenInBits.len,
2477 tdata->validAuthOffsetLenInBits.len);
2481 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2483 ut_params->obuf = ut_params->op->sym->m_src;
2484 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2485 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2486 + plaintext_pad_len + tdata->aad.len;
2489 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2492 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2493 "SNOW 3G Generated auth tag not as expected");
2499 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2501 struct crypto_testsuite_params *ts_params = &testsuite_params;
2502 struct crypto_unittest_params *ut_params = &unittest_params;
2505 unsigned plaintext_pad_len;
2506 unsigned plaintext_len;
2509 /* Create SNOW 3G session */
2510 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2511 tdata->key.data, tdata->key.len,
2512 tdata->aad.len, tdata->digest.len,
2513 RTE_CRYPTO_AUTH_OP_VERIFY,
2514 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2517 /* alloc mbuf and set payload */
2518 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2520 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2521 rte_pktmbuf_tailroom(ut_params->ibuf));
2523 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2524 /* Append data which is padded to a multiple of */
2525 /* the algorithms block size */
2526 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2527 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2529 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2531 /* Create SNOW 3G operation */
2532 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2534 tdata->aad.data, tdata->aad.len,
2536 RTE_CRYPTO_AUTH_OP_VERIFY,
2537 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2538 tdata->validAuthLenInBits.len,
2539 tdata->validAuthOffsetLenInBits.len);
2543 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2545 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2546 ut_params->obuf = ut_params->op->sym->m_src;
2547 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2548 + plaintext_pad_len + tdata->aad.len;
2551 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2560 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2562 struct crypto_testsuite_params *ts_params = &testsuite_params;
2563 struct crypto_unittest_params *ut_params = &unittest_params;
2566 unsigned plaintext_pad_len;
2567 unsigned plaintext_len;
2570 /* Create KASUMI session */
2571 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2572 tdata->key.data, tdata->key.len,
2573 tdata->aad.len, tdata->digest.len,
2574 RTE_CRYPTO_AUTH_OP_GENERATE,
2575 RTE_CRYPTO_AUTH_KASUMI_F9);
2579 /* alloc mbuf and set payload */
2580 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2582 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2583 rte_pktmbuf_tailroom(ut_params->ibuf));
2585 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2586 /* Append data which is padded to a multiple of */
2587 /* the algorithms block size */
2588 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2589 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2591 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2593 /* Create KASUMI operation */
2594 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2595 tdata->aad.data, tdata->aad.len,
2596 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2597 RTE_CRYPTO_AUTH_KASUMI_F9,
2598 tdata->validAuthLenInBits.len,
2599 tdata->validAuthOffsetLenInBits.len);
2603 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2605 ut_params->obuf = ut_params->op->sym->m_src;
2606 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2607 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2608 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2611 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2614 DIGEST_BYTE_LENGTH_KASUMI_F9,
2615 "KASUMI Generated auth tag not as expected");
2621 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2623 struct crypto_testsuite_params *ts_params = &testsuite_params;
2624 struct crypto_unittest_params *ut_params = &unittest_params;
2627 unsigned plaintext_pad_len;
2628 unsigned plaintext_len;
2631 /* Create KASUMI session */
2632 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2633 tdata->key.data, tdata->key.len,
2634 tdata->aad.len, tdata->digest.len,
2635 RTE_CRYPTO_AUTH_OP_VERIFY,
2636 RTE_CRYPTO_AUTH_KASUMI_F9);
2639 /* alloc mbuf and set payload */
2640 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2642 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2643 rte_pktmbuf_tailroom(ut_params->ibuf));
2645 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2646 /* Append data which is padded to a multiple */
2647 /* of the algorithms block size */
2648 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2649 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2651 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2653 /* Create KASUMI operation */
2654 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2656 tdata->aad.data, tdata->aad.len,
2658 RTE_CRYPTO_AUTH_OP_VERIFY,
2659 RTE_CRYPTO_AUTH_KASUMI_F9,
2660 tdata->validAuthLenInBits.len,
2661 tdata->validAuthOffsetLenInBits.len);
2665 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2667 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2668 ut_params->obuf = ut_params->op->sym->m_src;
2669 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2670 + plaintext_pad_len + tdata->aad.len;
2673 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2682 test_snow3g_hash_generate_test_case_1(void)
2684 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2688 test_snow3g_hash_generate_test_case_2(void)
2690 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2694 test_snow3g_hash_generate_test_case_3(void)
2696 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2700 test_snow3g_hash_generate_test_case_4(void)
2702 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2706 test_snow3g_hash_generate_test_case_5(void)
2708 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2712 test_snow3g_hash_generate_test_case_6(void)
2714 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2718 test_snow3g_hash_verify_test_case_1(void)
2720 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2725 test_snow3g_hash_verify_test_case_2(void)
2727 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2731 test_snow3g_hash_verify_test_case_3(void)
2733 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2737 test_snow3g_hash_verify_test_case_4(void)
2739 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2743 test_snow3g_hash_verify_test_case_5(void)
2745 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2749 test_snow3g_hash_verify_test_case_6(void)
2751 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2755 test_kasumi_hash_generate_test_case_1(void)
2757 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2761 test_kasumi_hash_generate_test_case_2(void)
2763 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2767 test_kasumi_hash_generate_test_case_3(void)
2769 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2773 test_kasumi_hash_generate_test_case_4(void)
2775 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2779 test_kasumi_hash_generate_test_case_5(void)
2781 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2785 test_kasumi_hash_generate_test_case_6(void)
2787 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2791 test_kasumi_hash_verify_test_case_1(void)
2793 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2797 test_kasumi_hash_verify_test_case_2(void)
2799 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2803 test_kasumi_hash_verify_test_case_3(void)
2805 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2809 test_kasumi_hash_verify_test_case_4(void)
2811 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2815 test_kasumi_hash_verify_test_case_5(void)
2817 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2821 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2823 struct crypto_testsuite_params *ts_params = &testsuite_params;
2824 struct crypto_unittest_params *ut_params = &unittest_params;
2827 uint8_t *plaintext, *ciphertext;
2828 unsigned plaintext_pad_len;
2829 unsigned plaintext_len;
2831 /* Create KASUMI session */
2832 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2833 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2834 RTE_CRYPTO_CIPHER_KASUMI_F8,
2835 tdata->key.data, tdata->key.len);
2839 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2841 /* Clear mbuf payload */
2842 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2843 rte_pktmbuf_tailroom(ut_params->ibuf));
2845 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2846 /* Append data which is padded to a multiple */
2847 /* of the algorithms block size */
2848 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2849 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2851 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2853 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2855 /* Create KASUMI operation */
2856 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2857 tdata->plaintext.len,
2858 tdata->validCipherOffsetLenInBits.len,
2859 RTE_CRYPTO_CIPHER_KASUMI_F8);
2863 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2865 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2867 ut_params->obuf = ut_params->op->sym->m_dst;
2868 if (ut_params->obuf)
2869 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2872 ciphertext = plaintext;
2874 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2877 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2879 tdata->ciphertext.data,
2880 tdata->validCipherLenInBits.len,
2881 "KASUMI Ciphertext data not as expected");
2886 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2888 struct crypto_testsuite_params *ts_params = &testsuite_params;
2889 struct crypto_unittest_params *ut_params = &unittest_params;
2893 unsigned int plaintext_pad_len;
2894 unsigned int plaintext_len;
2896 uint8_t buffer[10000];
2897 const uint8_t *ciphertext;
2899 struct rte_cryptodev_info dev_info;
2901 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2902 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2903 printf("Device doesn't support scatter-gather. "
2908 /* Create KASUMI session */
2909 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2910 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2911 RTE_CRYPTO_CIPHER_KASUMI_F8,
2912 tdata->key.data, tdata->key.len);
2916 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2919 /* Append data which is padded to a multiple */
2920 /* of the algorithms block size */
2921 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2923 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2924 plaintext_pad_len, 10, 0);
2926 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2928 /* Create KASUMI operation */
2929 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2931 tdata->plaintext.len,
2932 tdata->validCipherOffsetLenInBits.len,
2933 RTE_CRYPTO_CIPHER_KASUMI_F8);
2937 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2939 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2941 ut_params->obuf = ut_params->op->sym->m_dst;
2943 if (ut_params->obuf)
2944 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2945 plaintext_len, buffer);
2947 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2948 plaintext_len, buffer);
2951 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2954 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2956 tdata->ciphertext.data,
2957 tdata->validCipherLenInBits.len,
2958 "KASUMI Ciphertext data not as expected");
2963 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2965 struct crypto_testsuite_params *ts_params = &testsuite_params;
2966 struct crypto_unittest_params *ut_params = &unittest_params;
2969 uint8_t *plaintext, *ciphertext;
2970 unsigned plaintext_pad_len;
2971 unsigned plaintext_len;
2973 /* Create KASUMI session */
2974 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2975 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2976 RTE_CRYPTO_CIPHER_KASUMI_F8,
2977 tdata->key.data, tdata->key.len);
2981 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2982 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2984 /* Clear mbuf payload */
2985 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2986 rte_pktmbuf_tailroom(ut_params->ibuf));
2988 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2989 /* Append data which is padded to a multiple */
2990 /* of the algorithms block size */
2991 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2992 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2994 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2995 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2997 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2999 /* Create KASUMI operation */
3000 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3002 tdata->plaintext.len,
3003 tdata->validCipherOffsetLenInBits.len,
3004 RTE_CRYPTO_CIPHER_KASUMI_F8);
3008 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3010 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3012 ut_params->obuf = ut_params->op->sym->m_dst;
3013 if (ut_params->obuf)
3014 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3017 ciphertext = plaintext;
3019 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3022 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3024 tdata->ciphertext.data,
3025 tdata->validCipherLenInBits.len,
3026 "KASUMI Ciphertext data not as expected");
3031 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3033 struct crypto_testsuite_params *ts_params = &testsuite_params;
3034 struct crypto_unittest_params *ut_params = &unittest_params;
3037 unsigned int plaintext_pad_len;
3038 unsigned int plaintext_len;
3040 const uint8_t *ciphertext;
3041 uint8_t buffer[2048];
3043 struct rte_cryptodev_info dev_info;
3045 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3046 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3047 printf("Device doesn't support scatter-gather. "
3052 /* Create KASUMI session */
3053 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3054 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3055 RTE_CRYPTO_CIPHER_KASUMI_F8,
3056 tdata->key.data, tdata->key.len);
3060 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3061 /* Append data which is padded to a multiple */
3062 /* of the algorithms block size */
3063 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3065 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3066 plaintext_pad_len, 10, 0);
3067 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3068 plaintext_pad_len, 3, 0);
3070 /* Append data which is padded to a multiple */
3071 /* of the algorithms block size */
3072 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3074 /* Create KASUMI operation */
3075 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3077 tdata->plaintext.len,
3078 tdata->validCipherOffsetLenInBits.len,
3079 RTE_CRYPTO_CIPHER_KASUMI_F8);
3083 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3085 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3087 ut_params->obuf = ut_params->op->sym->m_dst;
3088 if (ut_params->obuf)
3089 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3090 plaintext_pad_len, buffer);
3092 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3093 plaintext_pad_len, buffer);
3096 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3098 tdata->ciphertext.data,
3099 tdata->validCipherLenInBits.len,
3100 "KASUMI Ciphertext data not as expected");
3106 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3108 struct crypto_testsuite_params *ts_params = &testsuite_params;
3109 struct crypto_unittest_params *ut_params = &unittest_params;
3112 uint8_t *ciphertext, *plaintext;
3113 unsigned ciphertext_pad_len;
3114 unsigned ciphertext_len;
3116 /* Create KASUMI session */
3117 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3118 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3119 RTE_CRYPTO_CIPHER_KASUMI_F8,
3120 tdata->key.data, tdata->key.len);
3124 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3125 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3127 /* Clear mbuf payload */
3128 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3129 rte_pktmbuf_tailroom(ut_params->ibuf));
3131 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3132 /* Append data which is padded to a multiple */
3133 /* of the algorithms block size */
3134 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3135 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3136 ciphertext_pad_len);
3137 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3138 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3140 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3142 /* Create KASUMI operation */
3143 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3145 tdata->ciphertext.len,
3146 tdata->validCipherOffsetLenInBits.len,
3147 RTE_CRYPTO_CIPHER_KASUMI_F8);
3151 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3153 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3155 ut_params->obuf = ut_params->op->sym->m_dst;
3156 if (ut_params->obuf)
3157 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3160 plaintext = ciphertext;
3162 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3165 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3167 tdata->plaintext.data,
3168 tdata->validCipherLenInBits.len,
3169 "KASUMI Plaintext data not as expected");
3174 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3176 struct crypto_testsuite_params *ts_params = &testsuite_params;
3177 struct crypto_unittest_params *ut_params = &unittest_params;
3180 uint8_t *ciphertext, *plaintext;
3181 unsigned ciphertext_pad_len;
3182 unsigned ciphertext_len;
3184 /* Create KASUMI session */
3185 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3186 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3187 RTE_CRYPTO_CIPHER_KASUMI_F8,
3188 tdata->key.data, tdata->key.len);
3192 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3194 /* Clear mbuf payload */
3195 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3196 rte_pktmbuf_tailroom(ut_params->ibuf));
3198 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3199 /* Append data which is padded to a multiple */
3200 /* of the algorithms block size */
3201 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3202 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3203 ciphertext_pad_len);
3204 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3206 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3208 /* Create KASUMI operation */
3209 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3211 tdata->ciphertext.len,
3212 tdata->validCipherOffsetLenInBits.len,
3213 RTE_CRYPTO_CIPHER_KASUMI_F8);
3217 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3219 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3221 ut_params->obuf = ut_params->op->sym->m_dst;
3222 if (ut_params->obuf)
3223 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3226 plaintext = ciphertext;
3228 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3231 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3233 tdata->plaintext.data,
3234 tdata->validCipherLenInBits.len,
3235 "KASUMI Plaintext data not as expected");
3240 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3242 struct crypto_testsuite_params *ts_params = &testsuite_params;
3243 struct crypto_unittest_params *ut_params = &unittest_params;
3246 uint8_t *plaintext, *ciphertext;
3247 unsigned plaintext_pad_len;
3248 unsigned plaintext_len;
3250 /* Create SNOW 3G session */
3251 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3252 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3253 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3254 tdata->key.data, tdata->key.len);
3258 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3260 /* Clear mbuf payload */
3261 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3262 rte_pktmbuf_tailroom(ut_params->ibuf));
3264 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3265 /* Append data which is padded to a multiple of */
3266 /* the algorithms block size */
3267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3268 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3270 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3272 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3274 /* Create SNOW 3G operation */
3275 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3276 tdata->validCipherLenInBits.len,
3277 tdata->validCipherOffsetLenInBits.len,
3278 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3282 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3284 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3286 ut_params->obuf = ut_params->op->sym->m_dst;
3287 if (ut_params->obuf)
3288 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3291 ciphertext = plaintext;
3293 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3296 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3298 tdata->ciphertext.data,
3299 tdata->validDataLenInBits.len,
3300 "SNOW 3G Ciphertext data not as expected");
3306 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3308 struct crypto_testsuite_params *ts_params = &testsuite_params;
3309 struct crypto_unittest_params *ut_params = &unittest_params;
3310 uint8_t *plaintext, *ciphertext;
3313 unsigned plaintext_pad_len;
3314 unsigned plaintext_len;
3316 /* Create SNOW 3G session */
3317 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3318 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3319 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3320 tdata->key.data, tdata->key.len);
3324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3325 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3327 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3328 "Failed to allocate input buffer in mempool");
3329 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3330 "Failed to allocate output buffer in mempool");
3332 /* Clear mbuf payload */
3333 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3334 rte_pktmbuf_tailroom(ut_params->ibuf));
3336 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3337 /* Append data which is padded to a multiple of */
3338 /* the algorithms block size */
3339 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3340 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3342 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3343 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3345 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3347 /* Create SNOW 3G operation */
3348 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3350 tdata->validCipherLenInBits.len,
3351 tdata->validCipherOffsetLenInBits.len,
3352 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3356 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3358 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3360 ut_params->obuf = ut_params->op->sym->m_dst;
3361 if (ut_params->obuf)
3362 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3365 ciphertext = plaintext;
3367 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3370 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3372 tdata->ciphertext.data,
3373 tdata->validDataLenInBits.len,
3374 "SNOW 3G Ciphertext data not as expected");
3379 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3381 struct crypto_testsuite_params *ts_params = &testsuite_params;
3382 struct crypto_unittest_params *ut_params = &unittest_params;
3385 unsigned int plaintext_pad_len;
3386 unsigned int plaintext_len;
3387 uint8_t buffer[10000];
3388 const uint8_t *ciphertext;
3390 struct rte_cryptodev_info dev_info;
3392 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3393 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3394 printf("Device doesn't support scatter-gather. "
3399 /* Create SNOW 3G session */
3400 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3401 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3402 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3403 tdata->key.data, tdata->key.len);
3407 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3408 /* Append data which is padded to a multiple of */
3409 /* the algorithms block size */
3410 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3412 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3413 plaintext_pad_len, 10, 0);
3414 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3415 plaintext_pad_len, 3, 0);
3417 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3418 "Failed to allocate input buffer in mempool");
3419 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3420 "Failed to allocate output buffer in mempool");
3422 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3424 /* Create SNOW 3G operation */
3425 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3427 tdata->validCipherLenInBits.len,
3428 tdata->validCipherOffsetLenInBits.len,
3429 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3433 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3435 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3437 ut_params->obuf = ut_params->op->sym->m_dst;
3438 if (ut_params->obuf)
3439 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3440 plaintext_len, buffer);
3442 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3443 plaintext_len, buffer);
3445 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3448 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3450 tdata->ciphertext.data,
3451 tdata->validDataLenInBits.len,
3452 "SNOW 3G Ciphertext data not as expected");
3457 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3459 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3461 uint8_t curr_byte, prev_byte;
3462 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3463 uint8_t lower_byte_mask = (1 << offset) - 1;
3466 prev_byte = buffer[0];
3467 buffer[0] >>= offset;
3469 for (i = 1; i < length_in_bytes; i++) {
3470 curr_byte = buffer[i];
3471 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3472 (curr_byte >> offset);
3473 prev_byte = curr_byte;
3478 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3480 struct crypto_testsuite_params *ts_params = &testsuite_params;
3481 struct crypto_unittest_params *ut_params = &unittest_params;
3482 uint8_t *plaintext, *ciphertext;
3484 uint32_t plaintext_len;
3485 uint32_t plaintext_pad_len;
3486 uint8_t extra_offset = 4;
3487 uint8_t *expected_ciphertext_shifted;
3489 /* Create SNOW 3G session */
3490 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3491 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3492 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3493 tdata->key.data, tdata->key.len);
3497 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3498 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3500 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3501 "Failed to allocate input buffer in mempool");
3502 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3503 "Failed to allocate output buffer in mempool");
3505 /* Clear mbuf payload */
3506 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3507 rte_pktmbuf_tailroom(ut_params->ibuf));
3509 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3511 * Append data which is padded to a
3512 * multiple of the algorithms block size
3514 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3516 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3519 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3521 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3522 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3524 #ifdef RTE_APP_TEST_DEBUG
3525 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3527 /* Create SNOW 3G operation */
3528 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3530 tdata->validCipherLenInBits.len,
3531 tdata->validCipherOffsetLenInBits.len +
3533 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3537 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3539 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3541 ut_params->obuf = ut_params->op->sym->m_dst;
3542 if (ut_params->obuf)
3543 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3546 ciphertext = plaintext;
3548 #ifdef RTE_APP_TEST_DEBUG
3549 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3552 expected_ciphertext_shifted = rte_malloc(NULL,
3553 ceil_byte_length(plaintext_len + extra_offset), 0);
3555 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3556 "failed to reserve memory for ciphertext shifted\n");
3558 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3559 ceil_byte_length(tdata->ciphertext.len));
3560 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3563 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3565 expected_ciphertext_shifted,
3566 tdata->validDataLenInBits.len,
3568 "SNOW 3G Ciphertext data not as expected");
3572 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3574 struct crypto_testsuite_params *ts_params = &testsuite_params;
3575 struct crypto_unittest_params *ut_params = &unittest_params;
3579 uint8_t *plaintext, *ciphertext;
3580 unsigned ciphertext_pad_len;
3581 unsigned ciphertext_len;
3583 /* Create SNOW 3G session */
3584 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3585 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3586 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3587 tdata->key.data, tdata->key.len);
3591 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3593 /* Clear mbuf payload */
3594 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3595 rte_pktmbuf_tailroom(ut_params->ibuf));
3597 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3598 /* Append data which is padded to a multiple of */
3599 /* the algorithms block size */
3600 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3601 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3602 ciphertext_pad_len);
3603 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3605 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3607 /* Create SNOW 3G operation */
3608 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3609 tdata->validCipherLenInBits.len,
3610 tdata->validCipherOffsetLenInBits.len,
3611 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3615 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3617 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3618 ut_params->obuf = ut_params->op->sym->m_dst;
3619 if (ut_params->obuf)
3620 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3623 plaintext = ciphertext;
3625 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3628 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3629 tdata->plaintext.data,
3630 tdata->validDataLenInBits.len,
3631 "SNOW 3G Plaintext data not as expected");
3635 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3637 struct crypto_testsuite_params *ts_params = &testsuite_params;
3638 struct crypto_unittest_params *ut_params = &unittest_params;
3642 uint8_t *plaintext, *ciphertext;
3643 unsigned ciphertext_pad_len;
3644 unsigned ciphertext_len;
3646 /* Create SNOW 3G session */
3647 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3648 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3649 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3650 tdata->key.data, tdata->key.len);
3654 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3655 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3657 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3658 "Failed to allocate input buffer");
3659 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3660 "Failed to allocate output buffer");
3662 /* Clear mbuf payload */
3663 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3664 rte_pktmbuf_tailroom(ut_params->ibuf));
3666 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3667 rte_pktmbuf_tailroom(ut_params->obuf));
3669 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3670 /* Append data which is padded to a multiple of */
3671 /* the algorithms block size */
3672 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3673 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3674 ciphertext_pad_len);
3675 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3676 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3678 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3680 /* Create SNOW 3G operation */
3681 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3683 tdata->validCipherLenInBits.len,
3684 tdata->validCipherOffsetLenInBits.len,
3685 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3689 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3691 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3692 ut_params->obuf = ut_params->op->sym->m_dst;
3693 if (ut_params->obuf)
3694 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3697 plaintext = ciphertext;
3699 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3702 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3703 tdata->plaintext.data,
3704 tdata->validDataLenInBits.len,
3705 "SNOW 3G Plaintext data not as expected");
3710 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3712 struct crypto_testsuite_params *ts_params = &testsuite_params;
3713 struct crypto_unittest_params *ut_params = &unittest_params;
3717 uint8_t *plaintext, *ciphertext;
3718 unsigned int plaintext_pad_len;
3719 unsigned int plaintext_len;
3721 struct rte_cryptodev_sym_capability_idx cap_idx;
3723 /* Check if device supports ZUC EEA3 */
3724 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3725 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3727 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3731 /* Check if device supports ZUC EIA3 */
3732 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3733 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3735 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3739 /* Create ZUC session */
3740 retval = create_zuc_cipher_auth_encrypt_generate_session(
3741 ts_params->valid_devs[0],
3745 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3747 /* clear mbuf payload */
3748 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3749 rte_pktmbuf_tailroom(ut_params->ibuf));
3751 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3752 /* Append data which is padded to a multiple of */
3753 /* the algorithms block size */
3754 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3755 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3757 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3759 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3761 /* Create ZUC operation */
3762 retval = create_zuc_cipher_hash_generate_operation(tdata);
3766 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3768 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3769 ut_params->obuf = ut_params->op->sym->m_src;
3770 if (ut_params->obuf)
3771 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3772 + tdata->iv.len + tdata->aad.len;
3774 ciphertext = plaintext;
3776 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3778 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3780 tdata->ciphertext.data,
3781 tdata->validDataLenInBits.len,
3782 "ZUC Ciphertext data not as expected");
3784 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3785 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3788 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3792 "ZUC Generated auth tag not as expected");
3797 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3799 struct crypto_testsuite_params *ts_params = &testsuite_params;
3800 struct crypto_unittest_params *ut_params = &unittest_params;
3804 uint8_t *plaintext, *ciphertext;
3805 unsigned plaintext_pad_len;
3806 unsigned plaintext_len;
3808 /* Create SNOW 3G session */
3809 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3810 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3811 RTE_CRYPTO_AUTH_OP_GENERATE,
3812 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3813 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3814 tdata->key.data, tdata->key.len,
3815 tdata->aad.len, tdata->digest.len);
3818 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3820 /* clear mbuf payload */
3821 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3822 rte_pktmbuf_tailroom(ut_params->ibuf));
3824 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3825 /* Append data which is padded to a multiple of */
3826 /* the algorithms block size */
3827 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3828 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3830 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3832 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3834 /* Create SNOW 3G operation */
3835 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3836 tdata->digest.len, tdata->aad.data,
3837 tdata->aad.len, /*tdata->plaintext.len,*/
3838 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3839 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3840 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3841 tdata->iv.data, tdata->iv.len,
3842 tdata->validCipherLenInBits.len,
3843 tdata->validCipherOffsetLenInBits.len,
3844 tdata->validAuthLenInBits.len,
3845 tdata->validAuthOffsetLenInBits.len
3850 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3852 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3853 ut_params->obuf = ut_params->op->sym->m_src;
3854 if (ut_params->obuf)
3855 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3856 + tdata->iv.len + tdata->aad.len;
3858 ciphertext = plaintext;
3860 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3862 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3864 tdata->ciphertext.data,
3865 tdata->validDataLenInBits.len,
3866 "SNOW 3G Ciphertext data not as expected");
3868 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3869 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3872 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3875 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3876 "SNOW 3G Generated auth tag not as expected");
3880 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3882 struct crypto_testsuite_params *ts_params = &testsuite_params;
3883 struct crypto_unittest_params *ut_params = &unittest_params;
3887 uint8_t *plaintext, *ciphertext;
3888 unsigned plaintext_pad_len;
3889 unsigned plaintext_len;
3891 /* Create SNOW 3G session */
3892 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3893 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3894 RTE_CRYPTO_AUTH_OP_GENERATE,
3895 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3896 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3897 tdata->key.data, tdata->key.len,
3898 tdata->aad.len, tdata->digest.len);
3902 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3904 /* clear mbuf payload */
3905 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3906 rte_pktmbuf_tailroom(ut_params->ibuf));
3908 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3909 /* Append data which is padded to a multiple of */
3910 /* the algorithms block size */
3911 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3912 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3914 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3916 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3918 /* Create SNOW 3G operation */
3919 retval = create_wireless_algo_auth_cipher_operation(
3921 tdata->iv.data, tdata->iv.len,
3922 tdata->aad.data, tdata->aad.len,
3924 tdata->validCipherLenInBits.len,
3925 tdata->validCipherOffsetLenInBits.len,
3926 tdata->validAuthLenInBits.len,
3927 tdata->validAuthOffsetLenInBits.len,
3928 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3929 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3935 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3937 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3938 ut_params->obuf = ut_params->op->sym->m_src;
3939 if (ut_params->obuf)
3940 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3941 + tdata->aad.len + tdata->iv.len;
3943 ciphertext = plaintext;
3945 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3946 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3947 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3950 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3952 tdata->ciphertext.data,
3953 tdata->validDataLenInBits.len,
3954 "SNOW 3G Ciphertext data not as expected");
3957 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3960 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3961 "SNOW 3G Generated auth tag not as expected");
3966 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3968 struct crypto_testsuite_params *ts_params = &testsuite_params;
3969 struct crypto_unittest_params *ut_params = &unittest_params;
3973 uint8_t *plaintext, *ciphertext;
3974 unsigned plaintext_pad_len;
3975 unsigned plaintext_len;
3977 /* Create KASUMI session */
3978 retval = create_wireless_algo_auth_cipher_session(
3979 ts_params->valid_devs[0],
3980 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3981 RTE_CRYPTO_AUTH_OP_GENERATE,
3982 RTE_CRYPTO_AUTH_KASUMI_F9,
3983 RTE_CRYPTO_CIPHER_KASUMI_F8,
3984 tdata->key.data, tdata->key.len,
3985 tdata->aad.len, tdata->digest.len);
3988 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3990 /* clear mbuf payload */
3991 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3992 rte_pktmbuf_tailroom(ut_params->ibuf));
3994 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3995 /* Append data which is padded to a multiple of */
3996 /* the algorithms block size */
3997 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3998 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4000 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4002 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4004 /* Create KASUMI operation */
4005 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4006 tdata->iv.data, tdata->iv.len,
4007 tdata->aad.data, tdata->aad.len,
4009 tdata->validCipherLenInBits.len,
4010 tdata->validCipherOffsetLenInBits.len,
4011 tdata->validAuthLenInBits.len,
4012 tdata->validAuthOffsetLenInBits.len,
4013 RTE_CRYPTO_AUTH_KASUMI_F9,
4014 RTE_CRYPTO_CIPHER_KASUMI_F8
4020 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4022 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4023 ut_params->obuf = ut_params->op->sym->m_src;
4024 if (ut_params->obuf)
4025 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4026 + tdata->iv.len + tdata->aad.len;
4028 ciphertext = plaintext;
4031 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4033 tdata->ciphertext.data,
4034 tdata->validCipherLenInBits.len,
4035 "KASUMI Ciphertext data not as expected");
4036 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4037 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
4040 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4043 DIGEST_BYTE_LENGTH_KASUMI_F9,
4044 "KASUMI Generated auth tag not as expected");
4049 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4051 struct crypto_testsuite_params *ts_params = &testsuite_params;
4052 struct crypto_unittest_params *ut_params = &unittest_params;
4056 uint8_t *plaintext, *ciphertext;
4057 unsigned plaintext_pad_len;
4058 unsigned plaintext_len;
4060 /* Create KASUMI session */
4061 retval = create_wireless_algo_cipher_auth_session(
4062 ts_params->valid_devs[0],
4063 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4064 RTE_CRYPTO_AUTH_OP_GENERATE,
4065 RTE_CRYPTO_AUTH_KASUMI_F9,
4066 RTE_CRYPTO_CIPHER_KASUMI_F8,
4067 tdata->key.data, tdata->key.len,
4068 tdata->aad.len, tdata->digest.len);
4072 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4074 /* clear mbuf payload */
4075 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4076 rte_pktmbuf_tailroom(ut_params->ibuf));
4078 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4079 /* Append data which is padded to a multiple of */
4080 /* the algorithms block size */
4081 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4082 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4084 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4086 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4088 /* Create KASUMI operation */
4089 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4090 tdata->digest.len, tdata->aad.data,
4092 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4093 RTE_CRYPTO_AUTH_KASUMI_F9,
4094 RTE_CRYPTO_CIPHER_KASUMI_F8,
4095 tdata->iv.data, tdata->iv.len,
4096 tdata->validCipherLenInBits.len,
4097 tdata->validCipherOffsetLenInBits.len,
4098 tdata->validAuthLenInBits.len,
4099 tdata->validAuthOffsetLenInBits.len
4104 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4106 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4107 ut_params->obuf = ut_params->op->sym->m_src;
4108 if (ut_params->obuf)
4109 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4110 + tdata->aad.len + tdata->iv.len;
4112 ciphertext = plaintext;
4114 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4115 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
4118 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4120 tdata->ciphertext.data,
4121 tdata->validCipherLenInBits.len,
4122 "KASUMI Ciphertext data not as expected");
4125 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4128 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4129 "KASUMI Generated auth tag not as expected");
4134 test_zuc_encryption(const struct wireless_test_data *tdata)
4136 struct crypto_testsuite_params *ts_params = &testsuite_params;
4137 struct crypto_unittest_params *ut_params = &unittest_params;
4140 uint8_t *plaintext, *ciphertext;
4141 unsigned plaintext_pad_len;
4142 unsigned plaintext_len;
4144 struct rte_cryptodev_sym_capability_idx cap_idx;
4146 /* Check if device supports ZUC EEA3 */
4147 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4148 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4150 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4154 /* Create ZUC session */
4155 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4156 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4157 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4158 tdata->key.data, tdata->key.len);
4162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4164 /* Clear mbuf payload */
4165 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4166 rte_pktmbuf_tailroom(ut_params->ibuf));
4168 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4169 /* Append data which is padded to a multiple */
4170 /* of the algorithms block size */
4171 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4172 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4174 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4176 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4178 /* Create ZUC operation */
4179 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
4180 tdata->plaintext.len,
4181 tdata->validCipherOffsetLenInBits.len,
4182 RTE_CRYPTO_CIPHER_ZUC_EEA3);
4186 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4188 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4190 ut_params->obuf = ut_params->op->sym->m_dst;
4191 if (ut_params->obuf)
4192 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4195 ciphertext = plaintext;
4197 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4200 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4202 tdata->ciphertext.data,
4203 tdata->validCipherLenInBits.len,
4204 "ZUC Ciphertext data not as expected");
4209 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4211 struct crypto_testsuite_params *ts_params = &testsuite_params;
4212 struct crypto_unittest_params *ut_params = &unittest_params;
4216 unsigned int plaintext_pad_len;
4217 unsigned int plaintext_len;
4218 const uint8_t *ciphertext;
4219 uint8_t ciphertext_buffer[2048];
4220 struct rte_cryptodev_info dev_info;
4222 struct rte_cryptodev_sym_capability_idx cap_idx;
4224 /* Check if device supports ZUC EEA3 */
4225 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4226 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4228 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4232 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4233 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4234 printf("Device doesn't support scatter-gather. "
4239 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4241 /* Append data which is padded to a multiple */
4242 /* of the algorithms block size */
4243 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4245 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4246 plaintext_pad_len, 10, 0);
4248 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4249 tdata->plaintext.data);
4251 /* Create ZUC session */
4252 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4253 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4254 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4255 tdata->key.data, tdata->key.len);
4259 /* Clear mbuf payload */
4261 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4263 /* Create ZUC operation */
4264 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
4265 tdata->iv.len, tdata->plaintext.len,
4266 tdata->validCipherOffsetLenInBits.len,
4267 RTE_CRYPTO_CIPHER_ZUC_EEA3);
4271 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4273 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4275 ut_params->obuf = ut_params->op->sym->m_dst;
4276 if (ut_params->obuf)
4277 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4278 tdata->iv.len, plaintext_len, ciphertext_buffer);
4280 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4281 tdata->iv.len, plaintext_len, ciphertext_buffer);
4284 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4289 tdata->ciphertext.data,
4290 tdata->validCipherLenInBits.len,
4291 "ZUC Ciphertext data not as expected");
4297 test_zuc_authentication(const struct wireless_test_data *tdata)
4299 struct crypto_testsuite_params *ts_params = &testsuite_params;
4300 struct crypto_unittest_params *ut_params = &unittest_params;
4303 unsigned plaintext_pad_len;
4304 unsigned plaintext_len;
4307 struct rte_cryptodev_sym_capability_idx cap_idx;
4309 /* Check if device supports ZUC EIA3 */
4310 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4311 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4313 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4317 /* Create ZUC session */
4318 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4319 tdata->key.data, tdata->key.len,
4320 tdata->aad.len, tdata->digest.len,
4321 RTE_CRYPTO_AUTH_OP_GENERATE,
4322 RTE_CRYPTO_AUTH_ZUC_EIA3);
4326 /* alloc mbuf and set payload */
4327 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4329 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4330 rte_pktmbuf_tailroom(ut_params->ibuf));
4332 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4333 /* Append data which is padded to a multiple of */
4334 /* the algorithms block size */
4335 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4336 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4338 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4340 /* Create ZUC operation */
4341 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4342 tdata->aad.data, tdata->aad.len,
4343 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4344 RTE_CRYPTO_AUTH_ZUC_EIA3,
4345 tdata->validAuthLenInBits.len,
4346 tdata->validAuthOffsetLenInBits.len);
4350 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4352 ut_params->obuf = ut_params->op->sym->m_src;
4353 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4354 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4355 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
4358 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4361 DIGEST_BYTE_LENGTH_KASUMI_F9,
4362 "ZUC Generated auth tag not as expected");
4368 test_kasumi_encryption_test_case_1(void)
4370 return test_kasumi_encryption(&kasumi_test_case_1);
4374 test_kasumi_encryption_test_case_1_sgl(void)
4376 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4380 test_kasumi_encryption_test_case_1_oop(void)
4382 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4386 test_kasumi_encryption_test_case_1_oop_sgl(void)
4388 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4392 test_kasumi_encryption_test_case_2(void)
4394 return test_kasumi_encryption(&kasumi_test_case_2);
4398 test_kasumi_encryption_test_case_3(void)
4400 return test_kasumi_encryption(&kasumi_test_case_3);
4404 test_kasumi_encryption_test_case_4(void)
4406 return test_kasumi_encryption(&kasumi_test_case_4);
4410 test_kasumi_encryption_test_case_5(void)
4412 return test_kasumi_encryption(&kasumi_test_case_5);
4416 test_kasumi_decryption_test_case_1(void)
4418 return test_kasumi_decryption(&kasumi_test_case_1);
4422 test_kasumi_decryption_test_case_1_oop(void)
4424 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4428 test_kasumi_decryption_test_case_2(void)
4430 return test_kasumi_decryption(&kasumi_test_case_2);
4434 test_kasumi_decryption_test_case_3(void)
4436 return test_kasumi_decryption(&kasumi_test_case_3);
4440 test_kasumi_decryption_test_case_4(void)
4442 return test_kasumi_decryption(&kasumi_test_case_4);
4446 test_kasumi_decryption_test_case_5(void)
4448 return test_kasumi_decryption(&kasumi_test_case_5);
4451 test_snow3g_encryption_test_case_1(void)
4453 return test_snow3g_encryption(&snow3g_test_case_1);
4457 test_snow3g_encryption_test_case_1_oop(void)
4459 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4463 test_snow3g_encryption_test_case_1_oop_sgl(void)
4465 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4470 test_snow3g_encryption_test_case_1_offset_oop(void)
4472 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4476 test_snow3g_encryption_test_case_2(void)
4478 return test_snow3g_encryption(&snow3g_test_case_2);
4482 test_snow3g_encryption_test_case_3(void)
4484 return test_snow3g_encryption(&snow3g_test_case_3);
4488 test_snow3g_encryption_test_case_4(void)
4490 return test_snow3g_encryption(&snow3g_test_case_4);
4494 test_snow3g_encryption_test_case_5(void)
4496 return test_snow3g_encryption(&snow3g_test_case_5);
4500 test_snow3g_decryption_test_case_1(void)
4502 return test_snow3g_decryption(&snow3g_test_case_1);
4506 test_snow3g_decryption_test_case_1_oop(void)
4508 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4512 test_snow3g_decryption_test_case_2(void)
4514 return test_snow3g_decryption(&snow3g_test_case_2);
4518 test_snow3g_decryption_test_case_3(void)
4520 return test_snow3g_decryption(&snow3g_test_case_3);
4524 test_snow3g_decryption_test_case_4(void)
4526 return test_snow3g_decryption(&snow3g_test_case_4);
4530 test_snow3g_decryption_test_case_5(void)
4532 return test_snow3g_decryption(&snow3g_test_case_5);
4535 test_snow3g_cipher_auth_test_case_1(void)
4537 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4541 test_snow3g_auth_cipher_test_case_1(void)
4543 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4547 test_kasumi_auth_cipher_test_case_1(void)
4549 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4553 test_kasumi_cipher_auth_test_case_1(void)
4555 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4559 test_zuc_encryption_test_case_1(void)
4561 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4565 test_zuc_encryption_test_case_2(void)
4567 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4571 test_zuc_encryption_test_case_3(void)
4573 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4577 test_zuc_encryption_test_case_4(void)
4579 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4583 test_zuc_encryption_test_case_5(void)
4585 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4589 test_zuc_encryption_test_case_6_sgl(void)
4591 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4595 test_zuc_hash_generate_test_case_1(void)
4597 return test_zuc_authentication(&zuc_test_case_auth_1b);
4601 test_zuc_hash_generate_test_case_2(void)
4603 return test_zuc_authentication(&zuc_test_case_auth_90b);
4607 test_zuc_hash_generate_test_case_3(void)
4609 return test_zuc_authentication(&zuc_test_case_auth_577b);
4613 test_zuc_hash_generate_test_case_4(void)
4615 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4619 test_zuc_hash_generate_test_case_5(void)
4621 return test_zuc_authentication(&zuc_test_auth_5670b);
4625 test_zuc_hash_generate_test_case_6(void)
4627 return test_zuc_authentication(&zuc_test_case_auth_128b);
4631 test_zuc_hash_generate_test_case_7(void)
4633 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4637 test_zuc_hash_generate_test_case_8(void)
4639 return test_zuc_authentication(&zuc_test_case_auth_584b);
4643 test_zuc_cipher_auth_test_case_1(void)
4645 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4649 test_zuc_cipher_auth_test_case_2(void)
4651 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4655 test_3DES_chain_qat_all(void)
4657 struct crypto_testsuite_params *ts_params = &testsuite_params;
4660 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4661 ts_params->op_mpool, ts_params->valid_devs[0],
4662 RTE_CRYPTODEV_QAT_SYM_PMD,
4663 BLKCIPHER_3DES_CHAIN_TYPE);
4665 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4667 return TEST_SUCCESS;
4671 test_DES_cipheronly_qat_all(void)
4673 struct crypto_testsuite_params *ts_params = &testsuite_params;
4676 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4677 ts_params->op_mpool, ts_params->valid_devs[0],
4678 RTE_CRYPTODEV_QAT_SYM_PMD,
4679 BLKCIPHER_DES_CIPHERONLY_TYPE);
4681 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4683 return TEST_SUCCESS;
4687 test_DES_docsis_openssl_all(void)
4689 struct crypto_testsuite_params *ts_params = &testsuite_params;
4692 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4693 ts_params->op_mpool, ts_params->valid_devs[0],
4694 RTE_CRYPTODEV_OPENSSL_PMD,
4695 BLKCIPHER_DES_DOCSIS_TYPE);
4697 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4699 return TEST_SUCCESS;
4703 test_3DES_cipheronly_qat_all(void)
4705 struct crypto_testsuite_params *ts_params = &testsuite_params;
4708 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4709 ts_params->op_mpool, ts_params->valid_devs[0],
4710 RTE_CRYPTODEV_QAT_SYM_PMD,
4711 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4713 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4715 return TEST_SUCCESS;
4719 test_3DES_chain_openssl_all(void)
4721 struct crypto_testsuite_params *ts_params = &testsuite_params;
4724 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4725 ts_params->op_mpool, ts_params->valid_devs[0],
4726 RTE_CRYPTODEV_OPENSSL_PMD,
4727 BLKCIPHER_3DES_CHAIN_TYPE);
4729 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4731 return TEST_SUCCESS;
4735 test_3DES_cipheronly_openssl_all(void)
4737 struct crypto_testsuite_params *ts_params = &testsuite_params;
4740 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4741 ts_params->op_mpool, ts_params->valid_devs[0],
4742 RTE_CRYPTODEV_OPENSSL_PMD,
4743 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4745 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4747 return TEST_SUCCESS;
4750 /* ***** AES-GCM Tests ***** */
4753 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4754 const uint8_t *key, const uint8_t key_len,
4755 const uint8_t aad_len, const uint8_t auth_len,
4756 enum rte_crypto_auth_operation auth_op)
4758 uint8_t cipher_key[key_len];
4760 struct crypto_unittest_params *ut_params = &unittest_params;
4762 memcpy(cipher_key, key, key_len);
4764 /* Setup Cipher Parameters */
4765 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4766 ut_params->cipher_xform.next = NULL;
4768 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4769 ut_params->auth_xform.auth.op = auth_op;
4770 ut_params->cipher_xform.cipher.op = op;
4771 ut_params->cipher_xform.cipher.key.data = cipher_key;
4772 ut_params->cipher_xform.cipher.key.length = key_len;
4774 TEST_HEXDUMP(stdout, "key:", key, key_len);
4776 /* Setup Authentication Parameters */
4777 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4778 ut_params->auth_xform.next = NULL;
4780 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4782 ut_params->auth_xform.auth.digest_length = auth_len;
4783 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4784 ut_params->auth_xform.auth.key.length = 0;
4785 ut_params->auth_xform.auth.key.data = NULL;
4787 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4788 ut_params->cipher_xform.next = &ut_params->auth_xform;
4790 /* Create Crypto session*/
4791 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4792 &ut_params->cipher_xform);
4793 } else {/* Create Crypto session*/
4794 ut_params->auth_xform.next = &ut_params->cipher_xform;
4795 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4796 &ut_params->auth_xform);
4799 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4805 create_gcm_xforms(struct rte_crypto_op *op,
4806 enum rte_crypto_cipher_operation cipher_op,
4807 uint8_t *key, const uint8_t key_len,
4808 const uint8_t aad_len, const uint8_t auth_len,
4809 enum rte_crypto_auth_operation auth_op)
4811 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4812 "failed to allocate space for crypto transforms");
4814 struct rte_crypto_sym_op *sym_op = op->sym;
4816 /* Setup Cipher Parameters */
4817 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4818 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4819 sym_op->xform->cipher.op = cipher_op;
4820 sym_op->xform->cipher.key.data = key;
4821 sym_op->xform->cipher.key.length = key_len;
4823 TEST_HEXDUMP(stdout, "key:", key, key_len);
4825 /* Setup Authentication Parameters */
4826 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4827 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4828 sym_op->xform->next->auth.op = auth_op;
4829 sym_op->xform->next->auth.digest_length = auth_len;
4830 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4831 sym_op->xform->next->auth.key.length = 0;
4832 sym_op->xform->next->auth.key.data = NULL;
4833 sym_op->xform->next->next = NULL;
4839 create_gcm_operation(enum rte_crypto_cipher_operation op,
4840 const struct gcm_test_data *tdata)
4842 struct crypto_testsuite_params *ts_params = &testsuite_params;
4843 struct crypto_unittest_params *ut_params = &unittest_params;
4845 uint8_t *plaintext, *ciphertext;
4846 unsigned int iv_pad_len, aad_pad_len, plaintext_pad_len;
4848 /* Generate Crypto op data structure */
4849 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4850 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4851 TEST_ASSERT_NOT_NULL(ut_params->op,
4852 "Failed to allocate symmetric crypto operation struct");
4854 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4856 /* Append aad data */
4857 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4858 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4860 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4861 "no room to append aad");
4863 sym_op->auth.aad.length = tdata->aad.len;
4864 sym_op->auth.aad.phys_addr =
4865 rte_pktmbuf_mtophys(ut_params->ibuf);
4866 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4867 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4868 sym_op->auth.aad.length);
4871 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
4872 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4873 ut_params->ibuf, iv_pad_len);
4874 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4876 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4877 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4878 sym_op->cipher.iv.length = tdata->iv.len;
4880 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4881 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
4882 sym_op->cipher.iv.length);
4884 /* Append plaintext/ciphertext */
4885 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4886 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4887 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4889 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4891 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4892 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4893 tdata->plaintext.len);
4895 if (ut_params->obuf) {
4896 ciphertext = (uint8_t *)rte_pktmbuf_append(
4898 plaintext_pad_len + aad_pad_len +
4900 TEST_ASSERT_NOT_NULL(ciphertext,
4901 "no room to append ciphertext");
4903 memset(ciphertext + aad_pad_len + iv_pad_len, 0,
4904 tdata->ciphertext.len);
4907 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4908 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4910 TEST_ASSERT_NOT_NULL(ciphertext,
4911 "no room to append ciphertext");
4913 memcpy(ciphertext, tdata->ciphertext.data,
4914 tdata->ciphertext.len);
4915 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4916 tdata->ciphertext.len);
4918 if (ut_params->obuf) {
4919 plaintext = (uint8_t *)rte_pktmbuf_append(
4921 plaintext_pad_len + aad_pad_len +
4923 TEST_ASSERT_NOT_NULL(plaintext,
4924 "no room to append plaintext");
4926 memset(plaintext + aad_pad_len + iv_pad_len, 0,
4927 tdata->plaintext.len);
4931 /* Append digest data */
4932 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4933 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4934 ut_params->obuf ? ut_params->obuf :
4936 tdata->auth_tag.len);
4937 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4938 "no room to append digest");
4939 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4940 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4941 ut_params->obuf ? ut_params->obuf :
4944 aad_pad_len + iv_pad_len);
4945 sym_op->auth.digest.length = tdata->auth_tag.len;
4947 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4948 ut_params->ibuf, tdata->auth_tag.len);
4949 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4950 "no room to append digest");
4951 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4953 plaintext_pad_len + aad_pad_len + iv_pad_len);
4954 sym_op->auth.digest.length = tdata->auth_tag.len;
4956 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4957 tdata->auth_tag.len);
4958 TEST_HEXDUMP(stdout, "digest:",
4959 sym_op->auth.digest.data,
4960 sym_op->auth.digest.length);
4963 sym_op->cipher.data.length = tdata->plaintext.len;
4964 sym_op->cipher.data.offset = aad_pad_len + iv_pad_len;
4966 sym_op->auth.data.length = tdata->plaintext.len;
4967 sym_op->auth.data.offset = aad_pad_len + iv_pad_len;
4973 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4975 struct crypto_testsuite_params *ts_params = &testsuite_params;
4976 struct crypto_unittest_params *ut_params = &unittest_params;
4979 uint8_t *ciphertext, *auth_tag;
4980 uint16_t plaintext_pad_len;
4983 /* Create GCM session */
4984 retval = create_gcm_session(ts_params->valid_devs[0],
4985 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4986 tdata->key.data, tdata->key.len,
4987 tdata->aad.len, tdata->auth_tag.len,
4988 RTE_CRYPTO_AUTH_OP_GENERATE);
4992 if (tdata->aad.len > MBUF_SIZE) {
4993 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4994 /* Populate full size of add data */
4995 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4996 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4998 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5000 /* clear mbuf payload */
5001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5002 rte_pktmbuf_tailroom(ut_params->ibuf));
5004 /* Create GCM operation */
5005 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5009 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5011 ut_params->op->sym->m_src = ut_params->ibuf;
5013 /* Process crypto operation */
5014 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5015 ut_params->op), "failed to process sym crypto op");
5017 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5018 "crypto op processing failed");
5020 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5022 if (ut_params->op->sym->m_dst) {
5023 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5025 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5026 uint8_t *, plaintext_pad_len);
5028 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5030 ut_params->op->sym->cipher.data.offset);
5031 auth_tag = ciphertext + plaintext_pad_len;
5034 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5035 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5038 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5040 tdata->ciphertext.data,
5041 tdata->ciphertext.len,
5042 "GCM Ciphertext data not as expected");
5044 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5046 tdata->auth_tag.data,
5047 tdata->auth_tag.len,
5048 "GCM Generated auth tag not as expected");
5055 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
5057 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
5061 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
5063 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
5067 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
5069 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
5073 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
5075 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
5079 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
5081 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
5085 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
5087 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
5091 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
5093 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
5097 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
5099 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5103 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
5105 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5109 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
5111 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5115 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
5117 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5121 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
5123 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5127 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
5129 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5133 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
5135 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5139 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
5141 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5145 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
5147 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5151 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5153 struct crypto_testsuite_params *ts_params = &testsuite_params;
5154 struct crypto_unittest_params *ut_params = &unittest_params;
5160 /* Create GCM session */
5161 retval = create_gcm_session(ts_params->valid_devs[0],
5162 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5163 tdata->key.data, tdata->key.len,
5164 tdata->aad.len, tdata->auth_tag.len,
5165 RTE_CRYPTO_AUTH_OP_VERIFY);
5169 /* alloc mbuf and set payload */
5170 if (tdata->aad.len > MBUF_SIZE) {
5171 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5172 /* Populate full size of add data */
5173 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5174 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5178 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5179 rte_pktmbuf_tailroom(ut_params->ibuf));
5181 /* Create GCM operation */
5182 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5186 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5188 ut_params->op->sym->m_src = ut_params->ibuf;
5190 /* Process crypto operation */
5191 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5192 ut_params->op), "failed to process sym crypto op");
5194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5195 "crypto op processing failed");
5197 if (ut_params->op->sym->m_dst)
5198 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5201 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5203 ut_params->op->sym->cipher.data.offset);
5205 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5208 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5210 tdata->plaintext.data,
5211 tdata->plaintext.len,
5212 "GCM plaintext data not as expected");
5214 TEST_ASSERT_EQUAL(ut_params->op->status,
5215 RTE_CRYPTO_OP_STATUS_SUCCESS,
5216 "GCM authentication failed");
5221 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5223 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5227 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5229 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5233 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5235 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5239 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5241 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5245 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5247 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5251 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5253 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5257 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5259 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5263 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5265 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5269 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5271 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5275 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5277 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5281 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5283 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5287 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5289 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5293 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5295 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5299 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5301 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5305 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5307 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5311 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5313 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5317 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5319 struct crypto_testsuite_params *ts_params = &testsuite_params;
5320 struct crypto_unittest_params *ut_params = &unittest_params;
5323 uint8_t *ciphertext, *auth_tag;
5324 uint16_t plaintext_pad_len;
5326 /* Create GCM session */
5327 retval = create_gcm_session(ts_params->valid_devs[0],
5328 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5329 tdata->key.data, tdata->key.len,
5330 tdata->aad.len, tdata->auth_tag.len,
5331 RTE_CRYPTO_AUTH_OP_GENERATE);
5335 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5336 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5338 /* clear mbuf payload */
5339 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5340 rte_pktmbuf_tailroom(ut_params->ibuf));
5341 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5342 rte_pktmbuf_tailroom(ut_params->obuf));
5344 /* Create GCM operation */
5345 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5349 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5351 ut_params->op->sym->m_src = ut_params->ibuf;
5352 ut_params->op->sym->m_dst = ut_params->obuf;
5354 /* Process crypto operation */
5355 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5356 ut_params->op), "failed to process sym crypto op");
5358 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5359 "crypto op processing failed");
5361 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5363 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5364 ut_params->op->sym->cipher.data.offset);
5365 auth_tag = ciphertext + plaintext_pad_len;
5367 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5368 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5371 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5373 tdata->ciphertext.data,
5374 tdata->ciphertext.len,
5375 "GCM Ciphertext data not as expected");
5377 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5379 tdata->auth_tag.data,
5380 tdata->auth_tag.len,
5381 "GCM Generated auth tag not as expected");
5388 test_mb_AES_GCM_authenticated_encryption_oop(void)
5390 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5394 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5396 struct crypto_testsuite_params *ts_params = &testsuite_params;
5397 struct crypto_unittest_params *ut_params = &unittest_params;
5402 /* Create GCM session */
5403 retval = create_gcm_session(ts_params->valid_devs[0],
5404 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5405 tdata->key.data, tdata->key.len,
5406 tdata->aad.len, tdata->auth_tag.len,
5407 RTE_CRYPTO_AUTH_OP_VERIFY);
5411 /* alloc mbuf and set payload */
5412 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5413 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5415 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5416 rte_pktmbuf_tailroom(ut_params->ibuf));
5417 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5418 rte_pktmbuf_tailroom(ut_params->obuf));
5420 /* Create GCM operation */
5421 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5425 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5427 ut_params->op->sym->m_src = ut_params->ibuf;
5428 ut_params->op->sym->m_dst = ut_params->obuf;
5430 /* Process crypto operation */
5431 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5432 ut_params->op), "failed to process sym crypto op");
5434 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5435 "crypto op processing failed");
5437 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5438 ut_params->op->sym->cipher.data.offset);
5440 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5443 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5445 tdata->plaintext.data,
5446 tdata->plaintext.len,
5447 "GCM plaintext data not as expected");
5449 TEST_ASSERT_EQUAL(ut_params->op->status,
5450 RTE_CRYPTO_OP_STATUS_SUCCESS,
5451 "GCM authentication failed");
5456 test_mb_AES_GCM_authenticated_decryption_oop(void)
5458 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5462 test_AES_GCM_authenticated_encryption_sessionless(
5463 const struct gcm_test_data *tdata)
5465 struct crypto_testsuite_params *ts_params = &testsuite_params;
5466 struct crypto_unittest_params *ut_params = &unittest_params;
5469 uint8_t *ciphertext, *auth_tag;
5470 uint16_t plaintext_pad_len;
5471 uint8_t key[tdata->key.len + 1];
5473 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5475 /* clear mbuf payload */
5476 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5477 rte_pktmbuf_tailroom(ut_params->ibuf));
5479 /* Create GCM operation */
5480 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5484 /* Create GCM xforms */
5485 memcpy(key, tdata->key.data, tdata->key.len);
5486 retval = create_gcm_xforms(ut_params->op,
5487 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5488 key, tdata->key.len,
5489 tdata->aad.len, tdata->auth_tag.len,
5490 RTE_CRYPTO_AUTH_OP_GENERATE);
5494 ut_params->op->sym->m_src = ut_params->ibuf;
5496 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5497 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5498 "crypto op session type not sessionless");
5500 /* Process crypto operation */
5501 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5502 ut_params->op), "failed to process sym crypto op");
5504 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5506 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5507 "crypto op status not success");
5509 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5511 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5512 ut_params->op->sym->cipher.data.offset);
5513 auth_tag = ciphertext + plaintext_pad_len;
5515 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5516 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5519 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5521 tdata->ciphertext.data,
5522 tdata->ciphertext.len,
5523 "GCM Ciphertext data not as expected");
5525 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5527 tdata->auth_tag.data,
5528 tdata->auth_tag.len,
5529 "GCM Generated auth tag not as expected");
5536 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5538 return test_AES_GCM_authenticated_encryption_sessionless(
5543 test_AES_GCM_authenticated_decryption_sessionless(
5544 const struct gcm_test_data *tdata)
5546 struct crypto_testsuite_params *ts_params = &testsuite_params;
5547 struct crypto_unittest_params *ut_params = &unittest_params;
5551 uint8_t key[tdata->key.len + 1];
5553 /* alloc mbuf and set payload */
5554 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5556 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5557 rte_pktmbuf_tailroom(ut_params->ibuf));
5559 /* Create GCM operation */
5560 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5564 /* Create GCM xforms */
5565 memcpy(key, tdata->key.data, tdata->key.len);
5566 retval = create_gcm_xforms(ut_params->op,
5567 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5568 key, tdata->key.len,
5569 tdata->aad.len, tdata->auth_tag.len,
5570 RTE_CRYPTO_AUTH_OP_VERIFY);
5574 ut_params->op->sym->m_src = ut_params->ibuf;
5576 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5577 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5578 "crypto op session type not sessionless");
5580 /* Process crypto operation */
5581 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5582 ut_params->op), "failed to process sym crypto op");
5584 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5586 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5587 "crypto op status not success");
5589 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5590 ut_params->op->sym->cipher.data.offset);
5592 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5595 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5597 tdata->plaintext.data,
5598 tdata->plaintext.len,
5599 "GCM plaintext data not as expected");
5601 TEST_ASSERT_EQUAL(ut_params->op->status,
5602 RTE_CRYPTO_OP_STATUS_SUCCESS,
5603 "GCM authentication failed");
5608 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5610 return test_AES_GCM_authenticated_decryption_sessionless(
5617 struct crypto_testsuite_params *ts_params = &testsuite_params;
5618 struct rte_cryptodev_stats stats;
5619 struct rte_cryptodev *dev;
5620 cryptodev_stats_get_t temp_pfn;
5622 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5623 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5624 &stats) == -ENODEV),
5625 "rte_cryptodev_stats_get invalid dev failed");
5626 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5627 "rte_cryptodev_stats_get invalid Param failed");
5628 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5629 temp_pfn = dev->dev_ops->stats_get;
5630 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5631 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5633 "rte_cryptodev_stats_get invalid Param failed");
5634 dev->dev_ops->stats_get = temp_pfn;
5636 /* Test expected values */
5638 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5640 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5642 "rte_cryptodev_stats_get failed");
5643 TEST_ASSERT((stats.enqueued_count == 1),
5644 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5645 TEST_ASSERT((stats.dequeued_count == 1),
5646 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5647 TEST_ASSERT((stats.enqueue_err_count == 0),
5648 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5649 TEST_ASSERT((stats.dequeue_err_count == 0),
5650 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5652 /* invalid device but should ignore and not reset device stats*/
5653 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5654 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5656 "rte_cryptodev_stats_get failed");
5657 TEST_ASSERT((stats.enqueued_count == 1),
5658 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5660 /* check that a valid reset clears stats */
5661 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5662 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5664 "rte_cryptodev_stats_get failed");
5665 TEST_ASSERT((stats.enqueued_count == 0),
5666 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5667 TEST_ASSERT((stats.dequeued_count == 0),
5668 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5670 return TEST_SUCCESS;
5673 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5674 struct crypto_unittest_params *ut_params,
5675 enum rte_crypto_auth_operation op,
5676 const struct HMAC_MD5_vector *test_case)
5680 memcpy(key, test_case->key.data, test_case->key.len);
5682 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5683 ut_params->auth_xform.next = NULL;
5684 ut_params->auth_xform.auth.op = op;
5686 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5688 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5689 ut_params->auth_xform.auth.add_auth_data_length = 0;
5690 ut_params->auth_xform.auth.key.length = test_case->key.len;
5691 ut_params->auth_xform.auth.key.data = key;
5693 ut_params->sess = rte_cryptodev_sym_session_create(
5694 ts_params->valid_devs[0], &ut_params->auth_xform);
5696 if (ut_params->sess == NULL)
5699 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5701 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5702 rte_pktmbuf_tailroom(ut_params->ibuf));
5707 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5708 const struct HMAC_MD5_vector *test_case,
5709 uint8_t **plaintext)
5711 uint16_t plaintext_pad_len;
5713 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5715 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5718 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5720 memcpy(*plaintext, test_case->plaintext.data,
5721 test_case->plaintext.len);
5723 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5724 ut_params->ibuf, MD5_DIGEST_LEN);
5725 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5726 "no room to append digest");
5727 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5728 ut_params->ibuf, plaintext_pad_len);
5729 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5731 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5732 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5733 test_case->auth_tag.len);
5736 sym_op->auth.data.offset = 0;
5737 sym_op->auth.data.length = test_case->plaintext.len;
5739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5740 ut_params->op->sym->m_src = ut_params->ibuf;
5746 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5748 uint16_t plaintext_pad_len;
5749 uint8_t *plaintext, *auth_tag;
5751 struct crypto_testsuite_params *ts_params = &testsuite_params;
5752 struct crypto_unittest_params *ut_params = &unittest_params;
5754 if (MD5_HMAC_create_session(ts_params, ut_params,
5755 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5758 /* Generate Crypto op data structure */
5759 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5760 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5761 TEST_ASSERT_NOT_NULL(ut_params->op,
5762 "Failed to allocate symmetric crypto operation struct");
5764 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5767 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5770 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5771 ut_params->op), "failed to process sym crypto op");
5773 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5774 "crypto op processing failed");
5776 if (ut_params->op->sym->m_dst) {
5777 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5778 uint8_t *, plaintext_pad_len);
5780 auth_tag = plaintext + plaintext_pad_len;
5783 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5785 test_case->auth_tag.data,
5786 test_case->auth_tag.len,
5787 "HMAC_MD5 generated tag not as expected");
5789 return TEST_SUCCESS;
5793 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5797 struct crypto_testsuite_params *ts_params = &testsuite_params;
5798 struct crypto_unittest_params *ut_params = &unittest_params;
5800 if (MD5_HMAC_create_session(ts_params, ut_params,
5801 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5805 /* Generate Crypto op data structure */
5806 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5807 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5808 TEST_ASSERT_NOT_NULL(ut_params->op,
5809 "Failed to allocate symmetric crypto operation struct");
5811 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5814 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5815 ut_params->op), "failed to process sym crypto op");
5817 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5818 "HMAC_MD5 crypto op processing failed");
5820 return TEST_SUCCESS;
5824 test_MD5_HMAC_generate_case_1(void)
5826 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5830 test_MD5_HMAC_verify_case_1(void)
5832 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5836 test_MD5_HMAC_generate_case_2(void)
5838 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5842 test_MD5_HMAC_verify_case_2(void)
5844 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5848 test_multi_session(void)
5850 struct crypto_testsuite_params *ts_params = &testsuite_params;
5851 struct crypto_unittest_params *ut_params = &unittest_params;
5853 struct rte_cryptodev_info dev_info;
5854 struct rte_cryptodev_sym_session **sessions;
5858 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5859 aes_cbc_key, hmac_sha512_key);
5862 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5864 sessions = rte_malloc(NULL,
5865 (sizeof(struct rte_cryptodev_sym_session *) *
5866 dev_info.sym.max_nb_sessions) + 1, 0);
5868 /* Create multiple crypto sessions*/
5869 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5870 sessions[i] = rte_cryptodev_sym_session_create(
5871 ts_params->valid_devs[0],
5872 &ut_params->auth_xform);
5873 TEST_ASSERT_NOT_NULL(sessions[i],
5874 "Session creation failed at session number %u",
5877 /* Attempt to send a request on each session */
5878 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5882 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5883 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5885 "Failed to perform decrypt on request number %u.", i);
5886 /* free crypto operation structure */
5888 rte_crypto_op_free(ut_params->op);
5891 * free mbuf - both obuf and ibuf are usually the same,
5892 * so check if they point at the same address is necessary,
5893 * to avoid freeing the mbuf twice.
5895 if (ut_params->obuf) {
5896 rte_pktmbuf_free(ut_params->obuf);
5897 if (ut_params->ibuf == ut_params->obuf)
5898 ut_params->ibuf = 0;
5899 ut_params->obuf = 0;
5901 if (ut_params->ibuf) {
5902 rte_pktmbuf_free(ut_params->ibuf);
5903 ut_params->ibuf = 0;
5907 /* Next session create should fail */
5908 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5909 &ut_params->auth_xform);
5910 TEST_ASSERT_NULL(sessions[i],
5911 "Session creation succeeded unexpectedly!");
5913 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5914 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5919 return TEST_SUCCESS;
5922 struct multi_session_params {
5923 struct crypto_unittest_params ut_params;
5924 uint8_t *cipher_key;
5926 const uint8_t *cipher;
5927 const uint8_t *digest;
5931 #define MB_SESSION_NUMBER 3
5934 test_multi_session_random_usage(void)
5936 struct crypto_testsuite_params *ts_params = &testsuite_params;
5937 struct rte_cryptodev_info dev_info;
5938 struct rte_cryptodev_sym_session **sessions;
5940 struct multi_session_params ut_paramz[] = {
5943 .cipher_key = ms_aes_cbc_key0,
5944 .hmac_key = ms_hmac_key0,
5945 .cipher = ms_aes_cbc_cipher0,
5946 .digest = ms_hmac_digest0,
5947 .iv = ms_aes_cbc_iv0
5950 .cipher_key = ms_aes_cbc_key1,
5951 .hmac_key = ms_hmac_key1,
5952 .cipher = ms_aes_cbc_cipher1,
5953 .digest = ms_hmac_digest1,
5954 .iv = ms_aes_cbc_iv1
5957 .cipher_key = ms_aes_cbc_key2,
5958 .hmac_key = ms_hmac_key2,
5959 .cipher = ms_aes_cbc_cipher2,
5960 .digest = ms_hmac_digest2,
5961 .iv = ms_aes_cbc_iv2
5966 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5968 sessions = rte_malloc(NULL,
5969 (sizeof(struct rte_cryptodev_sym_session *)
5970 * dev_info.sym.max_nb_sessions) + 1, 0);
5972 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5973 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5974 sizeof(struct crypto_unittest_params));
5976 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5977 &ut_paramz[i].ut_params,
5978 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5980 /* Create multiple crypto sessions*/
5981 sessions[i] = rte_cryptodev_sym_session_create(
5982 ts_params->valid_devs[0],
5983 &ut_paramz[i].ut_params.auth_xform);
5985 TEST_ASSERT_NOT_NULL(sessions[i],
5986 "Session creation failed at session number %u",
5992 for (i = 0; i < 40000; i++) {
5994 j = rand() % MB_SESSION_NUMBER;
5996 TEST_ASSERT_SUCCESS(
5997 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5999 &ut_paramz[j].ut_params,
6000 ts_params, ut_paramz[j].cipher,
6001 ut_paramz[j].digest,
6003 "Failed to perform decrypt on request number %u.", i);
6005 if (ut_paramz[j].ut_params.op)
6006 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6009 * free mbuf - both obuf and ibuf are usually the same,
6010 * so check if they point at the same address is necessary,
6011 * to avoid freeing the mbuf twice.
6013 if (ut_paramz[j].ut_params.obuf) {
6014 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6015 if (ut_paramz[j].ut_params.ibuf
6016 == ut_paramz[j].ut_params.obuf)
6017 ut_paramz[j].ut_params.ibuf = 0;
6018 ut_paramz[j].ut_params.obuf = 0;
6020 if (ut_paramz[j].ut_params.ibuf) {
6021 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6022 ut_paramz[j].ut_params.ibuf = 0;
6026 for (i = 0; i < MB_SESSION_NUMBER; i++)
6027 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
6032 return TEST_SUCCESS;
6036 test_null_cipher_only_operation(void)
6038 struct crypto_testsuite_params *ts_params = &testsuite_params;
6039 struct crypto_unittest_params *ut_params = &unittest_params;
6041 /* Generate test mbuf data and space for digest */
6042 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6043 catch_22_quote, QUOTE_512_BYTES, 0);
6045 /* Setup Cipher Parameters */
6046 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6047 ut_params->cipher_xform.next = NULL;
6049 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6050 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6052 /* Create Crypto session*/
6053 ut_params->sess = rte_cryptodev_sym_session_create(
6054 ts_params->valid_devs[0], &ut_params->cipher_xform);
6055 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6057 /* Generate Crypto op data structure */
6058 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6059 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6060 TEST_ASSERT_NOT_NULL(ut_params->op,
6061 "Failed to allocate symmetric crypto operation struct");
6063 /* Set crypto operation data parameters */
6064 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6066 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6068 /* set crypto operation source mbuf */
6069 sym_op->m_src = ut_params->ibuf;
6071 sym_op->cipher.data.offset = 0;
6072 sym_op->cipher.data.length = QUOTE_512_BYTES;
6074 /* Process crypto operation */
6075 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6077 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6079 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6080 "crypto operation processing failed");
6083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6084 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6087 "Ciphertext data not as expected");
6089 return TEST_SUCCESS;
6093 test_null_auth_only_operation(void)
6095 struct crypto_testsuite_params *ts_params = &testsuite_params;
6096 struct crypto_unittest_params *ut_params = &unittest_params;
6098 /* Generate test mbuf data and space for digest */
6099 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6100 catch_22_quote, QUOTE_512_BYTES, 0);
6102 /* Setup HMAC Parameters */
6103 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6104 ut_params->auth_xform.next = NULL;
6106 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6107 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6109 /* Create Crypto session*/
6110 ut_params->sess = rte_cryptodev_sym_session_create(
6111 ts_params->valid_devs[0], &ut_params->auth_xform);
6112 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6114 /* Generate Crypto op data structure */
6115 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6116 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6117 TEST_ASSERT_NOT_NULL(ut_params->op,
6118 "Failed to allocate symmetric crypto operation struct");
6120 /* Set crypto operation data parameters */
6121 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6123 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6125 sym_op->m_src = ut_params->ibuf;
6127 sym_op->auth.data.offset = 0;
6128 sym_op->auth.data.length = QUOTE_512_BYTES;
6130 /* Process crypto operation */
6131 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6133 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6135 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6136 "crypto operation processing failed");
6138 return TEST_SUCCESS;
6142 test_null_cipher_auth_operation(void)
6144 struct crypto_testsuite_params *ts_params = &testsuite_params;
6145 struct crypto_unittest_params *ut_params = &unittest_params;
6147 /* Generate test mbuf data and space for digest */
6148 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6149 catch_22_quote, QUOTE_512_BYTES, 0);
6151 /* Setup Cipher Parameters */
6152 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6153 ut_params->cipher_xform.next = &ut_params->auth_xform;
6155 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6156 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6158 /* Setup HMAC Parameters */
6159 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6160 ut_params->auth_xform.next = NULL;
6162 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6163 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6165 /* Create Crypto session*/
6166 ut_params->sess = rte_cryptodev_sym_session_create(
6167 ts_params->valid_devs[0], &ut_params->cipher_xform);
6168 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6170 /* Generate Crypto op data structure */
6171 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6172 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6173 TEST_ASSERT_NOT_NULL(ut_params->op,
6174 "Failed to allocate symmetric crypto operation struct");
6176 /* Set crypto operation data parameters */
6177 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6179 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6181 sym_op->m_src = ut_params->ibuf;
6183 sym_op->cipher.data.offset = 0;
6184 sym_op->cipher.data.length = QUOTE_512_BYTES;
6186 sym_op->auth.data.offset = 0;
6187 sym_op->auth.data.length = QUOTE_512_BYTES;
6189 /* Process crypto operation */
6190 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6192 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6195 "crypto operation processing failed");
6198 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6199 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6202 "Ciphertext data not as expected");
6204 return TEST_SUCCESS;
6208 test_null_auth_cipher_operation(void)
6210 struct crypto_testsuite_params *ts_params = &testsuite_params;
6211 struct crypto_unittest_params *ut_params = &unittest_params;
6213 /* Generate test mbuf data and space for digest */
6214 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6215 catch_22_quote, QUOTE_512_BYTES, 0);
6217 /* Setup Cipher Parameters */
6218 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6219 ut_params->cipher_xform.next = NULL;
6221 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6222 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6224 /* Setup HMAC Parameters */
6225 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6226 ut_params->auth_xform.next = &ut_params->cipher_xform;
6228 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6229 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6231 /* Create Crypto session*/
6232 ut_params->sess = rte_cryptodev_sym_session_create(
6233 ts_params->valid_devs[0], &ut_params->cipher_xform);
6234 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6236 /* Generate Crypto op data structure */
6237 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6238 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6239 TEST_ASSERT_NOT_NULL(ut_params->op,
6240 "Failed to allocate symmetric crypto operation struct");
6242 /* Set crypto operation data parameters */
6243 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6245 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6247 sym_op->m_src = ut_params->ibuf;
6249 sym_op->cipher.data.offset = 0;
6250 sym_op->cipher.data.length = QUOTE_512_BYTES;
6252 sym_op->auth.data.offset = 0;
6253 sym_op->auth.data.length = QUOTE_512_BYTES;
6255 /* Process crypto operation */
6256 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6258 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6260 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6261 "crypto operation processing failed");
6264 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6265 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6268 "Ciphertext data not as expected");
6270 return TEST_SUCCESS;
6275 test_null_invalid_operation(void)
6277 struct crypto_testsuite_params *ts_params = &testsuite_params;
6278 struct crypto_unittest_params *ut_params = &unittest_params;
6280 /* Setup Cipher Parameters */
6281 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6282 ut_params->cipher_xform.next = NULL;
6284 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6285 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6287 /* Create Crypto session*/
6288 ut_params->sess = rte_cryptodev_sym_session_create(
6289 ts_params->valid_devs[0], &ut_params->cipher_xform);
6290 TEST_ASSERT_NULL(ut_params->sess,
6291 "Session creation succeeded unexpectedly");
6294 /* Setup HMAC Parameters */
6295 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6296 ut_params->auth_xform.next = NULL;
6298 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6299 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6301 /* Create Crypto session*/
6302 ut_params->sess = rte_cryptodev_sym_session_create(
6303 ts_params->valid_devs[0], &ut_params->auth_xform);
6304 TEST_ASSERT_NULL(ut_params->sess,
6305 "Session creation succeeded unexpectedly");
6307 return TEST_SUCCESS;
6311 #define NULL_BURST_LENGTH (32)
6314 test_null_burst_operation(void)
6316 struct crypto_testsuite_params *ts_params = &testsuite_params;
6317 struct crypto_unittest_params *ut_params = &unittest_params;
6319 unsigned i, burst_len = NULL_BURST_LENGTH;
6321 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6322 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6324 /* Setup Cipher Parameters */
6325 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6326 ut_params->cipher_xform.next = &ut_params->auth_xform;
6328 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6329 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6331 /* Setup HMAC Parameters */
6332 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6333 ut_params->auth_xform.next = NULL;
6335 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6336 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6338 /* Create Crypto session*/
6339 ut_params->sess = rte_cryptodev_sym_session_create(
6340 ts_params->valid_devs[0], &ut_params->cipher_xform);
6341 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6343 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6344 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6345 burst_len, "failed to generate burst of crypto ops");
6347 /* Generate an operation for each mbuf in burst */
6348 for (i = 0; i < burst_len; i++) {
6349 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6351 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6353 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6357 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6359 burst[i]->sym->m_src = m;
6362 /* Process crypto operation */
6363 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6364 0, burst, burst_len),
6366 "Error enqueuing burst");
6368 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6369 0, burst_dequeued, burst_len),
6371 "Error dequeuing burst");
6374 for (i = 0; i < burst_len; i++) {
6376 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6377 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6379 "data not as expected");
6381 rte_pktmbuf_free(burst[i]->sym->m_src);
6382 rte_crypto_op_free(burst[i]);
6385 return TEST_SUCCESS;
6389 generate_gmac_large_plaintext(uint8_t *data)
6393 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6394 memcpy(&data[i], &data[0], 32);
6398 create_gmac_operation(enum rte_crypto_auth_operation op,
6399 const struct gmac_test_data *tdata)
6401 struct crypto_testsuite_params *ts_params = &testsuite_params;
6402 struct crypto_unittest_params *ut_params = &unittest_params;
6403 struct rte_crypto_sym_op *sym_op;
6405 unsigned iv_pad_len;
6406 unsigned aad_pad_len;
6408 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
6409 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6412 * Runtime generate the large plain text instead of use hard code
6413 * plain text vector. It is done to avoid create huge source file
6414 * with the test vector.
6416 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6417 generate_gmac_large_plaintext(tdata->aad.data);
6419 /* Generate Crypto op data structure */
6420 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6421 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6422 TEST_ASSERT_NOT_NULL(ut_params->op,
6423 "Failed to allocate symmetric crypto operation struct");
6425 sym_op = ut_params->op->sym;
6426 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6428 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6429 "no room to append aad");
6431 sym_op->auth.aad.length = tdata->aad.len;
6432 sym_op->auth.aad.phys_addr =
6433 rte_pktmbuf_mtophys(ut_params->ibuf);
6434 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6436 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6437 ut_params->ibuf, tdata->gmac_tag.len);
6438 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6439 "no room to append digest");
6441 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6442 ut_params->ibuf, aad_pad_len);
6443 sym_op->auth.digest.length = tdata->gmac_tag.len;
6445 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6446 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6447 tdata->gmac_tag.len);
6448 TEST_HEXDUMP(stdout, "digest:",
6449 sym_op->auth.digest.data,
6450 sym_op->auth.digest.length);
6453 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6454 ut_params->ibuf, iv_pad_len);
6455 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6457 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6458 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6459 sym_op->cipher.iv.length = tdata->iv.len;
6461 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
6463 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6465 sym_op->cipher.data.length = 0;
6466 sym_op->cipher.data.offset = 0;
6468 sym_op->auth.data.offset = 0;
6469 sym_op->auth.data.length = 0;
6474 static int create_gmac_session(uint8_t dev_id,
6475 enum rte_crypto_cipher_operation op,
6476 const struct gmac_test_data *tdata,
6477 enum rte_crypto_auth_operation auth_op)
6479 uint8_t cipher_key[tdata->key.len];
6481 struct crypto_unittest_params *ut_params = &unittest_params;
6483 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6485 /* For GMAC we setup cipher parameters */
6486 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6487 ut_params->cipher_xform.next = NULL;
6488 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6489 ut_params->cipher_xform.cipher.op = op;
6490 ut_params->cipher_xform.cipher.key.data = cipher_key;
6491 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6493 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6494 ut_params->auth_xform.next = NULL;
6496 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6497 ut_params->auth_xform.auth.op = auth_op;
6498 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6499 ut_params->auth_xform.auth.add_auth_data_length = 0;
6500 ut_params->auth_xform.auth.key.length = 0;
6501 ut_params->auth_xform.auth.key.data = NULL;
6503 ut_params->cipher_xform.next = &ut_params->auth_xform;
6505 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6506 &ut_params->cipher_xform);
6508 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6514 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6516 struct crypto_testsuite_params *ts_params = &testsuite_params;
6517 struct crypto_unittest_params *ut_params = &unittest_params;
6521 uint8_t *auth_tag, *p;
6522 uint16_t aad_pad_len;
6524 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6525 "No GMAC length in the source data");
6527 retval = create_gmac_session(ts_params->valid_devs[0],
6528 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6529 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6534 if (tdata->aad.len > MBUF_SIZE)
6535 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6537 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6538 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6539 "Failed to allocate input buffer in mempool");
6541 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6542 rte_pktmbuf_tailroom(ut_params->ibuf));
6544 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6546 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6548 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6554 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6556 ut_params->op->sym->m_src = ut_params->ibuf;
6558 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6559 ut_params->op), "failed to process sym crypto op");
6561 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6562 "crypto op processing failed");
6564 if (ut_params->op->sym->m_dst) {
6565 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6566 uint8_t *, aad_pad_len);
6568 auth_tag = p + aad_pad_len;
6571 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6573 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6575 tdata->gmac_tag.data,
6576 tdata->gmac_tag.len,
6577 "GMAC Generated auth tag not as expected");
6583 test_AES_GMAC_authentication_test_case_1(void)
6585 return test_AES_GMAC_authentication(&gmac_test_case_1);
6589 test_AES_GMAC_authentication_test_case_2(void)
6591 return test_AES_GMAC_authentication(&gmac_test_case_2);
6595 test_AES_GMAC_authentication_test_case_3(void)
6597 return test_AES_GMAC_authentication(&gmac_test_case_3);
6601 test_AES_GMAC_authentication_test_case_4(void)
6603 return test_AES_GMAC_authentication(&gmac_test_case_4);
6607 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6609 struct crypto_testsuite_params *ts_params = &testsuite_params;
6610 struct crypto_unittest_params *ut_params = &unittest_params;
6613 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6614 "No GMAC length in the source data");
6616 retval = create_gmac_session(ts_params->valid_devs[0],
6617 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6618 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6623 if (tdata->aad.len > MBUF_SIZE)
6624 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6626 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6627 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6628 "Failed to allocate input buffer in mempool");
6630 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6631 rte_pktmbuf_tailroom(ut_params->ibuf));
6633 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6639 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6641 ut_params->op->sym->m_src = ut_params->ibuf;
6643 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6644 ut_params->op), "failed to process sym crypto op");
6646 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6647 "crypto op processing failed");
6654 test_AES_GMAC_authentication_verify_test_case_1(void)
6656 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6660 test_AES_GMAC_authentication_verify_test_case_2(void)
6662 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6666 test_AES_GMAC_authentication_verify_test_case_3(void)
6668 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6672 test_AES_GMAC_authentication_verify_test_case_4(void)
6674 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6677 struct test_crypto_vector {
6678 enum rte_crypto_cipher_algorithm crypto_algo;
6691 const uint8_t *data;
6696 const uint8_t *data;
6700 enum rte_crypto_auth_algorithm auth_algo;
6708 const uint8_t *data;
6718 static const struct test_crypto_vector
6719 hmac_sha1_test_crypto_vector = {
6720 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6722 .data = plaintext_hash,
6727 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6728 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6729 0xDE, 0xF4, 0xDE, 0xAD
6735 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6736 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6737 0x3F, 0x91, 0x64, 0x59
6743 static const struct test_crypto_vector
6744 aes128_gmac_test_vector = {
6745 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6746 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6748 .data = plaintext_hash,
6753 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6754 0x08, 0x09, 0x0A, 0x0B
6760 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6761 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6767 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6768 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6774 static const struct test_crypto_vector
6775 aes128cbc_hmac_sha1_test_vector = {
6776 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6779 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6780 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6786 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6787 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6792 .data = plaintext_hash,
6796 .data = ciphertext512_aes128cbc,
6799 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6802 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6803 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6804 0xDE, 0xF4, 0xDE, 0xAD
6810 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6811 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6812 0x18, 0x8C, 0x1D, 0x32
6819 data_corruption(uint8_t *data)
6825 tag_corruption(uint8_t *data, unsigned int tag_offset)
6827 data[tag_offset] += 1;
6831 create_auth_session(struct crypto_unittest_params *ut_params,
6833 const struct test_crypto_vector *reference,
6834 enum rte_crypto_auth_operation auth_op)
6836 uint8_t auth_key[reference->auth_key.len + 1];
6838 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6840 /* Setup Authentication Parameters */
6841 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6842 ut_params->auth_xform.auth.op = auth_op;
6843 ut_params->auth_xform.next = NULL;
6844 ut_params->auth_xform.auth.algo = reference->auth_algo;
6845 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6846 ut_params->auth_xform.auth.key.data = auth_key;
6847 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6848 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6850 /* Create Crypto session*/
6851 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6852 &ut_params->auth_xform);
6854 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6860 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6862 const struct test_crypto_vector *reference,
6863 enum rte_crypto_auth_operation auth_op,
6864 enum rte_crypto_cipher_operation cipher_op)
6866 uint8_t cipher_key[reference->cipher_key.len + 1];
6867 uint8_t auth_key[reference->auth_key.len + 1];
6869 memcpy(cipher_key, reference->cipher_key.data,
6870 reference->cipher_key.len);
6871 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6873 /* Setup Authentication Parameters */
6874 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6875 ut_params->auth_xform.auth.op = auth_op;
6876 ut_params->auth_xform.next = &ut_params->cipher_xform;
6877 ut_params->auth_xform.auth.algo = reference->auth_algo;
6878 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6879 ut_params->auth_xform.auth.key.data = auth_key;
6880 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6881 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6883 /* Setup Cipher Parameters */
6884 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6885 ut_params->cipher_xform.next = NULL;
6886 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6887 ut_params->cipher_xform.cipher.op = cipher_op;
6888 ut_params->cipher_xform.cipher.key.data = cipher_key;
6889 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6891 /* Create Crypto session*/
6892 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6893 &ut_params->auth_xform);
6895 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6901 create_auth_operation(struct crypto_testsuite_params *ts_params,
6902 struct crypto_unittest_params *ut_params,
6903 const struct test_crypto_vector *reference,
6904 unsigned int auth_generate)
6906 /* Generate Crypto op data structure */
6907 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6908 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6909 TEST_ASSERT_NOT_NULL(ut_params->op,
6910 "Failed to allocate pktmbuf offload");
6912 /* Set crypto operation data parameters */
6913 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6915 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6917 /* set crypto operation source mbuf */
6918 sym_op->m_src = ut_params->ibuf;
6921 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6922 ut_params->ibuf, reference->digest.len);
6924 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6925 "no room to append auth tag");
6927 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6928 ut_params->ibuf, reference->plaintext.len);
6929 sym_op->auth.digest.length = reference->digest.len;
6932 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6934 memcpy(sym_op->auth.digest.data,
6935 reference->digest.data,
6936 reference->digest.len);
6938 TEST_HEXDUMP(stdout, "digest:",
6939 sym_op->auth.digest.data,
6940 sym_op->auth.digest.length);
6942 sym_op->auth.data.length = reference->plaintext.len;
6943 sym_op->auth.data.offset = 0;
6949 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6950 struct crypto_unittest_params *ut_params,
6951 const struct test_crypto_vector *reference,
6952 unsigned int auth_generate)
6954 /* Generate Crypto op data structure */
6955 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6956 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6957 TEST_ASSERT_NOT_NULL(ut_params->op,
6958 "Failed to allocate pktmbuf offload");
6960 /* Set crypto operation data parameters */
6961 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6963 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6965 /* set crypto operation source mbuf */
6966 sym_op->m_src = ut_params->ibuf;
6969 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6970 reference->aad.len);
6971 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6972 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6974 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6976 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6977 sym_op->auth.aad.length = reference->aad.len;
6980 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6981 ut_params->ibuf, reference->digest.len);
6983 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6984 "no room to append auth tag");
6986 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6987 ut_params->ibuf, reference->ciphertext.len);
6988 sym_op->auth.digest.length = reference->digest.len;
6991 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6993 memcpy(sym_op->auth.digest.data,
6994 reference->digest.data,
6995 reference->digest.len);
6997 TEST_HEXDUMP(stdout, "digest:",
6998 sym_op->auth.digest.data,
6999 sym_op->auth.digest.length);
7001 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
7002 ut_params->ibuf, reference->iv.len);
7003 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
7005 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
7006 sym_op->cipher.iv.length = reference->iv.len;
7008 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
7010 sym_op->cipher.data.length = 0;
7011 sym_op->cipher.data.offset = 0;
7013 sym_op->auth.data.length = 0;
7014 sym_op->auth.data.offset = 0;
7020 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7021 struct crypto_unittest_params *ut_params,
7022 const struct test_crypto_vector *reference,
7023 unsigned int auth_generate)
7025 /* Generate Crypto op data structure */
7026 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7027 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7028 TEST_ASSERT_NOT_NULL(ut_params->op,
7029 "Failed to allocate pktmbuf offload");
7031 /* Set crypto operation data parameters */
7032 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7034 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7036 /* set crypto operation source mbuf */
7037 sym_op->m_src = ut_params->ibuf;
7040 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7041 ut_params->ibuf, reference->digest.len);
7043 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7044 "no room to append auth tag");
7046 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7047 ut_params->ibuf, reference->ciphertext.len);
7048 sym_op->auth.digest.length = reference->digest.len;
7051 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7053 memcpy(sym_op->auth.digest.data,
7054 reference->digest.data,
7055 reference->digest.len);
7057 TEST_HEXDUMP(stdout, "digest:",
7058 sym_op->auth.digest.data,
7059 sym_op->auth.digest.length);
7061 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
7062 ut_params->ibuf, reference->iv.len);
7063 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
7065 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
7066 sym_op->cipher.iv.length = reference->iv.len;
7068 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
7070 sym_op->cipher.data.length = reference->ciphertext.len;
7071 sym_op->cipher.data.offset = reference->iv.len;
7073 sym_op->auth.data.length = reference->ciphertext.len;
7074 sym_op->auth.data.offset = reference->iv.len;
7080 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7081 struct crypto_unittest_params *ut_params,
7082 const struct test_crypto_vector *reference)
7084 return create_auth_operation(ts_params, ut_params, reference, 0);
7088 create_auth_verify_GMAC_operation(
7089 struct crypto_testsuite_params *ts_params,
7090 struct crypto_unittest_params *ut_params,
7091 const struct test_crypto_vector *reference)
7093 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7097 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7098 struct crypto_unittest_params *ut_params,
7099 const struct test_crypto_vector *reference)
7101 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7105 test_authentication_verify_fail_when_data_corruption(
7106 struct crypto_testsuite_params *ts_params,
7107 struct crypto_unittest_params *ut_params,
7108 const struct test_crypto_vector *reference,
7109 unsigned int data_corrupted)
7115 /* Create session */
7116 retval = create_auth_session(ut_params,
7117 ts_params->valid_devs[0],
7119 RTE_CRYPTO_AUTH_OP_VERIFY);
7123 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7124 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7125 "Failed to allocate input buffer in mempool");
7127 /* clear mbuf payload */
7128 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7129 rte_pktmbuf_tailroom(ut_params->ibuf));
7131 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7132 reference->plaintext.len);
7133 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7134 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7136 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7138 /* Create operation */
7139 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7145 data_corruption(plaintext);
7147 tag_corruption(plaintext, reference->plaintext.len);
7149 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7151 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7152 TEST_ASSERT_EQUAL(ut_params->op->status,
7153 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7154 "authentication not failed");
7156 ut_params->obuf = ut_params->op->sym->m_src;
7157 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7163 test_authentication_verify_GMAC_fail_when_corruption(
7164 struct crypto_testsuite_params *ts_params,
7165 struct crypto_unittest_params *ut_params,
7166 const struct test_crypto_vector *reference,
7167 unsigned int data_corrupted)
7171 /* Create session */
7172 retval = create_auth_cipher_session(ut_params,
7173 ts_params->valid_devs[0],
7175 RTE_CRYPTO_AUTH_OP_VERIFY,
7176 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7180 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7181 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7182 "Failed to allocate input buffer in mempool");
7184 /* clear mbuf payload */
7185 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7186 rte_pktmbuf_tailroom(ut_params->ibuf));
7188 /* Create operation */
7189 retval = create_auth_verify_GMAC_operation(ts_params,
7197 data_corruption(ut_params->op->sym->auth.aad.data);
7199 tag_corruption(ut_params->op->sym->auth.aad.data,
7200 reference->aad.len);
7202 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7204 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7205 TEST_ASSERT_EQUAL(ut_params->op->status,
7206 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7207 "authentication not failed");
7209 ut_params->obuf = ut_params->op->sym->m_src;
7210 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7216 test_authenticated_decryption_fail_when_corruption(
7217 struct crypto_testsuite_params *ts_params,
7218 struct crypto_unittest_params *ut_params,
7219 const struct test_crypto_vector *reference,
7220 unsigned int data_corrupted)
7224 uint8_t *ciphertext;
7226 /* Create session */
7227 retval = create_auth_cipher_session(ut_params,
7228 ts_params->valid_devs[0],
7230 RTE_CRYPTO_AUTH_OP_VERIFY,
7231 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7235 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7236 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7237 "Failed to allocate input buffer in mempool");
7239 /* clear mbuf payload */
7240 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7241 rte_pktmbuf_tailroom(ut_params->ibuf));
7243 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7244 reference->ciphertext.len);
7245 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7246 memcpy(ciphertext, reference->ciphertext.data,
7247 reference->ciphertext.len);
7249 /* Create operation */
7250 retval = create_cipher_auth_verify_operation(ts_params,
7258 data_corruption(ciphertext);
7260 tag_corruption(ciphertext, reference->ciphertext.len);
7262 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7265 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7266 TEST_ASSERT_EQUAL(ut_params->op->status,
7267 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7268 "authentication not failed");
7270 ut_params->obuf = ut_params->op->sym->m_src;
7271 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7277 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7278 const struct gcm_test_data *tdata,
7279 void *digest_mem, uint64_t digest_phys)
7281 struct crypto_testsuite_params *ts_params = &testsuite_params;
7282 struct crypto_unittest_params *ut_params = &unittest_params;
7284 const unsigned int auth_tag_len = tdata->auth_tag.len;
7285 const unsigned int iv_len = tdata->iv.len;
7286 const unsigned int aad_len = tdata->aad.len;
7288 unsigned int iv_pad_len = 0;
7290 /* Generate Crypto op data structure */
7291 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7292 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7293 TEST_ASSERT_NOT_NULL(ut_params->op,
7294 "Failed to allocate symmetric crypto operation struct");
7296 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7298 sym_op->auth.digest.data = digest_mem;
7300 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7301 "no room to append digest");
7303 sym_op->auth.digest.phys_addr = digest_phys;
7304 sym_op->auth.digest.length = auth_tag_len;
7306 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7307 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7309 TEST_HEXDUMP(stdout, "digest:",
7310 sym_op->auth.digest.data,
7311 sym_op->auth.digest.length);
7314 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
7316 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
7317 ut_params->ibuf, iv_pad_len);
7319 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
7320 "no room to prepend iv");
7322 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
7323 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
7324 sym_op->cipher.iv.length = iv_len;
7326 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
7328 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7329 ut_params->ibuf, aad_len);
7330 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7331 "no room to prepend aad");
7332 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7334 sym_op->auth.aad.length = aad_len;
7336 memset(sym_op->auth.aad.data, 0, aad_len);
7337 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7339 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
7340 TEST_HEXDUMP(stdout, "aad:",
7341 sym_op->auth.aad.data, aad_len);
7343 sym_op->cipher.data.length = tdata->plaintext.len;
7344 sym_op->cipher.data.offset = aad_len + iv_pad_len;
7346 sym_op->auth.data.offset = aad_len + iv_pad_len;
7347 sym_op->auth.data.length = tdata->plaintext.len;
7352 #define SGL_MAX_NO 16
7355 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7356 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7358 struct crypto_testsuite_params *ts_params = &testsuite_params;
7359 struct crypto_unittest_params *ut_params = &unittest_params;
7360 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7363 int to_trn_tbl[SGL_MAX_NO];
7365 unsigned int trn_data = 0;
7366 uint8_t *plaintext, *ciphertext, *auth_tag;
7368 if (fragsz > tdata->plaintext.len)
7369 fragsz = tdata->plaintext.len;
7371 uint16_t plaintext_len = fragsz;
7372 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7374 if (fragsz_oop > tdata->plaintext.len)
7375 frag_size_oop = tdata->plaintext.len;
7378 void *digest_mem = NULL;
7380 uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
7383 if (tdata->plaintext.len % fragsz != 0) {
7384 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7387 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7392 * For out-op-place we need to alloc another mbuf
7395 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7396 rte_pktmbuf_append(ut_params->obuf,
7397 frag_size_oop + prepend_len);
7398 buf_oop = ut_params->obuf;
7401 /* Create GCM session */
7402 retval = create_gcm_session(ts_params->valid_devs[0],
7403 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7404 tdata->key.data, tdata->key.len,
7405 tdata->aad.len, tdata->auth_tag.len,
7406 RTE_CRYPTO_AUTH_OP_GENERATE);
7410 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7412 /* clear mbuf payload */
7413 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7414 rte_pktmbuf_tailroom(ut_params->ibuf));
7416 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7419 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7421 trn_data += plaintext_len;
7423 buf = ut_params->ibuf;
7426 * Loop until no more fragments
7429 while (trn_data < tdata->plaintext.len) {
7431 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7432 (tdata->plaintext.len - trn_data) : fragsz;
7434 to_trn_tbl[ecx++] = to_trn;
7436 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7439 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7440 rte_pktmbuf_tailroom(buf));
7443 if (oop && !fragsz_oop) {
7444 buf_last_oop = buf_oop->next =
7445 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7446 buf_oop = buf_oop->next;
7447 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7448 0, rte_pktmbuf_tailroom(buf_oop));
7449 rte_pktmbuf_append(buf_oop, to_trn);
7452 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7455 memcpy(plaintext, tdata->plaintext.data + trn_data,
7458 if (trn_data == tdata->plaintext.len) {
7461 digest_mem = rte_pktmbuf_append(buf_oop,
7462 tdata->auth_tag.len);
7464 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7465 tdata->auth_tag.len);
7469 uint64_t digest_phys = 0;
7471 ut_params->ibuf->nb_segs = segs;
7474 if (fragsz_oop && oop) {
7478 if (frag_size_oop == tdata->plaintext.len) {
7479 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7480 tdata->auth_tag.len);
7482 digest_phys = rte_pktmbuf_mtophys_offset(
7484 tdata->plaintext.len + prepend_len);
7487 trn_data = frag_size_oop;
7488 while (trn_data < tdata->plaintext.len) {
7491 (tdata->plaintext.len - trn_data <
7493 (tdata->plaintext.len - trn_data) :
7496 to_trn_tbl[ecx++] = to_trn;
7498 buf_last_oop = buf_oop->next =
7499 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7500 buf_oop = buf_oop->next;
7501 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7502 0, rte_pktmbuf_tailroom(buf_oop));
7503 rte_pktmbuf_append(buf_oop, to_trn);
7507 if (trn_data == tdata->plaintext.len) {
7508 digest_mem = rte_pktmbuf_append(buf_oop,
7509 tdata->auth_tag.len);
7513 ut_params->obuf->nb_segs = segs;
7517 * Place digest at the end of the last buffer
7520 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7521 if (oop && buf_last_oop)
7522 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7524 if (!digest_mem && !oop) {
7525 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7526 + tdata->auth_tag.len);
7527 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7528 tdata->plaintext.len);
7531 /* Create GCM opertaion */
7532 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7533 tdata, digest_mem, digest_phys);
7538 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7540 ut_params->op->sym->m_src = ut_params->ibuf;
7542 ut_params->op->sym->m_dst = ut_params->obuf;
7544 /* Process crypto operation */
7545 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7546 ut_params->op), "failed to process sym crypto op");
7548 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7549 "crypto op processing failed");
7552 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7553 uint8_t *, prepend_len);
7555 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7556 uint8_t *, prepend_len);
7560 fragsz = fragsz_oop;
7562 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7564 tdata->ciphertext.data,
7566 "GCM Ciphertext data not as expected");
7568 buf = ut_params->op->sym->m_src->next;
7570 buf = ut_params->op->sym->m_dst->next;
7572 unsigned int off = fragsz;
7576 ciphertext = rte_pktmbuf_mtod(buf,
7579 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7581 tdata->ciphertext.data + off,
7583 "GCM Ciphertext data not as expected");
7585 off += to_trn_tbl[ecx++];
7589 auth_tag = digest_mem;
7590 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7592 tdata->auth_tag.data,
7593 tdata->auth_tag.len,
7594 "GCM Generated auth tag not as expected");
7600 #define OUT_OF_PLACE 1
7603 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7605 return test_AES_GCM_authenticated_encryption_SGL(
7606 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7610 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7612 return test_AES_GCM_authenticated_encryption_SGL(
7613 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7617 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7619 return test_AES_GCM_authenticated_encryption_SGL(
7620 &gcm_test_case_8, OUT_OF_PLACE, 400,
7621 gcm_test_case_8.plaintext.len);
7625 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7628 return test_AES_GCM_authenticated_encryption_SGL(
7629 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7633 test_authentication_verify_fail_when_data_corrupted(
7634 struct crypto_testsuite_params *ts_params,
7635 struct crypto_unittest_params *ut_params,
7636 const struct test_crypto_vector *reference)
7638 return test_authentication_verify_fail_when_data_corruption(
7639 ts_params, ut_params, reference, 1);
7643 test_authentication_verify_fail_when_tag_corrupted(
7644 struct crypto_testsuite_params *ts_params,
7645 struct crypto_unittest_params *ut_params,
7646 const struct test_crypto_vector *reference)
7648 return test_authentication_verify_fail_when_data_corruption(
7649 ts_params, ut_params, reference, 0);
7653 test_authentication_verify_GMAC_fail_when_data_corrupted(
7654 struct crypto_testsuite_params *ts_params,
7655 struct crypto_unittest_params *ut_params,
7656 const struct test_crypto_vector *reference)
7658 return test_authentication_verify_GMAC_fail_when_corruption(
7659 ts_params, ut_params, reference, 1);
7663 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7664 struct crypto_testsuite_params *ts_params,
7665 struct crypto_unittest_params *ut_params,
7666 const struct test_crypto_vector *reference)
7668 return test_authentication_verify_GMAC_fail_when_corruption(
7669 ts_params, ut_params, reference, 0);
7673 test_authenticated_decryption_fail_when_data_corrupted(
7674 struct crypto_testsuite_params *ts_params,
7675 struct crypto_unittest_params *ut_params,
7676 const struct test_crypto_vector *reference)
7678 return test_authenticated_decryption_fail_when_corruption(
7679 ts_params, ut_params, reference, 1);
7683 test_authenticated_decryption_fail_when_tag_corrupted(
7684 struct crypto_testsuite_params *ts_params,
7685 struct crypto_unittest_params *ut_params,
7686 const struct test_crypto_vector *reference)
7688 return test_authenticated_decryption_fail_when_corruption(
7689 ts_params, ut_params, reference, 0);
7693 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7695 return test_authentication_verify_fail_when_data_corrupted(
7696 &testsuite_params, &unittest_params,
7697 &hmac_sha1_test_crypto_vector);
7701 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7703 return test_authentication_verify_fail_when_tag_corrupted(
7704 &testsuite_params, &unittest_params,
7705 &hmac_sha1_test_crypto_vector);
7709 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7711 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7712 &testsuite_params, &unittest_params,
7713 &aes128_gmac_test_vector);
7717 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7719 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7720 &testsuite_params, &unittest_params,
7721 &aes128_gmac_test_vector);
7725 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7727 return test_authenticated_decryption_fail_when_data_corrupted(
7730 &aes128cbc_hmac_sha1_test_vector);
7734 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7736 return test_authenticated_decryption_fail_when_tag_corrupted(
7739 &aes128cbc_hmac_sha1_test_vector);
7742 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7744 /* global AESNI slave IDs for the scheduler test */
7745 uint8_t aesni_ids[2];
7748 test_scheduler_attach_slave_op(void)
7750 struct crypto_testsuite_params *ts_params = &testsuite_params;
7751 uint8_t sched_id = ts_params->valid_devs[0];
7752 uint32_t nb_devs, i, nb_devs_attached = 0;
7755 /* create 2 AESNI_MB if necessary */
7756 nb_devs = rte_cryptodev_count_devtype(
7757 RTE_CRYPTODEV_AESNI_MB_PMD);
7759 for (i = nb_devs; i < 2; i++) {
7760 ret = rte_eal_vdev_init(
7761 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
7763 TEST_ASSERT(ret == 0,
7764 "Failed to create instance %u of"
7766 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7770 /* attach 2 AESNI_MB cdevs */
7771 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7773 struct rte_cryptodev_info info;
7775 rte_cryptodev_info_get(i, &info);
7776 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7779 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7782 TEST_ASSERT(ret == 0,
7783 "Failed to attach device %u of pmd : %s", i,
7784 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7786 aesni_ids[nb_devs_attached] = (uint8_t)i;
7795 test_scheduler_detach_slave_op(void)
7797 struct crypto_testsuite_params *ts_params = &testsuite_params;
7798 uint8_t sched_id = ts_params->valid_devs[0];
7802 for (i = 0; i < 2; i++) {
7803 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7805 TEST_ASSERT(ret == 0,
7806 "Failed to detach device %u", aesni_ids[i]);
7813 test_scheduler_mode_op(void)
7815 struct crypto_testsuite_params *ts_params = &testsuite_params;
7816 uint8_t sched_id = ts_params->valid_devs[0];
7817 struct rte_cryptodev_scheduler_ops op = {0};
7818 struct rte_cryptodev_scheduler dummy_scheduler = {
7819 .description = "dummy scheduler to test mode",
7820 .name = "dummy scheduler",
7821 .mode = CDEV_SCHED_MODE_USERDEFINED,
7826 /* set user defined mode */
7827 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7829 TEST_ASSERT(ret == 0,
7830 "Failed to set cdev %u to user defined mode", sched_id);
7832 /* set round robin mode */
7833 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7834 CDEV_SCHED_MODE_ROUNDROBIN);
7835 TEST_ASSERT(ret == 0,
7836 "Failed to set cdev %u to round-robin mode", sched_id);
7837 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7838 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7844 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7845 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7846 .setup = testsuite_setup,
7847 .teardown = testsuite_teardown,
7848 .unit_test_cases = {
7849 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7850 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7851 TEST_CASE_ST(ut_setup, ut_teardown,
7852 test_AES_chain_scheduler_all),
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_AES_cipheronly_scheduler_all),
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_authonly_scheduler_all),
7857 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7858 TEST_CASES_END() /**< NULL terminate unit test array */
7862 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7864 static struct unit_test_suite cryptodev_qat_testsuite = {
7865 .suite_name = "Crypto QAT Unit Test Suite",
7866 .setup = testsuite_setup,
7867 .teardown = testsuite_teardown,
7868 .unit_test_cases = {
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_device_configure_invalid_dev_id),
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_device_configure_invalid_queue_pair_ids),
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 test_queue_pair_descriptor_setup),
7875 TEST_CASE_ST(ut_setup, ut_teardown,
7876 test_multi_session),
7878 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 test_AES_cipheronly_qat_all),
7881 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7882 TEST_CASE_ST(ut_setup, ut_teardown,
7883 test_3DES_cipheronly_qat_all),
7884 TEST_CASE_ST(ut_setup, ut_teardown,
7885 test_DES_cipheronly_qat_all),
7886 TEST_CASE_ST(ut_setup, ut_teardown,
7887 test_AES_docsis_qat_all),
7888 TEST_CASE_ST(ut_setup, ut_teardown,
7889 test_DES_docsis_qat_all),
7890 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7892 /** AES GCM Authenticated Encryption */
7893 TEST_CASE_ST(ut_setup, ut_teardown,
7894 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7895 TEST_CASE_ST(ut_setup, ut_teardown,
7896 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7897 TEST_CASE_ST(ut_setup, ut_teardown,
7898 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7899 TEST_CASE_ST(ut_setup, ut_teardown,
7900 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7901 TEST_CASE_ST(ut_setup, ut_teardown,
7902 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7903 TEST_CASE_ST(ut_setup, ut_teardown,
7904 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7905 TEST_CASE_ST(ut_setup, ut_teardown,
7906 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7907 TEST_CASE_ST(ut_setup, ut_teardown,
7908 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7909 TEST_CASE_ST(ut_setup, ut_teardown,
7910 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7911 TEST_CASE_ST(ut_setup, ut_teardown,
7912 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7914 /** AES GCM Authenticated Decryption */
7915 TEST_CASE_ST(ut_setup, ut_teardown,
7916 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7917 TEST_CASE_ST(ut_setup, ut_teardown,
7918 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7919 TEST_CASE_ST(ut_setup, ut_teardown,
7920 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7921 TEST_CASE_ST(ut_setup, ut_teardown,
7922 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7923 TEST_CASE_ST(ut_setup, ut_teardown,
7924 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7925 TEST_CASE_ST(ut_setup, ut_teardown,
7926 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7927 TEST_CASE_ST(ut_setup, ut_teardown,
7928 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7930 /** AES GMAC Authentication */
7931 TEST_CASE_ST(ut_setup, ut_teardown,
7932 test_AES_GMAC_authentication_test_case_1),
7933 TEST_CASE_ST(ut_setup, ut_teardown,
7934 test_AES_GMAC_authentication_verify_test_case_1),
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_AES_GMAC_authentication_test_case_2),
7937 TEST_CASE_ST(ut_setup, ut_teardown,
7938 test_AES_GMAC_authentication_verify_test_case_2),
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_AES_GMAC_authentication_test_case_3),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_AES_GMAC_authentication_verify_test_case_3),
7944 /** SNOW 3G encrypt only (UEA2) */
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_snow3g_encryption_test_case_1),
7947 TEST_CASE_ST(ut_setup, ut_teardown,
7948 test_snow3g_encryption_test_case_2),
7949 TEST_CASE_ST(ut_setup, ut_teardown,
7950 test_snow3g_encryption_test_case_3),
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_snow3g_encryption_test_case_4),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_snow3g_encryption_test_case_5),
7956 TEST_CASE_ST(ut_setup, ut_teardown,
7957 test_snow3g_encryption_test_case_1_oop),
7958 TEST_CASE_ST(ut_setup, ut_teardown,
7959 test_snow3g_decryption_test_case_1_oop),
7961 /** SNOW 3G decrypt only (UEA2) */
7962 TEST_CASE_ST(ut_setup, ut_teardown,
7963 test_snow3g_decryption_test_case_1),
7964 TEST_CASE_ST(ut_setup, ut_teardown,
7965 test_snow3g_decryption_test_case_2),
7966 TEST_CASE_ST(ut_setup, ut_teardown,
7967 test_snow3g_decryption_test_case_3),
7968 TEST_CASE_ST(ut_setup, ut_teardown,
7969 test_snow3g_decryption_test_case_4),
7970 TEST_CASE_ST(ut_setup, ut_teardown,
7971 test_snow3g_decryption_test_case_5),
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_snow3g_hash_generate_test_case_1),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_snow3g_hash_generate_test_case_2),
7976 TEST_CASE_ST(ut_setup, ut_teardown,
7977 test_snow3g_hash_generate_test_case_3),
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_snow3g_hash_verify_test_case_1),
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 test_snow3g_hash_verify_test_case_2),
7982 TEST_CASE_ST(ut_setup, ut_teardown,
7983 test_snow3g_hash_verify_test_case_3),
7984 TEST_CASE_ST(ut_setup, ut_teardown,
7985 test_snow3g_cipher_auth_test_case_1),
7986 TEST_CASE_ST(ut_setup, ut_teardown,
7987 test_snow3g_auth_cipher_test_case_1),
7989 /** ZUC encrypt only (EEA3) */
7990 TEST_CASE_ST(ut_setup, ut_teardown,
7991 test_zuc_encryption_test_case_1),
7992 TEST_CASE_ST(ut_setup, ut_teardown,
7993 test_zuc_encryption_test_case_2),
7994 TEST_CASE_ST(ut_setup, ut_teardown,
7995 test_zuc_encryption_test_case_3),
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_zuc_encryption_test_case_4),
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 test_zuc_encryption_test_case_5),
8001 /** ZUC authenticate (EIA3) */
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_zuc_hash_generate_test_case_6),
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_zuc_hash_generate_test_case_7),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_zuc_hash_generate_test_case_8),
8009 /** ZUC alg-chain (EEA3/EIA3) */
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 test_zuc_cipher_auth_test_case_1),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 test_zuc_cipher_auth_test_case_2),
8015 /** HMAC_MD5 Authentication */
8016 TEST_CASE_ST(ut_setup, ut_teardown,
8017 test_MD5_HMAC_generate_case_1),
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 test_MD5_HMAC_verify_case_1),
8020 TEST_CASE_ST(ut_setup, ut_teardown,
8021 test_MD5_HMAC_generate_case_2),
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 test_MD5_HMAC_verify_case_2),
8026 TEST_CASE_ST(ut_setup, ut_teardown,
8027 test_null_auth_only_operation),
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 test_null_cipher_only_operation),
8030 TEST_CASE_ST(ut_setup, ut_teardown,
8031 test_null_cipher_auth_operation),
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_null_auth_cipher_operation),
8035 TEST_CASE_ST(ut_setup, ut_teardown,
8036 test_kasumi_hash_generate_test_case_6),
8039 TEST_CASE_ST(ut_setup, ut_teardown,
8040 test_kasumi_encryption_test_case_1),
8041 TEST_CASE_ST(ut_setup, ut_teardown,
8042 test_kasumi_encryption_test_case_3),
8043 TEST_CASE_ST(ut_setup, ut_teardown,
8044 test_kasumi_auth_cipher_test_case_1),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_kasumi_cipher_auth_test_case_1),
8048 /** Negative tests */
8049 TEST_CASE_ST(ut_setup, ut_teardown,
8050 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8053 TEST_CASE_ST(ut_setup, ut_teardown,
8054 authentication_verify_AES128_GMAC_fail_data_corrupt),
8055 TEST_CASE_ST(ut_setup, ut_teardown,
8056 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8062 TEST_CASES_END() /**< NULL terminate unit test array */
8066 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8067 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8068 .setup = testsuite_setup,
8069 .teardown = testsuite_teardown,
8070 .unit_test_cases = {
8071 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8072 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8073 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8074 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8076 TEST_CASES_END() /**< NULL terminate unit test array */
8080 static struct unit_test_suite cryptodev_openssl_testsuite = {
8081 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8082 .setup = testsuite_setup,
8083 .teardown = testsuite_teardown,
8084 .unit_test_cases = {
8085 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8086 TEST_CASE_ST(ut_setup, ut_teardown,
8087 test_multi_session_random_usage),
8088 TEST_CASE_ST(ut_setup, ut_teardown,
8089 test_AES_chain_openssl_all),
8090 TEST_CASE_ST(ut_setup, ut_teardown,
8091 test_AES_cipheronly_openssl_all),
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_3DES_chain_openssl_all),
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_3DES_cipheronly_openssl_all),
8096 TEST_CASE_ST(ut_setup, ut_teardown,
8097 test_DES_docsis_openssl_all),
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_authonly_openssl_all),
8101 /** AES GCM Authenticated Encryption */
8102 TEST_CASE_ST(ut_setup, ut_teardown,
8103 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8104 TEST_CASE_ST(ut_setup, ut_teardown,
8105 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8117 /** AES GCM Authenticated Decryption */
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8133 /** AES GMAC Authentication */
8134 TEST_CASE_ST(ut_setup, ut_teardown,
8135 test_AES_GMAC_authentication_test_case_1),
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 test_AES_GMAC_authentication_verify_test_case_1),
8138 TEST_CASE_ST(ut_setup, ut_teardown,
8139 test_AES_GMAC_authentication_test_case_2),
8140 TEST_CASE_ST(ut_setup, ut_teardown,
8141 test_AES_GMAC_authentication_verify_test_case_2),
8142 TEST_CASE_ST(ut_setup, ut_teardown,
8143 test_AES_GMAC_authentication_test_case_3),
8144 TEST_CASE_ST(ut_setup, ut_teardown,
8145 test_AES_GMAC_authentication_verify_test_case_3),
8146 TEST_CASE_ST(ut_setup, ut_teardown,
8147 test_AES_GMAC_authentication_test_case_4),
8148 TEST_CASE_ST(ut_setup, ut_teardown,
8149 test_AES_GMAC_authentication_verify_test_case_4),
8151 /** Scatter-Gather */
8152 TEST_CASE_ST(ut_setup, ut_teardown,
8153 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8155 /** Negative tests */
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8158 TEST_CASE_ST(ut_setup, ut_teardown,
8159 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 authentication_verify_AES128_GMAC_fail_data_corrupt),
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8166 TEST_CASE_ST(ut_setup, ut_teardown,
8167 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8169 TEST_CASES_END() /**< NULL terminate unit test array */
8173 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8174 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8175 .setup = testsuite_setup,
8176 .teardown = testsuite_teardown,
8177 .unit_test_cases = {
8178 /** AES GCM Authenticated Encryption */
8179 TEST_CASE_ST(ut_setup, ut_teardown,
8180 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8181 TEST_CASE_ST(ut_setup, ut_teardown,
8182 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8183 TEST_CASE_ST(ut_setup, ut_teardown,
8184 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8185 TEST_CASE_ST(ut_setup, ut_teardown,
8186 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8187 TEST_CASE_ST(ut_setup, ut_teardown,
8188 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8189 TEST_CASE_ST(ut_setup, ut_teardown,
8190 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8191 TEST_CASE_ST(ut_setup, ut_teardown,
8192 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8194 /** AES GCM Authenticated Decryption */
8195 TEST_CASE_ST(ut_setup, ut_teardown,
8196 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8210 /** AES GCM Authenticated Encryption 256 bits key */
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8221 TEST_CASE_ST(ut_setup, ut_teardown,
8222 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8226 /** AES GCM Authenticated Decryption 256 bits key */
8227 TEST_CASE_ST(ut_setup, ut_teardown,
8228 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8233 TEST_CASE_ST(ut_setup, ut_teardown,
8234 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8235 TEST_CASE_ST(ut_setup, ut_teardown,
8236 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8237 TEST_CASE_ST(ut_setup, ut_teardown,
8238 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8239 TEST_CASE_ST(ut_setup, ut_teardown,
8240 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8242 /** AES GCM Authenticated Encryption big aad size */
8243 TEST_CASE_ST(ut_setup, ut_teardown,
8244 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8245 TEST_CASE_ST(ut_setup, ut_teardown,
8246 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8248 /** AES GCM Authenticated Decryption big aad size */
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8254 /** AES GMAC Authentication */
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_AES_GMAC_authentication_test_case_1),
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_AES_GMAC_authentication_verify_test_case_1),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_AES_GMAC_authentication_test_case_3),
8261 TEST_CASE_ST(ut_setup, ut_teardown,
8262 test_AES_GMAC_authentication_verify_test_case_3),
8263 TEST_CASE_ST(ut_setup, ut_teardown,
8264 test_AES_GMAC_authentication_test_case_4),
8265 TEST_CASE_ST(ut_setup, ut_teardown,
8266 test_AES_GMAC_authentication_verify_test_case_4),
8268 /** Negative tests */
8269 TEST_CASE_ST(ut_setup, ut_teardown,
8270 authentication_verify_AES128_GMAC_fail_data_corrupt),
8271 TEST_CASE_ST(ut_setup, ut_teardown,
8272 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8274 /** Out of place tests */
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_mb_AES_GCM_authenticated_encryption_oop),
8277 TEST_CASE_ST(ut_setup, ut_teardown,
8278 test_mb_AES_GCM_authenticated_decryption_oop),
8280 /** Session-less tests */
8281 TEST_CASE_ST(ut_setup, ut_teardown,
8282 test_mb_AES_GCM_authenticated_encryption_sessionless),
8283 TEST_CASE_ST(ut_setup, ut_teardown,
8284 test_mb_AES_GCM_authenticated_decryption_sessionless),
8286 /** Scatter-Gather */
8287 TEST_CASE_ST(ut_setup, ut_teardown,
8288 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8290 TEST_CASES_END() /**< NULL terminate unit test array */
8294 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8295 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8296 .setup = testsuite_setup,
8297 .teardown = testsuite_teardown,
8298 .unit_test_cases = {
8299 /** KASUMI encrypt only (UEA1) */
8300 TEST_CASE_ST(ut_setup, ut_teardown,
8301 test_kasumi_encryption_test_case_1),
8302 TEST_CASE_ST(ut_setup, ut_teardown,
8303 test_kasumi_encryption_test_case_1_sgl),
8304 TEST_CASE_ST(ut_setup, ut_teardown,
8305 test_kasumi_encryption_test_case_2),
8306 TEST_CASE_ST(ut_setup, ut_teardown,
8307 test_kasumi_encryption_test_case_3),
8308 TEST_CASE_ST(ut_setup, ut_teardown,
8309 test_kasumi_encryption_test_case_4),
8310 TEST_CASE_ST(ut_setup, ut_teardown,
8311 test_kasumi_encryption_test_case_5),
8312 /** KASUMI decrypt only (UEA1) */
8313 TEST_CASE_ST(ut_setup, ut_teardown,
8314 test_kasumi_decryption_test_case_1),
8315 TEST_CASE_ST(ut_setup, ut_teardown,
8316 test_kasumi_decryption_test_case_2),
8317 TEST_CASE_ST(ut_setup, ut_teardown,
8318 test_kasumi_decryption_test_case_3),
8319 TEST_CASE_ST(ut_setup, ut_teardown,
8320 test_kasumi_decryption_test_case_4),
8321 TEST_CASE_ST(ut_setup, ut_teardown,
8322 test_kasumi_decryption_test_case_5),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_kasumi_encryption_test_case_1_oop),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_kasumi_encryption_test_case_1_oop_sgl),
8330 TEST_CASE_ST(ut_setup, ut_teardown,
8331 test_kasumi_decryption_test_case_1_oop),
8333 /** KASUMI hash only (UIA1) */
8334 TEST_CASE_ST(ut_setup, ut_teardown,
8335 test_kasumi_hash_generate_test_case_1),
8336 TEST_CASE_ST(ut_setup, ut_teardown,
8337 test_kasumi_hash_generate_test_case_2),
8338 TEST_CASE_ST(ut_setup, ut_teardown,
8339 test_kasumi_hash_generate_test_case_3),
8340 TEST_CASE_ST(ut_setup, ut_teardown,
8341 test_kasumi_hash_generate_test_case_4),
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_kasumi_hash_generate_test_case_5),
8344 TEST_CASE_ST(ut_setup, ut_teardown,
8345 test_kasumi_hash_generate_test_case_6),
8346 TEST_CASE_ST(ut_setup, ut_teardown,
8347 test_kasumi_hash_verify_test_case_1),
8348 TEST_CASE_ST(ut_setup, ut_teardown,
8349 test_kasumi_hash_verify_test_case_2),
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_kasumi_hash_verify_test_case_3),
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_kasumi_hash_verify_test_case_4),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_kasumi_hash_verify_test_case_5),
8356 TEST_CASE_ST(ut_setup, ut_teardown,
8357 test_kasumi_auth_cipher_test_case_1),
8358 TEST_CASE_ST(ut_setup, ut_teardown,
8359 test_kasumi_cipher_auth_test_case_1),
8360 TEST_CASES_END() /**< NULL terminate unit test array */
8363 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8364 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8365 .setup = testsuite_setup,
8366 .teardown = testsuite_teardown,
8367 .unit_test_cases = {
8368 /** SNOW 3G encrypt only (UEA2) */
8369 TEST_CASE_ST(ut_setup, ut_teardown,
8370 test_snow3g_encryption_test_case_1),
8371 TEST_CASE_ST(ut_setup, ut_teardown,
8372 test_snow3g_encryption_test_case_2),
8373 TEST_CASE_ST(ut_setup, ut_teardown,
8374 test_snow3g_encryption_test_case_3),
8375 TEST_CASE_ST(ut_setup, ut_teardown,
8376 test_snow3g_encryption_test_case_4),
8377 TEST_CASE_ST(ut_setup, ut_teardown,
8378 test_snow3g_encryption_test_case_5),
8380 TEST_CASE_ST(ut_setup, ut_teardown,
8381 test_snow3g_encryption_test_case_1_oop),
8382 TEST_CASE_ST(ut_setup, ut_teardown,
8383 test_snow3g_encryption_test_case_1_oop_sgl),
8384 TEST_CASE_ST(ut_setup, ut_teardown,
8385 test_snow3g_decryption_test_case_1_oop),
8387 TEST_CASE_ST(ut_setup, ut_teardown,
8388 test_snow3g_encryption_test_case_1_offset_oop),
8390 /** SNOW 3G decrypt only (UEA2) */
8391 TEST_CASE_ST(ut_setup, ut_teardown,
8392 test_snow3g_decryption_test_case_1),
8393 TEST_CASE_ST(ut_setup, ut_teardown,
8394 test_snow3g_decryption_test_case_2),
8395 TEST_CASE_ST(ut_setup, ut_teardown,
8396 test_snow3g_decryption_test_case_3),
8397 TEST_CASE_ST(ut_setup, ut_teardown,
8398 test_snow3g_decryption_test_case_4),
8399 TEST_CASE_ST(ut_setup, ut_teardown,
8400 test_snow3g_decryption_test_case_5),
8401 TEST_CASE_ST(ut_setup, ut_teardown,
8402 test_snow3g_hash_generate_test_case_1),
8403 TEST_CASE_ST(ut_setup, ut_teardown,
8404 test_snow3g_hash_generate_test_case_2),
8405 TEST_CASE_ST(ut_setup, ut_teardown,
8406 test_snow3g_hash_generate_test_case_3),
8407 /* Tests with buffers which length is not byte-aligned */
8408 TEST_CASE_ST(ut_setup, ut_teardown,
8409 test_snow3g_hash_generate_test_case_4),
8410 TEST_CASE_ST(ut_setup, ut_teardown,
8411 test_snow3g_hash_generate_test_case_5),
8412 TEST_CASE_ST(ut_setup, ut_teardown,
8413 test_snow3g_hash_generate_test_case_6),
8414 TEST_CASE_ST(ut_setup, ut_teardown,
8415 test_snow3g_hash_verify_test_case_1),
8416 TEST_CASE_ST(ut_setup, ut_teardown,
8417 test_snow3g_hash_verify_test_case_2),
8418 TEST_CASE_ST(ut_setup, ut_teardown,
8419 test_snow3g_hash_verify_test_case_3),
8420 /* Tests with buffers which length is not byte-aligned */
8421 TEST_CASE_ST(ut_setup, ut_teardown,
8422 test_snow3g_hash_verify_test_case_4),
8423 TEST_CASE_ST(ut_setup, ut_teardown,
8424 test_snow3g_hash_verify_test_case_5),
8425 TEST_CASE_ST(ut_setup, ut_teardown,
8426 test_snow3g_hash_verify_test_case_6),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_snow3g_cipher_auth_test_case_1),
8429 TEST_CASE_ST(ut_setup, ut_teardown,
8430 test_snow3g_auth_cipher_test_case_1),
8432 TEST_CASES_END() /**< NULL terminate unit test array */
8436 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8437 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8438 .setup = testsuite_setup,
8439 .teardown = testsuite_teardown,
8440 .unit_test_cases = {
8441 /** ZUC encrypt only (EEA3) */
8442 TEST_CASE_ST(ut_setup, ut_teardown,
8443 test_zuc_encryption_test_case_1),
8444 TEST_CASE_ST(ut_setup, ut_teardown,
8445 test_zuc_encryption_test_case_2),
8446 TEST_CASE_ST(ut_setup, ut_teardown,
8447 test_zuc_encryption_test_case_3),
8448 TEST_CASE_ST(ut_setup, ut_teardown,
8449 test_zuc_encryption_test_case_4),
8450 TEST_CASE_ST(ut_setup, ut_teardown,
8451 test_zuc_encryption_test_case_5),
8452 TEST_CASE_ST(ut_setup, ut_teardown,
8453 test_zuc_hash_generate_test_case_1),
8454 TEST_CASE_ST(ut_setup, ut_teardown,
8455 test_zuc_hash_generate_test_case_2),
8456 TEST_CASE_ST(ut_setup, ut_teardown,
8457 test_zuc_hash_generate_test_case_3),
8458 TEST_CASE_ST(ut_setup, ut_teardown,
8459 test_zuc_hash_generate_test_case_4),
8460 TEST_CASE_ST(ut_setup, ut_teardown,
8461 test_zuc_hash_generate_test_case_5),
8462 TEST_CASE_ST(ut_setup, ut_teardown,
8463 test_zuc_encryption_test_case_6_sgl),
8464 TEST_CASES_END() /**< NULL terminate unit test array */
8468 static struct unit_test_suite cryptodev_null_testsuite = {
8469 .suite_name = "Crypto Device NULL Unit Test Suite",
8470 .setup = testsuite_setup,
8471 .teardown = testsuite_teardown,
8472 .unit_test_cases = {
8473 TEST_CASE_ST(ut_setup, ut_teardown,
8474 test_null_auth_only_operation),
8475 TEST_CASE_ST(ut_setup, ut_teardown,
8476 test_null_cipher_only_operation),
8477 TEST_CASE_ST(ut_setup, ut_teardown,
8478 test_null_cipher_auth_operation),
8479 TEST_CASE_ST(ut_setup, ut_teardown,
8480 test_null_auth_cipher_operation),
8481 TEST_CASE_ST(ut_setup, ut_teardown,
8482 test_null_invalid_operation),
8483 TEST_CASE_ST(ut_setup, ut_teardown,
8484 test_null_burst_operation),
8486 TEST_CASES_END() /**< NULL terminate unit test array */
8490 static struct unit_test_suite cryptodev_armv8_testsuite = {
8491 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8492 .setup = testsuite_setup,
8493 .teardown = testsuite_teardown,
8494 .unit_test_cases = {
8495 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8497 /** Negative tests */
8498 TEST_CASE_ST(ut_setup, ut_teardown,
8499 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8503 TEST_CASES_END() /**< NULL terminate unit test array */
8508 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8510 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8511 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8515 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8517 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8519 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8523 test_cryptodev_openssl(void)
8525 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8527 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8531 test_cryptodev_aesni_gcm(void)
8533 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8535 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8539 test_cryptodev_null(void)
8541 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8543 return unit_test_suite_runner(&cryptodev_null_testsuite);
8547 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8549 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8551 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8555 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8557 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8559 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8563 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8565 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8567 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8571 test_cryptodev_armv8(void)
8573 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8575 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8578 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8581 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8583 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8584 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8587 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8591 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8592 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8593 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8594 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8595 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8596 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8597 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8598 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8599 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);