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 2 AESNI MB devices 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 for (i = nb_devs; i < 2; i++) {
223 ret = rte_eal_vdev_init(
224 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
226 TEST_ASSERT(ret == 0,
227 "Failed to create instance %u of"
229 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
234 /* Create 2 AESNI GCM devices if required */
235 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
236 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
237 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
238 " enabled in config file to run this testsuite.\n");
241 nb_devs = rte_cryptodev_count_devtype(
242 RTE_CRYPTODEV_AESNI_GCM_PMD);
244 for (i = nb_devs; i < 2; i++) {
245 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
246 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
247 "Failed to create instance %u of"
249 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
254 /* Create 2 SNOW 3G devices if required */
255 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
256 #ifndef RTE_LIBRTE_PMD_SNOW3G
257 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
258 " enabled in config file to run this testsuite.\n");
261 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
263 for (i = nb_devs; i < 2; i++) {
264 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
265 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
266 "Failed to create instance %u of"
268 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
273 /* Create 2 KASUMI devices if required */
274 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
275 #ifndef RTE_LIBRTE_PMD_KASUMI
276 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
277 " enabled in config file to run this testsuite.\n");
280 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
282 for (i = nb_devs; i < 2; i++) {
283 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
284 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
285 "Failed to create instance %u of"
287 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
292 /* Create 2 ZUC devices if required */
293 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
294 #ifndef RTE_LIBRTE_PMD_ZUC
295 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
296 " enabled in config file to run this testsuite.\n");
299 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
301 for (i = nb_devs; i < 2; i++) {
302 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
303 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
304 "Failed to create instance %u of"
306 i, RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
311 /* Create 2 NULL devices if required */
312 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
313 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
314 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
315 " enabled in config file to run this testsuite.\n");
318 nb_devs = rte_cryptodev_count_devtype(
319 RTE_CRYPTODEV_NULL_PMD);
321 for (i = nb_devs; i < 2; i++) {
322 int dev_id = rte_eal_vdev_init(
323 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
325 TEST_ASSERT(dev_id >= 0,
326 "Failed to create instance %u of"
328 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
333 /* Create 2 OPENSSL devices if required */
334 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
335 #ifndef RTE_LIBRTE_PMD_OPENSSL
336 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
337 " enabled in config file to run this testsuite.\n");
340 nb_devs = rte_cryptodev_count_devtype(
341 RTE_CRYPTODEV_OPENSSL_PMD);
343 for (i = nb_devs; i < 2; i++) {
344 ret = rte_eal_vdev_init(
345 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
348 TEST_ASSERT(ret == 0, "Failed to create "
349 "instance %u of pmd : %s", i,
350 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
355 /* Create 2 ARMv8 devices if required */
356 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
357 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
358 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
359 " enabled in config file to run this testsuite.\n");
362 nb_devs = rte_cryptodev_count_devtype(
363 RTE_CRYPTODEV_ARMV8_PMD);
365 for (i = nb_devs; i < 2; i++) {
366 ret = rte_eal_vdev_init(
367 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
370 TEST_ASSERT(ret == 0, "Failed to create "
371 "instance %u of pmd : %s", i,
372 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
377 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
378 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
380 #ifndef RTE_LIBRTE_PMD_AESNI_MB
381 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
382 " enabled in config file to run this testsuite.\n");
385 nb_devs = rte_cryptodev_count_devtype(
386 RTE_CRYPTODEV_SCHEDULER_PMD);
388 ret = rte_eal_vdev_init(
389 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
392 TEST_ASSERT(ret == 0,
393 "Failed to create instance %u of"
395 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
398 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
400 #ifndef RTE_LIBRTE_PMD_QAT
401 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
402 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
403 "in config file to run this testsuite.\n");
408 nb_devs = rte_cryptodev_count();
410 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
414 /* Create list of valid crypto devs */
415 for (i = 0; i < nb_devs; i++) {
416 rte_cryptodev_info_get(i, &info);
417 if (info.dev_type == gbl_cryptodev_type)
418 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
421 if (ts_params->valid_dev_count < 1)
424 /* Set up all the qps on the first of the valid devices found */
426 dev_id = ts_params->valid_devs[0];
428 rte_cryptodev_info_get(dev_id, &info);
430 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
431 ts_params->conf.socket_id = SOCKET_ID_ANY;
432 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
434 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
436 "Failed to configure cryptodev %u with %u qps",
437 dev_id, ts_params->conf.nb_queue_pairs);
439 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
441 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
442 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
443 dev_id, qp_id, &ts_params->qp_conf,
444 rte_cryptodev_socket_id(dev_id)),
445 "Failed to setup queue pair %u on cryptodev %u",
453 testsuite_teardown(void)
455 struct crypto_testsuite_params *ts_params = &testsuite_params;
457 if (ts_params->mbuf_pool != NULL) {
458 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
459 rte_mempool_avail_count(ts_params->mbuf_pool));
462 if (ts_params->op_mpool != NULL) {
463 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
464 rte_mempool_avail_count(ts_params->op_mpool));
472 struct crypto_testsuite_params *ts_params = &testsuite_params;
473 struct crypto_unittest_params *ut_params = &unittest_params;
477 /* Clear unit test parameters before running test */
478 memset(ut_params, 0, sizeof(*ut_params));
480 /* Reconfigure device to default parameters */
481 ts_params->conf.socket_id = SOCKET_ID_ANY;
482 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
484 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
486 "Failed to configure cryptodev %u",
487 ts_params->valid_devs[0]);
489 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
490 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
491 ts_params->valid_devs[0], qp_id,
493 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
494 "Failed to setup queue pair %u on cryptodev %u",
495 qp_id, ts_params->valid_devs[0]);
499 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
501 /* Start the device */
502 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
503 "Failed to start cryptodev %u",
504 ts_params->valid_devs[0]);
512 struct crypto_testsuite_params *ts_params = &testsuite_params;
513 struct crypto_unittest_params *ut_params = &unittest_params;
514 struct rte_cryptodev_stats stats;
516 /* free crypto session structure */
517 if (ut_params->sess) {
518 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
520 ut_params->sess = NULL;
523 /* free crypto operation structure */
525 rte_crypto_op_free(ut_params->op);
528 * free mbuf - both obuf and ibuf are usually the same,
529 * so check if they point at the same address is necessary,
530 * to avoid freeing the mbuf twice.
532 if (ut_params->obuf) {
533 rte_pktmbuf_free(ut_params->obuf);
534 if (ut_params->ibuf == ut_params->obuf)
538 if (ut_params->ibuf) {
539 rte_pktmbuf_free(ut_params->ibuf);
543 if (ts_params->mbuf_pool != NULL)
544 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
545 rte_mempool_avail_count(ts_params->mbuf_pool));
547 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
549 /* Stop the device */
550 rte_cryptodev_stop(ts_params->valid_devs[0]);
554 test_device_configure_invalid_dev_id(void)
556 struct crypto_testsuite_params *ts_params = &testsuite_params;
557 uint16_t dev_id, num_devs = 0;
559 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
560 "Need at least %d devices for test", 1);
562 /* valid dev_id values */
563 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
565 /* Stop the device in case it's started so it can be configured */
566 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
568 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
569 "Failed test for rte_cryptodev_configure: "
570 "invalid dev_num %u", dev_id);
572 /* invalid dev_id values */
575 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
576 "Failed test for rte_cryptodev_configure: "
577 "invalid dev_num %u", dev_id);
581 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
582 "Failed test for rte_cryptodev_configure:"
583 "invalid dev_num %u", dev_id);
589 test_device_configure_invalid_queue_pair_ids(void)
591 struct crypto_testsuite_params *ts_params = &testsuite_params;
592 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
594 /* Stop the device in case it's started so it can be configured */
595 rte_cryptodev_stop(ts_params->valid_devs[0]);
597 /* valid - one queue pairs */
598 ts_params->conf.nb_queue_pairs = 1;
600 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
602 "Failed to configure cryptodev: dev_id %u, qp_id %u",
603 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
606 /* valid - max value queue pairs */
607 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
609 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
611 "Failed to configure cryptodev: dev_id %u, qp_id %u",
612 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
615 /* invalid - zero queue pairs */
616 ts_params->conf.nb_queue_pairs = 0;
618 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
620 "Failed test for rte_cryptodev_configure, dev_id %u,"
622 ts_params->valid_devs[0],
623 ts_params->conf.nb_queue_pairs);
626 /* invalid - max value supported by field queue pairs */
627 ts_params->conf.nb_queue_pairs = UINT16_MAX;
629 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
631 "Failed test for rte_cryptodev_configure, dev_id %u,"
633 ts_params->valid_devs[0],
634 ts_params->conf.nb_queue_pairs);
637 /* invalid - max value + 1 queue pairs */
638 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
640 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
642 "Failed test for rte_cryptodev_configure, dev_id %u,"
644 ts_params->valid_devs[0],
645 ts_params->conf.nb_queue_pairs);
647 /* revert to original testsuite value */
648 ts_params->conf.nb_queue_pairs = orig_nb_qps;
654 test_queue_pair_descriptor_setup(void)
656 struct crypto_testsuite_params *ts_params = &testsuite_params;
657 struct rte_cryptodev_info dev_info;
658 struct rte_cryptodev_qp_conf qp_conf = {
659 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
664 /* Stop the device in case it's started so it can be configured */
665 rte_cryptodev_stop(ts_params->valid_devs[0]);
668 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
670 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
672 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
673 &ts_params->conf), "Failed to configure cryptodev %u",
674 ts_params->valid_devs[0]);
678 * Test various ring sizes on this device. memzones can't be
679 * freed so are re-used if ring is released and re-created.
681 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
683 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
684 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
685 ts_params->valid_devs[0], qp_id, &qp_conf,
686 rte_cryptodev_socket_id(
687 ts_params->valid_devs[0])),
689 "rte_cryptodev_queue_pair_setup: num_inflights "
690 "%u on qp %u on cryptodev %u",
691 qp_conf.nb_descriptors, qp_id,
692 ts_params->valid_devs[0]);
695 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
697 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
698 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
699 ts_params->valid_devs[0], qp_id, &qp_conf,
700 rte_cryptodev_socket_id(
701 ts_params->valid_devs[0])),
703 " rte_cryptodev_queue_pair_setup: num_inflights"
704 " %u on qp %u on cryptodev %u",
705 qp_conf.nb_descriptors, qp_id,
706 ts_params->valid_devs[0]);
709 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
711 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
712 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
713 ts_params->valid_devs[0], qp_id, &qp_conf,
714 rte_cryptodev_socket_id(
715 ts_params->valid_devs[0])),
717 "rte_cryptodev_queue_pair_setup: num_inflights"
718 " %u on qp %u on cryptodev %u",
719 qp_conf.nb_descriptors, qp_id,
720 ts_params->valid_devs[0]);
723 /* invalid number of descriptors - max supported + 2 */
724 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
726 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
727 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
728 ts_params->valid_devs[0], qp_id, &qp_conf,
729 rte_cryptodev_socket_id(
730 ts_params->valid_devs[0])),
731 "Unexpectedly passed test for "
732 "rte_cryptodev_queue_pair_setup:"
733 "num_inflights %u on qp %u on cryptodev %u",
734 qp_conf.nb_descriptors, qp_id,
735 ts_params->valid_devs[0]);
738 /* invalid number of descriptors - max value of parameter */
739 qp_conf.nb_descriptors = UINT32_MAX-1;
741 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
742 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
743 ts_params->valid_devs[0], qp_id, &qp_conf,
744 rte_cryptodev_socket_id(
745 ts_params->valid_devs[0])),
746 "Unexpectedly passed test for "
747 "rte_cryptodev_queue_pair_setup:"
748 "num_inflights %u on qp %u on cryptodev %u",
749 qp_conf.nb_descriptors, qp_id,
750 ts_params->valid_devs[0]);
753 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
755 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
756 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
757 ts_params->valid_devs[0], qp_id, &qp_conf,
758 rte_cryptodev_socket_id(
759 ts_params->valid_devs[0])),
761 " rte_cryptodev_queue_pair_setup:"
762 "num_inflights %u on qp %u on cryptodev %u",
763 qp_conf.nb_descriptors, qp_id,
764 ts_params->valid_devs[0]);
767 /* invalid number of descriptors - max supported + 1 */
768 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
770 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
771 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
772 ts_params->valid_devs[0], qp_id, &qp_conf,
773 rte_cryptodev_socket_id(
774 ts_params->valid_devs[0])),
775 "Unexpectedly passed test for "
776 "rte_cryptodev_queue_pair_setup:"
777 "num_inflights %u on qp %u on cryptodev %u",
778 qp_conf.nb_descriptors, qp_id,
779 ts_params->valid_devs[0]);
782 /* test invalid queue pair id */
783 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
785 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
787 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
788 ts_params->valid_devs[0],
790 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
791 "Failed test for rte_cryptodev_queue_pair_setup:"
792 "invalid qp %u on cryptodev %u",
793 qp_id, ts_params->valid_devs[0]);
795 qp_id = 0xffff; /*invalid*/
797 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
798 ts_params->valid_devs[0],
800 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
801 "Failed test for rte_cryptodev_queue_pair_setup:"
802 "invalid qp %u on cryptodev %u",
803 qp_id, ts_params->valid_devs[0]);
808 /* ***** Plaintext data for tests ***** */
810 const char catch_22_quote_1[] =
811 "There was only one catch and that was Catch-22, which "
812 "specified that a concern for one's safety in the face of "
813 "dangers that were real and immediate was the process of a "
814 "rational mind. Orr was crazy and could be grounded. All he "
815 "had to do was ask; and as soon as he did, he would no longer "
816 "be crazy and would have to fly more missions. Orr would be "
817 "crazy to fly more missions and sane if he didn't, but if he "
818 "was sane he had to fly them. If he flew them he was crazy "
819 "and didn't have to; but if he didn't want to he was sane and "
820 "had to. Yossarian was moved very deeply by the absolute "
821 "simplicity of this clause of Catch-22 and let out a "
822 "respectful whistle. \"That's some catch, that Catch-22\", he "
823 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
825 const char catch_22_quote[] =
826 "What a lousy earth! He wondered how many people were "
827 "destitute that same night even in his own prosperous country, "
828 "how many homes were shanties, how many husbands were drunk "
829 "and wives socked, and how many children were bullied, abused, "
830 "or abandoned. How many families hungered for food they could "
831 "not afford to buy? How many hearts were broken? How many "
832 "suicides would take place that same night, how many people "
833 "would go insane? How many cockroaches and landlords would "
834 "triumph? How many winners were losers, successes failures, "
835 "and rich men poor men? How many wise guys were stupid? How "
836 "many happy endings were unhappy endings? How many honest men "
837 "were liars, brave men cowards, loyal men traitors, how many "
838 "sainted men were corrupt, how many people in positions of "
839 "trust had sold their souls to bodyguards, how many had never "
840 "had souls? How many straight-and-narrow paths were crooked "
841 "paths? How many best families were worst families and how "
842 "many good people were bad people? When you added them all up "
843 "and then subtracted, you might be left with only the children, "
844 "and perhaps with Albert Einstein and an old violinist or "
845 "sculptor somewhere.";
847 #define QUOTE_480_BYTES (480)
848 #define QUOTE_512_BYTES (512)
849 #define QUOTE_768_BYTES (768)
850 #define QUOTE_1024_BYTES (1024)
854 /* ***** SHA1 Hash Tests ***** */
856 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
858 static uint8_t hmac_sha1_key[] = {
859 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
860 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
861 0xDE, 0xF4, 0xDE, 0xAD };
863 /* ***** SHA224 Hash Tests ***** */
865 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
868 /* ***** AES-CBC Cipher Tests ***** */
870 #define CIPHER_KEY_LENGTH_AES_CBC (16)
871 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
873 static uint8_t aes_cbc_key[] = {
874 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
875 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
877 static uint8_t aes_cbc_iv[] = {
878 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
879 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
882 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
884 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
885 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
886 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
887 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
888 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
889 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
890 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
891 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
892 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
893 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
894 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
895 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
896 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
897 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
898 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
899 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
900 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
901 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
902 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
903 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
904 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
905 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
906 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
907 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
908 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
909 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
910 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
911 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
912 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
913 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
914 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
915 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
916 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
917 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
918 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
919 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
920 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
921 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
922 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
923 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
924 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
925 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
926 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
927 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
928 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
929 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
930 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
931 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
932 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
933 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
934 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
935 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
936 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
937 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
938 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
939 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
940 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
941 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
942 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
943 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
944 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
945 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
946 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
947 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
948 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
951 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
952 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
953 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
954 0x18, 0x8c, 0x1d, 0x32
958 /* Multisession Vector context Test */
960 static uint8_t ms_aes_cbc_key0[] = {
961 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
962 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
965 static uint8_t ms_aes_cbc_iv0[] = {
966 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
967 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
970 static const uint8_t ms_aes_cbc_cipher0[] = {
971 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
972 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
973 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
974 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
975 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
976 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
977 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
978 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
979 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
980 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
981 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
982 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
983 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
984 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
985 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
986 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
987 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
988 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
989 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
990 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
991 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
992 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
993 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
994 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
995 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
996 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
997 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
998 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
999 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1000 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1001 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1002 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1003 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1004 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1005 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1006 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1007 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1008 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1009 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1010 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1011 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1012 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1013 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1014 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1015 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1016 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1017 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1018 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1019 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1020 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1021 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1022 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1023 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1024 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1025 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1026 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1027 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1028 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1029 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1030 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1031 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1032 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1033 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1034 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1038 static uint8_t ms_hmac_key0[] = {
1039 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1040 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1041 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1042 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1043 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1044 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1045 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1046 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1049 static const uint8_t ms_hmac_digest0[] = {
1050 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1051 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1052 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1053 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1054 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1055 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1056 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1057 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1061 /* Begin session 1 */
1063 static uint8_t ms_aes_cbc_key1[] = {
1064 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1065 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1068 static uint8_t ms_aes_cbc_iv1[] = {
1069 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1070 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1073 static const uint8_t ms_aes_cbc_cipher1[] = {
1074 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1075 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1076 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1077 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1078 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1079 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1080 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1081 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1082 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1083 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1084 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1085 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1086 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1087 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1088 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1089 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1090 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1091 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1092 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1093 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1094 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1095 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1096 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1097 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1098 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1099 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1100 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1101 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1102 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1103 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1104 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1105 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1106 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1107 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1108 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1109 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1110 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1111 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1112 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1113 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1114 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1115 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1116 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1117 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1118 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1119 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1120 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1121 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1122 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1123 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1124 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1125 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1126 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1127 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1128 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1129 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1130 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1131 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1132 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1133 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1134 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1135 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1136 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1137 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1141 static uint8_t ms_hmac_key1[] = {
1142 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1143 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1144 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1145 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1146 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1147 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1148 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1149 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1152 static const uint8_t ms_hmac_digest1[] = {
1153 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1154 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1155 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1156 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1157 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1158 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1159 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1160 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1163 /* Begin Session 2 */
1164 static uint8_t ms_aes_cbc_key2[] = {
1165 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1166 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1169 static uint8_t ms_aes_cbc_iv2[] = {
1170 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1171 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1174 static const uint8_t ms_aes_cbc_cipher2[] = {
1175 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1176 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1177 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1178 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1179 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1180 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1181 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1182 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1183 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1184 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1185 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1186 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1187 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1188 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1189 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1190 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1191 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1192 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1193 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1194 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1195 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1196 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1197 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1198 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1199 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1200 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1201 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1202 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1203 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1204 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1205 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1206 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1207 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1208 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1209 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1210 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1211 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1212 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1213 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1214 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1215 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1216 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1217 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1218 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1219 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1220 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1221 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1222 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1223 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1224 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1225 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1226 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1227 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1228 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1229 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1230 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1231 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1232 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1233 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1234 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1235 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1236 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1237 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1238 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1241 static uint8_t ms_hmac_key2[] = {
1242 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1243 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1244 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1245 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1246 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1247 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1248 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1249 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1252 static const uint8_t ms_hmac_digest2[] = {
1253 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1254 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1255 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1256 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1257 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1258 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1259 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1260 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1267 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1269 struct crypto_testsuite_params *ts_params = &testsuite_params;
1270 struct crypto_unittest_params *ut_params = &unittest_params;
1272 /* Generate test mbuf data and space for digest */
1273 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1274 catch_22_quote, QUOTE_512_BYTES, 0);
1276 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1277 DIGEST_BYTE_LENGTH_SHA1);
1278 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1280 /* Setup Cipher Parameters */
1281 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1282 ut_params->cipher_xform.next = &ut_params->auth_xform;
1284 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1285 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1286 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1287 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1289 /* Setup HMAC Parameters */
1290 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1292 ut_params->auth_xform.next = NULL;
1294 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1295 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1296 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1297 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1298 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1300 /* Create crypto session*/
1301 ut_params->sess = rte_cryptodev_sym_session_create(
1302 ts_params->valid_devs[0],
1303 &ut_params->cipher_xform);
1304 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1306 /* Generate crypto op data structure */
1307 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1308 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1309 TEST_ASSERT_NOT_NULL(ut_params->op,
1310 "Failed to allocate symmetric crypto operation struct");
1312 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1314 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1316 /* set crypto operation source mbuf */
1317 sym_op->m_src = ut_params->ibuf;
1319 /* Set crypto operation authentication parameters */
1320 sym_op->auth.digest.data = ut_params->digest;
1321 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1322 ut_params->ibuf, QUOTE_512_BYTES);
1323 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1325 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1326 sym_op->auth.data.length = QUOTE_512_BYTES;
1328 /* Set crypto operation cipher parameters */
1329 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1330 CIPHER_IV_LENGTH_AES_CBC);
1331 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1332 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1334 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1335 CIPHER_IV_LENGTH_AES_CBC);
1337 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1338 sym_op->cipher.data.length = QUOTE_512_BYTES;
1340 /* Process crypto operation */
1341 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1342 ut_params->op), "failed to process sym crypto op");
1344 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1345 "crypto op processing failed");
1348 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1349 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1351 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1352 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1354 "ciphertext data not as expected");
1356 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1358 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1359 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1360 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1361 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1362 DIGEST_BYTE_LENGTH_SHA1,
1363 "Generated digest data not as expected");
1365 return TEST_SUCCESS;
1368 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1370 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1372 static uint8_t hmac_sha512_key[] = {
1373 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1374 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1375 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1376 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1377 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1378 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1379 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1380 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1382 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1383 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1384 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1385 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1386 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1387 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1388 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1389 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1390 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1395 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1396 struct crypto_unittest_params *ut_params,
1397 uint8_t *cipher_key,
1401 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1402 struct crypto_unittest_params *ut_params,
1403 struct crypto_testsuite_params *ts_params,
1404 const uint8_t *cipher,
1405 const uint8_t *digest,
1410 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1411 struct crypto_unittest_params *ut_params,
1412 uint8_t *cipher_key,
1416 /* Setup Cipher Parameters */
1417 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1418 ut_params->cipher_xform.next = NULL;
1420 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1421 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1422 ut_params->cipher_xform.cipher.key.data = cipher_key;
1423 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1425 /* Setup HMAC Parameters */
1426 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1427 ut_params->auth_xform.next = &ut_params->cipher_xform;
1429 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1430 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1431 ut_params->auth_xform.auth.key.data = hmac_key;
1432 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1433 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1435 return TEST_SUCCESS;
1440 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1441 struct crypto_unittest_params *ut_params,
1442 struct crypto_testsuite_params *ts_params,
1443 const uint8_t *cipher,
1444 const uint8_t *digest,
1447 /* Generate test mbuf data and digest */
1448 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1451 QUOTE_512_BYTES, 0);
1453 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1454 DIGEST_BYTE_LENGTH_SHA512);
1455 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1457 rte_memcpy(ut_params->digest,
1459 DIGEST_BYTE_LENGTH_SHA512);
1461 /* Generate Crypto op data structure */
1462 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1463 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1464 TEST_ASSERT_NOT_NULL(ut_params->op,
1465 "Failed to allocate symmetric crypto operation struct");
1467 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1469 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1471 /* set crypto operation source mbuf */
1472 sym_op->m_src = ut_params->ibuf;
1474 sym_op->auth.digest.data = ut_params->digest;
1475 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1476 ut_params->ibuf, QUOTE_512_BYTES);
1477 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1479 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1480 sym_op->auth.data.length = QUOTE_512_BYTES;
1482 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1483 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1484 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1485 ut_params->ibuf, 0);
1486 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1488 rte_memcpy(sym_op->cipher.iv.data, iv,
1489 CIPHER_IV_LENGTH_AES_CBC);
1491 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1492 sym_op->cipher.data.length = QUOTE_512_BYTES;
1494 /* Process crypto operation */
1495 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1496 ut_params->op), "failed to process sym crypto op");
1498 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1499 "crypto op processing failed");
1501 ut_params->obuf = ut_params->op->sym->m_src;
1504 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1505 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1506 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1508 "Plaintext data not as expected");
1511 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1512 "Digest verification failed");
1514 return TEST_SUCCESS;
1518 test_AES_cipheronly_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_CIPHERONLY_TYPE);
1528 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1530 return TEST_SUCCESS;
1534 test_AES_docsis_mb_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_AESNI_MB_PMD,
1542 BLKCIPHER_AES_DOCSIS_TYPE);
1544 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1546 return TEST_SUCCESS;
1550 test_AES_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_AES_DOCSIS_TYPE);
1560 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1562 return TEST_SUCCESS;
1566 test_DES_docsis_qat_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_QAT_SYM_PMD,
1574 BLKCIPHER_DES_DOCSIS_TYPE);
1576 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1578 return TEST_SUCCESS;
1582 test_authonly_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_AUTHONLY_TYPE);
1592 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1594 return TEST_SUCCESS;
1598 test_AES_chain_mb_all(void)
1600 struct crypto_testsuite_params *ts_params = &testsuite_params;
1603 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1604 ts_params->op_mpool, ts_params->valid_devs[0],
1605 RTE_CRYPTODEV_AESNI_MB_PMD,
1606 BLKCIPHER_AES_CHAIN_TYPE);
1608 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1610 return TEST_SUCCESS;
1613 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1616 test_AES_cipheronly_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_CIPHERONLY_TYPE);
1626 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1628 return TEST_SUCCESS;
1632 test_AES_chain_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_AES_CHAIN_TYPE);
1642 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1644 return TEST_SUCCESS;
1648 test_authonly_scheduler_all(void)
1650 struct crypto_testsuite_params *ts_params = &testsuite_params;
1653 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1654 ts_params->op_mpool, ts_params->valid_devs[0],
1655 RTE_CRYPTODEV_SCHEDULER_PMD,
1656 BLKCIPHER_AUTHONLY_TYPE);
1658 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1660 return TEST_SUCCESS;
1663 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1666 test_AES_chain_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_CHAIN_TYPE);
1676 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1678 return TEST_SUCCESS;
1682 test_AES_cipheronly_openssl_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_OPENSSL_PMD,
1690 BLKCIPHER_AES_CIPHERONLY_TYPE);
1692 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1694 return TEST_SUCCESS;
1698 test_AES_chain_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_CHAIN_TYPE);
1708 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1710 return TEST_SUCCESS;
1714 test_AES_cipheronly_qat_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_QAT_SYM_PMD,
1722 BLKCIPHER_AES_CIPHERONLY_TYPE);
1724 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1726 return TEST_SUCCESS;
1730 test_authonly_openssl_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_OPENSSL_PMD,
1738 BLKCIPHER_AUTHONLY_TYPE);
1740 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1742 return TEST_SUCCESS;
1746 test_AES_chain_armv8_all(void)
1748 struct crypto_testsuite_params *ts_params = &testsuite_params;
1751 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1752 ts_params->op_mpool, ts_params->valid_devs[0],
1753 RTE_CRYPTODEV_ARMV8_PMD,
1754 BLKCIPHER_AES_CHAIN_TYPE);
1756 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1758 return TEST_SUCCESS;
1761 /* ***** SNOW 3G Tests ***** */
1763 create_wireless_algo_hash_session(uint8_t dev_id,
1764 const uint8_t *key, const uint8_t key_len,
1765 const uint8_t aad_len, const uint8_t auth_len,
1766 enum rte_crypto_auth_operation op,
1767 enum rte_crypto_auth_algorithm algo)
1769 uint8_t hash_key[key_len];
1771 struct crypto_unittest_params *ut_params = &unittest_params;
1773 memcpy(hash_key, key, key_len);
1775 TEST_HEXDUMP(stdout, "key:", key, key_len);
1777 /* Setup Authentication Parameters */
1778 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1779 ut_params->auth_xform.next = NULL;
1781 ut_params->auth_xform.auth.op = op;
1782 ut_params->auth_xform.auth.algo = algo;
1783 ut_params->auth_xform.auth.key.length = key_len;
1784 ut_params->auth_xform.auth.key.data = hash_key;
1785 ut_params->auth_xform.auth.digest_length = auth_len;
1786 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1787 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1788 &ut_params->auth_xform);
1789 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1794 create_wireless_algo_cipher_session(uint8_t dev_id,
1795 enum rte_crypto_cipher_operation op,
1796 enum rte_crypto_cipher_algorithm algo,
1797 const uint8_t *key, const uint8_t key_len)
1799 uint8_t cipher_key[key_len];
1801 struct crypto_unittest_params *ut_params = &unittest_params;
1803 memcpy(cipher_key, key, key_len);
1805 /* Setup Cipher Parameters */
1806 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1807 ut_params->cipher_xform.next = NULL;
1809 ut_params->cipher_xform.cipher.algo = algo;
1810 ut_params->cipher_xform.cipher.op = op;
1811 ut_params->cipher_xform.cipher.key.data = cipher_key;
1812 ut_params->cipher_xform.cipher.key.length = key_len;
1814 TEST_HEXDUMP(stdout, "key:", key, key_len);
1816 /* Create Crypto session */
1817 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1820 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1825 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1826 const unsigned cipher_len,
1827 const unsigned cipher_offset,
1828 enum rte_crypto_cipher_algorithm algo)
1830 struct crypto_testsuite_params *ts_params = &testsuite_params;
1831 struct crypto_unittest_params *ut_params = &unittest_params;
1832 unsigned iv_pad_len = 0;
1834 /* Generate Crypto op data structure */
1835 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1836 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1837 TEST_ASSERT_NOT_NULL(ut_params->op,
1838 "Failed to allocate pktmbuf offload");
1840 /* Set crypto operation data parameters */
1841 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1843 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1845 /* set crypto operation source mbuf */
1846 sym_op->m_src = ut_params->ibuf;
1849 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1850 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1852 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1854 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1857 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1859 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1860 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1861 sym_op->cipher.iv.length = iv_pad_len;
1863 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1864 sym_op->cipher.data.length = cipher_len;
1865 sym_op->cipher.data.offset = cipher_offset;
1870 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1871 const unsigned cipher_len,
1872 const unsigned cipher_offset,
1873 enum rte_crypto_cipher_algorithm algo)
1875 struct crypto_testsuite_params *ts_params = &testsuite_params;
1876 struct crypto_unittest_params *ut_params = &unittest_params;
1877 unsigned iv_pad_len = 0;
1879 /* Generate Crypto op data structure */
1880 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1881 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1882 TEST_ASSERT_NOT_NULL(ut_params->op,
1883 "Failed to allocate pktmbuf offload");
1885 /* Set crypto operation data parameters */
1886 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1888 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1890 /* set crypto operation source mbuf */
1891 sym_op->m_src = ut_params->ibuf;
1892 sym_op->m_dst = ut_params->obuf;
1895 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1896 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1898 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1899 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1902 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1904 /* For OOP operation both buffers must have the same size */
1905 if (ut_params->obuf)
1906 rte_pktmbuf_prepend(ut_params->obuf, iv_pad_len);
1908 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1909 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1910 sym_op->cipher.iv.length = iv_pad_len;
1912 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1913 sym_op->cipher.data.length = cipher_len;
1914 sym_op->cipher.data.offset = cipher_offset;
1919 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1920 enum rte_crypto_cipher_operation cipher_op,
1921 enum rte_crypto_auth_operation auth_op,
1922 enum rte_crypto_auth_algorithm auth_algo,
1923 enum rte_crypto_cipher_algorithm cipher_algo,
1924 const uint8_t *key, const uint8_t key_len,
1925 const uint8_t aad_len, const uint8_t auth_len)
1928 uint8_t cipher_auth_key[key_len];
1930 struct crypto_unittest_params *ut_params = &unittest_params;
1932 memcpy(cipher_auth_key, key, key_len);
1934 /* Setup Authentication Parameters */
1935 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1936 ut_params->auth_xform.next = NULL;
1938 ut_params->auth_xform.auth.op = auth_op;
1939 ut_params->auth_xform.auth.algo = auth_algo;
1940 ut_params->auth_xform.auth.key.length = key_len;
1941 /* Hash key = cipher key */
1942 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1943 ut_params->auth_xform.auth.digest_length = auth_len;
1944 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1946 /* Setup Cipher Parameters */
1947 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1948 ut_params->cipher_xform.next = &ut_params->auth_xform;
1950 ut_params->cipher_xform.cipher.algo = cipher_algo;
1951 ut_params->cipher_xform.cipher.op = cipher_op;
1952 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1953 ut_params->cipher_xform.cipher.key.length = key_len;
1955 TEST_HEXDUMP(stdout, "key:", key, key_len);
1957 /* Create Crypto session*/
1958 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1959 &ut_params->cipher_xform);
1961 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1966 create_wireless_cipher_auth_session(uint8_t dev_id,
1967 enum rte_crypto_cipher_operation cipher_op,
1968 enum rte_crypto_auth_operation auth_op,
1969 enum rte_crypto_auth_algorithm auth_algo,
1970 enum rte_crypto_cipher_algorithm cipher_algo,
1971 const struct wireless_test_data *tdata)
1973 const uint8_t key_len = tdata->key.len;
1974 uint8_t cipher_auth_key[key_len];
1976 struct crypto_unittest_params *ut_params = &unittest_params;
1977 const uint8_t *key = tdata->key.data;
1978 const uint8_t aad_len = tdata->aad.len;
1979 const uint8_t auth_len = tdata->digest.len;
1981 memcpy(cipher_auth_key, key, key_len);
1983 /* Setup Authentication Parameters */
1984 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1985 ut_params->auth_xform.next = NULL;
1987 ut_params->auth_xform.auth.op = auth_op;
1988 ut_params->auth_xform.auth.algo = auth_algo;
1989 ut_params->auth_xform.auth.key.length = key_len;
1990 /* Hash key = cipher key */
1991 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1992 ut_params->auth_xform.auth.digest_length = auth_len;
1993 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1995 /* Setup Cipher Parameters */
1996 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1997 ut_params->cipher_xform.next = &ut_params->auth_xform;
1999 ut_params->cipher_xform.cipher.algo = cipher_algo;
2000 ut_params->cipher_xform.cipher.op = cipher_op;
2001 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2002 ut_params->cipher_xform.cipher.key.length = key_len;
2004 TEST_HEXDUMP(stdout, "key:", key, key_len);
2006 /* Create Crypto session*/
2007 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2008 &ut_params->cipher_xform);
2010 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2015 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2016 const struct wireless_test_data *tdata)
2018 return create_wireless_cipher_auth_session(dev_id,
2019 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2020 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2021 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2025 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2026 enum rte_crypto_cipher_operation cipher_op,
2027 enum rte_crypto_auth_operation auth_op,
2028 enum rte_crypto_auth_algorithm auth_algo,
2029 enum rte_crypto_cipher_algorithm cipher_algo,
2030 const uint8_t *key, const uint8_t key_len,
2031 const uint8_t aad_len, const uint8_t auth_len)
2033 uint8_t auth_cipher_key[key_len];
2035 struct crypto_unittest_params *ut_params = &unittest_params;
2037 memcpy(auth_cipher_key, key, key_len);
2039 /* Setup Authentication Parameters */
2040 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2041 ut_params->auth_xform.auth.op = auth_op;
2042 ut_params->auth_xform.next = &ut_params->cipher_xform;
2043 ut_params->auth_xform.auth.algo = auth_algo;
2044 ut_params->auth_xform.auth.key.length = key_len;
2045 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2046 ut_params->auth_xform.auth.digest_length = auth_len;
2047 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
2049 /* Setup Cipher Parameters */
2050 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2051 ut_params->cipher_xform.next = NULL;
2052 ut_params->cipher_xform.cipher.algo = cipher_algo;
2053 ut_params->cipher_xform.cipher.op = cipher_op;
2054 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2055 ut_params->cipher_xform.cipher.key.length = key_len;
2057 TEST_HEXDUMP(stdout, "key:", key, key_len);
2059 /* Create Crypto session*/
2060 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2061 &ut_params->auth_xform);
2063 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2069 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2070 const unsigned auth_tag_len,
2071 const uint8_t *aad, const unsigned aad_len,
2072 unsigned data_pad_len,
2073 enum rte_crypto_auth_operation op,
2074 enum rte_crypto_auth_algorithm algo,
2075 const unsigned auth_len, const unsigned auth_offset)
2077 struct crypto_testsuite_params *ts_params = &testsuite_params;
2079 struct crypto_unittest_params *ut_params = &unittest_params;
2081 unsigned aad_buffer_len;
2083 /* Generate Crypto op data structure */
2084 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2085 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2086 TEST_ASSERT_NOT_NULL(ut_params->op,
2087 "Failed to allocate pktmbuf offload");
2089 /* Set crypto operation data parameters */
2090 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2092 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2094 /* set crypto operation source mbuf */
2095 sym_op->m_src = ut_params->ibuf;
2099 * Always allocate the aad up to the block size.
2100 * The cryptodev API calls out -
2101 * - the array must be big enough to hold the AAD, plus any
2102 * space to round this up to the nearest multiple of the
2103 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2105 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2106 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2108 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2109 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2110 ut_params->ibuf, aad_buffer_len);
2111 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2112 "no room to prepend aad");
2113 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2115 sym_op->auth.aad.length = aad_len;
2117 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2118 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2120 TEST_HEXDUMP(stdout, "aad:",
2121 sym_op->auth.aad.data, aad_len);
2124 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2125 ut_params->ibuf, auth_tag_len);
2127 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2128 "no room to append auth tag");
2129 ut_params->digest = sym_op->auth.digest.data;
2130 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2131 ut_params->ibuf, data_pad_len + aad_len);
2132 sym_op->auth.digest.length = auth_tag_len;
2133 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2134 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2136 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2138 TEST_HEXDUMP(stdout, "digest:",
2139 sym_op->auth.digest.data,
2140 sym_op->auth.digest.length);
2142 sym_op->auth.data.length = auth_len;
2143 sym_op->auth.data.offset = auth_offset;
2149 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2150 enum rte_crypto_auth_operation op,
2151 enum rte_crypto_auth_algorithm auth_algo,
2152 enum rte_crypto_cipher_algorithm cipher_algo)
2154 struct crypto_testsuite_params *ts_params = &testsuite_params;
2155 struct crypto_unittest_params *ut_params = &unittest_params;
2157 const uint8_t *auth_tag = tdata->digest.data;
2158 const unsigned int auth_tag_len = tdata->digest.len;
2159 const uint8_t *aad = tdata->aad.data;
2160 const uint8_t aad_len = tdata->aad.len;
2161 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2162 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2164 const uint8_t *iv = tdata->iv.data;
2165 const uint8_t iv_len = tdata->iv.len;
2166 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2167 const unsigned int cipher_offset =
2168 tdata->validCipherOffsetLenInBits.len;
2169 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2170 const unsigned int auth_offset = tdata->validAuthOffsetLenInBits.len;
2172 unsigned int iv_pad_len = 0;
2173 unsigned int aad_buffer_len;
2175 /* Generate Crypto op data structure */
2176 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2177 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2178 TEST_ASSERT_NOT_NULL(ut_params->op,
2179 "Failed to allocate pktmbuf offload");
2180 /* Set crypto operation data parameters */
2181 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2183 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2185 /* set crypto operation source mbuf */
2186 sym_op->m_src = ut_params->ibuf;
2189 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2190 ut_params->ibuf, auth_tag_len);
2192 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2193 "no room to append auth tag");
2194 ut_params->digest = sym_op->auth.digest.data;
2195 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2196 ut_params->ibuf, data_pad_len);
2197 sym_op->auth.digest.length = auth_tag_len;
2198 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2199 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2201 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2203 TEST_HEXDUMP(stdout, "digest:",
2204 sym_op->auth.digest.data,
2205 sym_op->auth.digest.length);
2209 * Always allocate the aad up to the block size.
2210 * The cryptodev API calls out -
2211 * - the array must be big enough to hold the AAD, plus any
2212 * space to round this up to the nearest multiple of the
2213 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2215 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2216 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2218 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2219 sym_op->auth.aad.data =
2220 (uint8_t *)rte_pktmbuf_prepend(
2221 ut_params->ibuf, aad_buffer_len);
2222 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2223 "no room to prepend aad");
2224 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2226 sym_op->auth.aad.length = aad_len;
2227 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2228 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2229 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2232 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2233 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2235 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2236 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2237 ut_params->ibuf, iv_pad_len);
2239 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2240 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2241 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2242 sym_op->cipher.iv.length = iv_pad_len;
2243 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2244 sym_op->cipher.data.length = cipher_len;
2245 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2246 sym_op->auth.data.length = auth_len;
2247 sym_op->auth.data.offset = auth_offset + cipher_offset;
2253 create_zuc_cipher_hash_generate_operation(
2254 const struct wireless_test_data *tdata)
2256 return create_wireless_cipher_hash_operation(tdata,
2257 RTE_CRYPTO_AUTH_OP_GENERATE,
2258 RTE_CRYPTO_AUTH_ZUC_EIA3,
2259 RTE_CRYPTO_CIPHER_ZUC_EEA3);
2263 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2264 const unsigned auth_tag_len,
2265 const uint8_t *aad, const uint8_t aad_len,
2266 unsigned data_pad_len,
2267 enum rte_crypto_auth_operation op,
2268 enum rte_crypto_auth_algorithm auth_algo,
2269 enum rte_crypto_cipher_algorithm cipher_algo,
2270 const uint8_t *iv, const uint8_t iv_len,
2271 const unsigned cipher_len, const unsigned cipher_offset,
2272 const unsigned auth_len, const unsigned auth_offset)
2274 struct crypto_testsuite_params *ts_params = &testsuite_params;
2275 struct crypto_unittest_params *ut_params = &unittest_params;
2277 unsigned iv_pad_len = 0;
2278 unsigned aad_buffer_len;
2280 /* Generate Crypto op data structure */
2281 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2282 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2283 TEST_ASSERT_NOT_NULL(ut_params->op,
2284 "Failed to allocate pktmbuf offload");
2285 /* Set crypto operation data parameters */
2286 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2288 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2290 /* set crypto operation source mbuf */
2291 sym_op->m_src = ut_params->ibuf;
2294 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2295 ut_params->ibuf, auth_tag_len);
2297 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2298 "no room to append auth tag");
2299 ut_params->digest = sym_op->auth.digest.data;
2300 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2301 ut_params->ibuf, data_pad_len);
2302 sym_op->auth.digest.length = auth_tag_len;
2303 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2304 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2306 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2308 TEST_HEXDUMP(stdout, "digest:",
2309 sym_op->auth.digest.data,
2310 sym_op->auth.digest.length);
2314 * Always allocate the aad up to the block size.
2315 * The cryptodev API calls out -
2316 * - the array must be big enough to hold the AAD, plus any
2317 * space to round this up to the nearest multiple of the
2318 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2320 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2321 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2323 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2324 sym_op->auth.aad.data =
2325 (uint8_t *)rte_pktmbuf_prepend(
2326 ut_params->ibuf, aad_buffer_len);
2327 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2328 "no room to prepend aad");
2329 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2331 sym_op->auth.aad.length = aad_len;
2332 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2333 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2334 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2337 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2338 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2340 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2341 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2342 ut_params->ibuf, iv_pad_len);
2344 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2345 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2346 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2347 sym_op->cipher.iv.length = iv_pad_len;
2348 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2349 sym_op->cipher.data.length = cipher_len;
2350 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2351 sym_op->auth.data.length = auth_len;
2352 sym_op->auth.data.offset = auth_offset + cipher_offset;
2358 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2359 const uint8_t *iv, const uint8_t iv_len,
2360 const uint8_t *aad, const uint8_t aad_len,
2361 unsigned data_pad_len,
2362 const unsigned cipher_len, const unsigned cipher_offset,
2363 const unsigned auth_len, const unsigned auth_offset,
2364 enum rte_crypto_auth_algorithm auth_algo,
2365 enum rte_crypto_cipher_algorithm cipher_algo)
2367 struct crypto_testsuite_params *ts_params = &testsuite_params;
2368 struct crypto_unittest_params *ut_params = &unittest_params;
2370 unsigned iv_pad_len = 0;
2371 unsigned aad_buffer_len = 0;
2373 /* Generate Crypto op data structure */
2374 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2375 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2376 TEST_ASSERT_NOT_NULL(ut_params->op,
2377 "Failed to allocate pktmbuf offload");
2379 /* Set crypto operation data parameters */
2380 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2382 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2384 /* set crypto operation source mbuf */
2385 sym_op->m_src = ut_params->ibuf;
2388 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2389 ut_params->ibuf, auth_tag_len);
2391 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2392 "no room to append auth tag");
2394 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2395 ut_params->ibuf, data_pad_len);
2396 sym_op->auth.digest.length = auth_tag_len;
2398 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2400 TEST_HEXDUMP(stdout, "digest:",
2401 sym_op->auth.digest.data,
2402 sym_op->auth.digest.length);
2406 * Always allocate the aad up to the block size.
2407 * The cryptodev API calls out -
2408 * - the array must be big enough to hold the AAD, plus any
2409 * space to round this up to the nearest multiple of the
2410 * block size (8 bytes for KASUMI 16 bytes).
2412 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2413 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2415 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2416 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2417 ut_params->ibuf, aad_buffer_len);
2418 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2419 "no room to prepend aad");
2420 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2422 sym_op->auth.aad.length = aad_len;
2423 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2424 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2425 TEST_HEXDUMP(stdout, "aad:",
2426 sym_op->auth.aad.data, aad_len);
2429 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2430 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2432 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2434 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2435 ut_params->ibuf, iv_pad_len);
2436 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2438 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2439 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2440 sym_op->cipher.iv.length = iv_pad_len;
2442 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2444 sym_op->cipher.data.length = cipher_len;
2445 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2447 sym_op->auth.data.length = auth_len;
2448 sym_op->auth.data.offset = auth_offset + cipher_offset;
2454 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2456 struct crypto_testsuite_params *ts_params = &testsuite_params;
2457 struct crypto_unittest_params *ut_params = &unittest_params;
2460 unsigned plaintext_pad_len;
2461 unsigned plaintext_len;
2464 /* Create SNOW 3G session */
2465 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2466 tdata->key.data, tdata->key.len,
2467 tdata->aad.len, tdata->digest.len,
2468 RTE_CRYPTO_AUTH_OP_GENERATE,
2469 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2473 /* alloc mbuf and set payload */
2474 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2476 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2477 rte_pktmbuf_tailroom(ut_params->ibuf));
2479 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2480 /* Append data which is padded to a multiple of */
2481 /* the algorithms block size */
2482 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2483 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2485 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2487 /* Create SNOW 3G operation */
2488 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2489 tdata->aad.data, tdata->aad.len,
2490 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2491 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2492 tdata->validAuthLenInBits.len,
2493 tdata->validAuthOffsetLenInBits.len);
2497 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2499 ut_params->obuf = ut_params->op->sym->m_src;
2500 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2501 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2502 + plaintext_pad_len + tdata->aad.len;
2505 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2508 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2509 "SNOW 3G Generated auth tag not as expected");
2515 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2517 struct crypto_testsuite_params *ts_params = &testsuite_params;
2518 struct crypto_unittest_params *ut_params = &unittest_params;
2521 unsigned plaintext_pad_len;
2522 unsigned plaintext_len;
2525 /* Create SNOW 3G session */
2526 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2527 tdata->key.data, tdata->key.len,
2528 tdata->aad.len, tdata->digest.len,
2529 RTE_CRYPTO_AUTH_OP_VERIFY,
2530 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2533 /* alloc mbuf and set payload */
2534 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2536 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2537 rte_pktmbuf_tailroom(ut_params->ibuf));
2539 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2540 /* Append data which is padded to a multiple of */
2541 /* the algorithms block size */
2542 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2543 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2545 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2547 /* Create SNOW 3G operation */
2548 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2550 tdata->aad.data, tdata->aad.len,
2552 RTE_CRYPTO_AUTH_OP_VERIFY,
2553 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2554 tdata->validAuthLenInBits.len,
2555 tdata->validAuthOffsetLenInBits.len);
2559 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2561 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2562 ut_params->obuf = ut_params->op->sym->m_src;
2563 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2564 + plaintext_pad_len + tdata->aad.len;
2567 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2576 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2578 struct crypto_testsuite_params *ts_params = &testsuite_params;
2579 struct crypto_unittest_params *ut_params = &unittest_params;
2582 unsigned plaintext_pad_len;
2583 unsigned plaintext_len;
2586 /* Create KASUMI session */
2587 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2588 tdata->key.data, tdata->key.len,
2589 tdata->aad.len, tdata->digest.len,
2590 RTE_CRYPTO_AUTH_OP_GENERATE,
2591 RTE_CRYPTO_AUTH_KASUMI_F9);
2595 /* alloc mbuf and set payload */
2596 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2598 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2599 rte_pktmbuf_tailroom(ut_params->ibuf));
2601 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2602 /* Append data which is padded to a multiple of */
2603 /* the algorithms block size */
2604 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2605 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2607 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2609 /* Create KASUMI operation */
2610 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2611 tdata->aad.data, tdata->aad.len,
2612 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2613 RTE_CRYPTO_AUTH_KASUMI_F9,
2614 tdata->validAuthLenInBits.len,
2615 tdata->validAuthOffsetLenInBits.len);
2619 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2621 ut_params->obuf = ut_params->op->sym->m_src;
2622 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2623 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2624 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2627 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2630 DIGEST_BYTE_LENGTH_KASUMI_F9,
2631 "KASUMI Generated auth tag not as expected");
2637 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2639 struct crypto_testsuite_params *ts_params = &testsuite_params;
2640 struct crypto_unittest_params *ut_params = &unittest_params;
2643 unsigned plaintext_pad_len;
2644 unsigned plaintext_len;
2647 /* Create KASUMI session */
2648 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2649 tdata->key.data, tdata->key.len,
2650 tdata->aad.len, tdata->digest.len,
2651 RTE_CRYPTO_AUTH_OP_VERIFY,
2652 RTE_CRYPTO_AUTH_KASUMI_F9);
2655 /* alloc mbuf and set payload */
2656 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2658 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2659 rte_pktmbuf_tailroom(ut_params->ibuf));
2661 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2662 /* Append data which is padded to a multiple */
2663 /* of the algorithms block size */
2664 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2665 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2667 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2669 /* Create KASUMI operation */
2670 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2672 tdata->aad.data, tdata->aad.len,
2674 RTE_CRYPTO_AUTH_OP_VERIFY,
2675 RTE_CRYPTO_AUTH_KASUMI_F9,
2676 tdata->validAuthLenInBits.len,
2677 tdata->validAuthOffsetLenInBits.len);
2681 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2683 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2684 ut_params->obuf = ut_params->op->sym->m_src;
2685 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2686 + plaintext_pad_len + tdata->aad.len;
2689 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2698 test_snow3g_hash_generate_test_case_1(void)
2700 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2704 test_snow3g_hash_generate_test_case_2(void)
2706 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2710 test_snow3g_hash_generate_test_case_3(void)
2712 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2716 test_snow3g_hash_generate_test_case_4(void)
2718 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2722 test_snow3g_hash_generate_test_case_5(void)
2724 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2728 test_snow3g_hash_generate_test_case_6(void)
2730 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2734 test_snow3g_hash_verify_test_case_1(void)
2736 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2741 test_snow3g_hash_verify_test_case_2(void)
2743 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2747 test_snow3g_hash_verify_test_case_3(void)
2749 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2753 test_snow3g_hash_verify_test_case_4(void)
2755 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2759 test_snow3g_hash_verify_test_case_5(void)
2761 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2765 test_snow3g_hash_verify_test_case_6(void)
2767 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2771 test_kasumi_hash_generate_test_case_1(void)
2773 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2777 test_kasumi_hash_generate_test_case_2(void)
2779 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2783 test_kasumi_hash_generate_test_case_3(void)
2785 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2789 test_kasumi_hash_generate_test_case_4(void)
2791 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2795 test_kasumi_hash_generate_test_case_5(void)
2797 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2801 test_kasumi_hash_generate_test_case_6(void)
2803 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2807 test_kasumi_hash_verify_test_case_1(void)
2809 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2813 test_kasumi_hash_verify_test_case_2(void)
2815 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2819 test_kasumi_hash_verify_test_case_3(void)
2821 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2825 test_kasumi_hash_verify_test_case_4(void)
2827 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2831 test_kasumi_hash_verify_test_case_5(void)
2833 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2837 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2839 struct crypto_testsuite_params *ts_params = &testsuite_params;
2840 struct crypto_unittest_params *ut_params = &unittest_params;
2843 uint8_t *plaintext, *ciphertext;
2844 unsigned plaintext_pad_len;
2845 unsigned plaintext_len;
2847 /* Create KASUMI session */
2848 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2849 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2850 RTE_CRYPTO_CIPHER_KASUMI_F8,
2851 tdata->key.data, tdata->key.len);
2855 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2857 /* Clear mbuf payload */
2858 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2859 rte_pktmbuf_tailroom(ut_params->ibuf));
2861 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2862 /* Append data which is padded to a multiple */
2863 /* of the algorithms block size */
2864 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2865 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2867 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2869 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2871 /* Create KASUMI operation */
2872 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2873 tdata->plaintext.len,
2874 tdata->validCipherOffsetLenInBits.len,
2875 RTE_CRYPTO_CIPHER_KASUMI_F8);
2879 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2881 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2883 ut_params->obuf = ut_params->op->sym->m_dst;
2884 if (ut_params->obuf)
2885 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2888 ciphertext = plaintext;
2890 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2893 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2895 tdata->ciphertext.data,
2896 tdata->validCipherLenInBits.len,
2897 "KASUMI Ciphertext data not as expected");
2902 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2904 struct crypto_testsuite_params *ts_params = &testsuite_params;
2905 struct crypto_unittest_params *ut_params = &unittest_params;
2909 unsigned int plaintext_pad_len;
2910 unsigned int plaintext_len;
2912 uint8_t buffer[10000];
2913 const uint8_t *ciphertext;
2915 struct rte_cryptodev_info dev_info;
2917 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2918 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2919 printf("Device doesn't support scatter-gather. "
2924 /* Create KASUMI session */
2925 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2926 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2927 RTE_CRYPTO_CIPHER_KASUMI_F8,
2928 tdata->key.data, tdata->key.len);
2932 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2935 /* Append data which is padded to a multiple */
2936 /* of the algorithms block size */
2937 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2939 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2940 plaintext_pad_len, 10, 0);
2942 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2944 /* Create KASUMI operation */
2945 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2947 tdata->plaintext.len,
2948 tdata->validCipherOffsetLenInBits.len,
2949 RTE_CRYPTO_CIPHER_KASUMI_F8);
2953 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2955 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2957 ut_params->obuf = ut_params->op->sym->m_dst;
2959 if (ut_params->obuf)
2960 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2961 plaintext_len, buffer);
2963 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2964 plaintext_len, buffer);
2967 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2970 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2972 tdata->ciphertext.data,
2973 tdata->validCipherLenInBits.len,
2974 "KASUMI Ciphertext data not as expected");
2979 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2981 struct crypto_testsuite_params *ts_params = &testsuite_params;
2982 struct crypto_unittest_params *ut_params = &unittest_params;
2985 uint8_t *plaintext, *ciphertext;
2986 unsigned plaintext_pad_len;
2987 unsigned plaintext_len;
2989 /* Create KASUMI session */
2990 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2991 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2992 RTE_CRYPTO_CIPHER_KASUMI_F8,
2993 tdata->key.data, tdata->key.len);
2997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2998 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3000 /* Clear mbuf payload */
3001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3002 rte_pktmbuf_tailroom(ut_params->ibuf));
3004 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3005 /* Append data which is padded to a multiple */
3006 /* of the algorithms block size */
3007 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3008 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3010 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3011 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3013 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3015 /* Create KASUMI operation */
3016 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3018 tdata->plaintext.len,
3019 tdata->validCipherOffsetLenInBits.len,
3020 RTE_CRYPTO_CIPHER_KASUMI_F8);
3024 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3026 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3028 ut_params->obuf = ut_params->op->sym->m_dst;
3029 if (ut_params->obuf)
3030 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3033 ciphertext = plaintext;
3035 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3038 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3040 tdata->ciphertext.data,
3041 tdata->validCipherLenInBits.len,
3042 "KASUMI Ciphertext data not as expected");
3047 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3049 struct crypto_testsuite_params *ts_params = &testsuite_params;
3050 struct crypto_unittest_params *ut_params = &unittest_params;
3053 unsigned int plaintext_pad_len;
3054 unsigned int plaintext_len;
3056 const uint8_t *ciphertext;
3057 uint8_t buffer[2048];
3059 struct rte_cryptodev_info dev_info;
3061 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3062 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3063 printf("Device doesn't support scatter-gather. "
3068 /* Create KASUMI session */
3069 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3070 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3071 RTE_CRYPTO_CIPHER_KASUMI_F8,
3072 tdata->key.data, tdata->key.len);
3076 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3077 /* Append data which is padded to a multiple */
3078 /* of the algorithms block size */
3079 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3081 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3082 plaintext_pad_len, 10, 0);
3083 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3084 plaintext_pad_len, 3, 0);
3086 /* Append data which is padded to a multiple */
3087 /* of the algorithms block size */
3088 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3090 /* Create KASUMI operation */
3091 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3093 tdata->plaintext.len,
3094 tdata->validCipherOffsetLenInBits.len,
3095 RTE_CRYPTO_CIPHER_KASUMI_F8);
3099 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3101 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3103 ut_params->obuf = ut_params->op->sym->m_dst;
3104 if (ut_params->obuf)
3105 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3106 plaintext_pad_len, buffer);
3108 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3109 plaintext_pad_len, buffer);
3112 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3114 tdata->ciphertext.data,
3115 tdata->validCipherLenInBits.len,
3116 "KASUMI Ciphertext data not as expected");
3122 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3124 struct crypto_testsuite_params *ts_params = &testsuite_params;
3125 struct crypto_unittest_params *ut_params = &unittest_params;
3128 uint8_t *ciphertext, *plaintext;
3129 unsigned ciphertext_pad_len;
3130 unsigned ciphertext_len;
3132 /* Create KASUMI session */
3133 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3134 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3135 RTE_CRYPTO_CIPHER_KASUMI_F8,
3136 tdata->key.data, tdata->key.len);
3140 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3141 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3143 /* Clear mbuf payload */
3144 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3145 rte_pktmbuf_tailroom(ut_params->ibuf));
3147 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3148 /* Append data which is padded to a multiple */
3149 /* of the algorithms block size */
3150 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3151 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3152 ciphertext_pad_len);
3153 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3154 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3156 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3158 /* Create KASUMI operation */
3159 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3161 tdata->ciphertext.len,
3162 tdata->validCipherOffsetLenInBits.len,
3163 RTE_CRYPTO_CIPHER_KASUMI_F8);
3167 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3169 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3171 ut_params->obuf = ut_params->op->sym->m_dst;
3172 if (ut_params->obuf)
3173 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3176 plaintext = ciphertext;
3178 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3181 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3183 tdata->plaintext.data,
3184 tdata->validCipherLenInBits.len,
3185 "KASUMI Plaintext data not as expected");
3190 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3192 struct crypto_testsuite_params *ts_params = &testsuite_params;
3193 struct crypto_unittest_params *ut_params = &unittest_params;
3196 uint8_t *ciphertext, *plaintext;
3197 unsigned ciphertext_pad_len;
3198 unsigned ciphertext_len;
3200 /* Create KASUMI session */
3201 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3202 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3203 RTE_CRYPTO_CIPHER_KASUMI_F8,
3204 tdata->key.data, tdata->key.len);
3208 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3210 /* Clear mbuf payload */
3211 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3212 rte_pktmbuf_tailroom(ut_params->ibuf));
3214 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3215 /* Append data which is padded to a multiple */
3216 /* of the algorithms block size */
3217 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3218 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3219 ciphertext_pad_len);
3220 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3222 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3224 /* Create KASUMI operation */
3225 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3227 tdata->ciphertext.len,
3228 tdata->validCipherOffsetLenInBits.len,
3229 RTE_CRYPTO_CIPHER_KASUMI_F8);
3233 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3235 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3237 ut_params->obuf = ut_params->op->sym->m_dst;
3238 if (ut_params->obuf)
3239 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3242 plaintext = ciphertext;
3244 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3247 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3249 tdata->plaintext.data,
3250 tdata->validCipherLenInBits.len,
3251 "KASUMI Plaintext data not as expected");
3256 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3258 struct crypto_testsuite_params *ts_params = &testsuite_params;
3259 struct crypto_unittest_params *ut_params = &unittest_params;
3262 uint8_t *plaintext, *ciphertext;
3263 unsigned plaintext_pad_len;
3264 unsigned plaintext_len;
3266 /* Create SNOW 3G session */
3267 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3268 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3269 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3270 tdata->key.data, tdata->key.len);
3274 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3276 /* Clear mbuf payload */
3277 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3278 rte_pktmbuf_tailroom(ut_params->ibuf));
3280 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3281 /* Append data which is padded to a multiple of */
3282 /* the algorithms block size */
3283 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3284 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3286 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3288 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3290 /* Create SNOW 3G operation */
3291 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3292 tdata->validCipherLenInBits.len,
3293 tdata->validCipherOffsetLenInBits.len,
3294 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3298 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3300 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3302 ut_params->obuf = ut_params->op->sym->m_dst;
3303 if (ut_params->obuf)
3304 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3307 ciphertext = plaintext;
3309 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3312 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3314 tdata->ciphertext.data,
3315 tdata->validDataLenInBits.len,
3316 "SNOW 3G Ciphertext data not as expected");
3322 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3324 struct crypto_testsuite_params *ts_params = &testsuite_params;
3325 struct crypto_unittest_params *ut_params = &unittest_params;
3326 uint8_t *plaintext, *ciphertext;
3329 unsigned plaintext_pad_len;
3330 unsigned plaintext_len;
3332 /* Create SNOW 3G session */
3333 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3334 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3335 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3336 tdata->key.data, tdata->key.len);
3340 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3341 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3343 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3344 "Failed to allocate input buffer in mempool");
3345 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3346 "Failed to allocate output buffer in mempool");
3348 /* Clear mbuf payload */
3349 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3350 rte_pktmbuf_tailroom(ut_params->ibuf));
3352 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3353 /* Append data which is padded to a multiple of */
3354 /* the algorithms block size */
3355 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3356 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3358 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3359 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3361 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3363 /* Create SNOW 3G operation */
3364 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3366 tdata->validCipherLenInBits.len,
3367 tdata->validCipherOffsetLenInBits.len,
3368 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3372 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3374 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3376 ut_params->obuf = ut_params->op->sym->m_dst;
3377 if (ut_params->obuf)
3378 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3381 ciphertext = plaintext;
3383 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3386 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3388 tdata->ciphertext.data,
3389 tdata->validDataLenInBits.len,
3390 "SNOW 3G Ciphertext data not as expected");
3395 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3397 struct crypto_testsuite_params *ts_params = &testsuite_params;
3398 struct crypto_unittest_params *ut_params = &unittest_params;
3401 unsigned int plaintext_pad_len;
3402 unsigned int plaintext_len;
3403 uint8_t buffer[10000];
3404 const uint8_t *ciphertext;
3406 struct rte_cryptodev_info dev_info;
3408 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3409 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3410 printf("Device doesn't support scatter-gather. "
3415 /* Create SNOW 3G session */
3416 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3417 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3418 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3419 tdata->key.data, tdata->key.len);
3423 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3424 /* Append data which is padded to a multiple of */
3425 /* the algorithms block size */
3426 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3428 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3429 plaintext_pad_len, 10, 0);
3430 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3431 plaintext_pad_len, 3, 0);
3433 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3434 "Failed to allocate input buffer in mempool");
3435 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3436 "Failed to allocate output buffer in mempool");
3438 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3440 /* Create SNOW 3G operation */
3441 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3443 tdata->validCipherLenInBits.len,
3444 tdata->validCipherOffsetLenInBits.len,
3445 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3449 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3451 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3453 ut_params->obuf = ut_params->op->sym->m_dst;
3454 if (ut_params->obuf)
3455 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3456 plaintext_len, buffer);
3458 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3459 plaintext_len, buffer);
3461 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3464 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3466 tdata->ciphertext.data,
3467 tdata->validDataLenInBits.len,
3468 "SNOW 3G Ciphertext data not as expected");
3473 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3475 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3477 uint8_t curr_byte, prev_byte;
3478 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3479 uint8_t lower_byte_mask = (1 << offset) - 1;
3482 prev_byte = buffer[0];
3483 buffer[0] >>= offset;
3485 for (i = 1; i < length_in_bytes; i++) {
3486 curr_byte = buffer[i];
3487 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3488 (curr_byte >> offset);
3489 prev_byte = curr_byte;
3494 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3496 struct crypto_testsuite_params *ts_params = &testsuite_params;
3497 struct crypto_unittest_params *ut_params = &unittest_params;
3498 uint8_t *plaintext, *ciphertext;
3500 uint32_t plaintext_len;
3501 uint32_t plaintext_pad_len;
3502 uint8_t extra_offset = 4;
3503 uint8_t *expected_ciphertext_shifted;
3505 /* Create SNOW 3G session */
3506 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3507 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3508 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3509 tdata->key.data, tdata->key.len);
3513 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3514 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3516 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3517 "Failed to allocate input buffer in mempool");
3518 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3519 "Failed to allocate output buffer in mempool");
3521 /* Clear mbuf payload */
3522 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3523 rte_pktmbuf_tailroom(ut_params->ibuf));
3525 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3527 * Append data which is padded to a
3528 * multiple of the algorithms block size
3530 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3532 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3535 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3537 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3538 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3540 #ifdef RTE_APP_TEST_DEBUG
3541 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3543 /* Create SNOW 3G operation */
3544 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3546 tdata->validCipherLenInBits.len,
3547 tdata->validCipherOffsetLenInBits.len +
3549 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3553 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3555 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3557 ut_params->obuf = ut_params->op->sym->m_dst;
3558 if (ut_params->obuf)
3559 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3562 ciphertext = plaintext;
3564 #ifdef RTE_APP_TEST_DEBUG
3565 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3568 expected_ciphertext_shifted = rte_malloc(NULL,
3569 ceil_byte_length(plaintext_len + extra_offset), 0);
3571 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3572 "failed to reserve memory for ciphertext shifted\n");
3574 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3575 ceil_byte_length(tdata->ciphertext.len));
3576 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3579 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3581 expected_ciphertext_shifted,
3582 tdata->validDataLenInBits.len,
3584 "SNOW 3G Ciphertext data not as expected");
3588 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3590 struct crypto_testsuite_params *ts_params = &testsuite_params;
3591 struct crypto_unittest_params *ut_params = &unittest_params;
3595 uint8_t *plaintext, *ciphertext;
3596 unsigned ciphertext_pad_len;
3597 unsigned ciphertext_len;
3599 /* Create SNOW 3G session */
3600 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3601 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3602 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3603 tdata->key.data, tdata->key.len);
3607 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3609 /* Clear mbuf payload */
3610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3611 rte_pktmbuf_tailroom(ut_params->ibuf));
3613 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3614 /* Append data which is padded to a multiple of */
3615 /* the algorithms block size */
3616 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3617 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3618 ciphertext_pad_len);
3619 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3621 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3623 /* Create SNOW 3G operation */
3624 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3625 tdata->validCipherLenInBits.len,
3626 tdata->validCipherOffsetLenInBits.len,
3627 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3631 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3633 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3634 ut_params->obuf = ut_params->op->sym->m_dst;
3635 if (ut_params->obuf)
3636 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3639 plaintext = ciphertext;
3641 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3644 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3645 tdata->plaintext.data,
3646 tdata->validDataLenInBits.len,
3647 "SNOW 3G Plaintext data not as expected");
3651 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3653 struct crypto_testsuite_params *ts_params = &testsuite_params;
3654 struct crypto_unittest_params *ut_params = &unittest_params;
3658 uint8_t *plaintext, *ciphertext;
3659 unsigned ciphertext_pad_len;
3660 unsigned ciphertext_len;
3662 /* Create SNOW 3G session */
3663 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3664 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3665 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3666 tdata->key.data, tdata->key.len);
3670 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3671 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3673 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3674 "Failed to allocate input buffer");
3675 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3676 "Failed to allocate output buffer");
3678 /* Clear mbuf payload */
3679 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3680 rte_pktmbuf_tailroom(ut_params->ibuf));
3682 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3683 rte_pktmbuf_tailroom(ut_params->obuf));
3685 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3686 /* Append data which is padded to a multiple of */
3687 /* the algorithms block size */
3688 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3689 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3690 ciphertext_pad_len);
3691 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3692 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3694 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3696 /* Create SNOW 3G operation */
3697 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3699 tdata->validCipherLenInBits.len,
3700 tdata->validCipherOffsetLenInBits.len,
3701 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3705 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3707 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3708 ut_params->obuf = ut_params->op->sym->m_dst;
3709 if (ut_params->obuf)
3710 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3713 plaintext = ciphertext;
3715 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3718 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3719 tdata->plaintext.data,
3720 tdata->validDataLenInBits.len,
3721 "SNOW 3G Plaintext data not as expected");
3726 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3728 struct crypto_testsuite_params *ts_params = &testsuite_params;
3729 struct crypto_unittest_params *ut_params = &unittest_params;
3733 uint8_t *plaintext, *ciphertext;
3734 unsigned int plaintext_pad_len;
3735 unsigned int plaintext_len;
3737 struct rte_cryptodev_sym_capability_idx cap_idx;
3739 /* Check if device supports ZUC EEA3 */
3740 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3741 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3743 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3747 /* Check if device supports ZUC EIA3 */
3748 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3749 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3751 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3755 /* Create ZUC session */
3756 retval = create_zuc_cipher_auth_encrypt_generate_session(
3757 ts_params->valid_devs[0],
3761 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3763 /* clear mbuf payload */
3764 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3765 rte_pktmbuf_tailroom(ut_params->ibuf));
3767 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3768 /* Append data which is padded to a multiple of */
3769 /* the algorithms block size */
3770 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3771 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3773 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3775 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3777 /* Create ZUC operation */
3778 retval = create_zuc_cipher_hash_generate_operation(tdata);
3782 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3784 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3785 ut_params->obuf = ut_params->op->sym->m_src;
3786 if (ut_params->obuf)
3787 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3788 + tdata->iv.len + tdata->aad.len;
3790 ciphertext = plaintext;
3792 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3794 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3796 tdata->ciphertext.data,
3797 tdata->validDataLenInBits.len,
3798 "ZUC Ciphertext data not as expected");
3800 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3801 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3804 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3808 "ZUC Generated auth tag not as expected");
3813 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3815 struct crypto_testsuite_params *ts_params = &testsuite_params;
3816 struct crypto_unittest_params *ut_params = &unittest_params;
3820 uint8_t *plaintext, *ciphertext;
3821 unsigned plaintext_pad_len;
3822 unsigned plaintext_len;
3824 /* Create SNOW 3G session */
3825 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3826 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3827 RTE_CRYPTO_AUTH_OP_GENERATE,
3828 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3829 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3830 tdata->key.data, tdata->key.len,
3831 tdata->aad.len, tdata->digest.len);
3834 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3836 /* clear mbuf payload */
3837 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3838 rte_pktmbuf_tailroom(ut_params->ibuf));
3840 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3841 /* Append data which is padded to a multiple of */
3842 /* the algorithms block size */
3843 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3844 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3846 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3848 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3850 /* Create SNOW 3G operation */
3851 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3852 tdata->digest.len, tdata->aad.data,
3853 tdata->aad.len, /*tdata->plaintext.len,*/
3854 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3855 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3856 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3857 tdata->iv.data, tdata->iv.len,
3858 tdata->validCipherLenInBits.len,
3859 tdata->validCipherOffsetLenInBits.len,
3860 tdata->validAuthLenInBits.len,
3861 tdata->validAuthOffsetLenInBits.len
3866 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3868 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3869 ut_params->obuf = ut_params->op->sym->m_src;
3870 if (ut_params->obuf)
3871 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3872 + tdata->iv.len + tdata->aad.len;
3874 ciphertext = plaintext;
3876 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3878 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3880 tdata->ciphertext.data,
3881 tdata->validDataLenInBits.len,
3882 "SNOW 3G Ciphertext data not as expected");
3884 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3885 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3888 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3891 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3892 "SNOW 3G Generated auth tag not as expected");
3896 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3898 struct crypto_testsuite_params *ts_params = &testsuite_params;
3899 struct crypto_unittest_params *ut_params = &unittest_params;
3903 uint8_t *plaintext, *ciphertext;
3904 unsigned plaintext_pad_len;
3905 unsigned plaintext_len;
3907 /* Create SNOW 3G session */
3908 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3909 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3910 RTE_CRYPTO_AUTH_OP_GENERATE,
3911 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3912 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3913 tdata->key.data, tdata->key.len,
3914 tdata->aad.len, tdata->digest.len);
3918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3920 /* clear mbuf payload */
3921 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3922 rte_pktmbuf_tailroom(ut_params->ibuf));
3924 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3925 /* Append data which is padded to a multiple of */
3926 /* the algorithms block size */
3927 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3928 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3930 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3932 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3934 /* Create SNOW 3G operation */
3935 retval = create_wireless_algo_auth_cipher_operation(
3937 tdata->iv.data, tdata->iv.len,
3938 tdata->aad.data, tdata->aad.len,
3940 tdata->validCipherLenInBits.len,
3941 tdata->validCipherOffsetLenInBits.len,
3942 tdata->validAuthLenInBits.len,
3943 tdata->validAuthOffsetLenInBits.len,
3944 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3945 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3951 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3953 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3954 ut_params->obuf = ut_params->op->sym->m_src;
3955 if (ut_params->obuf)
3956 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3957 + tdata->aad.len + tdata->iv.len;
3959 ciphertext = plaintext;
3961 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3962 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3963 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3966 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3968 tdata->ciphertext.data,
3969 tdata->validDataLenInBits.len,
3970 "SNOW 3G Ciphertext data not as expected");
3973 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3976 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3977 "SNOW 3G Generated auth tag not as expected");
3982 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3984 struct crypto_testsuite_params *ts_params = &testsuite_params;
3985 struct crypto_unittest_params *ut_params = &unittest_params;
3989 uint8_t *plaintext, *ciphertext;
3990 unsigned plaintext_pad_len;
3991 unsigned plaintext_len;
3993 /* Create KASUMI session */
3994 retval = create_wireless_algo_auth_cipher_session(
3995 ts_params->valid_devs[0],
3996 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3997 RTE_CRYPTO_AUTH_OP_GENERATE,
3998 RTE_CRYPTO_AUTH_KASUMI_F9,
3999 RTE_CRYPTO_CIPHER_KASUMI_F8,
4000 tdata->key.data, tdata->key.len,
4001 tdata->aad.len, tdata->digest.len);
4004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4006 /* clear mbuf payload */
4007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4008 rte_pktmbuf_tailroom(ut_params->ibuf));
4010 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4011 /* Append data which is padded to a multiple of */
4012 /* the algorithms block size */
4013 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4014 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4016 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4018 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4020 /* Create KASUMI operation */
4021 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4022 tdata->iv.data, tdata->iv.len,
4023 tdata->aad.data, tdata->aad.len,
4025 tdata->validCipherLenInBits.len,
4026 tdata->validCipherOffsetLenInBits.len,
4027 tdata->validAuthLenInBits.len,
4028 tdata->validAuthOffsetLenInBits.len,
4029 RTE_CRYPTO_AUTH_KASUMI_F9,
4030 RTE_CRYPTO_CIPHER_KASUMI_F8
4036 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4038 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4039 ut_params->obuf = ut_params->op->sym->m_src;
4040 if (ut_params->obuf)
4041 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4042 + tdata->iv.len + tdata->aad.len;
4044 ciphertext = plaintext;
4047 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4049 tdata->ciphertext.data,
4050 tdata->validCipherLenInBits.len,
4051 "KASUMI Ciphertext data not as expected");
4052 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4053 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
4056 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4059 DIGEST_BYTE_LENGTH_KASUMI_F9,
4060 "KASUMI Generated auth tag not as expected");
4065 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4067 struct crypto_testsuite_params *ts_params = &testsuite_params;
4068 struct crypto_unittest_params *ut_params = &unittest_params;
4072 uint8_t *plaintext, *ciphertext;
4073 unsigned plaintext_pad_len;
4074 unsigned plaintext_len;
4076 /* Create KASUMI session */
4077 retval = create_wireless_algo_cipher_auth_session(
4078 ts_params->valid_devs[0],
4079 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4080 RTE_CRYPTO_AUTH_OP_GENERATE,
4081 RTE_CRYPTO_AUTH_KASUMI_F9,
4082 RTE_CRYPTO_CIPHER_KASUMI_F8,
4083 tdata->key.data, tdata->key.len,
4084 tdata->aad.len, tdata->digest.len);
4088 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4090 /* clear mbuf payload */
4091 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4092 rte_pktmbuf_tailroom(ut_params->ibuf));
4094 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4095 /* Append data which is padded to a multiple of */
4096 /* the algorithms block size */
4097 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4098 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4100 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4102 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4104 /* Create KASUMI operation */
4105 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4106 tdata->digest.len, tdata->aad.data,
4108 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4109 RTE_CRYPTO_AUTH_KASUMI_F9,
4110 RTE_CRYPTO_CIPHER_KASUMI_F8,
4111 tdata->iv.data, tdata->iv.len,
4112 tdata->validCipherLenInBits.len,
4113 tdata->validCipherOffsetLenInBits.len,
4114 tdata->validAuthLenInBits.len,
4115 tdata->validAuthOffsetLenInBits.len
4120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4122 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4123 ut_params->obuf = ut_params->op->sym->m_src;
4124 if (ut_params->obuf)
4125 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4126 + tdata->aad.len + tdata->iv.len;
4128 ciphertext = plaintext;
4130 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4131 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
4134 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4136 tdata->ciphertext.data,
4137 tdata->validCipherLenInBits.len,
4138 "KASUMI Ciphertext data not as expected");
4141 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4144 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4145 "KASUMI Generated auth tag not as expected");
4150 test_zuc_encryption(const struct wireless_test_data *tdata)
4152 struct crypto_testsuite_params *ts_params = &testsuite_params;
4153 struct crypto_unittest_params *ut_params = &unittest_params;
4156 uint8_t *plaintext, *ciphertext;
4157 unsigned plaintext_pad_len;
4158 unsigned plaintext_len;
4160 struct rte_cryptodev_sym_capability_idx cap_idx;
4162 /* Check if device supports ZUC EEA3 */
4163 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4164 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4166 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4170 /* Create ZUC session */
4171 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4172 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4173 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4174 tdata->key.data, tdata->key.len);
4178 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4180 /* Clear mbuf payload */
4181 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4182 rte_pktmbuf_tailroom(ut_params->ibuf));
4184 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4185 /* Append data which is padded to a multiple */
4186 /* of the algorithms block size */
4187 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4188 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4190 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4192 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4194 /* Create ZUC operation */
4195 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
4196 tdata->plaintext.len,
4197 tdata->validCipherOffsetLenInBits.len,
4198 RTE_CRYPTO_CIPHER_ZUC_EEA3);
4202 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4204 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4206 ut_params->obuf = ut_params->op->sym->m_dst;
4207 if (ut_params->obuf)
4208 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4211 ciphertext = plaintext;
4213 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4216 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4218 tdata->ciphertext.data,
4219 tdata->validCipherLenInBits.len,
4220 "ZUC Ciphertext data not as expected");
4225 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4227 struct crypto_testsuite_params *ts_params = &testsuite_params;
4228 struct crypto_unittest_params *ut_params = &unittest_params;
4232 unsigned int plaintext_pad_len;
4233 unsigned int plaintext_len;
4234 const uint8_t *ciphertext;
4235 uint8_t ciphertext_buffer[2048];
4236 struct rte_cryptodev_info dev_info;
4238 struct rte_cryptodev_sym_capability_idx cap_idx;
4240 /* Check if device supports ZUC EEA3 */
4241 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4242 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4244 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4248 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4249 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4250 printf("Device doesn't support scatter-gather. "
4255 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4257 /* Append data which is padded to a multiple */
4258 /* of the algorithms block size */
4259 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4261 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4262 plaintext_pad_len, 10, 0);
4264 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4265 tdata->plaintext.data);
4267 /* Create ZUC session */
4268 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4269 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4270 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4271 tdata->key.data, tdata->key.len);
4275 /* Clear mbuf payload */
4277 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4279 /* Create ZUC operation */
4280 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
4281 tdata->iv.len, tdata->plaintext.len,
4282 tdata->validCipherOffsetLenInBits.len,
4283 RTE_CRYPTO_CIPHER_ZUC_EEA3);
4287 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4289 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4291 ut_params->obuf = ut_params->op->sym->m_dst;
4292 if (ut_params->obuf)
4293 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4294 tdata->iv.len, plaintext_len, ciphertext_buffer);
4296 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4297 tdata->iv.len, plaintext_len, ciphertext_buffer);
4300 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4303 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4305 tdata->ciphertext.data,
4306 tdata->validCipherLenInBits.len,
4307 "ZUC Ciphertext data not as expected");
4313 test_zuc_authentication(const struct wireless_test_data *tdata)
4315 struct crypto_testsuite_params *ts_params = &testsuite_params;
4316 struct crypto_unittest_params *ut_params = &unittest_params;
4319 unsigned plaintext_pad_len;
4320 unsigned plaintext_len;
4323 struct rte_cryptodev_sym_capability_idx cap_idx;
4325 /* Check if device supports ZUC EIA3 */
4326 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4327 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4329 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4333 /* Create ZUC session */
4334 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4335 tdata->key.data, tdata->key.len,
4336 tdata->aad.len, tdata->digest.len,
4337 RTE_CRYPTO_AUTH_OP_GENERATE,
4338 RTE_CRYPTO_AUTH_ZUC_EIA3);
4342 /* alloc mbuf and set payload */
4343 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4345 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4346 rte_pktmbuf_tailroom(ut_params->ibuf));
4348 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4349 /* Append data which is padded to a multiple of */
4350 /* the algorithms block size */
4351 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4352 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4354 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4356 /* Create ZUC operation */
4357 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4358 tdata->aad.data, tdata->aad.len,
4359 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4360 RTE_CRYPTO_AUTH_ZUC_EIA3,
4361 tdata->validAuthLenInBits.len,
4362 tdata->validAuthOffsetLenInBits.len);
4366 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4368 ut_params->obuf = ut_params->op->sym->m_src;
4369 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4370 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4371 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
4374 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4377 DIGEST_BYTE_LENGTH_KASUMI_F9,
4378 "ZUC Generated auth tag not as expected");
4384 test_kasumi_encryption_test_case_1(void)
4386 return test_kasumi_encryption(&kasumi_test_case_1);
4390 test_kasumi_encryption_test_case_1_sgl(void)
4392 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4396 test_kasumi_encryption_test_case_1_oop(void)
4398 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4402 test_kasumi_encryption_test_case_1_oop_sgl(void)
4404 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4408 test_kasumi_encryption_test_case_2(void)
4410 return test_kasumi_encryption(&kasumi_test_case_2);
4414 test_kasumi_encryption_test_case_3(void)
4416 return test_kasumi_encryption(&kasumi_test_case_3);
4420 test_kasumi_encryption_test_case_4(void)
4422 return test_kasumi_encryption(&kasumi_test_case_4);
4426 test_kasumi_encryption_test_case_5(void)
4428 return test_kasumi_encryption(&kasumi_test_case_5);
4432 test_kasumi_decryption_test_case_1(void)
4434 return test_kasumi_decryption(&kasumi_test_case_1);
4438 test_kasumi_decryption_test_case_1_oop(void)
4440 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4444 test_kasumi_decryption_test_case_2(void)
4446 return test_kasumi_decryption(&kasumi_test_case_2);
4450 test_kasumi_decryption_test_case_3(void)
4452 return test_kasumi_decryption(&kasumi_test_case_3);
4456 test_kasumi_decryption_test_case_4(void)
4458 return test_kasumi_decryption(&kasumi_test_case_4);
4462 test_kasumi_decryption_test_case_5(void)
4464 return test_kasumi_decryption(&kasumi_test_case_5);
4467 test_snow3g_encryption_test_case_1(void)
4469 return test_snow3g_encryption(&snow3g_test_case_1);
4473 test_snow3g_encryption_test_case_1_oop(void)
4475 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4479 test_snow3g_encryption_test_case_1_oop_sgl(void)
4481 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4486 test_snow3g_encryption_test_case_1_offset_oop(void)
4488 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4492 test_snow3g_encryption_test_case_2(void)
4494 return test_snow3g_encryption(&snow3g_test_case_2);
4498 test_snow3g_encryption_test_case_3(void)
4500 return test_snow3g_encryption(&snow3g_test_case_3);
4504 test_snow3g_encryption_test_case_4(void)
4506 return test_snow3g_encryption(&snow3g_test_case_4);
4510 test_snow3g_encryption_test_case_5(void)
4512 return test_snow3g_encryption(&snow3g_test_case_5);
4516 test_snow3g_decryption_test_case_1(void)
4518 return test_snow3g_decryption(&snow3g_test_case_1);
4522 test_snow3g_decryption_test_case_1_oop(void)
4524 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4528 test_snow3g_decryption_test_case_2(void)
4530 return test_snow3g_decryption(&snow3g_test_case_2);
4534 test_snow3g_decryption_test_case_3(void)
4536 return test_snow3g_decryption(&snow3g_test_case_3);
4540 test_snow3g_decryption_test_case_4(void)
4542 return test_snow3g_decryption(&snow3g_test_case_4);
4546 test_snow3g_decryption_test_case_5(void)
4548 return test_snow3g_decryption(&snow3g_test_case_5);
4551 test_snow3g_cipher_auth_test_case_1(void)
4553 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4557 test_snow3g_auth_cipher_test_case_1(void)
4559 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4563 test_kasumi_auth_cipher_test_case_1(void)
4565 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4569 test_kasumi_cipher_auth_test_case_1(void)
4571 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4575 test_zuc_encryption_test_case_1(void)
4577 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4581 test_zuc_encryption_test_case_2(void)
4583 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4587 test_zuc_encryption_test_case_3(void)
4589 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4593 test_zuc_encryption_test_case_4(void)
4595 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4599 test_zuc_encryption_test_case_5(void)
4601 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4605 test_zuc_encryption_test_case_6_sgl(void)
4607 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4611 test_zuc_hash_generate_test_case_1(void)
4613 return test_zuc_authentication(&zuc_test_case_auth_1b);
4617 test_zuc_hash_generate_test_case_2(void)
4619 return test_zuc_authentication(&zuc_test_case_auth_90b);
4623 test_zuc_hash_generate_test_case_3(void)
4625 return test_zuc_authentication(&zuc_test_case_auth_577b);
4629 test_zuc_hash_generate_test_case_4(void)
4631 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4635 test_zuc_hash_generate_test_case_5(void)
4637 return test_zuc_authentication(&zuc_test_auth_5670b);
4641 test_zuc_hash_generate_test_case_6(void)
4643 return test_zuc_authentication(&zuc_test_case_auth_128b);
4647 test_zuc_hash_generate_test_case_7(void)
4649 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4653 test_zuc_hash_generate_test_case_8(void)
4655 return test_zuc_authentication(&zuc_test_case_auth_584b);
4659 test_zuc_cipher_auth_test_case_1(void)
4661 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4665 test_zuc_cipher_auth_test_case_2(void)
4667 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4671 test_3DES_chain_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_3DES_CHAIN_TYPE);
4681 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4683 return TEST_SUCCESS;
4687 test_DES_cipheronly_qat_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_QAT_SYM_PMD,
4695 BLKCIPHER_DES_CIPHERONLY_TYPE);
4697 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4699 return TEST_SUCCESS;
4703 test_DES_docsis_openssl_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_OPENSSL_PMD,
4711 BLKCIPHER_DES_DOCSIS_TYPE);
4713 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4715 return TEST_SUCCESS;
4719 test_3DES_cipheronly_qat_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_QAT_SYM_PMD,
4727 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4729 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4731 return TEST_SUCCESS;
4735 test_3DES_chain_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_CHAIN_TYPE);
4745 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4747 return TEST_SUCCESS;
4751 test_3DES_cipheronly_openssl_all(void)
4753 struct crypto_testsuite_params *ts_params = &testsuite_params;
4756 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4757 ts_params->op_mpool, ts_params->valid_devs[0],
4758 RTE_CRYPTODEV_OPENSSL_PMD,
4759 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4761 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4763 return TEST_SUCCESS;
4766 /* ***** AES-GCM Tests ***** */
4769 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4770 const uint8_t *key, const uint8_t key_len,
4771 const uint8_t aad_len, const uint8_t auth_len,
4772 enum rte_crypto_auth_operation auth_op)
4774 uint8_t cipher_key[key_len];
4776 struct crypto_unittest_params *ut_params = &unittest_params;
4778 memcpy(cipher_key, key, key_len);
4780 /* Setup Cipher Parameters */
4781 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4782 ut_params->cipher_xform.next = NULL;
4784 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4785 ut_params->auth_xform.auth.op = auth_op;
4786 ut_params->cipher_xform.cipher.op = op;
4787 ut_params->cipher_xform.cipher.key.data = cipher_key;
4788 ut_params->cipher_xform.cipher.key.length = key_len;
4790 TEST_HEXDUMP(stdout, "key:", key, key_len);
4792 /* Setup Authentication Parameters */
4793 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4794 ut_params->auth_xform.next = NULL;
4796 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4798 ut_params->auth_xform.auth.digest_length = auth_len;
4799 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4800 ut_params->auth_xform.auth.key.length = 0;
4801 ut_params->auth_xform.auth.key.data = NULL;
4803 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4804 ut_params->cipher_xform.next = &ut_params->auth_xform;
4806 /* Create Crypto session*/
4807 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4808 &ut_params->cipher_xform);
4809 } else {/* Create Crypto session*/
4810 ut_params->auth_xform.next = &ut_params->cipher_xform;
4811 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4812 &ut_params->auth_xform);
4815 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4821 create_gcm_xforms(struct rte_crypto_op *op,
4822 enum rte_crypto_cipher_operation cipher_op,
4823 uint8_t *key, const uint8_t key_len,
4824 const uint8_t aad_len, const uint8_t auth_len,
4825 enum rte_crypto_auth_operation auth_op)
4827 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4828 "failed to allocate space for crypto transforms");
4830 struct rte_crypto_sym_op *sym_op = op->sym;
4832 /* Setup Cipher Parameters */
4833 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4834 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4835 sym_op->xform->cipher.op = cipher_op;
4836 sym_op->xform->cipher.key.data = key;
4837 sym_op->xform->cipher.key.length = key_len;
4839 TEST_HEXDUMP(stdout, "key:", key, key_len);
4841 /* Setup Authentication Parameters */
4842 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4843 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4844 sym_op->xform->next->auth.op = auth_op;
4845 sym_op->xform->next->auth.digest_length = auth_len;
4846 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4847 sym_op->xform->next->auth.key.length = 0;
4848 sym_op->xform->next->auth.key.data = NULL;
4849 sym_op->xform->next->next = NULL;
4855 create_gcm_operation(enum rte_crypto_cipher_operation op,
4856 const struct gcm_test_data *tdata)
4858 struct crypto_testsuite_params *ts_params = &testsuite_params;
4859 struct crypto_unittest_params *ut_params = &unittest_params;
4861 uint8_t *plaintext, *ciphertext;
4862 unsigned int iv_pad_len, aad_pad_len, plaintext_pad_len;
4864 /* Generate Crypto op data structure */
4865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4867 TEST_ASSERT_NOT_NULL(ut_params->op,
4868 "Failed to allocate symmetric crypto operation struct");
4870 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4872 /* Append aad data */
4873 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4874 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4876 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4877 "no room to append aad");
4879 sym_op->auth.aad.length = tdata->aad.len;
4880 sym_op->auth.aad.phys_addr =
4881 rte_pktmbuf_mtophys(ut_params->ibuf);
4882 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4883 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4884 sym_op->auth.aad.length);
4887 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
4888 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4889 ut_params->ibuf, iv_pad_len);
4890 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4892 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4893 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4894 sym_op->cipher.iv.length = tdata->iv.len;
4896 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4897 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
4898 sym_op->cipher.iv.length);
4900 /* Append plaintext/ciphertext */
4901 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4902 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4903 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4905 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4907 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4908 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4909 tdata->plaintext.len);
4911 if (ut_params->obuf) {
4912 ciphertext = (uint8_t *)rte_pktmbuf_append(
4914 plaintext_pad_len + aad_pad_len +
4916 TEST_ASSERT_NOT_NULL(ciphertext,
4917 "no room to append ciphertext");
4919 memset(ciphertext + aad_pad_len + iv_pad_len, 0,
4920 tdata->ciphertext.len);
4923 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4924 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4926 TEST_ASSERT_NOT_NULL(ciphertext,
4927 "no room to append ciphertext");
4929 memcpy(ciphertext, tdata->ciphertext.data,
4930 tdata->ciphertext.len);
4931 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4932 tdata->ciphertext.len);
4934 if (ut_params->obuf) {
4935 plaintext = (uint8_t *)rte_pktmbuf_append(
4937 plaintext_pad_len + aad_pad_len +
4939 TEST_ASSERT_NOT_NULL(plaintext,
4940 "no room to append plaintext");
4942 memset(plaintext + aad_pad_len + iv_pad_len, 0,
4943 tdata->plaintext.len);
4947 /* Append digest data */
4948 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4949 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4950 ut_params->obuf ? ut_params->obuf :
4952 tdata->auth_tag.len);
4953 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4954 "no room to append digest");
4955 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4956 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4957 ut_params->obuf ? ut_params->obuf :
4960 aad_pad_len + iv_pad_len);
4961 sym_op->auth.digest.length = tdata->auth_tag.len;
4963 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4964 ut_params->ibuf, tdata->auth_tag.len);
4965 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4966 "no room to append digest");
4967 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4969 plaintext_pad_len + aad_pad_len + iv_pad_len);
4970 sym_op->auth.digest.length = tdata->auth_tag.len;
4972 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4973 tdata->auth_tag.len);
4974 TEST_HEXDUMP(stdout, "digest:",
4975 sym_op->auth.digest.data,
4976 sym_op->auth.digest.length);
4979 sym_op->cipher.data.length = tdata->plaintext.len;
4980 sym_op->cipher.data.offset = aad_pad_len + iv_pad_len;
4982 sym_op->auth.data.length = tdata->plaintext.len;
4983 sym_op->auth.data.offset = aad_pad_len + iv_pad_len;
4989 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4991 struct crypto_testsuite_params *ts_params = &testsuite_params;
4992 struct crypto_unittest_params *ut_params = &unittest_params;
4995 uint8_t *ciphertext, *auth_tag;
4996 uint16_t plaintext_pad_len;
4999 /* Create GCM session */
5000 retval = create_gcm_session(ts_params->valid_devs[0],
5001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5002 tdata->key.data, tdata->key.len,
5003 tdata->aad.len, tdata->auth_tag.len,
5004 RTE_CRYPTO_AUTH_OP_GENERATE);
5008 if (tdata->aad.len > MBUF_SIZE) {
5009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5010 /* Populate full size of add data */
5011 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5012 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5014 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5016 /* clear mbuf payload */
5017 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5018 rte_pktmbuf_tailroom(ut_params->ibuf));
5020 /* Create GCM operation */
5021 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5025 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5027 ut_params->op->sym->m_src = ut_params->ibuf;
5029 /* Process crypto operation */
5030 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5031 ut_params->op), "failed to process sym crypto op");
5033 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5034 "crypto op processing failed");
5036 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5038 if (ut_params->op->sym->m_dst) {
5039 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5041 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5042 uint8_t *, plaintext_pad_len);
5044 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5046 ut_params->op->sym->cipher.data.offset);
5047 auth_tag = ciphertext + plaintext_pad_len;
5050 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5051 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5054 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5056 tdata->ciphertext.data,
5057 tdata->ciphertext.len,
5058 "GCM Ciphertext data not as expected");
5060 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5062 tdata->auth_tag.data,
5063 tdata->auth_tag.len,
5064 "GCM Generated auth tag not as expected");
5071 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
5073 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
5077 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
5079 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
5083 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
5085 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
5089 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
5091 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
5095 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
5097 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
5101 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
5103 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
5107 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
5109 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
5113 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
5115 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5119 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
5121 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5125 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
5127 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5131 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
5133 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5137 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
5139 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5143 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
5145 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5149 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
5151 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5155 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
5157 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5161 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
5163 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5167 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5169 struct crypto_testsuite_params *ts_params = &testsuite_params;
5170 struct crypto_unittest_params *ut_params = &unittest_params;
5176 /* Create GCM session */
5177 retval = create_gcm_session(ts_params->valid_devs[0],
5178 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5179 tdata->key.data, tdata->key.len,
5180 tdata->aad.len, tdata->auth_tag.len,
5181 RTE_CRYPTO_AUTH_OP_VERIFY);
5185 /* alloc mbuf and set payload */
5186 if (tdata->aad.len > MBUF_SIZE) {
5187 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5188 /* Populate full size of add data */
5189 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5190 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5192 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5195 rte_pktmbuf_tailroom(ut_params->ibuf));
5197 /* Create GCM operation */
5198 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5202 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5204 ut_params->op->sym->m_src = ut_params->ibuf;
5206 /* Process crypto operation */
5207 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5208 ut_params->op), "failed to process sym crypto op");
5210 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5211 "crypto op processing failed");
5213 if (ut_params->op->sym->m_dst)
5214 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5217 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5219 ut_params->op->sym->cipher.data.offset);
5221 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5224 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5226 tdata->plaintext.data,
5227 tdata->plaintext.len,
5228 "GCM plaintext data not as expected");
5230 TEST_ASSERT_EQUAL(ut_params->op->status,
5231 RTE_CRYPTO_OP_STATUS_SUCCESS,
5232 "GCM authentication failed");
5237 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5239 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5243 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5245 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5249 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5251 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5255 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5257 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5261 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5263 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5267 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5269 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5273 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5275 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5279 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5281 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5285 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5287 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5291 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5293 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5297 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5299 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5303 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5305 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5309 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5311 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5315 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5317 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5321 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5323 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5327 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5329 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5333 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5335 struct crypto_testsuite_params *ts_params = &testsuite_params;
5336 struct crypto_unittest_params *ut_params = &unittest_params;
5339 uint8_t *ciphertext, *auth_tag;
5340 uint16_t plaintext_pad_len;
5342 /* Create GCM session */
5343 retval = create_gcm_session(ts_params->valid_devs[0],
5344 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5345 tdata->key.data, tdata->key.len,
5346 tdata->aad.len, tdata->auth_tag.len,
5347 RTE_CRYPTO_AUTH_OP_GENERATE);
5351 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5352 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5354 /* clear mbuf payload */
5355 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5356 rte_pktmbuf_tailroom(ut_params->ibuf));
5357 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5358 rte_pktmbuf_tailroom(ut_params->obuf));
5360 /* Create GCM operation */
5361 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5365 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5367 ut_params->op->sym->m_src = ut_params->ibuf;
5368 ut_params->op->sym->m_dst = ut_params->obuf;
5370 /* Process crypto operation */
5371 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5372 ut_params->op), "failed to process sym crypto op");
5374 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5375 "crypto op processing failed");
5377 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5379 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5380 ut_params->op->sym->cipher.data.offset);
5381 auth_tag = ciphertext + plaintext_pad_len;
5383 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5384 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5387 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5389 tdata->ciphertext.data,
5390 tdata->ciphertext.len,
5391 "GCM Ciphertext data not as expected");
5393 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5395 tdata->auth_tag.data,
5396 tdata->auth_tag.len,
5397 "GCM Generated auth tag not as expected");
5404 test_mb_AES_GCM_authenticated_encryption_oop(void)
5406 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5410 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5412 struct crypto_testsuite_params *ts_params = &testsuite_params;
5413 struct crypto_unittest_params *ut_params = &unittest_params;
5418 /* Create GCM session */
5419 retval = create_gcm_session(ts_params->valid_devs[0],
5420 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5421 tdata->key.data, tdata->key.len,
5422 tdata->aad.len, tdata->auth_tag.len,
5423 RTE_CRYPTO_AUTH_OP_VERIFY);
5427 /* alloc mbuf and set payload */
5428 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5429 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5431 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5432 rte_pktmbuf_tailroom(ut_params->ibuf));
5433 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5434 rte_pktmbuf_tailroom(ut_params->obuf));
5436 /* Create GCM operation */
5437 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5441 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5443 ut_params->op->sym->m_src = ut_params->ibuf;
5444 ut_params->op->sym->m_dst = ut_params->obuf;
5446 /* Process crypto operation */
5447 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5448 ut_params->op), "failed to process sym crypto op");
5450 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5451 "crypto op processing failed");
5453 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5454 ut_params->op->sym->cipher.data.offset);
5456 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5459 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5461 tdata->plaintext.data,
5462 tdata->plaintext.len,
5463 "GCM plaintext data not as expected");
5465 TEST_ASSERT_EQUAL(ut_params->op->status,
5466 RTE_CRYPTO_OP_STATUS_SUCCESS,
5467 "GCM authentication failed");
5472 test_mb_AES_GCM_authenticated_decryption_oop(void)
5474 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5478 test_AES_GCM_authenticated_encryption_sessionless(
5479 const struct gcm_test_data *tdata)
5481 struct crypto_testsuite_params *ts_params = &testsuite_params;
5482 struct crypto_unittest_params *ut_params = &unittest_params;
5485 uint8_t *ciphertext, *auth_tag;
5486 uint16_t plaintext_pad_len;
5487 uint8_t key[tdata->key.len + 1];
5489 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5491 /* clear mbuf payload */
5492 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5493 rte_pktmbuf_tailroom(ut_params->ibuf));
5495 /* Create GCM operation */
5496 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5500 /* Create GCM xforms */
5501 memcpy(key, tdata->key.data, tdata->key.len);
5502 retval = create_gcm_xforms(ut_params->op,
5503 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5504 key, tdata->key.len,
5505 tdata->aad.len, tdata->auth_tag.len,
5506 RTE_CRYPTO_AUTH_OP_GENERATE);
5510 ut_params->op->sym->m_src = ut_params->ibuf;
5512 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5513 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5514 "crypto op session type not sessionless");
5516 /* Process crypto operation */
5517 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5518 ut_params->op), "failed to process sym crypto op");
5520 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5522 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5523 "crypto op status not success");
5525 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5527 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5528 ut_params->op->sym->cipher.data.offset);
5529 auth_tag = ciphertext + plaintext_pad_len;
5531 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5532 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5537 tdata->ciphertext.data,
5538 tdata->ciphertext.len,
5539 "GCM Ciphertext data not as expected");
5541 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5543 tdata->auth_tag.data,
5544 tdata->auth_tag.len,
5545 "GCM Generated auth tag not as expected");
5552 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5554 return test_AES_GCM_authenticated_encryption_sessionless(
5559 test_AES_GCM_authenticated_decryption_sessionless(
5560 const struct gcm_test_data *tdata)
5562 struct crypto_testsuite_params *ts_params = &testsuite_params;
5563 struct crypto_unittest_params *ut_params = &unittest_params;
5567 uint8_t key[tdata->key.len + 1];
5569 /* alloc mbuf and set payload */
5570 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5572 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5573 rte_pktmbuf_tailroom(ut_params->ibuf));
5575 /* Create GCM operation */
5576 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5580 /* Create GCM xforms */
5581 memcpy(key, tdata->key.data, tdata->key.len);
5582 retval = create_gcm_xforms(ut_params->op,
5583 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5584 key, tdata->key.len,
5585 tdata->aad.len, tdata->auth_tag.len,
5586 RTE_CRYPTO_AUTH_OP_VERIFY);
5590 ut_params->op->sym->m_src = ut_params->ibuf;
5592 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5593 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5594 "crypto op session type not sessionless");
5596 /* Process crypto operation */
5597 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5598 ut_params->op), "failed to process sym crypto op");
5600 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5602 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5603 "crypto op status not success");
5605 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5606 ut_params->op->sym->cipher.data.offset);
5608 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5611 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5613 tdata->plaintext.data,
5614 tdata->plaintext.len,
5615 "GCM plaintext data not as expected");
5617 TEST_ASSERT_EQUAL(ut_params->op->status,
5618 RTE_CRYPTO_OP_STATUS_SUCCESS,
5619 "GCM authentication failed");
5624 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5626 return test_AES_GCM_authenticated_decryption_sessionless(
5633 struct crypto_testsuite_params *ts_params = &testsuite_params;
5634 struct rte_cryptodev_stats stats;
5635 struct rte_cryptodev *dev;
5636 cryptodev_stats_get_t temp_pfn;
5638 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5639 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5640 &stats) == -ENODEV),
5641 "rte_cryptodev_stats_get invalid dev failed");
5642 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5643 "rte_cryptodev_stats_get invalid Param failed");
5644 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5645 temp_pfn = dev->dev_ops->stats_get;
5646 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5647 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5649 "rte_cryptodev_stats_get invalid Param failed");
5650 dev->dev_ops->stats_get = temp_pfn;
5652 /* Test expected values */
5654 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5656 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5658 "rte_cryptodev_stats_get failed");
5659 TEST_ASSERT((stats.enqueued_count == 1),
5660 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5661 TEST_ASSERT((stats.dequeued_count == 1),
5662 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5663 TEST_ASSERT((stats.enqueue_err_count == 0),
5664 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5665 TEST_ASSERT((stats.dequeue_err_count == 0),
5666 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5668 /* invalid device but should ignore and not reset device stats*/
5669 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5670 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5672 "rte_cryptodev_stats_get failed");
5673 TEST_ASSERT((stats.enqueued_count == 1),
5674 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5676 /* check that a valid reset clears stats */
5677 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5678 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5680 "rte_cryptodev_stats_get failed");
5681 TEST_ASSERT((stats.enqueued_count == 0),
5682 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5683 TEST_ASSERT((stats.dequeued_count == 0),
5684 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5686 return TEST_SUCCESS;
5689 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5690 struct crypto_unittest_params *ut_params,
5691 enum rte_crypto_auth_operation op,
5692 const struct HMAC_MD5_vector *test_case)
5696 memcpy(key, test_case->key.data, test_case->key.len);
5698 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5699 ut_params->auth_xform.next = NULL;
5700 ut_params->auth_xform.auth.op = op;
5702 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5704 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5705 ut_params->auth_xform.auth.add_auth_data_length = 0;
5706 ut_params->auth_xform.auth.key.length = test_case->key.len;
5707 ut_params->auth_xform.auth.key.data = key;
5709 ut_params->sess = rte_cryptodev_sym_session_create(
5710 ts_params->valid_devs[0], &ut_params->auth_xform);
5712 if (ut_params->sess == NULL)
5715 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5717 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5718 rte_pktmbuf_tailroom(ut_params->ibuf));
5723 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5724 const struct HMAC_MD5_vector *test_case,
5725 uint8_t **plaintext)
5727 uint16_t plaintext_pad_len;
5729 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5731 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5734 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5736 memcpy(*plaintext, test_case->plaintext.data,
5737 test_case->plaintext.len);
5739 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5740 ut_params->ibuf, MD5_DIGEST_LEN);
5741 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5742 "no room to append digest");
5743 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5744 ut_params->ibuf, plaintext_pad_len);
5745 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5747 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5748 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5749 test_case->auth_tag.len);
5752 sym_op->auth.data.offset = 0;
5753 sym_op->auth.data.length = test_case->plaintext.len;
5755 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5756 ut_params->op->sym->m_src = ut_params->ibuf;
5762 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5764 uint16_t plaintext_pad_len;
5765 uint8_t *plaintext, *auth_tag;
5767 struct crypto_testsuite_params *ts_params = &testsuite_params;
5768 struct crypto_unittest_params *ut_params = &unittest_params;
5770 if (MD5_HMAC_create_session(ts_params, ut_params,
5771 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5774 /* Generate Crypto op data structure */
5775 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5776 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5777 TEST_ASSERT_NOT_NULL(ut_params->op,
5778 "Failed to allocate symmetric crypto operation struct");
5780 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5783 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5786 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5787 ut_params->op), "failed to process sym crypto op");
5789 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5790 "crypto op processing failed");
5792 if (ut_params->op->sym->m_dst) {
5793 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5794 uint8_t *, plaintext_pad_len);
5796 auth_tag = plaintext + plaintext_pad_len;
5799 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5801 test_case->auth_tag.data,
5802 test_case->auth_tag.len,
5803 "HMAC_MD5 generated tag not as expected");
5805 return TEST_SUCCESS;
5809 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5813 struct crypto_testsuite_params *ts_params = &testsuite_params;
5814 struct crypto_unittest_params *ut_params = &unittest_params;
5816 if (MD5_HMAC_create_session(ts_params, ut_params,
5817 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5821 /* Generate Crypto op data structure */
5822 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5823 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5824 TEST_ASSERT_NOT_NULL(ut_params->op,
5825 "Failed to allocate symmetric crypto operation struct");
5827 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5830 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5831 ut_params->op), "failed to process sym crypto op");
5833 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5834 "HMAC_MD5 crypto op processing failed");
5836 return TEST_SUCCESS;
5840 test_MD5_HMAC_generate_case_1(void)
5842 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5846 test_MD5_HMAC_verify_case_1(void)
5848 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5852 test_MD5_HMAC_generate_case_2(void)
5854 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5858 test_MD5_HMAC_verify_case_2(void)
5860 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5864 test_multi_session(void)
5866 struct crypto_testsuite_params *ts_params = &testsuite_params;
5867 struct crypto_unittest_params *ut_params = &unittest_params;
5869 struct rte_cryptodev_info dev_info;
5870 struct rte_cryptodev_sym_session **sessions;
5874 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5875 aes_cbc_key, hmac_sha512_key);
5878 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5880 sessions = rte_malloc(NULL,
5881 (sizeof(struct rte_cryptodev_sym_session *) *
5882 dev_info.sym.max_nb_sessions) + 1, 0);
5884 /* Create multiple crypto sessions*/
5885 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5886 sessions[i] = rte_cryptodev_sym_session_create(
5887 ts_params->valid_devs[0],
5888 &ut_params->auth_xform);
5889 TEST_ASSERT_NOT_NULL(sessions[i],
5890 "Session creation failed at session number %u",
5893 /* Attempt to send a request on each session */
5894 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5898 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5899 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5901 "Failed to perform decrypt on request number %u.", i);
5902 /* free crypto operation structure */
5904 rte_crypto_op_free(ut_params->op);
5907 * free mbuf - both obuf and ibuf are usually the same,
5908 * so check if they point at the same address is necessary,
5909 * to avoid freeing the mbuf twice.
5911 if (ut_params->obuf) {
5912 rte_pktmbuf_free(ut_params->obuf);
5913 if (ut_params->ibuf == ut_params->obuf)
5914 ut_params->ibuf = 0;
5915 ut_params->obuf = 0;
5917 if (ut_params->ibuf) {
5918 rte_pktmbuf_free(ut_params->ibuf);
5919 ut_params->ibuf = 0;
5923 /* Next session create should fail */
5924 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5925 &ut_params->auth_xform);
5926 TEST_ASSERT_NULL(sessions[i],
5927 "Session creation succeeded unexpectedly!");
5929 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5930 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5935 return TEST_SUCCESS;
5938 struct multi_session_params {
5939 struct crypto_unittest_params ut_params;
5940 uint8_t *cipher_key;
5942 const uint8_t *cipher;
5943 const uint8_t *digest;
5947 #define MB_SESSION_NUMBER 3
5950 test_multi_session_random_usage(void)
5952 struct crypto_testsuite_params *ts_params = &testsuite_params;
5953 struct rte_cryptodev_info dev_info;
5954 struct rte_cryptodev_sym_session **sessions;
5956 struct multi_session_params ut_paramz[] = {
5959 .cipher_key = ms_aes_cbc_key0,
5960 .hmac_key = ms_hmac_key0,
5961 .cipher = ms_aes_cbc_cipher0,
5962 .digest = ms_hmac_digest0,
5963 .iv = ms_aes_cbc_iv0
5966 .cipher_key = ms_aes_cbc_key1,
5967 .hmac_key = ms_hmac_key1,
5968 .cipher = ms_aes_cbc_cipher1,
5969 .digest = ms_hmac_digest1,
5970 .iv = ms_aes_cbc_iv1
5973 .cipher_key = ms_aes_cbc_key2,
5974 .hmac_key = ms_hmac_key2,
5975 .cipher = ms_aes_cbc_cipher2,
5976 .digest = ms_hmac_digest2,
5977 .iv = ms_aes_cbc_iv2
5982 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5984 sessions = rte_malloc(NULL,
5985 (sizeof(struct rte_cryptodev_sym_session *)
5986 * dev_info.sym.max_nb_sessions) + 1, 0);
5988 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5989 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5990 sizeof(struct crypto_unittest_params));
5992 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5993 &ut_paramz[i].ut_params,
5994 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5996 /* Create multiple crypto sessions*/
5997 sessions[i] = rte_cryptodev_sym_session_create(
5998 ts_params->valid_devs[0],
5999 &ut_paramz[i].ut_params.auth_xform);
6001 TEST_ASSERT_NOT_NULL(sessions[i],
6002 "Session creation failed at session number %u",
6008 for (i = 0; i < 40000; i++) {
6010 j = rand() % MB_SESSION_NUMBER;
6012 TEST_ASSERT_SUCCESS(
6013 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6015 &ut_paramz[j].ut_params,
6016 ts_params, ut_paramz[j].cipher,
6017 ut_paramz[j].digest,
6019 "Failed to perform decrypt on request number %u.", i);
6021 if (ut_paramz[j].ut_params.op)
6022 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6025 * free mbuf - both obuf and ibuf are usually the same,
6026 * so check if they point at the same address is necessary,
6027 * to avoid freeing the mbuf twice.
6029 if (ut_paramz[j].ut_params.obuf) {
6030 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6031 if (ut_paramz[j].ut_params.ibuf
6032 == ut_paramz[j].ut_params.obuf)
6033 ut_paramz[j].ut_params.ibuf = 0;
6034 ut_paramz[j].ut_params.obuf = 0;
6036 if (ut_paramz[j].ut_params.ibuf) {
6037 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6038 ut_paramz[j].ut_params.ibuf = 0;
6042 for (i = 0; i < MB_SESSION_NUMBER; i++)
6043 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
6048 return TEST_SUCCESS;
6052 test_null_cipher_only_operation(void)
6054 struct crypto_testsuite_params *ts_params = &testsuite_params;
6055 struct crypto_unittest_params *ut_params = &unittest_params;
6057 /* Generate test mbuf data and space for digest */
6058 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6059 catch_22_quote, QUOTE_512_BYTES, 0);
6061 /* Setup Cipher Parameters */
6062 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6063 ut_params->cipher_xform.next = NULL;
6065 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6066 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6068 /* Create Crypto session*/
6069 ut_params->sess = rte_cryptodev_sym_session_create(
6070 ts_params->valid_devs[0], &ut_params->cipher_xform);
6071 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6073 /* Generate Crypto op data structure */
6074 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6075 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6076 TEST_ASSERT_NOT_NULL(ut_params->op,
6077 "Failed to allocate symmetric crypto operation struct");
6079 /* Set crypto operation data parameters */
6080 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6082 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6084 /* set crypto operation source mbuf */
6085 sym_op->m_src = ut_params->ibuf;
6087 sym_op->cipher.data.offset = 0;
6088 sym_op->cipher.data.length = QUOTE_512_BYTES;
6090 /* Process crypto operation */
6091 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6093 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6095 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6096 "crypto operation processing failed");
6099 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6100 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6103 "Ciphertext data not as expected");
6105 return TEST_SUCCESS;
6109 test_null_auth_only_operation(void)
6111 struct crypto_testsuite_params *ts_params = &testsuite_params;
6112 struct crypto_unittest_params *ut_params = &unittest_params;
6114 /* Generate test mbuf data and space for digest */
6115 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6116 catch_22_quote, QUOTE_512_BYTES, 0);
6118 /* Setup HMAC Parameters */
6119 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6120 ut_params->auth_xform.next = NULL;
6122 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6123 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6125 /* Create Crypto session*/
6126 ut_params->sess = rte_cryptodev_sym_session_create(
6127 ts_params->valid_devs[0], &ut_params->auth_xform);
6128 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6130 /* Generate Crypto op data structure */
6131 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6132 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6133 TEST_ASSERT_NOT_NULL(ut_params->op,
6134 "Failed to allocate symmetric crypto operation struct");
6136 /* Set crypto operation data parameters */
6137 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6139 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6141 sym_op->m_src = ut_params->ibuf;
6143 sym_op->auth.data.offset = 0;
6144 sym_op->auth.data.length = QUOTE_512_BYTES;
6146 /* Process crypto operation */
6147 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6149 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6151 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6152 "crypto operation processing failed");
6154 return TEST_SUCCESS;
6158 test_null_cipher_auth_operation(void)
6160 struct crypto_testsuite_params *ts_params = &testsuite_params;
6161 struct crypto_unittest_params *ut_params = &unittest_params;
6163 /* Generate test mbuf data and space for digest */
6164 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6165 catch_22_quote, QUOTE_512_BYTES, 0);
6167 /* Setup Cipher Parameters */
6168 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6169 ut_params->cipher_xform.next = &ut_params->auth_xform;
6171 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6172 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6174 /* Setup HMAC Parameters */
6175 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6176 ut_params->auth_xform.next = NULL;
6178 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6179 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6181 /* Create Crypto session*/
6182 ut_params->sess = rte_cryptodev_sym_session_create(
6183 ts_params->valid_devs[0], &ut_params->cipher_xform);
6184 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6186 /* Generate Crypto op data structure */
6187 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6188 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6189 TEST_ASSERT_NOT_NULL(ut_params->op,
6190 "Failed to allocate symmetric crypto operation struct");
6192 /* Set crypto operation data parameters */
6193 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6195 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6197 sym_op->m_src = ut_params->ibuf;
6199 sym_op->cipher.data.offset = 0;
6200 sym_op->cipher.data.length = QUOTE_512_BYTES;
6202 sym_op->auth.data.offset = 0;
6203 sym_op->auth.data.length = QUOTE_512_BYTES;
6205 /* Process crypto operation */
6206 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6208 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6210 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6211 "crypto operation processing failed");
6214 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6215 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6218 "Ciphertext data not as expected");
6220 return TEST_SUCCESS;
6224 test_null_auth_cipher_operation(void)
6226 struct crypto_testsuite_params *ts_params = &testsuite_params;
6227 struct crypto_unittest_params *ut_params = &unittest_params;
6229 /* Generate test mbuf data and space for digest */
6230 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6231 catch_22_quote, QUOTE_512_BYTES, 0);
6233 /* Setup Cipher Parameters */
6234 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6235 ut_params->cipher_xform.next = NULL;
6237 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6238 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6240 /* Setup HMAC Parameters */
6241 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6242 ut_params->auth_xform.next = &ut_params->cipher_xform;
6244 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6245 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6247 /* Create Crypto session*/
6248 ut_params->sess = rte_cryptodev_sym_session_create(
6249 ts_params->valid_devs[0], &ut_params->cipher_xform);
6250 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6252 /* Generate Crypto op data structure */
6253 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6254 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6255 TEST_ASSERT_NOT_NULL(ut_params->op,
6256 "Failed to allocate symmetric crypto operation struct");
6258 /* Set crypto operation data parameters */
6259 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6261 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6263 sym_op->m_src = ut_params->ibuf;
6265 sym_op->cipher.data.offset = 0;
6266 sym_op->cipher.data.length = QUOTE_512_BYTES;
6268 sym_op->auth.data.offset = 0;
6269 sym_op->auth.data.length = QUOTE_512_BYTES;
6271 /* Process crypto operation */
6272 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6274 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6276 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6277 "crypto operation processing failed");
6280 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6281 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6284 "Ciphertext data not as expected");
6286 return TEST_SUCCESS;
6291 test_null_invalid_operation(void)
6293 struct crypto_testsuite_params *ts_params = &testsuite_params;
6294 struct crypto_unittest_params *ut_params = &unittest_params;
6296 /* Setup Cipher Parameters */
6297 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6298 ut_params->cipher_xform.next = NULL;
6300 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6301 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6303 /* Create Crypto session*/
6304 ut_params->sess = rte_cryptodev_sym_session_create(
6305 ts_params->valid_devs[0], &ut_params->cipher_xform);
6306 TEST_ASSERT_NULL(ut_params->sess,
6307 "Session creation succeeded unexpectedly");
6310 /* Setup HMAC Parameters */
6311 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6312 ut_params->auth_xform.next = NULL;
6314 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6315 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6317 /* Create Crypto session*/
6318 ut_params->sess = rte_cryptodev_sym_session_create(
6319 ts_params->valid_devs[0], &ut_params->auth_xform);
6320 TEST_ASSERT_NULL(ut_params->sess,
6321 "Session creation succeeded unexpectedly");
6323 return TEST_SUCCESS;
6327 #define NULL_BURST_LENGTH (32)
6330 test_null_burst_operation(void)
6332 struct crypto_testsuite_params *ts_params = &testsuite_params;
6333 struct crypto_unittest_params *ut_params = &unittest_params;
6335 unsigned i, burst_len = NULL_BURST_LENGTH;
6337 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6338 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6340 /* Setup Cipher Parameters */
6341 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6342 ut_params->cipher_xform.next = &ut_params->auth_xform;
6344 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6345 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6347 /* Setup HMAC Parameters */
6348 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6349 ut_params->auth_xform.next = NULL;
6351 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6352 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6354 /* Create Crypto session*/
6355 ut_params->sess = rte_cryptodev_sym_session_create(
6356 ts_params->valid_devs[0], &ut_params->cipher_xform);
6357 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6359 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6360 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6361 burst_len, "failed to generate burst of crypto ops");
6363 /* Generate an operation for each mbuf in burst */
6364 for (i = 0; i < burst_len; i++) {
6365 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6367 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6369 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6373 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6375 burst[i]->sym->m_src = m;
6378 /* Process crypto operation */
6379 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6380 0, burst, burst_len),
6382 "Error enqueuing burst");
6384 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6385 0, burst_dequeued, burst_len),
6387 "Error dequeuing burst");
6390 for (i = 0; i < burst_len; i++) {
6392 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6393 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6395 "data not as expected");
6397 rte_pktmbuf_free(burst[i]->sym->m_src);
6398 rte_crypto_op_free(burst[i]);
6401 return TEST_SUCCESS;
6405 generate_gmac_large_plaintext(uint8_t *data)
6409 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6410 memcpy(&data[i], &data[0], 32);
6414 create_gmac_operation(enum rte_crypto_auth_operation op,
6415 const struct gmac_test_data *tdata)
6417 struct crypto_testsuite_params *ts_params = &testsuite_params;
6418 struct crypto_unittest_params *ut_params = &unittest_params;
6419 struct rte_crypto_sym_op *sym_op;
6421 unsigned iv_pad_len;
6422 unsigned aad_pad_len;
6424 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
6425 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6428 * Runtime generate the large plain text instead of use hard code
6429 * plain text vector. It is done to avoid create huge source file
6430 * with the test vector.
6432 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6433 generate_gmac_large_plaintext(tdata->aad.data);
6435 /* Generate Crypto op data structure */
6436 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6437 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6438 TEST_ASSERT_NOT_NULL(ut_params->op,
6439 "Failed to allocate symmetric crypto operation struct");
6441 sym_op = ut_params->op->sym;
6442 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6444 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6445 "no room to append aad");
6447 sym_op->auth.aad.length = tdata->aad.len;
6448 sym_op->auth.aad.phys_addr =
6449 rte_pktmbuf_mtophys(ut_params->ibuf);
6450 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6452 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6453 ut_params->ibuf, tdata->gmac_tag.len);
6454 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6455 "no room to append digest");
6457 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6458 ut_params->ibuf, aad_pad_len);
6459 sym_op->auth.digest.length = tdata->gmac_tag.len;
6461 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6462 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6463 tdata->gmac_tag.len);
6464 TEST_HEXDUMP(stdout, "digest:",
6465 sym_op->auth.digest.data,
6466 sym_op->auth.digest.length);
6469 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6470 ut_params->ibuf, iv_pad_len);
6471 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6473 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6474 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6475 sym_op->cipher.iv.length = tdata->iv.len;
6477 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
6479 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6481 sym_op->cipher.data.length = 0;
6482 sym_op->cipher.data.offset = 0;
6484 sym_op->auth.data.offset = 0;
6485 sym_op->auth.data.length = 0;
6490 static int create_gmac_session(uint8_t dev_id,
6491 enum rte_crypto_cipher_operation op,
6492 const struct gmac_test_data *tdata,
6493 enum rte_crypto_auth_operation auth_op)
6495 uint8_t cipher_key[tdata->key.len];
6497 struct crypto_unittest_params *ut_params = &unittest_params;
6499 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6501 /* For GMAC we setup cipher parameters */
6502 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6503 ut_params->cipher_xform.next = NULL;
6504 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6505 ut_params->cipher_xform.cipher.op = op;
6506 ut_params->cipher_xform.cipher.key.data = cipher_key;
6507 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6509 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6510 ut_params->auth_xform.next = NULL;
6512 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6513 ut_params->auth_xform.auth.op = auth_op;
6514 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6515 ut_params->auth_xform.auth.add_auth_data_length = 0;
6516 ut_params->auth_xform.auth.key.length = 0;
6517 ut_params->auth_xform.auth.key.data = NULL;
6519 ut_params->cipher_xform.next = &ut_params->auth_xform;
6521 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6522 &ut_params->cipher_xform);
6524 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6530 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6532 struct crypto_testsuite_params *ts_params = &testsuite_params;
6533 struct crypto_unittest_params *ut_params = &unittest_params;
6537 uint8_t *auth_tag, *p;
6538 uint16_t aad_pad_len;
6540 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6541 "No GMAC length in the source data");
6543 retval = create_gmac_session(ts_params->valid_devs[0],
6544 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6545 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6550 if (tdata->aad.len > MBUF_SIZE)
6551 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6553 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6554 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6555 "Failed to allocate input buffer in mempool");
6557 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6558 rte_pktmbuf_tailroom(ut_params->ibuf));
6560 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6562 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6564 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6570 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6572 ut_params->op->sym->m_src = ut_params->ibuf;
6574 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6575 ut_params->op), "failed to process sym crypto op");
6577 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6578 "crypto op processing failed");
6580 if (ut_params->op->sym->m_dst) {
6581 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6582 uint8_t *, aad_pad_len);
6584 auth_tag = p + aad_pad_len;
6587 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6589 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6591 tdata->gmac_tag.data,
6592 tdata->gmac_tag.len,
6593 "GMAC Generated auth tag not as expected");
6599 test_AES_GMAC_authentication_test_case_1(void)
6601 return test_AES_GMAC_authentication(&gmac_test_case_1);
6605 test_AES_GMAC_authentication_test_case_2(void)
6607 return test_AES_GMAC_authentication(&gmac_test_case_2);
6611 test_AES_GMAC_authentication_test_case_3(void)
6613 return test_AES_GMAC_authentication(&gmac_test_case_3);
6617 test_AES_GMAC_authentication_test_case_4(void)
6619 return test_AES_GMAC_authentication(&gmac_test_case_4);
6623 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6625 struct crypto_testsuite_params *ts_params = &testsuite_params;
6626 struct crypto_unittest_params *ut_params = &unittest_params;
6629 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6630 "No GMAC length in the source data");
6632 retval = create_gmac_session(ts_params->valid_devs[0],
6633 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6634 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6639 if (tdata->aad.len > MBUF_SIZE)
6640 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6642 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6643 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6644 "Failed to allocate input buffer in mempool");
6646 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6647 rte_pktmbuf_tailroom(ut_params->ibuf));
6649 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6655 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6657 ut_params->op->sym->m_src = ut_params->ibuf;
6659 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6660 ut_params->op), "failed to process sym crypto op");
6662 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6663 "crypto op processing failed");
6670 test_AES_GMAC_authentication_verify_test_case_1(void)
6672 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6676 test_AES_GMAC_authentication_verify_test_case_2(void)
6678 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6682 test_AES_GMAC_authentication_verify_test_case_3(void)
6684 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6688 test_AES_GMAC_authentication_verify_test_case_4(void)
6690 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6693 struct test_crypto_vector {
6694 enum rte_crypto_cipher_algorithm crypto_algo;
6707 const uint8_t *data;
6712 const uint8_t *data;
6716 enum rte_crypto_auth_algorithm auth_algo;
6724 const uint8_t *data;
6734 static const struct test_crypto_vector
6735 hmac_sha1_test_crypto_vector = {
6736 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6738 .data = plaintext_hash,
6743 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6744 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6745 0xDE, 0xF4, 0xDE, 0xAD
6751 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6752 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6753 0x3F, 0x91, 0x64, 0x59
6759 static const struct test_crypto_vector
6760 aes128_gmac_test_vector = {
6761 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6762 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6764 .data = plaintext_hash,
6769 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6770 0x08, 0x09, 0x0A, 0x0B
6776 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6777 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6783 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6784 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6790 static const struct test_crypto_vector
6791 aes128cbc_hmac_sha1_test_vector = {
6792 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6795 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6796 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6802 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6803 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6808 .data = plaintext_hash,
6812 .data = ciphertext512_aes128cbc,
6815 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6818 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6819 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6820 0xDE, 0xF4, 0xDE, 0xAD
6826 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6827 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6828 0x18, 0x8C, 0x1D, 0x32
6835 data_corruption(uint8_t *data)
6841 tag_corruption(uint8_t *data, unsigned int tag_offset)
6843 data[tag_offset] += 1;
6847 create_auth_session(struct crypto_unittest_params *ut_params,
6849 const struct test_crypto_vector *reference,
6850 enum rte_crypto_auth_operation auth_op)
6852 uint8_t auth_key[reference->auth_key.len + 1];
6854 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6856 /* Setup Authentication Parameters */
6857 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6858 ut_params->auth_xform.auth.op = auth_op;
6859 ut_params->auth_xform.next = NULL;
6860 ut_params->auth_xform.auth.algo = reference->auth_algo;
6861 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6862 ut_params->auth_xform.auth.key.data = auth_key;
6863 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6864 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6866 /* Create Crypto session*/
6867 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6868 &ut_params->auth_xform);
6870 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6876 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6878 const struct test_crypto_vector *reference,
6879 enum rte_crypto_auth_operation auth_op,
6880 enum rte_crypto_cipher_operation cipher_op)
6882 uint8_t cipher_key[reference->cipher_key.len + 1];
6883 uint8_t auth_key[reference->auth_key.len + 1];
6885 memcpy(cipher_key, reference->cipher_key.data,
6886 reference->cipher_key.len);
6887 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6889 /* Setup Authentication Parameters */
6890 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6891 ut_params->auth_xform.auth.op = auth_op;
6892 ut_params->auth_xform.next = &ut_params->cipher_xform;
6893 ut_params->auth_xform.auth.algo = reference->auth_algo;
6894 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6895 ut_params->auth_xform.auth.key.data = auth_key;
6896 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6897 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6899 /* Setup Cipher Parameters */
6900 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6901 ut_params->cipher_xform.next = NULL;
6902 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6903 ut_params->cipher_xform.cipher.op = cipher_op;
6904 ut_params->cipher_xform.cipher.key.data = cipher_key;
6905 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6907 /* Create Crypto session*/
6908 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6909 &ut_params->auth_xform);
6911 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6917 create_auth_operation(struct crypto_testsuite_params *ts_params,
6918 struct crypto_unittest_params *ut_params,
6919 const struct test_crypto_vector *reference,
6920 unsigned int auth_generate)
6922 /* Generate Crypto op data structure */
6923 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6924 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6925 TEST_ASSERT_NOT_NULL(ut_params->op,
6926 "Failed to allocate pktmbuf offload");
6928 /* Set crypto operation data parameters */
6929 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6931 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6933 /* set crypto operation source mbuf */
6934 sym_op->m_src = ut_params->ibuf;
6937 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6938 ut_params->ibuf, reference->digest.len);
6940 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6941 "no room to append auth tag");
6943 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6944 ut_params->ibuf, reference->plaintext.len);
6945 sym_op->auth.digest.length = reference->digest.len;
6948 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6950 memcpy(sym_op->auth.digest.data,
6951 reference->digest.data,
6952 reference->digest.len);
6954 TEST_HEXDUMP(stdout, "digest:",
6955 sym_op->auth.digest.data,
6956 sym_op->auth.digest.length);
6958 sym_op->auth.data.length = reference->plaintext.len;
6959 sym_op->auth.data.offset = 0;
6965 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6966 struct crypto_unittest_params *ut_params,
6967 const struct test_crypto_vector *reference,
6968 unsigned int auth_generate)
6970 /* Generate Crypto op data structure */
6971 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6972 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6973 TEST_ASSERT_NOT_NULL(ut_params->op,
6974 "Failed to allocate pktmbuf offload");
6976 /* Set crypto operation data parameters */
6977 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6979 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6981 /* set crypto operation source mbuf */
6982 sym_op->m_src = ut_params->ibuf;
6985 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6986 reference->aad.len);
6987 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6988 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6990 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6992 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6993 sym_op->auth.aad.length = reference->aad.len;
6996 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6997 ut_params->ibuf, reference->digest.len);
6999 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7000 "no room to append auth tag");
7002 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7003 ut_params->ibuf, reference->ciphertext.len);
7004 sym_op->auth.digest.length = reference->digest.len;
7007 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7009 memcpy(sym_op->auth.digest.data,
7010 reference->digest.data,
7011 reference->digest.len);
7013 TEST_HEXDUMP(stdout, "digest:",
7014 sym_op->auth.digest.data,
7015 sym_op->auth.digest.length);
7017 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
7018 ut_params->ibuf, reference->iv.len);
7019 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
7021 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
7022 sym_op->cipher.iv.length = reference->iv.len;
7024 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
7026 sym_op->cipher.data.length = 0;
7027 sym_op->cipher.data.offset = 0;
7029 sym_op->auth.data.length = 0;
7030 sym_op->auth.data.offset = 0;
7036 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7037 struct crypto_unittest_params *ut_params,
7038 const struct test_crypto_vector *reference,
7039 unsigned int auth_generate)
7041 /* Generate Crypto op data structure */
7042 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7043 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7044 TEST_ASSERT_NOT_NULL(ut_params->op,
7045 "Failed to allocate pktmbuf offload");
7047 /* Set crypto operation data parameters */
7048 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7050 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7052 /* set crypto operation source mbuf */
7053 sym_op->m_src = ut_params->ibuf;
7056 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7057 ut_params->ibuf, reference->digest.len);
7059 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7060 "no room to append auth tag");
7062 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7063 ut_params->ibuf, reference->ciphertext.len);
7064 sym_op->auth.digest.length = reference->digest.len;
7067 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7069 memcpy(sym_op->auth.digest.data,
7070 reference->digest.data,
7071 reference->digest.len);
7073 TEST_HEXDUMP(stdout, "digest:",
7074 sym_op->auth.digest.data,
7075 sym_op->auth.digest.length);
7077 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
7078 ut_params->ibuf, reference->iv.len);
7079 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
7081 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
7082 sym_op->cipher.iv.length = reference->iv.len;
7084 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
7086 sym_op->cipher.data.length = reference->ciphertext.len;
7087 sym_op->cipher.data.offset = reference->iv.len;
7089 sym_op->auth.data.length = reference->ciphertext.len;
7090 sym_op->auth.data.offset = reference->iv.len;
7096 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7097 struct crypto_unittest_params *ut_params,
7098 const struct test_crypto_vector *reference)
7100 return create_auth_operation(ts_params, ut_params, reference, 0);
7104 create_auth_verify_GMAC_operation(
7105 struct crypto_testsuite_params *ts_params,
7106 struct crypto_unittest_params *ut_params,
7107 const struct test_crypto_vector *reference)
7109 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7113 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7114 struct crypto_unittest_params *ut_params,
7115 const struct test_crypto_vector *reference)
7117 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7121 test_authentication_verify_fail_when_data_corruption(
7122 struct crypto_testsuite_params *ts_params,
7123 struct crypto_unittest_params *ut_params,
7124 const struct test_crypto_vector *reference,
7125 unsigned int data_corrupted)
7131 /* Create session */
7132 retval = create_auth_session(ut_params,
7133 ts_params->valid_devs[0],
7135 RTE_CRYPTO_AUTH_OP_VERIFY);
7139 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7140 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7141 "Failed to allocate input buffer in mempool");
7143 /* clear mbuf payload */
7144 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7145 rte_pktmbuf_tailroom(ut_params->ibuf));
7147 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7148 reference->plaintext.len);
7149 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7150 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7152 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7154 /* Create operation */
7155 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7161 data_corruption(plaintext);
7163 tag_corruption(plaintext, reference->plaintext.len);
7165 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7167 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7168 TEST_ASSERT_EQUAL(ut_params->op->status,
7169 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7170 "authentication not failed");
7172 ut_params->obuf = ut_params->op->sym->m_src;
7173 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7179 test_authentication_verify_GMAC_fail_when_corruption(
7180 struct crypto_testsuite_params *ts_params,
7181 struct crypto_unittest_params *ut_params,
7182 const struct test_crypto_vector *reference,
7183 unsigned int data_corrupted)
7187 /* Create session */
7188 retval = create_auth_cipher_session(ut_params,
7189 ts_params->valid_devs[0],
7191 RTE_CRYPTO_AUTH_OP_VERIFY,
7192 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7196 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7197 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7198 "Failed to allocate input buffer in mempool");
7200 /* clear mbuf payload */
7201 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7202 rte_pktmbuf_tailroom(ut_params->ibuf));
7204 /* Create operation */
7205 retval = create_auth_verify_GMAC_operation(ts_params,
7213 data_corruption(ut_params->op->sym->auth.aad.data);
7215 tag_corruption(ut_params->op->sym->auth.aad.data,
7216 reference->aad.len);
7218 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7220 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7221 TEST_ASSERT_EQUAL(ut_params->op->status,
7222 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7223 "authentication not failed");
7225 ut_params->obuf = ut_params->op->sym->m_src;
7226 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7232 test_authenticated_decryption_fail_when_corruption(
7233 struct crypto_testsuite_params *ts_params,
7234 struct crypto_unittest_params *ut_params,
7235 const struct test_crypto_vector *reference,
7236 unsigned int data_corrupted)
7240 uint8_t *ciphertext;
7242 /* Create session */
7243 retval = create_auth_cipher_session(ut_params,
7244 ts_params->valid_devs[0],
7246 RTE_CRYPTO_AUTH_OP_VERIFY,
7247 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7251 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7252 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7253 "Failed to allocate input buffer in mempool");
7255 /* clear mbuf payload */
7256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7257 rte_pktmbuf_tailroom(ut_params->ibuf));
7259 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7260 reference->ciphertext.len);
7261 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7262 memcpy(ciphertext, reference->ciphertext.data,
7263 reference->ciphertext.len);
7265 /* Create operation */
7266 retval = create_cipher_auth_verify_operation(ts_params,
7274 data_corruption(ciphertext);
7276 tag_corruption(ciphertext, reference->ciphertext.len);
7278 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7281 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7282 TEST_ASSERT_EQUAL(ut_params->op->status,
7283 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7284 "authentication not failed");
7286 ut_params->obuf = ut_params->op->sym->m_src;
7287 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7293 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7294 const struct gcm_test_data *tdata,
7295 void *digest_mem, uint64_t digest_phys)
7297 struct crypto_testsuite_params *ts_params = &testsuite_params;
7298 struct crypto_unittest_params *ut_params = &unittest_params;
7300 const unsigned int auth_tag_len = tdata->auth_tag.len;
7301 const unsigned int iv_len = tdata->iv.len;
7302 const unsigned int aad_len = tdata->aad.len;
7304 unsigned int iv_pad_len = 0;
7306 /* Generate Crypto op data structure */
7307 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7308 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7309 TEST_ASSERT_NOT_NULL(ut_params->op,
7310 "Failed to allocate symmetric crypto operation struct");
7312 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7314 sym_op->auth.digest.data = digest_mem;
7316 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7317 "no room to append digest");
7319 sym_op->auth.digest.phys_addr = digest_phys;
7320 sym_op->auth.digest.length = auth_tag_len;
7322 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7323 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7325 TEST_HEXDUMP(stdout, "digest:",
7326 sym_op->auth.digest.data,
7327 sym_op->auth.digest.length);
7330 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
7332 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
7333 ut_params->ibuf, iv_pad_len);
7335 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
7336 "no room to prepend iv");
7338 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
7339 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
7340 sym_op->cipher.iv.length = iv_len;
7342 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
7344 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7345 ut_params->ibuf, aad_len);
7346 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7347 "no room to prepend aad");
7348 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7350 sym_op->auth.aad.length = aad_len;
7352 memset(sym_op->auth.aad.data, 0, aad_len);
7353 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7355 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
7356 TEST_HEXDUMP(stdout, "aad:",
7357 sym_op->auth.aad.data, aad_len);
7359 sym_op->cipher.data.length = tdata->plaintext.len;
7360 sym_op->cipher.data.offset = aad_len + iv_pad_len;
7362 sym_op->auth.data.offset = aad_len + iv_pad_len;
7363 sym_op->auth.data.length = tdata->plaintext.len;
7368 #define SGL_MAX_NO 16
7371 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7372 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7374 struct crypto_testsuite_params *ts_params = &testsuite_params;
7375 struct crypto_unittest_params *ut_params = &unittest_params;
7376 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7379 int to_trn_tbl[SGL_MAX_NO];
7381 unsigned int trn_data = 0;
7382 uint8_t *plaintext, *ciphertext, *auth_tag;
7384 if (fragsz > tdata->plaintext.len)
7385 fragsz = tdata->plaintext.len;
7387 uint16_t plaintext_len = fragsz;
7388 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7390 if (fragsz_oop > tdata->plaintext.len)
7391 frag_size_oop = tdata->plaintext.len;
7394 void *digest_mem = NULL;
7396 uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
7399 if (tdata->plaintext.len % fragsz != 0) {
7400 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7403 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7408 * For out-op-place we need to alloc another mbuf
7411 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7412 rte_pktmbuf_append(ut_params->obuf,
7413 frag_size_oop + prepend_len);
7414 buf_oop = ut_params->obuf;
7417 /* Create GCM session */
7418 retval = create_gcm_session(ts_params->valid_devs[0],
7419 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7420 tdata->key.data, tdata->key.len,
7421 tdata->aad.len, tdata->auth_tag.len,
7422 RTE_CRYPTO_AUTH_OP_GENERATE);
7426 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7428 /* clear mbuf payload */
7429 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7430 rte_pktmbuf_tailroom(ut_params->ibuf));
7432 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7435 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7437 trn_data += plaintext_len;
7439 buf = ut_params->ibuf;
7442 * Loop until no more fragments
7445 while (trn_data < tdata->plaintext.len) {
7447 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7448 (tdata->plaintext.len - trn_data) : fragsz;
7450 to_trn_tbl[ecx++] = to_trn;
7452 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7455 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7456 rte_pktmbuf_tailroom(buf));
7459 if (oop && !fragsz_oop) {
7460 buf_last_oop = buf_oop->next =
7461 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7462 buf_oop = buf_oop->next;
7463 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7464 0, rte_pktmbuf_tailroom(buf_oop));
7465 rte_pktmbuf_append(buf_oop, to_trn);
7468 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7471 memcpy(plaintext, tdata->plaintext.data + trn_data,
7474 if (trn_data == tdata->plaintext.len) {
7477 digest_mem = rte_pktmbuf_append(buf_oop,
7478 tdata->auth_tag.len);
7480 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7481 tdata->auth_tag.len);
7485 uint64_t digest_phys = 0;
7487 ut_params->ibuf->nb_segs = segs;
7490 if (fragsz_oop && oop) {
7494 if (frag_size_oop == tdata->plaintext.len) {
7495 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7496 tdata->auth_tag.len);
7498 digest_phys = rte_pktmbuf_mtophys_offset(
7500 tdata->plaintext.len + prepend_len);
7503 trn_data = frag_size_oop;
7504 while (trn_data < tdata->plaintext.len) {
7507 (tdata->plaintext.len - trn_data <
7509 (tdata->plaintext.len - trn_data) :
7512 to_trn_tbl[ecx++] = to_trn;
7514 buf_last_oop = buf_oop->next =
7515 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7516 buf_oop = buf_oop->next;
7517 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7518 0, rte_pktmbuf_tailroom(buf_oop));
7519 rte_pktmbuf_append(buf_oop, to_trn);
7523 if (trn_data == tdata->plaintext.len) {
7524 digest_mem = rte_pktmbuf_append(buf_oop,
7525 tdata->auth_tag.len);
7529 ut_params->obuf->nb_segs = segs;
7533 * Place digest at the end of the last buffer
7536 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7537 if (oop && buf_last_oop)
7538 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7540 if (!digest_mem && !oop) {
7541 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7542 + tdata->auth_tag.len);
7543 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7544 tdata->plaintext.len);
7547 /* Create GCM opertaion */
7548 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7549 tdata, digest_mem, digest_phys);
7554 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7556 ut_params->op->sym->m_src = ut_params->ibuf;
7558 ut_params->op->sym->m_dst = ut_params->obuf;
7560 /* Process crypto operation */
7561 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7562 ut_params->op), "failed to process sym crypto op");
7564 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7565 "crypto op processing failed");
7568 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7569 uint8_t *, prepend_len);
7571 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7572 uint8_t *, prepend_len);
7576 fragsz = fragsz_oop;
7578 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7580 tdata->ciphertext.data,
7582 "GCM Ciphertext data not as expected");
7584 buf = ut_params->op->sym->m_src->next;
7586 buf = ut_params->op->sym->m_dst->next;
7588 unsigned int off = fragsz;
7592 ciphertext = rte_pktmbuf_mtod(buf,
7595 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7597 tdata->ciphertext.data + off,
7599 "GCM Ciphertext data not as expected");
7601 off += to_trn_tbl[ecx++];
7605 auth_tag = digest_mem;
7606 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7608 tdata->auth_tag.data,
7609 tdata->auth_tag.len,
7610 "GCM Generated auth tag not as expected");
7616 #define OUT_OF_PLACE 1
7619 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7621 return test_AES_GCM_authenticated_encryption_SGL(
7622 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7626 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7628 return test_AES_GCM_authenticated_encryption_SGL(
7629 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7633 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7635 return test_AES_GCM_authenticated_encryption_SGL(
7636 &gcm_test_case_8, OUT_OF_PLACE, 400,
7637 gcm_test_case_8.plaintext.len);
7641 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7644 return test_AES_GCM_authenticated_encryption_SGL(
7645 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7649 test_authentication_verify_fail_when_data_corrupted(
7650 struct crypto_testsuite_params *ts_params,
7651 struct crypto_unittest_params *ut_params,
7652 const struct test_crypto_vector *reference)
7654 return test_authentication_verify_fail_when_data_corruption(
7655 ts_params, ut_params, reference, 1);
7659 test_authentication_verify_fail_when_tag_corrupted(
7660 struct crypto_testsuite_params *ts_params,
7661 struct crypto_unittest_params *ut_params,
7662 const struct test_crypto_vector *reference)
7664 return test_authentication_verify_fail_when_data_corruption(
7665 ts_params, ut_params, reference, 0);
7669 test_authentication_verify_GMAC_fail_when_data_corrupted(
7670 struct crypto_testsuite_params *ts_params,
7671 struct crypto_unittest_params *ut_params,
7672 const struct test_crypto_vector *reference)
7674 return test_authentication_verify_GMAC_fail_when_corruption(
7675 ts_params, ut_params, reference, 1);
7679 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7680 struct crypto_testsuite_params *ts_params,
7681 struct crypto_unittest_params *ut_params,
7682 const struct test_crypto_vector *reference)
7684 return test_authentication_verify_GMAC_fail_when_corruption(
7685 ts_params, ut_params, reference, 0);
7689 test_authenticated_decryption_fail_when_data_corrupted(
7690 struct crypto_testsuite_params *ts_params,
7691 struct crypto_unittest_params *ut_params,
7692 const struct test_crypto_vector *reference)
7694 return test_authenticated_decryption_fail_when_corruption(
7695 ts_params, ut_params, reference, 1);
7699 test_authenticated_decryption_fail_when_tag_corrupted(
7700 struct crypto_testsuite_params *ts_params,
7701 struct crypto_unittest_params *ut_params,
7702 const struct test_crypto_vector *reference)
7704 return test_authenticated_decryption_fail_when_corruption(
7705 ts_params, ut_params, reference, 0);
7709 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7711 return test_authentication_verify_fail_when_data_corrupted(
7712 &testsuite_params, &unittest_params,
7713 &hmac_sha1_test_crypto_vector);
7717 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7719 return test_authentication_verify_fail_when_tag_corrupted(
7720 &testsuite_params, &unittest_params,
7721 &hmac_sha1_test_crypto_vector);
7725 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7727 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7728 &testsuite_params, &unittest_params,
7729 &aes128_gmac_test_vector);
7733 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7735 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7736 &testsuite_params, &unittest_params,
7737 &aes128_gmac_test_vector);
7741 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7743 return test_authenticated_decryption_fail_when_data_corrupted(
7746 &aes128cbc_hmac_sha1_test_vector);
7750 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7752 return test_authenticated_decryption_fail_when_tag_corrupted(
7755 &aes128cbc_hmac_sha1_test_vector);
7758 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7760 /* global AESNI slave IDs for the scheduler test */
7761 uint8_t aesni_ids[2];
7764 test_scheduler_attach_slave_op(void)
7766 struct crypto_testsuite_params *ts_params = &testsuite_params;
7767 uint8_t sched_id = ts_params->valid_devs[0];
7768 uint32_t nb_devs, i, nb_devs_attached = 0;
7771 /* create 2 AESNI_MB if necessary */
7772 nb_devs = rte_cryptodev_count_devtype(
7773 RTE_CRYPTODEV_AESNI_MB_PMD);
7775 for (i = nb_devs; i < 2; i++) {
7776 ret = rte_eal_vdev_init(
7777 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
7779 TEST_ASSERT(ret == 0,
7780 "Failed to create instance %u of"
7782 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7786 /* attach 2 AESNI_MB cdevs */
7787 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7789 struct rte_cryptodev_info info;
7791 rte_cryptodev_info_get(i, &info);
7792 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7795 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7798 TEST_ASSERT(ret == 0,
7799 "Failed to attach device %u of pmd : %s", i,
7800 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7802 aesni_ids[nb_devs_attached] = (uint8_t)i;
7811 test_scheduler_detach_slave_op(void)
7813 struct crypto_testsuite_params *ts_params = &testsuite_params;
7814 uint8_t sched_id = ts_params->valid_devs[0];
7818 for (i = 0; i < 2; i++) {
7819 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7821 TEST_ASSERT(ret == 0,
7822 "Failed to detach device %u", aesni_ids[i]);
7829 test_scheduler_mode_op(void)
7831 struct crypto_testsuite_params *ts_params = &testsuite_params;
7832 uint8_t sched_id = ts_params->valid_devs[0];
7833 struct rte_cryptodev_scheduler_ops op = {0};
7834 struct rte_cryptodev_scheduler dummy_scheduler = {
7835 .description = "dummy scheduler to test mode",
7836 .name = "dummy scheduler",
7837 .mode = CDEV_SCHED_MODE_USERDEFINED,
7842 /* set user defined mode */
7843 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7845 TEST_ASSERT(ret == 0,
7846 "Failed to set cdev %u to user defined mode", sched_id);
7848 /* set round robin mode */
7849 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7850 CDEV_SCHED_MODE_ROUNDROBIN);
7851 TEST_ASSERT(ret == 0,
7852 "Failed to set cdev %u to round-robin mode", sched_id);
7853 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7854 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7860 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7861 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7862 .setup = testsuite_setup,
7863 .teardown = testsuite_teardown,
7864 .unit_test_cases = {
7865 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7866 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 test_AES_chain_scheduler_all),
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_AES_cipheronly_scheduler_all),
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_authonly_scheduler_all),
7873 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7874 TEST_CASES_END() /**< NULL terminate unit test array */
7878 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7880 static struct unit_test_suite cryptodev_qat_testsuite = {
7881 .suite_name = "Crypto QAT Unit Test Suite",
7882 .setup = testsuite_setup,
7883 .teardown = testsuite_teardown,
7884 .unit_test_cases = {
7885 TEST_CASE_ST(ut_setup, ut_teardown,
7886 test_device_configure_invalid_dev_id),
7887 TEST_CASE_ST(ut_setup, ut_teardown,
7888 test_device_configure_invalid_queue_pair_ids),
7889 TEST_CASE_ST(ut_setup, ut_teardown,
7890 test_queue_pair_descriptor_setup),
7891 TEST_CASE_ST(ut_setup, ut_teardown,
7892 test_multi_session),
7894 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7895 TEST_CASE_ST(ut_setup, ut_teardown,
7896 test_AES_cipheronly_qat_all),
7897 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7898 TEST_CASE_ST(ut_setup, ut_teardown,
7899 test_3DES_cipheronly_qat_all),
7900 TEST_CASE_ST(ut_setup, ut_teardown,
7901 test_DES_cipheronly_qat_all),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 test_AES_docsis_qat_all),
7904 TEST_CASE_ST(ut_setup, ut_teardown,
7905 test_DES_docsis_qat_all),
7906 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7908 /** AES GCM Authenticated Encryption */
7909 TEST_CASE_ST(ut_setup, ut_teardown,
7910 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7911 TEST_CASE_ST(ut_setup, ut_teardown,
7912 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7913 TEST_CASE_ST(ut_setup, ut_teardown,
7914 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7915 TEST_CASE_ST(ut_setup, ut_teardown,
7916 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7917 TEST_CASE_ST(ut_setup, ut_teardown,
7918 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7919 TEST_CASE_ST(ut_setup, ut_teardown,
7920 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7921 TEST_CASE_ST(ut_setup, ut_teardown,
7922 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7923 TEST_CASE_ST(ut_setup, ut_teardown,
7924 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7925 TEST_CASE_ST(ut_setup, ut_teardown,
7926 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7927 TEST_CASE_ST(ut_setup, ut_teardown,
7928 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7930 /** AES GCM Authenticated Decryption */
7931 TEST_CASE_ST(ut_setup, ut_teardown,
7932 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7933 TEST_CASE_ST(ut_setup, ut_teardown,
7934 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7937 TEST_CASE_ST(ut_setup, ut_teardown,
7938 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7943 TEST_CASE_ST(ut_setup, ut_teardown,
7944 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7946 /** AES GMAC Authentication */
7947 TEST_CASE_ST(ut_setup, ut_teardown,
7948 test_AES_GMAC_authentication_test_case_1),
7949 TEST_CASE_ST(ut_setup, ut_teardown,
7950 test_AES_GMAC_authentication_verify_test_case_1),
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_AES_GMAC_authentication_test_case_2),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_AES_GMAC_authentication_verify_test_case_2),
7955 TEST_CASE_ST(ut_setup, ut_teardown,
7956 test_AES_GMAC_authentication_test_case_3),
7957 TEST_CASE_ST(ut_setup, ut_teardown,
7958 test_AES_GMAC_authentication_verify_test_case_3),
7960 /** SNOW 3G encrypt only (UEA2) */
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 test_snow3g_encryption_test_case_1),
7963 TEST_CASE_ST(ut_setup, ut_teardown,
7964 test_snow3g_encryption_test_case_2),
7965 TEST_CASE_ST(ut_setup, ut_teardown,
7966 test_snow3g_encryption_test_case_3),
7967 TEST_CASE_ST(ut_setup, ut_teardown,
7968 test_snow3g_encryption_test_case_4),
7969 TEST_CASE_ST(ut_setup, ut_teardown,
7970 test_snow3g_encryption_test_case_5),
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_snow3g_encryption_test_case_1_oop),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_snow3g_decryption_test_case_1_oop),
7977 /** SNOW 3G decrypt only (UEA2) */
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_snow3g_decryption_test_case_1),
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 test_snow3g_decryption_test_case_2),
7982 TEST_CASE_ST(ut_setup, ut_teardown,
7983 test_snow3g_decryption_test_case_3),
7984 TEST_CASE_ST(ut_setup, ut_teardown,
7985 test_snow3g_decryption_test_case_4),
7986 TEST_CASE_ST(ut_setup, ut_teardown,
7987 test_snow3g_decryption_test_case_5),
7988 TEST_CASE_ST(ut_setup, ut_teardown,
7989 test_snow3g_hash_generate_test_case_1),
7990 TEST_CASE_ST(ut_setup, ut_teardown,
7991 test_snow3g_hash_generate_test_case_2),
7992 TEST_CASE_ST(ut_setup, ut_teardown,
7993 test_snow3g_hash_generate_test_case_3),
7994 TEST_CASE_ST(ut_setup, ut_teardown,
7995 test_snow3g_hash_verify_test_case_1),
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_snow3g_hash_verify_test_case_2),
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 test_snow3g_hash_verify_test_case_3),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_snow3g_cipher_auth_test_case_1),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_snow3g_auth_cipher_test_case_1),
8005 /** ZUC encrypt only (EEA3) */
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_zuc_encryption_test_case_1),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 test_zuc_encryption_test_case_2),
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 test_zuc_encryption_test_case_3),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 test_zuc_encryption_test_case_4),
8014 TEST_CASE_ST(ut_setup, ut_teardown,
8015 test_zuc_encryption_test_case_5),
8017 /** ZUC authenticate (EIA3) */
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 test_zuc_hash_generate_test_case_6),
8020 TEST_CASE_ST(ut_setup, ut_teardown,
8021 test_zuc_hash_generate_test_case_7),
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 test_zuc_hash_generate_test_case_8),
8025 /** ZUC alg-chain (EEA3/EIA3) */
8026 TEST_CASE_ST(ut_setup, ut_teardown,
8027 test_zuc_cipher_auth_test_case_1),
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 test_zuc_cipher_auth_test_case_2),
8031 /** HMAC_MD5 Authentication */
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_MD5_HMAC_generate_case_1),
8034 TEST_CASE_ST(ut_setup, ut_teardown,
8035 test_MD5_HMAC_verify_case_1),
8036 TEST_CASE_ST(ut_setup, ut_teardown,
8037 test_MD5_HMAC_generate_case_2),
8038 TEST_CASE_ST(ut_setup, ut_teardown,
8039 test_MD5_HMAC_verify_case_2),
8042 TEST_CASE_ST(ut_setup, ut_teardown,
8043 test_null_auth_only_operation),
8044 TEST_CASE_ST(ut_setup, ut_teardown,
8045 test_null_cipher_only_operation),
8046 TEST_CASE_ST(ut_setup, ut_teardown,
8047 test_null_cipher_auth_operation),
8048 TEST_CASE_ST(ut_setup, ut_teardown,
8049 test_null_auth_cipher_operation),
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 test_kasumi_hash_generate_test_case_6),
8055 TEST_CASE_ST(ut_setup, ut_teardown,
8056 test_kasumi_encryption_test_case_1),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_kasumi_encryption_test_case_3),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 test_kasumi_auth_cipher_test_case_1),
8061 TEST_CASE_ST(ut_setup, ut_teardown,
8062 test_kasumi_cipher_auth_test_case_1),
8064 /** Negative tests */
8065 TEST_CASE_ST(ut_setup, ut_teardown,
8066 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8067 TEST_CASE_ST(ut_setup, ut_teardown,
8068 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8069 TEST_CASE_ST(ut_setup, ut_teardown,
8070 authentication_verify_AES128_GMAC_fail_data_corrupt),
8071 TEST_CASE_ST(ut_setup, ut_teardown,
8072 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8073 TEST_CASE_ST(ut_setup, ut_teardown,
8074 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8078 TEST_CASES_END() /**< NULL terminate unit test array */
8082 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8083 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8084 .setup = testsuite_setup,
8085 .teardown = testsuite_teardown,
8086 .unit_test_cases = {
8087 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8088 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8089 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8090 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8092 TEST_CASES_END() /**< NULL terminate unit test array */
8096 static struct unit_test_suite cryptodev_openssl_testsuite = {
8097 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8098 .setup = testsuite_setup,
8099 .teardown = testsuite_teardown,
8100 .unit_test_cases = {
8101 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8102 TEST_CASE_ST(ut_setup, ut_teardown,
8103 test_multi_session_random_usage),
8104 TEST_CASE_ST(ut_setup, ut_teardown,
8105 test_AES_chain_openssl_all),
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_AES_cipheronly_openssl_all),
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_3DES_chain_openssl_all),
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_3DES_cipheronly_openssl_all),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_DES_docsis_openssl_all),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_authonly_openssl_all),
8117 /** AES GCM Authenticated Encryption */
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8133 /** AES GCM Authenticated Decryption */
8134 TEST_CASE_ST(ut_setup, ut_teardown,
8135 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8138 TEST_CASE_ST(ut_setup, ut_teardown,
8139 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8140 TEST_CASE_ST(ut_setup, ut_teardown,
8141 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8142 TEST_CASE_ST(ut_setup, ut_teardown,
8143 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8144 TEST_CASE_ST(ut_setup, ut_teardown,
8145 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8146 TEST_CASE_ST(ut_setup, ut_teardown,
8147 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8149 /** AES GMAC Authentication */
8150 TEST_CASE_ST(ut_setup, ut_teardown,
8151 test_AES_GMAC_authentication_test_case_1),
8152 TEST_CASE_ST(ut_setup, ut_teardown,
8153 test_AES_GMAC_authentication_verify_test_case_1),
8154 TEST_CASE_ST(ut_setup, ut_teardown,
8155 test_AES_GMAC_authentication_test_case_2),
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 test_AES_GMAC_authentication_verify_test_case_2),
8158 TEST_CASE_ST(ut_setup, ut_teardown,
8159 test_AES_GMAC_authentication_test_case_3),
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 test_AES_GMAC_authentication_verify_test_case_3),
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 test_AES_GMAC_authentication_test_case_4),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_AES_GMAC_authentication_verify_test_case_4),
8167 /** Scatter-Gather */
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8171 /** Negative tests */
8172 TEST_CASE_ST(ut_setup, ut_teardown,
8173 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8174 TEST_CASE_ST(ut_setup, ut_teardown,
8175 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8176 TEST_CASE_ST(ut_setup, ut_teardown,
8177 authentication_verify_AES128_GMAC_fail_data_corrupt),
8178 TEST_CASE_ST(ut_setup, ut_teardown,
8179 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8182 TEST_CASE_ST(ut_setup, ut_teardown,
8183 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8185 TEST_CASES_END() /**< NULL terminate unit test array */
8189 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8190 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8191 .setup = testsuite_setup,
8192 .teardown = testsuite_teardown,
8193 .unit_test_cases = {
8194 /** AES GCM Authenticated Encryption */
8195 TEST_CASE_ST(ut_setup, ut_teardown,
8196 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8210 /** AES GCM Authenticated Decryption */
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8221 TEST_CASE_ST(ut_setup, ut_teardown,
8222 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8226 /** AES GCM Authenticated Encryption 256 bits key */
8227 TEST_CASE_ST(ut_setup, ut_teardown,
8228 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8233 TEST_CASE_ST(ut_setup, ut_teardown,
8234 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8235 TEST_CASE_ST(ut_setup, ut_teardown,
8236 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8237 TEST_CASE_ST(ut_setup, ut_teardown,
8238 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8239 TEST_CASE_ST(ut_setup, ut_teardown,
8240 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8242 /** AES GCM Authenticated Decryption 256 bits key */
8243 TEST_CASE_ST(ut_setup, ut_teardown,
8244 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8245 TEST_CASE_ST(ut_setup, ut_teardown,
8246 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8253 TEST_CASE_ST(ut_setup, ut_teardown,
8254 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8258 /** AES GCM Authenticated Encryption big aad size */
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8261 TEST_CASE_ST(ut_setup, ut_teardown,
8262 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8264 /** AES GCM Authenticated Decryption big aad size */
8265 TEST_CASE_ST(ut_setup, ut_teardown,
8266 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8267 TEST_CASE_ST(ut_setup, ut_teardown,
8268 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8270 /** AES GMAC Authentication */
8271 TEST_CASE_ST(ut_setup, ut_teardown,
8272 test_AES_GMAC_authentication_test_case_1),
8273 TEST_CASE_ST(ut_setup, ut_teardown,
8274 test_AES_GMAC_authentication_verify_test_case_1),
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_AES_GMAC_authentication_test_case_3),
8277 TEST_CASE_ST(ut_setup, ut_teardown,
8278 test_AES_GMAC_authentication_verify_test_case_3),
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_AES_GMAC_authentication_test_case_4),
8281 TEST_CASE_ST(ut_setup, ut_teardown,
8282 test_AES_GMAC_authentication_verify_test_case_4),
8284 /** Negative tests */
8285 TEST_CASE_ST(ut_setup, ut_teardown,
8286 authentication_verify_AES128_GMAC_fail_data_corrupt),
8287 TEST_CASE_ST(ut_setup, ut_teardown,
8288 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8290 /** Out of place tests */
8291 TEST_CASE_ST(ut_setup, ut_teardown,
8292 test_mb_AES_GCM_authenticated_encryption_oop),
8293 TEST_CASE_ST(ut_setup, ut_teardown,
8294 test_mb_AES_GCM_authenticated_decryption_oop),
8296 /** Session-less tests */
8297 TEST_CASE_ST(ut_setup, ut_teardown,
8298 test_mb_AES_GCM_authenticated_encryption_sessionless),
8299 TEST_CASE_ST(ut_setup, ut_teardown,
8300 test_mb_AES_GCM_authenticated_decryption_sessionless),
8302 /** Scatter-Gather */
8303 TEST_CASE_ST(ut_setup, ut_teardown,
8304 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8306 TEST_CASES_END() /**< NULL terminate unit test array */
8310 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8311 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8312 .setup = testsuite_setup,
8313 .teardown = testsuite_teardown,
8314 .unit_test_cases = {
8315 /** KASUMI encrypt only (UEA1) */
8316 TEST_CASE_ST(ut_setup, ut_teardown,
8317 test_kasumi_encryption_test_case_1),
8318 TEST_CASE_ST(ut_setup, ut_teardown,
8319 test_kasumi_encryption_test_case_1_sgl),
8320 TEST_CASE_ST(ut_setup, ut_teardown,
8321 test_kasumi_encryption_test_case_2),
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_kasumi_encryption_test_case_3),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_kasumi_encryption_test_case_4),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_kasumi_encryption_test_case_5),
8328 /** KASUMI decrypt only (UEA1) */
8329 TEST_CASE_ST(ut_setup, ut_teardown,
8330 test_kasumi_decryption_test_case_1),
8331 TEST_CASE_ST(ut_setup, ut_teardown,
8332 test_kasumi_decryption_test_case_2),
8333 TEST_CASE_ST(ut_setup, ut_teardown,
8334 test_kasumi_decryption_test_case_3),
8335 TEST_CASE_ST(ut_setup, ut_teardown,
8336 test_kasumi_decryption_test_case_4),
8337 TEST_CASE_ST(ut_setup, ut_teardown,
8338 test_kasumi_decryption_test_case_5),
8340 TEST_CASE_ST(ut_setup, ut_teardown,
8341 test_kasumi_encryption_test_case_1_oop),
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_kasumi_encryption_test_case_1_oop_sgl),
8346 TEST_CASE_ST(ut_setup, ut_teardown,
8347 test_kasumi_decryption_test_case_1_oop),
8349 /** KASUMI hash only (UIA1) */
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_kasumi_hash_generate_test_case_1),
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_kasumi_hash_generate_test_case_2),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_kasumi_hash_generate_test_case_3),
8356 TEST_CASE_ST(ut_setup, ut_teardown,
8357 test_kasumi_hash_generate_test_case_4),
8358 TEST_CASE_ST(ut_setup, ut_teardown,
8359 test_kasumi_hash_generate_test_case_5),
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_kasumi_hash_generate_test_case_6),
8362 TEST_CASE_ST(ut_setup, ut_teardown,
8363 test_kasumi_hash_verify_test_case_1),
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_kasumi_hash_verify_test_case_2),
8366 TEST_CASE_ST(ut_setup, ut_teardown,
8367 test_kasumi_hash_verify_test_case_3),
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 test_kasumi_hash_verify_test_case_4),
8370 TEST_CASE_ST(ut_setup, ut_teardown,
8371 test_kasumi_hash_verify_test_case_5),
8372 TEST_CASE_ST(ut_setup, ut_teardown,
8373 test_kasumi_auth_cipher_test_case_1),
8374 TEST_CASE_ST(ut_setup, ut_teardown,
8375 test_kasumi_cipher_auth_test_case_1),
8376 TEST_CASES_END() /**< NULL terminate unit test array */
8379 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8380 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8381 .setup = testsuite_setup,
8382 .teardown = testsuite_teardown,
8383 .unit_test_cases = {
8384 /** SNOW 3G encrypt only (UEA2) */
8385 TEST_CASE_ST(ut_setup, ut_teardown,
8386 test_snow3g_encryption_test_case_1),
8387 TEST_CASE_ST(ut_setup, ut_teardown,
8388 test_snow3g_encryption_test_case_2),
8389 TEST_CASE_ST(ut_setup, ut_teardown,
8390 test_snow3g_encryption_test_case_3),
8391 TEST_CASE_ST(ut_setup, ut_teardown,
8392 test_snow3g_encryption_test_case_4),
8393 TEST_CASE_ST(ut_setup, ut_teardown,
8394 test_snow3g_encryption_test_case_5),
8396 TEST_CASE_ST(ut_setup, ut_teardown,
8397 test_snow3g_encryption_test_case_1_oop),
8398 TEST_CASE_ST(ut_setup, ut_teardown,
8399 test_snow3g_encryption_test_case_1_oop_sgl),
8400 TEST_CASE_ST(ut_setup, ut_teardown,
8401 test_snow3g_decryption_test_case_1_oop),
8403 TEST_CASE_ST(ut_setup, ut_teardown,
8404 test_snow3g_encryption_test_case_1_offset_oop),
8406 /** SNOW 3G decrypt only (UEA2) */
8407 TEST_CASE_ST(ut_setup, ut_teardown,
8408 test_snow3g_decryption_test_case_1),
8409 TEST_CASE_ST(ut_setup, ut_teardown,
8410 test_snow3g_decryption_test_case_2),
8411 TEST_CASE_ST(ut_setup, ut_teardown,
8412 test_snow3g_decryption_test_case_3),
8413 TEST_CASE_ST(ut_setup, ut_teardown,
8414 test_snow3g_decryption_test_case_4),
8415 TEST_CASE_ST(ut_setup, ut_teardown,
8416 test_snow3g_decryption_test_case_5),
8417 TEST_CASE_ST(ut_setup, ut_teardown,
8418 test_snow3g_hash_generate_test_case_1),
8419 TEST_CASE_ST(ut_setup, ut_teardown,
8420 test_snow3g_hash_generate_test_case_2),
8421 TEST_CASE_ST(ut_setup, ut_teardown,
8422 test_snow3g_hash_generate_test_case_3),
8423 /* Tests with buffers which length is not byte-aligned */
8424 TEST_CASE_ST(ut_setup, ut_teardown,
8425 test_snow3g_hash_generate_test_case_4),
8426 TEST_CASE_ST(ut_setup, ut_teardown,
8427 test_snow3g_hash_generate_test_case_5),
8428 TEST_CASE_ST(ut_setup, ut_teardown,
8429 test_snow3g_hash_generate_test_case_6),
8430 TEST_CASE_ST(ut_setup, ut_teardown,
8431 test_snow3g_hash_verify_test_case_1),
8432 TEST_CASE_ST(ut_setup, ut_teardown,
8433 test_snow3g_hash_verify_test_case_2),
8434 TEST_CASE_ST(ut_setup, ut_teardown,
8435 test_snow3g_hash_verify_test_case_3),
8436 /* Tests with buffers which length is not byte-aligned */
8437 TEST_CASE_ST(ut_setup, ut_teardown,
8438 test_snow3g_hash_verify_test_case_4),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_snow3g_hash_verify_test_case_5),
8441 TEST_CASE_ST(ut_setup, ut_teardown,
8442 test_snow3g_hash_verify_test_case_6),
8443 TEST_CASE_ST(ut_setup, ut_teardown,
8444 test_snow3g_cipher_auth_test_case_1),
8445 TEST_CASE_ST(ut_setup, ut_teardown,
8446 test_snow3g_auth_cipher_test_case_1),
8448 TEST_CASES_END() /**< NULL terminate unit test array */
8452 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8453 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8454 .setup = testsuite_setup,
8455 .teardown = testsuite_teardown,
8456 .unit_test_cases = {
8457 /** ZUC encrypt only (EEA3) */
8458 TEST_CASE_ST(ut_setup, ut_teardown,
8459 test_zuc_encryption_test_case_1),
8460 TEST_CASE_ST(ut_setup, ut_teardown,
8461 test_zuc_encryption_test_case_2),
8462 TEST_CASE_ST(ut_setup, ut_teardown,
8463 test_zuc_encryption_test_case_3),
8464 TEST_CASE_ST(ut_setup, ut_teardown,
8465 test_zuc_encryption_test_case_4),
8466 TEST_CASE_ST(ut_setup, ut_teardown,
8467 test_zuc_encryption_test_case_5),
8468 TEST_CASE_ST(ut_setup, ut_teardown,
8469 test_zuc_hash_generate_test_case_1),
8470 TEST_CASE_ST(ut_setup, ut_teardown,
8471 test_zuc_hash_generate_test_case_2),
8472 TEST_CASE_ST(ut_setup, ut_teardown,
8473 test_zuc_hash_generate_test_case_3),
8474 TEST_CASE_ST(ut_setup, ut_teardown,
8475 test_zuc_hash_generate_test_case_4),
8476 TEST_CASE_ST(ut_setup, ut_teardown,
8477 test_zuc_hash_generate_test_case_5),
8478 TEST_CASE_ST(ut_setup, ut_teardown,
8479 test_zuc_encryption_test_case_6_sgl),
8480 TEST_CASES_END() /**< NULL terminate unit test array */
8484 static struct unit_test_suite cryptodev_null_testsuite = {
8485 .suite_name = "Crypto Device NULL Unit Test Suite",
8486 .setup = testsuite_setup,
8487 .teardown = testsuite_teardown,
8488 .unit_test_cases = {
8489 TEST_CASE_ST(ut_setup, ut_teardown,
8490 test_null_auth_only_operation),
8491 TEST_CASE_ST(ut_setup, ut_teardown,
8492 test_null_cipher_only_operation),
8493 TEST_CASE_ST(ut_setup, ut_teardown,
8494 test_null_cipher_auth_operation),
8495 TEST_CASE_ST(ut_setup, ut_teardown,
8496 test_null_auth_cipher_operation),
8497 TEST_CASE_ST(ut_setup, ut_teardown,
8498 test_null_invalid_operation),
8499 TEST_CASE_ST(ut_setup, ut_teardown,
8500 test_null_burst_operation),
8502 TEST_CASES_END() /**< NULL terminate unit test array */
8506 static struct unit_test_suite cryptodev_armv8_testsuite = {
8507 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8508 .setup = testsuite_setup,
8509 .teardown = testsuite_teardown,
8510 .unit_test_cases = {
8511 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8513 /** Negative tests */
8514 TEST_CASE_ST(ut_setup, ut_teardown,
8515 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8516 TEST_CASE_ST(ut_setup, ut_teardown,
8517 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8519 TEST_CASES_END() /**< NULL terminate unit test array */
8524 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8526 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8527 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8531 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8533 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8535 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8539 test_cryptodev_openssl(void)
8541 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8543 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8547 test_cryptodev_aesni_gcm(void)
8549 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8551 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8555 test_cryptodev_null(void)
8557 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8559 return unit_test_suite_runner(&cryptodev_null_testsuite);
8563 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8565 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8567 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8571 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8573 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8575 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8579 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8581 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8583 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8587 test_cryptodev_armv8(void)
8589 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8591 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8594 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8597 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8599 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8600 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8603 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8607 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8608 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8609 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8610 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8611 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8612 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8613 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8614 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8615 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);