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_algo_auth_cipher_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 uint8_t *key, const uint8_t key_len,
1972 const uint8_t aad_len, const uint8_t auth_len)
1974 uint8_t auth_cipher_key[key_len];
1976 struct crypto_unittest_params *ut_params = &unittest_params;
1978 memcpy(auth_cipher_key, key, key_len);
1980 /* Setup Authentication Parameters */
1981 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1982 ut_params->auth_xform.auth.op = auth_op;
1983 ut_params->auth_xform.next = &ut_params->cipher_xform;
1984 ut_params->auth_xform.auth.algo = auth_algo;
1985 ut_params->auth_xform.auth.key.length = key_len;
1986 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1987 ut_params->auth_xform.auth.digest_length = auth_len;
1988 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1990 /* Setup Cipher Parameters */
1991 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1992 ut_params->cipher_xform.next = NULL;
1993 ut_params->cipher_xform.cipher.algo = cipher_algo;
1994 ut_params->cipher_xform.cipher.op = cipher_op;
1995 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1996 ut_params->cipher_xform.cipher.key.length = key_len;
1998 TEST_HEXDUMP(stdout, "key:", key, key_len);
2000 /* Create Crypto session*/
2001 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2002 &ut_params->auth_xform);
2004 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2010 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2011 const unsigned auth_tag_len,
2012 const uint8_t *aad, const unsigned aad_len,
2013 unsigned data_pad_len,
2014 enum rte_crypto_auth_operation op,
2015 enum rte_crypto_auth_algorithm algo,
2016 const unsigned auth_len, const unsigned auth_offset)
2018 struct crypto_testsuite_params *ts_params = &testsuite_params;
2020 struct crypto_unittest_params *ut_params = &unittest_params;
2022 unsigned aad_buffer_len;
2024 /* Generate Crypto op data structure */
2025 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2026 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2027 TEST_ASSERT_NOT_NULL(ut_params->op,
2028 "Failed to allocate pktmbuf offload");
2030 /* Set crypto operation data parameters */
2031 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2033 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2035 /* set crypto operation source mbuf */
2036 sym_op->m_src = ut_params->ibuf;
2040 * Always allocate the aad up to the block size.
2041 * The cryptodev API calls out -
2042 * - the array must be big enough to hold the AAD, plus any
2043 * space to round this up to the nearest multiple of the
2044 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2046 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2047 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2049 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2050 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2051 ut_params->ibuf, aad_buffer_len);
2052 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2053 "no room to prepend aad");
2054 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2056 sym_op->auth.aad.length = aad_len;
2058 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2059 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2061 TEST_HEXDUMP(stdout, "aad:",
2062 sym_op->auth.aad.data, aad_len);
2065 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2066 ut_params->ibuf, auth_tag_len);
2068 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2069 "no room to append auth tag");
2070 ut_params->digest = sym_op->auth.digest.data;
2071 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2072 ut_params->ibuf, data_pad_len + aad_len);
2073 sym_op->auth.digest.length = auth_tag_len;
2074 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2075 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2077 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2079 TEST_HEXDUMP(stdout, "digest:",
2080 sym_op->auth.digest.data,
2081 sym_op->auth.digest.length);
2083 sym_op->auth.data.length = auth_len;
2084 sym_op->auth.data.offset = auth_offset;
2090 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2091 const unsigned auth_tag_len,
2092 const uint8_t *aad, const uint8_t aad_len,
2093 unsigned data_pad_len,
2094 enum rte_crypto_auth_operation op,
2095 enum rte_crypto_auth_algorithm auth_algo,
2096 enum rte_crypto_cipher_algorithm cipher_algo,
2097 const uint8_t *iv, const uint8_t iv_len,
2098 const unsigned cipher_len, const unsigned cipher_offset,
2099 const unsigned auth_len, const unsigned auth_offset)
2101 struct crypto_testsuite_params *ts_params = &testsuite_params;
2102 struct crypto_unittest_params *ut_params = &unittest_params;
2104 unsigned iv_pad_len = 0;
2105 unsigned aad_buffer_len;
2107 /* Generate Crypto op data structure */
2108 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2109 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2110 TEST_ASSERT_NOT_NULL(ut_params->op,
2111 "Failed to allocate pktmbuf offload");
2112 /* Set crypto operation data parameters */
2113 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2115 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2117 /* set crypto operation source mbuf */
2118 sym_op->m_src = ut_params->ibuf;
2121 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2122 ut_params->ibuf, auth_tag_len);
2124 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2125 "no room to append auth tag");
2126 ut_params->digest = sym_op->auth.digest.data;
2127 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2128 ut_params->ibuf, data_pad_len);
2129 sym_op->auth.digest.length = auth_tag_len;
2130 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2131 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2133 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2135 TEST_HEXDUMP(stdout, "digest:",
2136 sym_op->auth.digest.data,
2137 sym_op->auth.digest.length);
2141 * Always allocate the aad up to the block size.
2142 * The cryptodev API calls out -
2143 * - the array must be big enough to hold the AAD, plus any
2144 * space to round this up to the nearest multiple of the
2145 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2147 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2148 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2150 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2151 sym_op->auth.aad.data =
2152 (uint8_t *)rte_pktmbuf_prepend(
2153 ut_params->ibuf, aad_buffer_len);
2154 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2155 "no room to prepend aad");
2156 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2158 sym_op->auth.aad.length = aad_len;
2159 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2160 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2161 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2164 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2165 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2167 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2168 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2169 ut_params->ibuf, iv_pad_len);
2171 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2172 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2173 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2174 sym_op->cipher.iv.length = iv_pad_len;
2175 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2176 sym_op->cipher.data.length = cipher_len;
2177 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2178 sym_op->auth.data.length = auth_len;
2179 sym_op->auth.data.offset = auth_offset + cipher_offset;
2185 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2186 const uint8_t *iv, const uint8_t iv_len,
2187 const uint8_t *aad, const uint8_t aad_len,
2188 unsigned data_pad_len,
2189 const unsigned cipher_len, const unsigned cipher_offset,
2190 const unsigned auth_len, const unsigned auth_offset,
2191 enum rte_crypto_auth_algorithm auth_algo,
2192 enum rte_crypto_cipher_algorithm cipher_algo)
2194 struct crypto_testsuite_params *ts_params = &testsuite_params;
2195 struct crypto_unittest_params *ut_params = &unittest_params;
2197 unsigned iv_pad_len = 0;
2198 unsigned aad_buffer_len = 0;
2200 /* Generate Crypto op data structure */
2201 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2202 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2203 TEST_ASSERT_NOT_NULL(ut_params->op,
2204 "Failed to allocate pktmbuf offload");
2206 /* Set crypto operation data parameters */
2207 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2209 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2211 /* set crypto operation source mbuf */
2212 sym_op->m_src = ut_params->ibuf;
2215 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2216 ut_params->ibuf, auth_tag_len);
2218 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2219 "no room to append auth tag");
2221 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2222 ut_params->ibuf, data_pad_len);
2223 sym_op->auth.digest.length = auth_tag_len;
2225 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2227 TEST_HEXDUMP(stdout, "digest:",
2228 sym_op->auth.digest.data,
2229 sym_op->auth.digest.length);
2233 * Always allocate the aad up to the block size.
2234 * The cryptodev API calls out -
2235 * - the array must be big enough to hold the AAD, plus any
2236 * space to round this up to the nearest multiple of the
2237 * block size (8 bytes for KASUMI 16 bytes).
2239 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2240 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2242 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2243 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2244 ut_params->ibuf, aad_buffer_len);
2245 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2246 "no room to prepend aad");
2247 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2249 sym_op->auth.aad.length = aad_len;
2250 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2251 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2252 TEST_HEXDUMP(stdout, "aad:",
2253 sym_op->auth.aad.data, aad_len);
2256 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2257 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2259 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2261 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2262 ut_params->ibuf, iv_pad_len);
2263 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2265 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2266 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2267 sym_op->cipher.iv.length = iv_pad_len;
2269 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2271 sym_op->cipher.data.length = cipher_len;
2272 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2274 sym_op->auth.data.length = auth_len;
2275 sym_op->auth.data.offset = auth_offset + cipher_offset;
2281 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2283 struct crypto_testsuite_params *ts_params = &testsuite_params;
2284 struct crypto_unittest_params *ut_params = &unittest_params;
2287 unsigned plaintext_pad_len;
2288 unsigned plaintext_len;
2291 /* Create SNOW 3G session */
2292 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2293 tdata->key.data, tdata->key.len,
2294 tdata->aad.len, tdata->digest.len,
2295 RTE_CRYPTO_AUTH_OP_GENERATE,
2296 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2300 /* alloc mbuf and set payload */
2301 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2303 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2304 rte_pktmbuf_tailroom(ut_params->ibuf));
2306 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2307 /* Append data which is padded to a multiple of */
2308 /* the algorithms block size */
2309 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2310 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2312 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2314 /* Create SNOW 3G operation */
2315 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2316 tdata->aad.data, tdata->aad.len,
2317 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2318 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2319 tdata->validAuthLenInBits.len,
2320 tdata->validAuthOffsetLenInBits.len);
2324 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2326 ut_params->obuf = ut_params->op->sym->m_src;
2327 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2328 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2329 + plaintext_pad_len + tdata->aad.len;
2332 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2335 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2336 "SNOW 3G Generated auth tag not as expected");
2342 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2344 struct crypto_testsuite_params *ts_params = &testsuite_params;
2345 struct crypto_unittest_params *ut_params = &unittest_params;
2348 unsigned plaintext_pad_len;
2349 unsigned plaintext_len;
2352 /* Create SNOW 3G session */
2353 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2354 tdata->key.data, tdata->key.len,
2355 tdata->aad.len, tdata->digest.len,
2356 RTE_CRYPTO_AUTH_OP_VERIFY,
2357 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2360 /* alloc mbuf and set payload */
2361 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2363 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2364 rte_pktmbuf_tailroom(ut_params->ibuf));
2366 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2367 /* Append data which is padded to a multiple of */
2368 /* the algorithms block size */
2369 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2370 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2372 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2374 /* Create SNOW 3G operation */
2375 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2377 tdata->aad.data, tdata->aad.len,
2379 RTE_CRYPTO_AUTH_OP_VERIFY,
2380 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2381 tdata->validAuthLenInBits.len,
2382 tdata->validAuthOffsetLenInBits.len);
2386 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2388 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2389 ut_params->obuf = ut_params->op->sym->m_src;
2390 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2391 + plaintext_pad_len + tdata->aad.len;
2394 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2403 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2405 struct crypto_testsuite_params *ts_params = &testsuite_params;
2406 struct crypto_unittest_params *ut_params = &unittest_params;
2409 unsigned plaintext_pad_len;
2410 unsigned plaintext_len;
2413 /* Create KASUMI session */
2414 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2415 tdata->key.data, tdata->key.len,
2416 tdata->aad.len, tdata->digest.len,
2417 RTE_CRYPTO_AUTH_OP_GENERATE,
2418 RTE_CRYPTO_AUTH_KASUMI_F9);
2422 /* alloc mbuf and set payload */
2423 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2425 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2426 rte_pktmbuf_tailroom(ut_params->ibuf));
2428 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2429 /* Append data which is padded to a multiple of */
2430 /* the algorithms block size */
2431 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2432 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2434 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2436 /* Create KASUMI operation */
2437 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2438 tdata->aad.data, tdata->aad.len,
2439 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2440 RTE_CRYPTO_AUTH_KASUMI_F9,
2441 tdata->validAuthLenInBits.len,
2442 tdata->validAuthOffsetLenInBits.len);
2446 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2448 ut_params->obuf = ut_params->op->sym->m_src;
2449 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2450 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2451 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2457 DIGEST_BYTE_LENGTH_KASUMI_F9,
2458 "KASUMI Generated auth tag not as expected");
2464 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2466 struct crypto_testsuite_params *ts_params = &testsuite_params;
2467 struct crypto_unittest_params *ut_params = &unittest_params;
2470 unsigned plaintext_pad_len;
2471 unsigned plaintext_len;
2474 /* Create KASUMI session */
2475 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2476 tdata->key.data, tdata->key.len,
2477 tdata->aad.len, tdata->digest.len,
2478 RTE_CRYPTO_AUTH_OP_VERIFY,
2479 RTE_CRYPTO_AUTH_KASUMI_F9);
2482 /* alloc mbuf and set payload */
2483 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2485 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2486 rte_pktmbuf_tailroom(ut_params->ibuf));
2488 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2489 /* Append data which is padded to a multiple */
2490 /* of the algorithms block size */
2491 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2492 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2494 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2496 /* Create KASUMI operation */
2497 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2499 tdata->aad.data, tdata->aad.len,
2501 RTE_CRYPTO_AUTH_OP_VERIFY,
2502 RTE_CRYPTO_AUTH_KASUMI_F9,
2503 tdata->validAuthLenInBits.len,
2504 tdata->validAuthOffsetLenInBits.len);
2508 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2510 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2511 ut_params->obuf = ut_params->op->sym->m_src;
2512 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2513 + plaintext_pad_len + tdata->aad.len;
2516 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2525 test_snow3g_hash_generate_test_case_1(void)
2527 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2531 test_snow3g_hash_generate_test_case_2(void)
2533 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2537 test_snow3g_hash_generate_test_case_3(void)
2539 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2543 test_snow3g_hash_generate_test_case_4(void)
2545 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2549 test_snow3g_hash_generate_test_case_5(void)
2551 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2555 test_snow3g_hash_generate_test_case_6(void)
2557 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2561 test_snow3g_hash_verify_test_case_1(void)
2563 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2568 test_snow3g_hash_verify_test_case_2(void)
2570 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2574 test_snow3g_hash_verify_test_case_3(void)
2576 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2580 test_snow3g_hash_verify_test_case_4(void)
2582 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2586 test_snow3g_hash_verify_test_case_5(void)
2588 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2592 test_snow3g_hash_verify_test_case_6(void)
2594 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2598 test_kasumi_hash_generate_test_case_1(void)
2600 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2604 test_kasumi_hash_generate_test_case_2(void)
2606 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2610 test_kasumi_hash_generate_test_case_3(void)
2612 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2616 test_kasumi_hash_generate_test_case_4(void)
2618 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2622 test_kasumi_hash_generate_test_case_5(void)
2624 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2628 test_kasumi_hash_generate_test_case_6(void)
2630 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2634 test_kasumi_hash_verify_test_case_1(void)
2636 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2640 test_kasumi_hash_verify_test_case_2(void)
2642 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2646 test_kasumi_hash_verify_test_case_3(void)
2648 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2652 test_kasumi_hash_verify_test_case_4(void)
2654 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2658 test_kasumi_hash_verify_test_case_5(void)
2660 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2664 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2666 struct crypto_testsuite_params *ts_params = &testsuite_params;
2667 struct crypto_unittest_params *ut_params = &unittest_params;
2670 uint8_t *plaintext, *ciphertext;
2671 unsigned plaintext_pad_len;
2672 unsigned plaintext_len;
2674 /* Create KASUMI session */
2675 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2676 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2677 RTE_CRYPTO_CIPHER_KASUMI_F8,
2678 tdata->key.data, tdata->key.len);
2682 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2684 /* Clear mbuf payload */
2685 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2686 rte_pktmbuf_tailroom(ut_params->ibuf));
2688 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2689 /* Append data which is padded to a multiple */
2690 /* of the algorithms block size */
2691 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2692 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2694 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2696 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2698 /* Create KASUMI operation */
2699 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2700 tdata->plaintext.len,
2701 tdata->validCipherOffsetLenInBits.len,
2702 RTE_CRYPTO_CIPHER_KASUMI_F8);
2706 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2708 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2710 ut_params->obuf = ut_params->op->sym->m_dst;
2711 if (ut_params->obuf)
2712 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2715 ciphertext = plaintext;
2717 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2720 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2722 tdata->ciphertext.data,
2723 tdata->validCipherLenInBits.len,
2724 "KASUMI Ciphertext data not as expected");
2729 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2731 struct crypto_testsuite_params *ts_params = &testsuite_params;
2732 struct crypto_unittest_params *ut_params = &unittest_params;
2736 unsigned int plaintext_pad_len;
2737 unsigned int plaintext_len;
2739 uint8_t buffer[10000];
2740 const uint8_t *ciphertext;
2742 struct rte_cryptodev_info dev_info;
2744 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2745 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2746 printf("Device doesn't support scatter-gather. "
2751 /* Create KASUMI session */
2752 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2753 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2754 RTE_CRYPTO_CIPHER_KASUMI_F8,
2755 tdata->key.data, tdata->key.len);
2759 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2762 /* Append data which is padded to a multiple */
2763 /* of the algorithms block size */
2764 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2766 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2767 plaintext_pad_len, 10, 0);
2769 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2771 /* Create KASUMI operation */
2772 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2774 tdata->plaintext.len,
2775 tdata->validCipherOffsetLenInBits.len,
2776 RTE_CRYPTO_CIPHER_KASUMI_F8);
2780 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2782 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2784 ut_params->obuf = ut_params->op->sym->m_dst;
2786 if (ut_params->obuf)
2787 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2788 plaintext_len, buffer);
2790 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2791 plaintext_len, buffer);
2794 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2797 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2799 tdata->ciphertext.data,
2800 tdata->validCipherLenInBits.len,
2801 "KASUMI Ciphertext data not as expected");
2806 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2808 struct crypto_testsuite_params *ts_params = &testsuite_params;
2809 struct crypto_unittest_params *ut_params = &unittest_params;
2812 uint8_t *plaintext, *ciphertext;
2813 unsigned plaintext_pad_len;
2814 unsigned plaintext_len;
2816 /* Create KASUMI session */
2817 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2818 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2819 RTE_CRYPTO_CIPHER_KASUMI_F8,
2820 tdata->key.data, tdata->key.len);
2824 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2825 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2827 /* Clear mbuf payload */
2828 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2829 rte_pktmbuf_tailroom(ut_params->ibuf));
2831 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2832 /* Append data which is padded to a multiple */
2833 /* of the algorithms block size */
2834 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2835 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2837 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2838 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2840 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2842 /* Create KASUMI operation */
2843 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2845 tdata->plaintext.len,
2846 tdata->validCipherOffsetLenInBits.len,
2847 RTE_CRYPTO_CIPHER_KASUMI_F8);
2851 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2853 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2855 ut_params->obuf = ut_params->op->sym->m_dst;
2856 if (ut_params->obuf)
2857 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2860 ciphertext = plaintext;
2862 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2865 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2867 tdata->ciphertext.data,
2868 tdata->validCipherLenInBits.len,
2869 "KASUMI Ciphertext data not as expected");
2874 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2876 struct crypto_testsuite_params *ts_params = &testsuite_params;
2877 struct crypto_unittest_params *ut_params = &unittest_params;
2880 unsigned int plaintext_pad_len;
2881 unsigned int plaintext_len;
2883 const uint8_t *ciphertext;
2884 uint8_t buffer[2048];
2886 struct rte_cryptodev_info dev_info;
2888 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2889 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2890 printf("Device doesn't support scatter-gather. "
2895 /* Create KASUMI session */
2896 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2897 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2898 RTE_CRYPTO_CIPHER_KASUMI_F8,
2899 tdata->key.data, tdata->key.len);
2903 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2904 /* Append data which is padded to a multiple */
2905 /* of the algorithms block size */
2906 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2908 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2909 plaintext_pad_len, 10, 0);
2910 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2911 plaintext_pad_len, 3, 0);
2913 /* Append data which is padded to a multiple */
2914 /* of the algorithms block size */
2915 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2917 /* Create KASUMI operation */
2918 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2920 tdata->plaintext.len,
2921 tdata->validCipherOffsetLenInBits.len,
2922 RTE_CRYPTO_CIPHER_KASUMI_F8);
2926 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2928 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2930 ut_params->obuf = ut_params->op->sym->m_dst;
2931 if (ut_params->obuf)
2932 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2933 plaintext_pad_len, buffer);
2935 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2936 plaintext_pad_len, buffer);
2939 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2941 tdata->ciphertext.data,
2942 tdata->validCipherLenInBits.len,
2943 "KASUMI Ciphertext data not as expected");
2949 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2951 struct crypto_testsuite_params *ts_params = &testsuite_params;
2952 struct crypto_unittest_params *ut_params = &unittest_params;
2955 uint8_t *ciphertext, *plaintext;
2956 unsigned ciphertext_pad_len;
2957 unsigned ciphertext_len;
2959 /* Create KASUMI session */
2960 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2961 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2962 RTE_CRYPTO_CIPHER_KASUMI_F8,
2963 tdata->key.data, tdata->key.len);
2967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2968 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2970 /* Clear mbuf payload */
2971 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2972 rte_pktmbuf_tailroom(ut_params->ibuf));
2974 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2975 /* Append data which is padded to a multiple */
2976 /* of the algorithms block size */
2977 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2978 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2979 ciphertext_pad_len);
2980 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2981 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2983 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2985 /* Create KASUMI operation */
2986 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2988 tdata->ciphertext.len,
2989 tdata->validCipherOffsetLenInBits.len,
2990 RTE_CRYPTO_CIPHER_KASUMI_F8);
2994 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2996 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2998 ut_params->obuf = ut_params->op->sym->m_dst;
2999 if (ut_params->obuf)
3000 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3003 plaintext = ciphertext;
3005 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3008 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3010 tdata->plaintext.data,
3011 tdata->validCipherLenInBits.len,
3012 "KASUMI Plaintext data not as expected");
3017 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3019 struct crypto_testsuite_params *ts_params = &testsuite_params;
3020 struct crypto_unittest_params *ut_params = &unittest_params;
3023 uint8_t *ciphertext, *plaintext;
3024 unsigned ciphertext_pad_len;
3025 unsigned ciphertext_len;
3027 /* Create KASUMI session */
3028 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3029 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3030 RTE_CRYPTO_CIPHER_KASUMI_F8,
3031 tdata->key.data, tdata->key.len);
3035 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3037 /* Clear mbuf payload */
3038 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3039 rte_pktmbuf_tailroom(ut_params->ibuf));
3041 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3042 /* Append data which is padded to a multiple */
3043 /* of the algorithms block size */
3044 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3045 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3046 ciphertext_pad_len);
3047 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3049 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3051 /* Create KASUMI operation */
3052 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3054 tdata->ciphertext.len,
3055 tdata->validCipherOffsetLenInBits.len,
3056 RTE_CRYPTO_CIPHER_KASUMI_F8);
3060 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3062 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3064 ut_params->obuf = ut_params->op->sym->m_dst;
3065 if (ut_params->obuf)
3066 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3069 plaintext = ciphertext;
3071 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3074 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3076 tdata->plaintext.data,
3077 tdata->validCipherLenInBits.len,
3078 "KASUMI Plaintext data not as expected");
3083 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3085 struct crypto_testsuite_params *ts_params = &testsuite_params;
3086 struct crypto_unittest_params *ut_params = &unittest_params;
3089 uint8_t *plaintext, *ciphertext;
3090 unsigned plaintext_pad_len;
3091 unsigned plaintext_len;
3093 /* Create SNOW 3G session */
3094 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3095 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3096 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3097 tdata->key.data, tdata->key.len);
3101 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3103 /* Clear mbuf payload */
3104 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3105 rte_pktmbuf_tailroom(ut_params->ibuf));
3107 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3108 /* Append data which is padded to a multiple of */
3109 /* the algorithms block size */
3110 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3111 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3113 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3115 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3117 /* Create SNOW 3G operation */
3118 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3119 tdata->validCipherLenInBits.len,
3120 tdata->validCipherOffsetLenInBits.len,
3121 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3125 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3127 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3129 ut_params->obuf = ut_params->op->sym->m_dst;
3130 if (ut_params->obuf)
3131 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3134 ciphertext = plaintext;
3136 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3139 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3141 tdata->ciphertext.data,
3142 tdata->validDataLenInBits.len,
3143 "SNOW 3G Ciphertext data not as expected");
3149 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3151 struct crypto_testsuite_params *ts_params = &testsuite_params;
3152 struct crypto_unittest_params *ut_params = &unittest_params;
3153 uint8_t *plaintext, *ciphertext;
3156 unsigned plaintext_pad_len;
3157 unsigned plaintext_len;
3159 /* Create SNOW 3G session */
3160 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3161 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3162 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3163 tdata->key.data, tdata->key.len);
3167 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3168 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3170 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3171 "Failed to allocate input buffer in mempool");
3172 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3173 "Failed to allocate output buffer in mempool");
3175 /* Clear mbuf payload */
3176 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3177 rte_pktmbuf_tailroom(ut_params->ibuf));
3179 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3180 /* Append data which is padded to a multiple of */
3181 /* the algorithms block size */
3182 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3183 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3185 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3186 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3188 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3190 /* Create SNOW 3G operation */
3191 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3193 tdata->validCipherLenInBits.len,
3194 tdata->validCipherOffsetLenInBits.len,
3195 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3199 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3201 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3203 ut_params->obuf = ut_params->op->sym->m_dst;
3204 if (ut_params->obuf)
3205 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3208 ciphertext = plaintext;
3210 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3213 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3215 tdata->ciphertext.data,
3216 tdata->validDataLenInBits.len,
3217 "SNOW 3G Ciphertext data not as expected");
3222 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3224 struct crypto_testsuite_params *ts_params = &testsuite_params;
3225 struct crypto_unittest_params *ut_params = &unittest_params;
3228 unsigned int plaintext_pad_len;
3229 unsigned int plaintext_len;
3230 uint8_t buffer[10000];
3231 const uint8_t *ciphertext;
3233 struct rte_cryptodev_info dev_info;
3235 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3236 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3237 printf("Device doesn't support scatter-gather. "
3242 /* Create SNOW 3G session */
3243 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3244 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3245 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3246 tdata->key.data, tdata->key.len);
3250 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3251 /* Append data which is padded to a multiple of */
3252 /* the algorithms block size */
3253 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3255 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3256 plaintext_pad_len, 10, 0);
3257 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3258 plaintext_pad_len, 3, 0);
3260 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3261 "Failed to allocate input buffer in mempool");
3262 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3263 "Failed to allocate output buffer in mempool");
3265 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3267 /* Create SNOW 3G operation */
3268 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3270 tdata->validCipherLenInBits.len,
3271 tdata->validCipherOffsetLenInBits.len,
3272 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3276 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3278 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3280 ut_params->obuf = ut_params->op->sym->m_dst;
3281 if (ut_params->obuf)
3282 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3283 plaintext_len, buffer);
3285 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3286 plaintext_len, buffer);
3288 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3291 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3293 tdata->ciphertext.data,
3294 tdata->validDataLenInBits.len,
3295 "SNOW 3G Ciphertext data not as expected");
3300 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3302 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3304 uint8_t curr_byte, prev_byte;
3305 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3306 uint8_t lower_byte_mask = (1 << offset) - 1;
3309 prev_byte = buffer[0];
3310 buffer[0] >>= offset;
3312 for (i = 1; i < length_in_bytes; i++) {
3313 curr_byte = buffer[i];
3314 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3315 (curr_byte >> offset);
3316 prev_byte = curr_byte;
3321 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3323 struct crypto_testsuite_params *ts_params = &testsuite_params;
3324 struct crypto_unittest_params *ut_params = &unittest_params;
3325 uint8_t *plaintext, *ciphertext;
3327 uint32_t plaintext_len;
3328 uint32_t plaintext_pad_len;
3329 uint8_t extra_offset = 4;
3330 uint8_t *expected_ciphertext_shifted;
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 + extra_offset);
3354 * Append data which is padded to a
3355 * multiple of the algorithms block size
3357 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3359 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3362 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3364 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3365 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3367 #ifdef RTE_APP_TEST_DEBUG
3368 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3370 /* Create SNOW 3G operation */
3371 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3373 tdata->validCipherLenInBits.len,
3374 tdata->validCipherOffsetLenInBits.len +
3376 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3380 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3382 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3384 ut_params->obuf = ut_params->op->sym->m_dst;
3385 if (ut_params->obuf)
3386 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3389 ciphertext = plaintext;
3391 #ifdef RTE_APP_TEST_DEBUG
3392 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3395 expected_ciphertext_shifted = rte_malloc(NULL,
3396 ceil_byte_length(plaintext_len + extra_offset), 0);
3398 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3399 "failed to reserve memory for ciphertext shifted\n");
3401 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3402 ceil_byte_length(tdata->ciphertext.len));
3403 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3406 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3408 expected_ciphertext_shifted,
3409 tdata->validDataLenInBits.len,
3411 "SNOW 3G Ciphertext data not as expected");
3415 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3417 struct crypto_testsuite_params *ts_params = &testsuite_params;
3418 struct crypto_unittest_params *ut_params = &unittest_params;
3422 uint8_t *plaintext, *ciphertext;
3423 unsigned ciphertext_pad_len;
3424 unsigned ciphertext_len;
3426 /* Create SNOW 3G session */
3427 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3428 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3429 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3430 tdata->key.data, tdata->key.len);
3434 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3436 /* Clear mbuf payload */
3437 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3438 rte_pktmbuf_tailroom(ut_params->ibuf));
3440 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3441 /* Append data which is padded to a multiple of */
3442 /* the algorithms block size */
3443 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3444 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3445 ciphertext_pad_len);
3446 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3448 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3450 /* Create SNOW 3G operation */
3451 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3452 tdata->validCipherLenInBits.len,
3453 tdata->validCipherOffsetLenInBits.len,
3454 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3458 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3460 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3461 ut_params->obuf = ut_params->op->sym->m_dst;
3462 if (ut_params->obuf)
3463 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3466 plaintext = ciphertext;
3468 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3471 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3472 tdata->plaintext.data,
3473 tdata->validDataLenInBits.len,
3474 "SNOW 3G Plaintext data not as expected");
3478 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3480 struct crypto_testsuite_params *ts_params = &testsuite_params;
3481 struct crypto_unittest_params *ut_params = &unittest_params;
3485 uint8_t *plaintext, *ciphertext;
3486 unsigned ciphertext_pad_len;
3487 unsigned ciphertext_len;
3489 /* Create SNOW 3G session */
3490 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3491 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3492 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3493 tdata->key.data, tdata->key.len);
3497 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3498 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3500 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3501 "Failed to allocate input buffer");
3502 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3503 "Failed to allocate output buffer");
3505 /* Clear mbuf payload */
3506 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3507 rte_pktmbuf_tailroom(ut_params->ibuf));
3509 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3510 rte_pktmbuf_tailroom(ut_params->obuf));
3512 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3513 /* Append data which is padded to a multiple of */
3514 /* the algorithms block size */
3515 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3516 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3517 ciphertext_pad_len);
3518 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3519 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3521 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3523 /* Create SNOW 3G operation */
3524 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3526 tdata->validCipherLenInBits.len,
3527 tdata->validCipherOffsetLenInBits.len,
3528 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3532 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3534 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3535 ut_params->obuf = ut_params->op->sym->m_dst;
3536 if (ut_params->obuf)
3537 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3540 plaintext = ciphertext;
3542 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3545 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3546 tdata->plaintext.data,
3547 tdata->validDataLenInBits.len,
3548 "SNOW 3G Plaintext data not as expected");
3553 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3555 struct crypto_testsuite_params *ts_params = &testsuite_params;
3556 struct crypto_unittest_params *ut_params = &unittest_params;
3560 uint8_t *plaintext, *ciphertext;
3561 unsigned plaintext_pad_len;
3562 unsigned plaintext_len;
3564 /* Create SNOW 3G session */
3565 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3566 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3567 RTE_CRYPTO_AUTH_OP_GENERATE,
3568 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3569 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3570 tdata->key.data, tdata->key.len,
3571 tdata->aad.len, tdata->digest.len);
3574 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3576 /* clear mbuf payload */
3577 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3578 rte_pktmbuf_tailroom(ut_params->ibuf));
3580 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3581 /* Append data which is padded to a multiple of */
3582 /* the algorithms block size */
3583 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3584 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3586 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3588 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3590 /* Create SNOW 3G operation */
3591 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3592 tdata->digest.len, tdata->aad.data,
3593 tdata->aad.len, /*tdata->plaintext.len,*/
3594 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3595 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3596 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3597 tdata->iv.data, tdata->iv.len,
3598 tdata->validCipherLenInBits.len,
3599 tdata->validCipherOffsetLenInBits.len,
3600 tdata->validAuthLenInBits.len,
3601 tdata->validAuthOffsetLenInBits.len
3606 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3608 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3609 ut_params->obuf = ut_params->op->sym->m_src;
3610 if (ut_params->obuf)
3611 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3612 + tdata->iv.len + tdata->aad.len;
3614 ciphertext = plaintext;
3616 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3618 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3620 tdata->ciphertext.data,
3621 tdata->validDataLenInBits.len,
3622 "SNOW 3G Ciphertext data not as expected");
3624 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3625 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3628 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3631 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3632 "SNOW 3G Generated auth tag not as expected");
3636 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3638 struct crypto_testsuite_params *ts_params = &testsuite_params;
3639 struct crypto_unittest_params *ut_params = &unittest_params;
3643 uint8_t *plaintext, *ciphertext;
3644 unsigned plaintext_pad_len;
3645 unsigned plaintext_len;
3647 /* Create SNOW 3G session */
3648 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3649 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3650 RTE_CRYPTO_AUTH_OP_GENERATE,
3651 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3652 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3653 tdata->key.data, tdata->key.len,
3654 tdata->aad.len, tdata->digest.len);
3658 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3660 /* clear mbuf payload */
3661 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3662 rte_pktmbuf_tailroom(ut_params->ibuf));
3664 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3665 /* Append data which is padded to a multiple of */
3666 /* the algorithms block size */
3667 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3668 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3670 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3672 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3674 /* Create SNOW 3G operation */
3675 retval = create_wireless_algo_auth_cipher_operation(
3677 tdata->iv.data, tdata->iv.len,
3678 tdata->aad.data, tdata->aad.len,
3680 tdata->validCipherLenInBits.len,
3681 tdata->validCipherOffsetLenInBits.len,
3682 tdata->validAuthLenInBits.len,
3683 tdata->validAuthOffsetLenInBits.len,
3684 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3685 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3691 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3693 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3694 ut_params->obuf = ut_params->op->sym->m_src;
3695 if (ut_params->obuf)
3696 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3697 + tdata->aad.len + tdata->iv.len;
3699 ciphertext = plaintext;
3701 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3702 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3703 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3706 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3708 tdata->ciphertext.data,
3709 tdata->validDataLenInBits.len,
3710 "SNOW 3G Ciphertext data not as expected");
3713 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3716 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3717 "SNOW 3G Generated auth tag not as expected");
3722 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3724 struct crypto_testsuite_params *ts_params = &testsuite_params;
3725 struct crypto_unittest_params *ut_params = &unittest_params;
3729 uint8_t *plaintext, *ciphertext;
3730 unsigned plaintext_pad_len;
3731 unsigned plaintext_len;
3733 /* Create KASUMI session */
3734 retval = create_wireless_algo_auth_cipher_session(
3735 ts_params->valid_devs[0],
3736 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3737 RTE_CRYPTO_AUTH_OP_GENERATE,
3738 RTE_CRYPTO_AUTH_KASUMI_F9,
3739 RTE_CRYPTO_CIPHER_KASUMI_F8,
3740 tdata->key.data, tdata->key.len,
3741 tdata->aad.len, tdata->digest.len);
3744 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3746 /* clear mbuf payload */
3747 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3748 rte_pktmbuf_tailroom(ut_params->ibuf));
3750 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3751 /* Append data which is padded to a multiple of */
3752 /* the algorithms block size */
3753 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3754 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3756 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3758 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3760 /* Create KASUMI operation */
3761 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3762 tdata->iv.data, tdata->iv.len,
3763 tdata->aad.data, tdata->aad.len,
3765 tdata->validCipherLenInBits.len,
3766 tdata->validCipherOffsetLenInBits.len,
3767 tdata->validAuthLenInBits.len,
3768 tdata->validAuthOffsetLenInBits.len,
3769 RTE_CRYPTO_AUTH_KASUMI_F9,
3770 RTE_CRYPTO_CIPHER_KASUMI_F8
3776 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3778 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3779 ut_params->obuf = ut_params->op->sym->m_src;
3780 if (ut_params->obuf)
3781 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3782 + tdata->iv.len + tdata->aad.len;
3784 ciphertext = plaintext;
3787 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3789 tdata->ciphertext.data,
3790 tdata->validCipherLenInBits.len,
3791 "KASUMI Ciphertext data not as expected");
3792 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3793 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3796 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3799 DIGEST_BYTE_LENGTH_KASUMI_F9,
3800 "KASUMI Generated auth tag not as expected");
3805 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3807 struct crypto_testsuite_params *ts_params = &testsuite_params;
3808 struct crypto_unittest_params *ut_params = &unittest_params;
3812 uint8_t *plaintext, *ciphertext;
3813 unsigned plaintext_pad_len;
3814 unsigned plaintext_len;
3816 /* Create KASUMI session */
3817 retval = create_wireless_algo_cipher_auth_session(
3818 ts_params->valid_devs[0],
3819 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3820 RTE_CRYPTO_AUTH_OP_GENERATE,
3821 RTE_CRYPTO_AUTH_KASUMI_F9,
3822 RTE_CRYPTO_CIPHER_KASUMI_F8,
3823 tdata->key.data, tdata->key.len,
3824 tdata->aad.len, tdata->digest.len);
3828 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3830 /* clear mbuf payload */
3831 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3832 rte_pktmbuf_tailroom(ut_params->ibuf));
3834 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3835 /* Append data which is padded to a multiple of */
3836 /* the algorithms block size */
3837 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3838 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3840 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3842 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3844 /* Create KASUMI operation */
3845 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3846 tdata->digest.len, tdata->aad.data,
3848 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3849 RTE_CRYPTO_AUTH_KASUMI_F9,
3850 RTE_CRYPTO_CIPHER_KASUMI_F8,
3851 tdata->iv.data, tdata->iv.len,
3852 tdata->validCipherLenInBits.len,
3853 tdata->validCipherOffsetLenInBits.len,
3854 tdata->validAuthLenInBits.len,
3855 tdata->validAuthOffsetLenInBits.len
3860 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3862 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3863 ut_params->obuf = ut_params->op->sym->m_src;
3864 if (ut_params->obuf)
3865 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3866 + tdata->aad.len + tdata->iv.len;
3868 ciphertext = plaintext;
3870 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3871 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3874 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3876 tdata->ciphertext.data,
3877 tdata->validCipherLenInBits.len,
3878 "KASUMI Ciphertext data not as expected");
3881 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3884 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3885 "KASUMI Generated auth tag not as expected");
3890 test_zuc_encryption(const struct zuc_test_data *tdata)
3892 struct crypto_testsuite_params *ts_params = &testsuite_params;
3893 struct crypto_unittest_params *ut_params = &unittest_params;
3896 uint8_t *plaintext, *ciphertext;
3897 unsigned plaintext_pad_len;
3898 unsigned plaintext_len;
3900 /* Create ZUC session */
3901 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3902 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3903 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3904 tdata->key.data, tdata->key.len);
3908 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3910 /* Clear mbuf payload */
3911 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3912 rte_pktmbuf_tailroom(ut_params->ibuf));
3914 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3915 /* Append data which is padded to a multiple */
3916 /* of the algorithms block size */
3917 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3918 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3920 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3922 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3924 /* Create ZUC operation */
3925 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3926 tdata->plaintext.len,
3927 tdata->validCipherOffsetLenInBits.len,
3928 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3932 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3934 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3936 ut_params->obuf = ut_params->op->sym->m_dst;
3937 if (ut_params->obuf)
3938 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3941 ciphertext = plaintext;
3943 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3946 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3948 tdata->ciphertext.data,
3949 tdata->validCipherLenInBits.len,
3950 "ZUC Ciphertext data not as expected");
3955 test_zuc_encryption_sgl(const struct zuc_test_data *tdata)
3957 struct crypto_testsuite_params *ts_params = &testsuite_params;
3958 struct crypto_unittest_params *ut_params = &unittest_params;
3962 unsigned int plaintext_pad_len;
3963 unsigned int plaintext_len;
3964 const uint8_t *ciphertext;
3965 uint8_t ciphertext_buffer[2048];
3966 struct rte_cryptodev_info dev_info;
3968 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3969 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3970 printf("Device doesn't support scatter-gather. "
3975 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3977 /* Append data which is padded to a multiple */
3978 /* of the algorithms block size */
3979 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3981 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3982 plaintext_pad_len, 10, 0);
3984 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
3985 tdata->plaintext.data);
3987 /* Create ZUC session */
3988 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3989 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3990 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3991 tdata->key.data, tdata->key.len);
3995 /* Clear mbuf payload */
3997 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3999 /* Create ZUC operation */
4000 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
4001 tdata->iv.len, tdata->plaintext.len,
4002 tdata->validCipherOffsetLenInBits.len,
4003 RTE_CRYPTO_CIPHER_ZUC_EEA3);
4007 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4009 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4011 ut_params->obuf = ut_params->op->sym->m_dst;
4012 if (ut_params->obuf)
4013 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4014 tdata->iv.len, plaintext_len, ciphertext_buffer);
4016 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4017 tdata->iv.len, plaintext_len, ciphertext_buffer);
4020 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4023 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4025 tdata->ciphertext.data,
4026 tdata->validCipherLenInBits.len,
4027 "ZUC Ciphertext data not as expected");
4033 test_zuc_authentication(const struct zuc_test_data *tdata)
4035 struct crypto_testsuite_params *ts_params = &testsuite_params;
4036 struct crypto_unittest_params *ut_params = &unittest_params;
4039 unsigned plaintext_pad_len;
4040 unsigned plaintext_len;
4043 /* Create ZUC session */
4044 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4045 tdata->key.data, tdata->key.len,
4046 tdata->aad.len, tdata->digest.len,
4047 RTE_CRYPTO_AUTH_OP_GENERATE,
4048 RTE_CRYPTO_AUTH_ZUC_EIA3);
4052 /* alloc mbuf and set payload */
4053 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4055 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4056 rte_pktmbuf_tailroom(ut_params->ibuf));
4058 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4059 /* Append data which is padded to a multiple of */
4060 /* the algorithms block size */
4061 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4062 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4064 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4066 /* Create ZUC operation */
4067 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4068 tdata->aad.data, tdata->aad.len,
4069 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4070 RTE_CRYPTO_AUTH_ZUC_EIA3,
4071 tdata->validAuthLenInBits.len,
4072 tdata->validAuthOffsetLenInBits.len);
4076 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4078 ut_params->obuf = ut_params->op->sym->m_src;
4079 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4080 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4081 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
4084 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4087 DIGEST_BYTE_LENGTH_KASUMI_F9,
4088 "ZUC Generated auth tag not as expected");
4094 test_kasumi_encryption_test_case_1(void)
4096 return test_kasumi_encryption(&kasumi_test_case_1);
4100 test_kasumi_encryption_test_case_1_sgl(void)
4102 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4106 test_kasumi_encryption_test_case_1_oop(void)
4108 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4112 test_kasumi_encryption_test_case_1_oop_sgl(void)
4114 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4118 test_kasumi_encryption_test_case_2(void)
4120 return test_kasumi_encryption(&kasumi_test_case_2);
4124 test_kasumi_encryption_test_case_3(void)
4126 return test_kasumi_encryption(&kasumi_test_case_3);
4130 test_kasumi_encryption_test_case_4(void)
4132 return test_kasumi_encryption(&kasumi_test_case_4);
4136 test_kasumi_encryption_test_case_5(void)
4138 return test_kasumi_encryption(&kasumi_test_case_5);
4142 test_kasumi_decryption_test_case_1(void)
4144 return test_kasumi_decryption(&kasumi_test_case_1);
4148 test_kasumi_decryption_test_case_1_oop(void)
4150 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4154 test_kasumi_decryption_test_case_2(void)
4156 return test_kasumi_decryption(&kasumi_test_case_2);
4160 test_kasumi_decryption_test_case_3(void)
4162 return test_kasumi_decryption(&kasumi_test_case_3);
4166 test_kasumi_decryption_test_case_4(void)
4168 return test_kasumi_decryption(&kasumi_test_case_4);
4172 test_kasumi_decryption_test_case_5(void)
4174 return test_kasumi_decryption(&kasumi_test_case_5);
4177 test_snow3g_encryption_test_case_1(void)
4179 return test_snow3g_encryption(&snow3g_test_case_1);
4183 test_snow3g_encryption_test_case_1_oop(void)
4185 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4189 test_snow3g_encryption_test_case_1_oop_sgl(void)
4191 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4196 test_snow3g_encryption_test_case_1_offset_oop(void)
4198 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4202 test_snow3g_encryption_test_case_2(void)
4204 return test_snow3g_encryption(&snow3g_test_case_2);
4208 test_snow3g_encryption_test_case_3(void)
4210 return test_snow3g_encryption(&snow3g_test_case_3);
4214 test_snow3g_encryption_test_case_4(void)
4216 return test_snow3g_encryption(&snow3g_test_case_4);
4220 test_snow3g_encryption_test_case_5(void)
4222 return test_snow3g_encryption(&snow3g_test_case_5);
4226 test_snow3g_decryption_test_case_1(void)
4228 return test_snow3g_decryption(&snow3g_test_case_1);
4232 test_snow3g_decryption_test_case_1_oop(void)
4234 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4238 test_snow3g_decryption_test_case_2(void)
4240 return test_snow3g_decryption(&snow3g_test_case_2);
4244 test_snow3g_decryption_test_case_3(void)
4246 return test_snow3g_decryption(&snow3g_test_case_3);
4250 test_snow3g_decryption_test_case_4(void)
4252 return test_snow3g_decryption(&snow3g_test_case_4);
4256 test_snow3g_decryption_test_case_5(void)
4258 return test_snow3g_decryption(&snow3g_test_case_5);
4261 test_snow3g_cipher_auth_test_case_1(void)
4263 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4267 test_snow3g_auth_cipher_test_case_1(void)
4269 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4273 test_kasumi_auth_cipher_test_case_1(void)
4275 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4279 test_kasumi_cipher_auth_test_case_1(void)
4281 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4285 test_zuc_encryption_test_case_1(void)
4287 return test_zuc_encryption(&zuc_test_case_1);
4291 test_zuc_encryption_test_case_2(void)
4293 return test_zuc_encryption(&zuc_test_case_2);
4297 test_zuc_encryption_test_case_3(void)
4299 return test_zuc_encryption(&zuc_test_case_3);
4303 test_zuc_encryption_test_case_4(void)
4305 return test_zuc_encryption(&zuc_test_case_4);
4309 test_zuc_encryption_test_case_5(void)
4311 return test_zuc_encryption(&zuc_test_case_5);
4315 test_zuc_encryption_test_case_6_sgl(void)
4317 return test_zuc_encryption_sgl(&zuc_test_case_1);
4321 test_zuc_hash_generate_test_case_1(void)
4323 return test_zuc_authentication(&zuc_hash_test_case_1);
4327 test_zuc_hash_generate_test_case_2(void)
4329 return test_zuc_authentication(&zuc_hash_test_case_2);
4333 test_zuc_hash_generate_test_case_3(void)
4335 return test_zuc_authentication(&zuc_hash_test_case_3);
4339 test_zuc_hash_generate_test_case_4(void)
4341 return test_zuc_authentication(&zuc_hash_test_case_4);
4345 test_zuc_hash_generate_test_case_5(void)
4347 return test_zuc_authentication(&zuc_hash_test_case_5);
4351 test_3DES_chain_qat_all(void)
4353 struct crypto_testsuite_params *ts_params = &testsuite_params;
4356 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4357 ts_params->op_mpool, ts_params->valid_devs[0],
4358 RTE_CRYPTODEV_QAT_SYM_PMD,
4359 BLKCIPHER_3DES_CHAIN_TYPE);
4361 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4363 return TEST_SUCCESS;
4367 test_DES_cipheronly_qat_all(void)
4369 struct crypto_testsuite_params *ts_params = &testsuite_params;
4372 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4373 ts_params->op_mpool, ts_params->valid_devs[0],
4374 RTE_CRYPTODEV_QAT_SYM_PMD,
4375 BLKCIPHER_DES_CIPHERONLY_TYPE);
4377 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4379 return TEST_SUCCESS;
4383 test_DES_docsis_openssl_all(void)
4385 struct crypto_testsuite_params *ts_params = &testsuite_params;
4388 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4389 ts_params->op_mpool, ts_params->valid_devs[0],
4390 RTE_CRYPTODEV_OPENSSL_PMD,
4391 BLKCIPHER_DES_DOCSIS_TYPE);
4393 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4395 return TEST_SUCCESS;
4399 test_3DES_cipheronly_qat_all(void)
4401 struct crypto_testsuite_params *ts_params = &testsuite_params;
4404 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4405 ts_params->op_mpool, ts_params->valid_devs[0],
4406 RTE_CRYPTODEV_QAT_SYM_PMD,
4407 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4409 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4411 return TEST_SUCCESS;
4415 test_3DES_chain_openssl_all(void)
4417 struct crypto_testsuite_params *ts_params = &testsuite_params;
4420 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4421 ts_params->op_mpool, ts_params->valid_devs[0],
4422 RTE_CRYPTODEV_OPENSSL_PMD,
4423 BLKCIPHER_3DES_CHAIN_TYPE);
4425 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4427 return TEST_SUCCESS;
4431 test_3DES_cipheronly_openssl_all(void)
4433 struct crypto_testsuite_params *ts_params = &testsuite_params;
4436 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4437 ts_params->op_mpool, ts_params->valid_devs[0],
4438 RTE_CRYPTODEV_OPENSSL_PMD,
4439 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4441 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4443 return TEST_SUCCESS;
4446 /* ***** AES-GCM Tests ***** */
4449 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4450 const uint8_t *key, const uint8_t key_len,
4451 const uint8_t aad_len, const uint8_t auth_len,
4452 enum rte_crypto_auth_operation auth_op)
4454 uint8_t cipher_key[key_len];
4456 struct crypto_unittest_params *ut_params = &unittest_params;
4458 memcpy(cipher_key, key, key_len);
4460 /* Setup Cipher Parameters */
4461 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4462 ut_params->cipher_xform.next = NULL;
4464 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4465 ut_params->auth_xform.auth.op = auth_op;
4466 ut_params->cipher_xform.cipher.op = op;
4467 ut_params->cipher_xform.cipher.key.data = cipher_key;
4468 ut_params->cipher_xform.cipher.key.length = key_len;
4470 TEST_HEXDUMP(stdout, "key:", key, key_len);
4472 /* Setup Authentication Parameters */
4473 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4474 ut_params->auth_xform.next = NULL;
4476 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4478 ut_params->auth_xform.auth.digest_length = auth_len;
4479 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4480 ut_params->auth_xform.auth.key.length = 0;
4481 ut_params->auth_xform.auth.key.data = NULL;
4483 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4484 ut_params->cipher_xform.next = &ut_params->auth_xform;
4486 /* Create Crypto session*/
4487 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4488 &ut_params->cipher_xform);
4489 } else {/* Create Crypto session*/
4490 ut_params->auth_xform.next = &ut_params->cipher_xform;
4491 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4492 &ut_params->auth_xform);
4495 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4501 create_gcm_xforms(struct rte_crypto_op *op,
4502 enum rte_crypto_cipher_operation cipher_op,
4503 uint8_t *key, const uint8_t key_len,
4504 const uint8_t aad_len, const uint8_t auth_len,
4505 enum rte_crypto_auth_operation auth_op)
4507 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4508 "failed to allocate space for crypto transforms");
4510 struct rte_crypto_sym_op *sym_op = op->sym;
4512 /* Setup Cipher Parameters */
4513 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4514 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4515 sym_op->xform->cipher.op = cipher_op;
4516 sym_op->xform->cipher.key.data = key;
4517 sym_op->xform->cipher.key.length = key_len;
4519 TEST_HEXDUMP(stdout, "key:", key, key_len);
4521 /* Setup Authentication Parameters */
4522 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4523 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4524 sym_op->xform->next->auth.op = auth_op;
4525 sym_op->xform->next->auth.digest_length = auth_len;
4526 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4527 sym_op->xform->next->auth.key.length = 0;
4528 sym_op->xform->next->auth.key.data = NULL;
4529 sym_op->xform->next->next = NULL;
4535 create_gcm_operation(enum rte_crypto_cipher_operation op,
4536 const struct gcm_test_data *tdata)
4538 struct crypto_testsuite_params *ts_params = &testsuite_params;
4539 struct crypto_unittest_params *ut_params = &unittest_params;
4541 uint8_t *plaintext, *ciphertext;
4542 unsigned int iv_pad_len, aad_pad_len, plaintext_pad_len;
4544 /* Generate Crypto op data structure */
4545 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4546 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4547 TEST_ASSERT_NOT_NULL(ut_params->op,
4548 "Failed to allocate symmetric crypto operation struct");
4550 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4552 /* Append aad data */
4553 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4554 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4556 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4557 "no room to append aad");
4559 sym_op->auth.aad.length = tdata->aad.len;
4560 sym_op->auth.aad.phys_addr =
4561 rte_pktmbuf_mtophys(ut_params->ibuf);
4562 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4563 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4564 sym_op->auth.aad.length);
4567 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
4568 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4569 ut_params->ibuf, iv_pad_len);
4570 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4572 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4573 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4574 sym_op->cipher.iv.length = tdata->iv.len;
4576 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4577 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
4578 sym_op->cipher.iv.length);
4580 /* Append plaintext/ciphertext */
4581 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4582 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4583 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4585 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4587 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4588 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4589 tdata->plaintext.len);
4591 if (ut_params->obuf) {
4592 ciphertext = (uint8_t *)rte_pktmbuf_append(
4594 plaintext_pad_len + aad_pad_len +
4596 TEST_ASSERT_NOT_NULL(ciphertext,
4597 "no room to append ciphertext");
4599 memset(ciphertext + aad_pad_len + iv_pad_len, 0,
4600 tdata->ciphertext.len);
4603 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4604 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4606 TEST_ASSERT_NOT_NULL(ciphertext,
4607 "no room to append ciphertext");
4609 memcpy(ciphertext, tdata->ciphertext.data,
4610 tdata->ciphertext.len);
4611 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4612 tdata->ciphertext.len);
4614 if (ut_params->obuf) {
4615 plaintext = (uint8_t *)rte_pktmbuf_append(
4617 plaintext_pad_len + aad_pad_len +
4619 TEST_ASSERT_NOT_NULL(plaintext,
4620 "no room to append plaintext");
4622 memset(plaintext + aad_pad_len + iv_pad_len, 0,
4623 tdata->plaintext.len);
4627 /* Append digest data */
4628 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4629 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4630 ut_params->obuf ? ut_params->obuf :
4632 tdata->auth_tag.len);
4633 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4634 "no room to append digest");
4635 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4636 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4637 ut_params->obuf ? ut_params->obuf :
4640 aad_pad_len + iv_pad_len);
4641 sym_op->auth.digest.length = tdata->auth_tag.len;
4643 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4644 ut_params->ibuf, tdata->auth_tag.len);
4645 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4646 "no room to append digest");
4647 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4649 plaintext_pad_len + aad_pad_len + iv_pad_len);
4650 sym_op->auth.digest.length = tdata->auth_tag.len;
4652 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4653 tdata->auth_tag.len);
4654 TEST_HEXDUMP(stdout, "digest:",
4655 sym_op->auth.digest.data,
4656 sym_op->auth.digest.length);
4659 sym_op->cipher.data.length = tdata->plaintext.len;
4660 sym_op->cipher.data.offset = aad_pad_len + iv_pad_len;
4662 sym_op->auth.data.length = tdata->plaintext.len;
4663 sym_op->auth.data.offset = aad_pad_len + iv_pad_len;
4669 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4671 struct crypto_testsuite_params *ts_params = &testsuite_params;
4672 struct crypto_unittest_params *ut_params = &unittest_params;
4675 uint8_t *ciphertext, *auth_tag;
4676 uint16_t plaintext_pad_len;
4679 /* Create GCM session */
4680 retval = create_gcm_session(ts_params->valid_devs[0],
4681 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4682 tdata->key.data, tdata->key.len,
4683 tdata->aad.len, tdata->auth_tag.len,
4684 RTE_CRYPTO_AUTH_OP_GENERATE);
4688 if (tdata->aad.len > MBUF_SIZE) {
4689 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4690 /* Populate full size of add data */
4691 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4692 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4694 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4696 /* clear mbuf payload */
4697 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4698 rte_pktmbuf_tailroom(ut_params->ibuf));
4700 /* Create GCM operation */
4701 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4705 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4707 ut_params->op->sym->m_src = ut_params->ibuf;
4709 /* Process crypto operation */
4710 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4711 ut_params->op), "failed to process sym crypto op");
4713 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4714 "crypto op processing failed");
4716 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4718 if (ut_params->op->sym->m_dst) {
4719 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4721 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4722 uint8_t *, plaintext_pad_len);
4724 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4726 ut_params->op->sym->cipher.data.offset);
4727 auth_tag = ciphertext + plaintext_pad_len;
4730 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4731 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4734 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4736 tdata->ciphertext.data,
4737 tdata->ciphertext.len,
4738 "GCM Ciphertext data not as expected");
4740 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4742 tdata->auth_tag.data,
4743 tdata->auth_tag.len,
4744 "GCM Generated auth tag not as expected");
4751 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4753 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4757 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4759 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4763 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4765 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4769 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4771 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4775 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4777 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4781 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4783 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4787 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4789 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4793 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4795 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4799 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4801 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4805 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4807 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4811 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
4813 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
4817 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
4819 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
4823 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
4825 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
4829 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
4831 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
4835 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
4837 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
4841 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
4843 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
4847 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4849 struct crypto_testsuite_params *ts_params = &testsuite_params;
4850 struct crypto_unittest_params *ut_params = &unittest_params;
4856 /* Create GCM session */
4857 retval = create_gcm_session(ts_params->valid_devs[0],
4858 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4859 tdata->key.data, tdata->key.len,
4860 tdata->aad.len, tdata->auth_tag.len,
4861 RTE_CRYPTO_AUTH_OP_VERIFY);
4865 /* alloc mbuf and set payload */
4866 if (tdata->aad.len > MBUF_SIZE) {
4867 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4868 /* Populate full size of add data */
4869 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4870 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4874 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4875 rte_pktmbuf_tailroom(ut_params->ibuf));
4877 /* Create GCM operation */
4878 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
4882 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4884 ut_params->op->sym->m_src = ut_params->ibuf;
4886 /* Process crypto operation */
4887 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4888 ut_params->op), "failed to process sym crypto op");
4890 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4891 "crypto op processing failed");
4893 if (ut_params->op->sym->m_dst)
4894 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4897 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4899 ut_params->op->sym->cipher.data.offset);
4901 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4904 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4906 tdata->plaintext.data,
4907 tdata->plaintext.len,
4908 "GCM plaintext data not as expected");
4910 TEST_ASSERT_EQUAL(ut_params->op->status,
4911 RTE_CRYPTO_OP_STATUS_SUCCESS,
4912 "GCM authentication failed");
4917 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4919 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4923 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4925 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4929 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4931 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4935 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4937 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4941 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4943 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4947 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4949 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4953 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4955 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4959 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
4961 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
4965 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
4967 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
4971 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
4973 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
4977 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
4979 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
4983 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
4985 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
4989 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
4991 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
4995 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
4997 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5001 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5003 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5007 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5009 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5013 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5015 struct crypto_testsuite_params *ts_params = &testsuite_params;
5016 struct crypto_unittest_params *ut_params = &unittest_params;
5019 uint8_t *ciphertext, *auth_tag;
5020 uint16_t plaintext_pad_len;
5022 /* Create GCM session */
5023 retval = create_gcm_session(ts_params->valid_devs[0],
5024 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5025 tdata->key.data, tdata->key.len,
5026 tdata->aad.len, tdata->auth_tag.len,
5027 RTE_CRYPTO_AUTH_OP_GENERATE);
5031 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5032 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5034 /* clear mbuf payload */
5035 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5036 rte_pktmbuf_tailroom(ut_params->ibuf));
5037 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5038 rte_pktmbuf_tailroom(ut_params->obuf));
5040 /* Create GCM operation */
5041 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5045 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5047 ut_params->op->sym->m_src = ut_params->ibuf;
5048 ut_params->op->sym->m_dst = ut_params->obuf;
5050 /* Process crypto operation */
5051 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5052 ut_params->op), "failed to process sym crypto op");
5054 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5055 "crypto op processing failed");
5057 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5059 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5060 ut_params->op->sym->cipher.data.offset);
5061 auth_tag = ciphertext + plaintext_pad_len;
5063 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5064 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5067 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5069 tdata->ciphertext.data,
5070 tdata->ciphertext.len,
5071 "GCM Ciphertext data not as expected");
5073 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5075 tdata->auth_tag.data,
5076 tdata->auth_tag.len,
5077 "GCM Generated auth tag not as expected");
5084 test_mb_AES_GCM_authenticated_encryption_oop(void)
5086 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5090 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5092 struct crypto_testsuite_params *ts_params = &testsuite_params;
5093 struct crypto_unittest_params *ut_params = &unittest_params;
5098 /* Create GCM session */
5099 retval = create_gcm_session(ts_params->valid_devs[0],
5100 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5101 tdata->key.data, tdata->key.len,
5102 tdata->aad.len, tdata->auth_tag.len,
5103 RTE_CRYPTO_AUTH_OP_VERIFY);
5107 /* alloc mbuf and set payload */
5108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5109 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5112 rte_pktmbuf_tailroom(ut_params->ibuf));
5113 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5114 rte_pktmbuf_tailroom(ut_params->obuf));
5116 /* Create GCM operation */
5117 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5121 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5123 ut_params->op->sym->m_src = ut_params->ibuf;
5124 ut_params->op->sym->m_dst = ut_params->obuf;
5126 /* Process crypto operation */
5127 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5128 ut_params->op), "failed to process sym crypto op");
5130 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5131 "crypto op processing failed");
5133 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5134 ut_params->op->sym->cipher.data.offset);
5136 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5139 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5141 tdata->plaintext.data,
5142 tdata->plaintext.len,
5143 "GCM plaintext data not as expected");
5145 TEST_ASSERT_EQUAL(ut_params->op->status,
5146 RTE_CRYPTO_OP_STATUS_SUCCESS,
5147 "GCM authentication failed");
5152 test_mb_AES_GCM_authenticated_decryption_oop(void)
5154 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5158 test_AES_GCM_authenticated_encryption_sessionless(
5159 const struct gcm_test_data *tdata)
5161 struct crypto_testsuite_params *ts_params = &testsuite_params;
5162 struct crypto_unittest_params *ut_params = &unittest_params;
5165 uint8_t *ciphertext, *auth_tag;
5166 uint16_t plaintext_pad_len;
5167 uint8_t key[tdata->key.len + 1];
5169 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5171 /* clear mbuf payload */
5172 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5173 rte_pktmbuf_tailroom(ut_params->ibuf));
5175 /* Create GCM operation */
5176 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5180 /* Create GCM xforms */
5181 memcpy(key, tdata->key.data, tdata->key.len);
5182 retval = create_gcm_xforms(ut_params->op,
5183 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5184 key, tdata->key.len,
5185 tdata->aad.len, tdata->auth_tag.len,
5186 RTE_CRYPTO_AUTH_OP_GENERATE);
5190 ut_params->op->sym->m_src = ut_params->ibuf;
5192 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5193 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5194 "crypto op session type not sessionless");
5196 /* Process crypto operation */
5197 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5198 ut_params->op), "failed to process sym crypto op");
5200 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5202 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5203 "crypto op status not success");
5205 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5207 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5208 ut_params->op->sym->cipher.data.offset);
5209 auth_tag = ciphertext + plaintext_pad_len;
5211 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5212 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5215 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5217 tdata->ciphertext.data,
5218 tdata->ciphertext.len,
5219 "GCM Ciphertext data not as expected");
5221 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5223 tdata->auth_tag.data,
5224 tdata->auth_tag.len,
5225 "GCM Generated auth tag not as expected");
5232 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5234 return test_AES_GCM_authenticated_encryption_sessionless(
5239 test_AES_GCM_authenticated_decryption_sessionless(
5240 const struct gcm_test_data *tdata)
5242 struct crypto_testsuite_params *ts_params = &testsuite_params;
5243 struct crypto_unittest_params *ut_params = &unittest_params;
5247 uint8_t key[tdata->key.len + 1];
5249 /* alloc mbuf and set payload */
5250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5252 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5253 rte_pktmbuf_tailroom(ut_params->ibuf));
5255 /* Create GCM operation */
5256 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5260 /* Create GCM xforms */
5261 memcpy(key, tdata->key.data, tdata->key.len);
5262 retval = create_gcm_xforms(ut_params->op,
5263 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5264 key, tdata->key.len,
5265 tdata->aad.len, tdata->auth_tag.len,
5266 RTE_CRYPTO_AUTH_OP_VERIFY);
5270 ut_params->op->sym->m_src = ut_params->ibuf;
5272 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5273 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5274 "crypto op session type not sessionless");
5276 /* Process crypto operation */
5277 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5278 ut_params->op), "failed to process sym crypto op");
5280 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5282 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5283 "crypto op status not success");
5285 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5286 ut_params->op->sym->cipher.data.offset);
5288 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5291 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5293 tdata->plaintext.data,
5294 tdata->plaintext.len,
5295 "GCM plaintext data not as expected");
5297 TEST_ASSERT_EQUAL(ut_params->op->status,
5298 RTE_CRYPTO_OP_STATUS_SUCCESS,
5299 "GCM authentication failed");
5304 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5306 return test_AES_GCM_authenticated_decryption_sessionless(
5313 struct crypto_testsuite_params *ts_params = &testsuite_params;
5314 struct rte_cryptodev_stats stats;
5315 struct rte_cryptodev *dev;
5316 cryptodev_stats_get_t temp_pfn;
5318 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5319 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5320 &stats) == -ENODEV),
5321 "rte_cryptodev_stats_get invalid dev failed");
5322 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5323 "rte_cryptodev_stats_get invalid Param failed");
5324 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5325 temp_pfn = dev->dev_ops->stats_get;
5326 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5327 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5329 "rte_cryptodev_stats_get invalid Param failed");
5330 dev->dev_ops->stats_get = temp_pfn;
5332 /* Test expected values */
5334 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5336 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5338 "rte_cryptodev_stats_get failed");
5339 TEST_ASSERT((stats.enqueued_count == 1),
5340 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5341 TEST_ASSERT((stats.dequeued_count == 1),
5342 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5343 TEST_ASSERT((stats.enqueue_err_count == 0),
5344 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5345 TEST_ASSERT((stats.dequeue_err_count == 0),
5346 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5348 /* invalid device but should ignore and not reset device stats*/
5349 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5350 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5352 "rte_cryptodev_stats_get failed");
5353 TEST_ASSERT((stats.enqueued_count == 1),
5354 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5356 /* check that a valid reset clears stats */
5357 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5358 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5360 "rte_cryptodev_stats_get failed");
5361 TEST_ASSERT((stats.enqueued_count == 0),
5362 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5363 TEST_ASSERT((stats.dequeued_count == 0),
5364 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5366 return TEST_SUCCESS;
5369 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5370 struct crypto_unittest_params *ut_params,
5371 enum rte_crypto_auth_operation op,
5372 const struct HMAC_MD5_vector *test_case)
5376 memcpy(key, test_case->key.data, test_case->key.len);
5378 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5379 ut_params->auth_xform.next = NULL;
5380 ut_params->auth_xform.auth.op = op;
5382 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5384 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5385 ut_params->auth_xform.auth.add_auth_data_length = 0;
5386 ut_params->auth_xform.auth.key.length = test_case->key.len;
5387 ut_params->auth_xform.auth.key.data = key;
5389 ut_params->sess = rte_cryptodev_sym_session_create(
5390 ts_params->valid_devs[0], &ut_params->auth_xform);
5392 if (ut_params->sess == NULL)
5395 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5397 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5398 rte_pktmbuf_tailroom(ut_params->ibuf));
5403 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5404 const struct HMAC_MD5_vector *test_case,
5405 uint8_t **plaintext)
5407 uint16_t plaintext_pad_len;
5409 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5411 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5414 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5416 memcpy(*plaintext, test_case->plaintext.data,
5417 test_case->plaintext.len);
5419 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5420 ut_params->ibuf, MD5_DIGEST_LEN);
5421 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5422 "no room to append digest");
5423 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5424 ut_params->ibuf, plaintext_pad_len);
5425 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5427 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5428 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5429 test_case->auth_tag.len);
5432 sym_op->auth.data.offset = 0;
5433 sym_op->auth.data.length = test_case->plaintext.len;
5435 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5436 ut_params->op->sym->m_src = ut_params->ibuf;
5442 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5444 uint16_t plaintext_pad_len;
5445 uint8_t *plaintext, *auth_tag;
5447 struct crypto_testsuite_params *ts_params = &testsuite_params;
5448 struct crypto_unittest_params *ut_params = &unittest_params;
5450 if (MD5_HMAC_create_session(ts_params, ut_params,
5451 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5454 /* Generate Crypto op data structure */
5455 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5456 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5457 TEST_ASSERT_NOT_NULL(ut_params->op,
5458 "Failed to allocate symmetric crypto operation struct");
5460 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5463 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5466 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5467 ut_params->op), "failed to process sym crypto op");
5469 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5470 "crypto op processing failed");
5472 if (ut_params->op->sym->m_dst) {
5473 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5474 uint8_t *, plaintext_pad_len);
5476 auth_tag = plaintext + plaintext_pad_len;
5479 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5481 test_case->auth_tag.data,
5482 test_case->auth_tag.len,
5483 "HMAC_MD5 generated tag not as expected");
5485 return TEST_SUCCESS;
5489 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5493 struct crypto_testsuite_params *ts_params = &testsuite_params;
5494 struct crypto_unittest_params *ut_params = &unittest_params;
5496 if (MD5_HMAC_create_session(ts_params, ut_params,
5497 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5501 /* Generate Crypto op data structure */
5502 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5503 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5504 TEST_ASSERT_NOT_NULL(ut_params->op,
5505 "Failed to allocate symmetric crypto operation struct");
5507 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5510 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5511 ut_params->op), "failed to process sym crypto op");
5513 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5514 "HMAC_MD5 crypto op processing failed");
5516 return TEST_SUCCESS;
5520 test_MD5_HMAC_generate_case_1(void)
5522 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5526 test_MD5_HMAC_verify_case_1(void)
5528 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5532 test_MD5_HMAC_generate_case_2(void)
5534 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5538 test_MD5_HMAC_verify_case_2(void)
5540 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5544 test_multi_session(void)
5546 struct crypto_testsuite_params *ts_params = &testsuite_params;
5547 struct crypto_unittest_params *ut_params = &unittest_params;
5549 struct rte_cryptodev_info dev_info;
5550 struct rte_cryptodev_sym_session **sessions;
5554 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5555 aes_cbc_key, hmac_sha512_key);
5558 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5560 sessions = rte_malloc(NULL,
5561 (sizeof(struct rte_cryptodev_sym_session *) *
5562 dev_info.sym.max_nb_sessions) + 1, 0);
5564 /* Create multiple crypto sessions*/
5565 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5566 sessions[i] = rte_cryptodev_sym_session_create(
5567 ts_params->valid_devs[0],
5568 &ut_params->auth_xform);
5569 TEST_ASSERT_NOT_NULL(sessions[i],
5570 "Session creation failed at session number %u",
5573 /* Attempt to send a request on each session */
5574 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5578 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5579 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5581 "Failed to perform decrypt on request number %u.", i);
5582 /* free crypto operation structure */
5584 rte_crypto_op_free(ut_params->op);
5587 * free mbuf - both obuf and ibuf are usually the same,
5588 * so check if they point at the same address is necessary,
5589 * to avoid freeing the mbuf twice.
5591 if (ut_params->obuf) {
5592 rte_pktmbuf_free(ut_params->obuf);
5593 if (ut_params->ibuf == ut_params->obuf)
5594 ut_params->ibuf = 0;
5595 ut_params->obuf = 0;
5597 if (ut_params->ibuf) {
5598 rte_pktmbuf_free(ut_params->ibuf);
5599 ut_params->ibuf = 0;
5603 /* Next session create should fail */
5604 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5605 &ut_params->auth_xform);
5606 TEST_ASSERT_NULL(sessions[i],
5607 "Session creation succeeded unexpectedly!");
5609 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5610 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5615 return TEST_SUCCESS;
5618 struct multi_session_params {
5619 struct crypto_unittest_params ut_params;
5620 uint8_t *cipher_key;
5622 const uint8_t *cipher;
5623 const uint8_t *digest;
5627 #define MB_SESSION_NUMBER 3
5630 test_multi_session_random_usage(void)
5632 struct crypto_testsuite_params *ts_params = &testsuite_params;
5633 struct rte_cryptodev_info dev_info;
5634 struct rte_cryptodev_sym_session **sessions;
5636 struct multi_session_params ut_paramz[] = {
5639 .cipher_key = ms_aes_cbc_key0,
5640 .hmac_key = ms_hmac_key0,
5641 .cipher = ms_aes_cbc_cipher0,
5642 .digest = ms_hmac_digest0,
5643 .iv = ms_aes_cbc_iv0
5646 .cipher_key = ms_aes_cbc_key1,
5647 .hmac_key = ms_hmac_key1,
5648 .cipher = ms_aes_cbc_cipher1,
5649 .digest = ms_hmac_digest1,
5650 .iv = ms_aes_cbc_iv1
5653 .cipher_key = ms_aes_cbc_key2,
5654 .hmac_key = ms_hmac_key2,
5655 .cipher = ms_aes_cbc_cipher2,
5656 .digest = ms_hmac_digest2,
5657 .iv = ms_aes_cbc_iv2
5662 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5664 sessions = rte_malloc(NULL,
5665 (sizeof(struct rte_cryptodev_sym_session *)
5666 * dev_info.sym.max_nb_sessions) + 1, 0);
5668 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5669 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5670 sizeof(struct crypto_unittest_params));
5672 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5673 &ut_paramz[i].ut_params,
5674 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5676 /* Create multiple crypto sessions*/
5677 sessions[i] = rte_cryptodev_sym_session_create(
5678 ts_params->valid_devs[0],
5679 &ut_paramz[i].ut_params.auth_xform);
5681 TEST_ASSERT_NOT_NULL(sessions[i],
5682 "Session creation failed at session number %u",
5688 for (i = 0; i < 40000; i++) {
5690 j = rand() % MB_SESSION_NUMBER;
5692 TEST_ASSERT_SUCCESS(
5693 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5695 &ut_paramz[j].ut_params,
5696 ts_params, ut_paramz[j].cipher,
5697 ut_paramz[j].digest,
5699 "Failed to perform decrypt on request number %u.", i);
5701 if (ut_paramz[j].ut_params.op)
5702 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5705 * free mbuf - both obuf and ibuf are usually the same,
5706 * so check if they point at the same address is necessary,
5707 * to avoid freeing the mbuf twice.
5709 if (ut_paramz[j].ut_params.obuf) {
5710 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5711 if (ut_paramz[j].ut_params.ibuf
5712 == ut_paramz[j].ut_params.obuf)
5713 ut_paramz[j].ut_params.ibuf = 0;
5714 ut_paramz[j].ut_params.obuf = 0;
5716 if (ut_paramz[j].ut_params.ibuf) {
5717 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5718 ut_paramz[j].ut_params.ibuf = 0;
5722 for (i = 0; i < MB_SESSION_NUMBER; i++)
5723 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5728 return TEST_SUCCESS;
5732 test_null_cipher_only_operation(void)
5734 struct crypto_testsuite_params *ts_params = &testsuite_params;
5735 struct crypto_unittest_params *ut_params = &unittest_params;
5737 /* Generate test mbuf data and space for digest */
5738 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5739 catch_22_quote, QUOTE_512_BYTES, 0);
5741 /* Setup Cipher Parameters */
5742 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5743 ut_params->cipher_xform.next = NULL;
5745 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5746 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5748 /* Create Crypto session*/
5749 ut_params->sess = rte_cryptodev_sym_session_create(
5750 ts_params->valid_devs[0], &ut_params->cipher_xform);
5751 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5753 /* Generate Crypto op data structure */
5754 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5755 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5756 TEST_ASSERT_NOT_NULL(ut_params->op,
5757 "Failed to allocate symmetric crypto operation struct");
5759 /* Set crypto operation data parameters */
5760 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5762 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5764 /* set crypto operation source mbuf */
5765 sym_op->m_src = ut_params->ibuf;
5767 sym_op->cipher.data.offset = 0;
5768 sym_op->cipher.data.length = QUOTE_512_BYTES;
5770 /* Process crypto operation */
5771 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5773 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5775 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5776 "crypto operation processing failed");
5779 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5780 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5783 "Ciphertext data not as expected");
5785 return TEST_SUCCESS;
5789 test_null_auth_only_operation(void)
5791 struct crypto_testsuite_params *ts_params = &testsuite_params;
5792 struct crypto_unittest_params *ut_params = &unittest_params;
5794 /* Generate test mbuf data and space for digest */
5795 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5796 catch_22_quote, QUOTE_512_BYTES, 0);
5798 /* Setup HMAC Parameters */
5799 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5800 ut_params->auth_xform.next = NULL;
5802 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5803 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5805 /* Create Crypto session*/
5806 ut_params->sess = rte_cryptodev_sym_session_create(
5807 ts_params->valid_devs[0], &ut_params->auth_xform);
5808 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5810 /* Generate Crypto op data structure */
5811 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5812 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5813 TEST_ASSERT_NOT_NULL(ut_params->op,
5814 "Failed to allocate symmetric crypto operation struct");
5816 /* Set crypto operation data parameters */
5817 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5819 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5821 sym_op->m_src = ut_params->ibuf;
5823 sym_op->auth.data.offset = 0;
5824 sym_op->auth.data.length = QUOTE_512_BYTES;
5826 /* Process crypto operation */
5827 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5829 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5831 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5832 "crypto operation processing failed");
5834 return TEST_SUCCESS;
5838 test_null_cipher_auth_operation(void)
5840 struct crypto_testsuite_params *ts_params = &testsuite_params;
5841 struct crypto_unittest_params *ut_params = &unittest_params;
5843 /* Generate test mbuf data and space for digest */
5844 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5845 catch_22_quote, QUOTE_512_BYTES, 0);
5847 /* Setup Cipher Parameters */
5848 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5849 ut_params->cipher_xform.next = &ut_params->auth_xform;
5851 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5852 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5854 /* Setup HMAC Parameters */
5855 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5856 ut_params->auth_xform.next = NULL;
5858 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5859 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5861 /* Create Crypto session*/
5862 ut_params->sess = rte_cryptodev_sym_session_create(
5863 ts_params->valid_devs[0], &ut_params->cipher_xform);
5864 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5866 /* Generate Crypto op data structure */
5867 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5868 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5869 TEST_ASSERT_NOT_NULL(ut_params->op,
5870 "Failed to allocate symmetric crypto operation struct");
5872 /* Set crypto operation data parameters */
5873 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5875 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5877 sym_op->m_src = ut_params->ibuf;
5879 sym_op->cipher.data.offset = 0;
5880 sym_op->cipher.data.length = QUOTE_512_BYTES;
5882 sym_op->auth.data.offset = 0;
5883 sym_op->auth.data.length = QUOTE_512_BYTES;
5885 /* Process crypto operation */
5886 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5888 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5890 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5891 "crypto operation processing failed");
5894 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5895 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5898 "Ciphertext data not as expected");
5900 return TEST_SUCCESS;
5904 test_null_auth_cipher_operation(void)
5906 struct crypto_testsuite_params *ts_params = &testsuite_params;
5907 struct crypto_unittest_params *ut_params = &unittest_params;
5909 /* Generate test mbuf data and space for digest */
5910 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5911 catch_22_quote, QUOTE_512_BYTES, 0);
5913 /* Setup Cipher Parameters */
5914 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5915 ut_params->cipher_xform.next = NULL;
5917 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5918 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5920 /* Setup HMAC Parameters */
5921 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5922 ut_params->auth_xform.next = &ut_params->cipher_xform;
5924 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5925 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5927 /* Create Crypto session*/
5928 ut_params->sess = rte_cryptodev_sym_session_create(
5929 ts_params->valid_devs[0], &ut_params->cipher_xform);
5930 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5932 /* Generate Crypto op data structure */
5933 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5934 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5935 TEST_ASSERT_NOT_NULL(ut_params->op,
5936 "Failed to allocate symmetric crypto operation struct");
5938 /* Set crypto operation data parameters */
5939 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5941 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5943 sym_op->m_src = ut_params->ibuf;
5945 sym_op->cipher.data.offset = 0;
5946 sym_op->cipher.data.length = QUOTE_512_BYTES;
5948 sym_op->auth.data.offset = 0;
5949 sym_op->auth.data.length = QUOTE_512_BYTES;
5951 /* Process crypto operation */
5952 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5954 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5956 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5957 "crypto operation processing failed");
5960 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5961 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5964 "Ciphertext data not as expected");
5966 return TEST_SUCCESS;
5971 test_null_invalid_operation(void)
5973 struct crypto_testsuite_params *ts_params = &testsuite_params;
5974 struct crypto_unittest_params *ut_params = &unittest_params;
5976 /* Setup Cipher Parameters */
5977 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5978 ut_params->cipher_xform.next = NULL;
5980 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
5981 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5983 /* Create Crypto session*/
5984 ut_params->sess = rte_cryptodev_sym_session_create(
5985 ts_params->valid_devs[0], &ut_params->cipher_xform);
5986 TEST_ASSERT_NULL(ut_params->sess,
5987 "Session creation succeeded unexpectedly");
5990 /* Setup HMAC Parameters */
5991 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5992 ut_params->auth_xform.next = NULL;
5994 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
5995 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5997 /* Create Crypto session*/
5998 ut_params->sess = rte_cryptodev_sym_session_create(
5999 ts_params->valid_devs[0], &ut_params->auth_xform);
6000 TEST_ASSERT_NULL(ut_params->sess,
6001 "Session creation succeeded unexpectedly");
6003 return TEST_SUCCESS;
6007 #define NULL_BURST_LENGTH (32)
6010 test_null_burst_operation(void)
6012 struct crypto_testsuite_params *ts_params = &testsuite_params;
6013 struct crypto_unittest_params *ut_params = &unittest_params;
6015 unsigned i, burst_len = NULL_BURST_LENGTH;
6017 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6018 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6020 /* Setup Cipher Parameters */
6021 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6022 ut_params->cipher_xform.next = &ut_params->auth_xform;
6024 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6025 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6027 /* Setup HMAC Parameters */
6028 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6029 ut_params->auth_xform.next = NULL;
6031 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6032 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6034 /* Create Crypto session*/
6035 ut_params->sess = rte_cryptodev_sym_session_create(
6036 ts_params->valid_devs[0], &ut_params->cipher_xform);
6037 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6039 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6040 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6041 burst_len, "failed to generate burst of crypto ops");
6043 /* Generate an operation for each mbuf in burst */
6044 for (i = 0; i < burst_len; i++) {
6045 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6047 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6049 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6053 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6055 burst[i]->sym->m_src = m;
6058 /* Process crypto operation */
6059 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6060 0, burst, burst_len),
6062 "Error enqueuing burst");
6064 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6065 0, burst_dequeued, burst_len),
6067 "Error dequeuing burst");
6070 for (i = 0; i < burst_len; i++) {
6072 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6073 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6075 "data not as expected");
6077 rte_pktmbuf_free(burst[i]->sym->m_src);
6078 rte_crypto_op_free(burst[i]);
6081 return TEST_SUCCESS;
6085 generate_gmac_large_plaintext(uint8_t *data)
6089 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6090 memcpy(&data[i], &data[0], 32);
6094 create_gmac_operation(enum rte_crypto_auth_operation op,
6095 const struct gmac_test_data *tdata)
6097 struct crypto_testsuite_params *ts_params = &testsuite_params;
6098 struct crypto_unittest_params *ut_params = &unittest_params;
6099 struct rte_crypto_sym_op *sym_op;
6101 unsigned iv_pad_len;
6102 unsigned aad_pad_len;
6104 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
6105 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6108 * Runtime generate the large plain text instead of use hard code
6109 * plain text vector. It is done to avoid create huge source file
6110 * with the test vector.
6112 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6113 generate_gmac_large_plaintext(tdata->aad.data);
6115 /* Generate Crypto op data structure */
6116 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6117 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6118 TEST_ASSERT_NOT_NULL(ut_params->op,
6119 "Failed to allocate symmetric crypto operation struct");
6121 sym_op = ut_params->op->sym;
6122 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6124 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6125 "no room to append aad");
6127 sym_op->auth.aad.length = tdata->aad.len;
6128 sym_op->auth.aad.phys_addr =
6129 rte_pktmbuf_mtophys(ut_params->ibuf);
6130 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6132 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6133 ut_params->ibuf, tdata->gmac_tag.len);
6134 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6135 "no room to append digest");
6137 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6138 ut_params->ibuf, aad_pad_len);
6139 sym_op->auth.digest.length = tdata->gmac_tag.len;
6141 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6142 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6143 tdata->gmac_tag.len);
6144 TEST_HEXDUMP(stdout, "digest:",
6145 sym_op->auth.digest.data,
6146 sym_op->auth.digest.length);
6149 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6150 ut_params->ibuf, iv_pad_len);
6151 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6153 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6154 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6155 sym_op->cipher.iv.length = tdata->iv.len;
6157 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
6159 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6161 sym_op->cipher.data.length = 0;
6162 sym_op->cipher.data.offset = 0;
6164 sym_op->auth.data.offset = 0;
6165 sym_op->auth.data.length = 0;
6170 static int create_gmac_session(uint8_t dev_id,
6171 enum rte_crypto_cipher_operation op,
6172 const struct gmac_test_data *tdata,
6173 enum rte_crypto_auth_operation auth_op)
6175 uint8_t cipher_key[tdata->key.len];
6177 struct crypto_unittest_params *ut_params = &unittest_params;
6179 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6181 /* For GMAC we setup cipher parameters */
6182 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6183 ut_params->cipher_xform.next = NULL;
6184 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6185 ut_params->cipher_xform.cipher.op = op;
6186 ut_params->cipher_xform.cipher.key.data = cipher_key;
6187 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6189 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6190 ut_params->auth_xform.next = NULL;
6192 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6193 ut_params->auth_xform.auth.op = auth_op;
6194 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6195 ut_params->auth_xform.auth.add_auth_data_length = 0;
6196 ut_params->auth_xform.auth.key.length = 0;
6197 ut_params->auth_xform.auth.key.data = NULL;
6199 ut_params->cipher_xform.next = &ut_params->auth_xform;
6201 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6202 &ut_params->cipher_xform);
6204 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6210 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6212 struct crypto_testsuite_params *ts_params = &testsuite_params;
6213 struct crypto_unittest_params *ut_params = &unittest_params;
6217 uint8_t *auth_tag, *p;
6218 uint16_t aad_pad_len;
6220 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6221 "No GMAC length in the source data");
6223 retval = create_gmac_session(ts_params->valid_devs[0],
6224 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6225 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6230 if (tdata->aad.len > MBUF_SIZE)
6231 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6233 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6234 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6235 "Failed to allocate input buffer in mempool");
6237 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6238 rte_pktmbuf_tailroom(ut_params->ibuf));
6240 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6242 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6244 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6250 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6252 ut_params->op->sym->m_src = ut_params->ibuf;
6254 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6255 ut_params->op), "failed to process sym crypto op");
6257 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6258 "crypto op processing failed");
6260 if (ut_params->op->sym->m_dst) {
6261 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6262 uint8_t *, aad_pad_len);
6264 auth_tag = p + aad_pad_len;
6267 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6269 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6271 tdata->gmac_tag.data,
6272 tdata->gmac_tag.len,
6273 "GMAC Generated auth tag not as expected");
6279 test_AES_GMAC_authentication_test_case_1(void)
6281 return test_AES_GMAC_authentication(&gmac_test_case_1);
6285 test_AES_GMAC_authentication_test_case_2(void)
6287 return test_AES_GMAC_authentication(&gmac_test_case_2);
6291 test_AES_GMAC_authentication_test_case_3(void)
6293 return test_AES_GMAC_authentication(&gmac_test_case_3);
6297 test_AES_GMAC_authentication_test_case_4(void)
6299 return test_AES_GMAC_authentication(&gmac_test_case_4);
6303 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6305 struct crypto_testsuite_params *ts_params = &testsuite_params;
6306 struct crypto_unittest_params *ut_params = &unittest_params;
6309 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6310 "No GMAC length in the source data");
6312 retval = create_gmac_session(ts_params->valid_devs[0],
6313 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6314 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6319 if (tdata->aad.len > MBUF_SIZE)
6320 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6322 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6323 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6324 "Failed to allocate input buffer in mempool");
6326 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6327 rte_pktmbuf_tailroom(ut_params->ibuf));
6329 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6335 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6337 ut_params->op->sym->m_src = ut_params->ibuf;
6339 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6340 ut_params->op), "failed to process sym crypto op");
6342 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6343 "crypto op processing failed");
6350 test_AES_GMAC_authentication_verify_test_case_1(void)
6352 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6356 test_AES_GMAC_authentication_verify_test_case_2(void)
6358 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6362 test_AES_GMAC_authentication_verify_test_case_3(void)
6364 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6368 test_AES_GMAC_authentication_verify_test_case_4(void)
6370 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6373 struct test_crypto_vector {
6374 enum rte_crypto_cipher_algorithm crypto_algo;
6387 const uint8_t *data;
6392 const uint8_t *data;
6396 enum rte_crypto_auth_algorithm auth_algo;
6404 const uint8_t *data;
6414 static const struct test_crypto_vector
6415 hmac_sha1_test_crypto_vector = {
6416 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6418 .data = plaintext_hash,
6423 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6424 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6425 0xDE, 0xF4, 0xDE, 0xAD
6431 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6432 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6433 0x3F, 0x91, 0x64, 0x59
6439 static const struct test_crypto_vector
6440 aes128_gmac_test_vector = {
6441 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6442 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6444 .data = plaintext_hash,
6449 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6450 0x08, 0x09, 0x0A, 0x0B
6456 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6457 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6463 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6464 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6470 static const struct test_crypto_vector
6471 aes128cbc_hmac_sha1_test_vector = {
6472 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6475 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6476 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6482 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6483 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6488 .data = plaintext_hash,
6492 .data = ciphertext512_aes128cbc,
6495 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6498 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6499 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6500 0xDE, 0xF4, 0xDE, 0xAD
6506 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6507 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6508 0x18, 0x8C, 0x1D, 0x32
6515 data_corruption(uint8_t *data)
6521 tag_corruption(uint8_t *data, unsigned int tag_offset)
6523 data[tag_offset] += 1;
6527 create_auth_session(struct crypto_unittest_params *ut_params,
6529 const struct test_crypto_vector *reference,
6530 enum rte_crypto_auth_operation auth_op)
6532 uint8_t auth_key[reference->auth_key.len + 1];
6534 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6536 /* Setup Authentication Parameters */
6537 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6538 ut_params->auth_xform.auth.op = auth_op;
6539 ut_params->auth_xform.next = NULL;
6540 ut_params->auth_xform.auth.algo = reference->auth_algo;
6541 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6542 ut_params->auth_xform.auth.key.data = auth_key;
6543 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6544 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6546 /* Create Crypto session*/
6547 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6548 &ut_params->auth_xform);
6550 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6556 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6558 const struct test_crypto_vector *reference,
6559 enum rte_crypto_auth_operation auth_op,
6560 enum rte_crypto_cipher_operation cipher_op)
6562 uint8_t cipher_key[reference->cipher_key.len + 1];
6563 uint8_t auth_key[reference->auth_key.len + 1];
6565 memcpy(cipher_key, reference->cipher_key.data,
6566 reference->cipher_key.len);
6567 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6569 /* Setup Authentication Parameters */
6570 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6571 ut_params->auth_xform.auth.op = auth_op;
6572 ut_params->auth_xform.next = &ut_params->cipher_xform;
6573 ut_params->auth_xform.auth.algo = reference->auth_algo;
6574 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6575 ut_params->auth_xform.auth.key.data = auth_key;
6576 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6577 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6579 /* Setup Cipher Parameters */
6580 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6581 ut_params->cipher_xform.next = NULL;
6582 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6583 ut_params->cipher_xform.cipher.op = cipher_op;
6584 ut_params->cipher_xform.cipher.key.data = cipher_key;
6585 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6587 /* Create Crypto session*/
6588 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6589 &ut_params->auth_xform);
6591 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6597 create_auth_operation(struct crypto_testsuite_params *ts_params,
6598 struct crypto_unittest_params *ut_params,
6599 const struct test_crypto_vector *reference,
6600 unsigned int auth_generate)
6602 /* Generate Crypto op data structure */
6603 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6604 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6605 TEST_ASSERT_NOT_NULL(ut_params->op,
6606 "Failed to allocate pktmbuf offload");
6608 /* Set crypto operation data parameters */
6609 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6611 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6613 /* set crypto operation source mbuf */
6614 sym_op->m_src = ut_params->ibuf;
6617 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6618 ut_params->ibuf, reference->digest.len);
6620 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6621 "no room to append auth tag");
6623 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6624 ut_params->ibuf, reference->plaintext.len);
6625 sym_op->auth.digest.length = reference->digest.len;
6628 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6630 memcpy(sym_op->auth.digest.data,
6631 reference->digest.data,
6632 reference->digest.len);
6634 TEST_HEXDUMP(stdout, "digest:",
6635 sym_op->auth.digest.data,
6636 sym_op->auth.digest.length);
6638 sym_op->auth.data.length = reference->plaintext.len;
6639 sym_op->auth.data.offset = 0;
6645 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6646 struct crypto_unittest_params *ut_params,
6647 const struct test_crypto_vector *reference,
6648 unsigned int auth_generate)
6650 /* Generate Crypto op data structure */
6651 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6652 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6653 TEST_ASSERT_NOT_NULL(ut_params->op,
6654 "Failed to allocate pktmbuf offload");
6656 /* Set crypto operation data parameters */
6657 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6659 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6661 /* set crypto operation source mbuf */
6662 sym_op->m_src = ut_params->ibuf;
6665 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6666 reference->aad.len);
6667 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6668 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6670 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6672 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6673 sym_op->auth.aad.length = reference->aad.len;
6676 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6677 ut_params->ibuf, reference->digest.len);
6679 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6680 "no room to append auth tag");
6682 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6683 ut_params->ibuf, reference->ciphertext.len);
6684 sym_op->auth.digest.length = reference->digest.len;
6687 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6689 memcpy(sym_op->auth.digest.data,
6690 reference->digest.data,
6691 reference->digest.len);
6693 TEST_HEXDUMP(stdout, "digest:",
6694 sym_op->auth.digest.data,
6695 sym_op->auth.digest.length);
6697 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6698 ut_params->ibuf, reference->iv.len);
6699 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6701 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6702 sym_op->cipher.iv.length = reference->iv.len;
6704 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6706 sym_op->cipher.data.length = 0;
6707 sym_op->cipher.data.offset = 0;
6709 sym_op->auth.data.length = 0;
6710 sym_op->auth.data.offset = 0;
6716 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6717 struct crypto_unittest_params *ut_params,
6718 const struct test_crypto_vector *reference,
6719 unsigned int auth_generate)
6721 /* Generate Crypto op data structure */
6722 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6723 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6724 TEST_ASSERT_NOT_NULL(ut_params->op,
6725 "Failed to allocate pktmbuf offload");
6727 /* Set crypto operation data parameters */
6728 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6730 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6732 /* set crypto operation source mbuf */
6733 sym_op->m_src = ut_params->ibuf;
6736 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6737 ut_params->ibuf, reference->digest.len);
6739 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6740 "no room to append auth tag");
6742 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6743 ut_params->ibuf, reference->ciphertext.len);
6744 sym_op->auth.digest.length = reference->digest.len;
6747 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6749 memcpy(sym_op->auth.digest.data,
6750 reference->digest.data,
6751 reference->digest.len);
6753 TEST_HEXDUMP(stdout, "digest:",
6754 sym_op->auth.digest.data,
6755 sym_op->auth.digest.length);
6757 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6758 ut_params->ibuf, reference->iv.len);
6759 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6761 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6762 sym_op->cipher.iv.length = reference->iv.len;
6764 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6766 sym_op->cipher.data.length = reference->ciphertext.len;
6767 sym_op->cipher.data.offset = reference->iv.len;
6769 sym_op->auth.data.length = reference->ciphertext.len;
6770 sym_op->auth.data.offset = reference->iv.len;
6776 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6777 struct crypto_unittest_params *ut_params,
6778 const struct test_crypto_vector *reference)
6780 return create_auth_operation(ts_params, ut_params, reference, 0);
6784 create_auth_verify_GMAC_operation(
6785 struct crypto_testsuite_params *ts_params,
6786 struct crypto_unittest_params *ut_params,
6787 const struct test_crypto_vector *reference)
6789 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6793 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6794 struct crypto_unittest_params *ut_params,
6795 const struct test_crypto_vector *reference)
6797 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6801 test_authentication_verify_fail_when_data_corruption(
6802 struct crypto_testsuite_params *ts_params,
6803 struct crypto_unittest_params *ut_params,
6804 const struct test_crypto_vector *reference,
6805 unsigned int data_corrupted)
6811 /* Create session */
6812 retval = create_auth_session(ut_params,
6813 ts_params->valid_devs[0],
6815 RTE_CRYPTO_AUTH_OP_VERIFY);
6819 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6820 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6821 "Failed to allocate input buffer in mempool");
6823 /* clear mbuf payload */
6824 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6825 rte_pktmbuf_tailroom(ut_params->ibuf));
6827 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6828 reference->plaintext.len);
6829 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6830 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6832 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6834 /* Create operation */
6835 retval = create_auth_verify_operation(ts_params, ut_params, reference);
6841 data_corruption(plaintext);
6843 tag_corruption(plaintext, reference->plaintext.len);
6845 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6847 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6848 TEST_ASSERT_EQUAL(ut_params->op->status,
6849 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6850 "authentication not failed");
6852 ut_params->obuf = ut_params->op->sym->m_src;
6853 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6859 test_authentication_verify_GMAC_fail_when_corruption(
6860 struct crypto_testsuite_params *ts_params,
6861 struct crypto_unittest_params *ut_params,
6862 const struct test_crypto_vector *reference,
6863 unsigned int data_corrupted)
6867 /* Create session */
6868 retval = create_auth_cipher_session(ut_params,
6869 ts_params->valid_devs[0],
6871 RTE_CRYPTO_AUTH_OP_VERIFY,
6872 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6876 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6877 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6878 "Failed to allocate input buffer in mempool");
6880 /* clear mbuf payload */
6881 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6882 rte_pktmbuf_tailroom(ut_params->ibuf));
6884 /* Create operation */
6885 retval = create_auth_verify_GMAC_operation(ts_params,
6893 data_corruption(ut_params->op->sym->auth.aad.data);
6895 tag_corruption(ut_params->op->sym->auth.aad.data,
6896 reference->aad.len);
6898 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6900 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6901 TEST_ASSERT_EQUAL(ut_params->op->status,
6902 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6903 "authentication not failed");
6905 ut_params->obuf = ut_params->op->sym->m_src;
6906 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6912 test_authenticated_decryption_fail_when_corruption(
6913 struct crypto_testsuite_params *ts_params,
6914 struct crypto_unittest_params *ut_params,
6915 const struct test_crypto_vector *reference,
6916 unsigned int data_corrupted)
6920 uint8_t *ciphertext;
6922 /* Create session */
6923 retval = create_auth_cipher_session(ut_params,
6924 ts_params->valid_devs[0],
6926 RTE_CRYPTO_AUTH_OP_VERIFY,
6927 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6931 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6932 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6933 "Failed to allocate input buffer in mempool");
6935 /* clear mbuf payload */
6936 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6937 rte_pktmbuf_tailroom(ut_params->ibuf));
6939 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6940 reference->ciphertext.len);
6941 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
6942 memcpy(ciphertext, reference->ciphertext.data,
6943 reference->ciphertext.len);
6945 /* Create operation */
6946 retval = create_cipher_auth_verify_operation(ts_params,
6954 data_corruption(ciphertext);
6956 tag_corruption(ciphertext, reference->ciphertext.len);
6958 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6961 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6962 TEST_ASSERT_EQUAL(ut_params->op->status,
6963 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6964 "authentication not failed");
6966 ut_params->obuf = ut_params->op->sym->m_src;
6967 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6973 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
6974 const struct gcm_test_data *tdata,
6975 void *digest_mem, uint64_t digest_phys)
6977 struct crypto_testsuite_params *ts_params = &testsuite_params;
6978 struct crypto_unittest_params *ut_params = &unittest_params;
6980 const unsigned int auth_tag_len = tdata->auth_tag.len;
6981 const unsigned int iv_len = tdata->iv.len;
6982 const unsigned int aad_len = tdata->aad.len;
6984 unsigned int iv_pad_len = 0;
6986 /* Generate Crypto op data structure */
6987 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6988 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6989 TEST_ASSERT_NOT_NULL(ut_params->op,
6990 "Failed to allocate symmetric crypto operation struct");
6992 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6994 sym_op->auth.digest.data = digest_mem;
6996 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6997 "no room to append digest");
6999 sym_op->auth.digest.phys_addr = digest_phys;
7000 sym_op->auth.digest.length = auth_tag_len;
7002 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7003 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7005 TEST_HEXDUMP(stdout, "digest:",
7006 sym_op->auth.digest.data,
7007 sym_op->auth.digest.length);
7010 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
7012 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
7013 ut_params->ibuf, iv_pad_len);
7015 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
7016 "no room to prepend iv");
7018 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
7019 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
7020 sym_op->cipher.iv.length = iv_len;
7022 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
7024 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7025 ut_params->ibuf, aad_len);
7026 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7027 "no room to prepend aad");
7028 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7030 sym_op->auth.aad.length = aad_len;
7032 memset(sym_op->auth.aad.data, 0, aad_len);
7033 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7035 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
7036 TEST_HEXDUMP(stdout, "aad:",
7037 sym_op->auth.aad.data, aad_len);
7039 sym_op->cipher.data.length = tdata->plaintext.len;
7040 sym_op->cipher.data.offset = aad_len + iv_pad_len;
7042 sym_op->auth.data.offset = aad_len + iv_pad_len;
7043 sym_op->auth.data.length = tdata->plaintext.len;
7048 #define SGL_MAX_NO 16
7051 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7052 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7054 struct crypto_testsuite_params *ts_params = &testsuite_params;
7055 struct crypto_unittest_params *ut_params = &unittest_params;
7056 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7059 int to_trn_tbl[SGL_MAX_NO];
7061 unsigned int trn_data = 0;
7062 uint8_t *plaintext, *ciphertext, *auth_tag;
7064 if (fragsz > tdata->plaintext.len)
7065 fragsz = tdata->plaintext.len;
7067 uint16_t plaintext_len = fragsz;
7068 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7070 if (fragsz_oop > tdata->plaintext.len)
7071 frag_size_oop = tdata->plaintext.len;
7074 void *digest_mem = NULL;
7076 uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
7079 if (tdata->plaintext.len % fragsz != 0) {
7080 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7083 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7088 * For out-op-place we need to alloc another mbuf
7091 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7092 rte_pktmbuf_append(ut_params->obuf,
7093 frag_size_oop + prepend_len);
7094 buf_oop = ut_params->obuf;
7097 /* Create GCM session */
7098 retval = create_gcm_session(ts_params->valid_devs[0],
7099 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7100 tdata->key.data, tdata->key.len,
7101 tdata->aad.len, tdata->auth_tag.len,
7102 RTE_CRYPTO_AUTH_OP_GENERATE);
7106 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7108 /* clear mbuf payload */
7109 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7110 rte_pktmbuf_tailroom(ut_params->ibuf));
7112 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7115 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7117 trn_data += plaintext_len;
7119 buf = ut_params->ibuf;
7122 * Loop until no more fragments
7125 while (trn_data < tdata->plaintext.len) {
7127 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7128 (tdata->plaintext.len - trn_data) : fragsz;
7130 to_trn_tbl[ecx++] = to_trn;
7132 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7135 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7136 rte_pktmbuf_tailroom(buf));
7139 if (oop && !fragsz_oop) {
7140 buf_last_oop = buf_oop->next =
7141 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7142 buf_oop = buf_oop->next;
7143 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7144 0, rte_pktmbuf_tailroom(buf_oop));
7145 rte_pktmbuf_append(buf_oop, to_trn);
7148 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7151 memcpy(plaintext, tdata->plaintext.data + trn_data,
7154 if (trn_data == tdata->plaintext.len) {
7157 digest_mem = rte_pktmbuf_append(buf_oop,
7158 tdata->auth_tag.len);
7160 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7161 tdata->auth_tag.len);
7165 uint64_t digest_phys = 0;
7167 ut_params->ibuf->nb_segs = segs;
7170 if (fragsz_oop && oop) {
7174 if (frag_size_oop == tdata->plaintext.len) {
7175 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7176 tdata->auth_tag.len);
7178 digest_phys = rte_pktmbuf_mtophys_offset(
7180 tdata->plaintext.len + prepend_len);
7183 trn_data = frag_size_oop;
7184 while (trn_data < tdata->plaintext.len) {
7187 (tdata->plaintext.len - trn_data <
7189 (tdata->plaintext.len - trn_data) :
7192 to_trn_tbl[ecx++] = to_trn;
7194 buf_last_oop = buf_oop->next =
7195 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7196 buf_oop = buf_oop->next;
7197 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7198 0, rte_pktmbuf_tailroom(buf_oop));
7199 rte_pktmbuf_append(buf_oop, to_trn);
7203 if (trn_data == tdata->plaintext.len) {
7204 digest_mem = rte_pktmbuf_append(buf_oop,
7205 tdata->auth_tag.len);
7209 ut_params->obuf->nb_segs = segs;
7213 * Place digest at the end of the last buffer
7216 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7217 if (oop && buf_last_oop)
7218 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7220 if (!digest_mem && !oop) {
7221 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7222 + tdata->auth_tag.len);
7223 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7224 tdata->plaintext.len);
7227 /* Create GCM opertaion */
7228 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7229 tdata, digest_mem, digest_phys);
7234 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7236 ut_params->op->sym->m_src = ut_params->ibuf;
7238 ut_params->op->sym->m_dst = ut_params->obuf;
7240 /* Process crypto operation */
7241 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7242 ut_params->op), "failed to process sym crypto op");
7244 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7245 "crypto op processing failed");
7248 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7249 uint8_t *, prepend_len);
7251 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7252 uint8_t *, prepend_len);
7256 fragsz = fragsz_oop;
7258 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7260 tdata->ciphertext.data,
7262 "GCM Ciphertext data not as expected");
7264 buf = ut_params->op->sym->m_src->next;
7266 buf = ut_params->op->sym->m_dst->next;
7268 unsigned int off = fragsz;
7272 ciphertext = rte_pktmbuf_mtod(buf,
7275 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7277 tdata->ciphertext.data + off,
7279 "GCM Ciphertext data not as expected");
7281 off += to_trn_tbl[ecx++];
7285 auth_tag = digest_mem;
7286 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7288 tdata->auth_tag.data,
7289 tdata->auth_tag.len,
7290 "GCM Generated auth tag not as expected");
7296 #define OUT_OF_PLACE 1
7299 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7301 return test_AES_GCM_authenticated_encryption_SGL(
7302 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7306 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7308 return test_AES_GCM_authenticated_encryption_SGL(
7309 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7313 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7315 return test_AES_GCM_authenticated_encryption_SGL(
7316 &gcm_test_case_8, OUT_OF_PLACE, 400,
7317 gcm_test_case_8.plaintext.len);
7321 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7324 return test_AES_GCM_authenticated_encryption_SGL(
7325 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7329 test_authentication_verify_fail_when_data_corrupted(
7330 struct crypto_testsuite_params *ts_params,
7331 struct crypto_unittest_params *ut_params,
7332 const struct test_crypto_vector *reference)
7334 return test_authentication_verify_fail_when_data_corruption(
7335 ts_params, ut_params, reference, 1);
7339 test_authentication_verify_fail_when_tag_corrupted(
7340 struct crypto_testsuite_params *ts_params,
7341 struct crypto_unittest_params *ut_params,
7342 const struct test_crypto_vector *reference)
7344 return test_authentication_verify_fail_when_data_corruption(
7345 ts_params, ut_params, reference, 0);
7349 test_authentication_verify_GMAC_fail_when_data_corrupted(
7350 struct crypto_testsuite_params *ts_params,
7351 struct crypto_unittest_params *ut_params,
7352 const struct test_crypto_vector *reference)
7354 return test_authentication_verify_GMAC_fail_when_corruption(
7355 ts_params, ut_params, reference, 1);
7359 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7360 struct crypto_testsuite_params *ts_params,
7361 struct crypto_unittest_params *ut_params,
7362 const struct test_crypto_vector *reference)
7364 return test_authentication_verify_GMAC_fail_when_corruption(
7365 ts_params, ut_params, reference, 0);
7369 test_authenticated_decryption_fail_when_data_corrupted(
7370 struct crypto_testsuite_params *ts_params,
7371 struct crypto_unittest_params *ut_params,
7372 const struct test_crypto_vector *reference)
7374 return test_authenticated_decryption_fail_when_corruption(
7375 ts_params, ut_params, reference, 1);
7379 test_authenticated_decryption_fail_when_tag_corrupted(
7380 struct crypto_testsuite_params *ts_params,
7381 struct crypto_unittest_params *ut_params,
7382 const struct test_crypto_vector *reference)
7384 return test_authenticated_decryption_fail_when_corruption(
7385 ts_params, ut_params, reference, 0);
7389 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7391 return test_authentication_verify_fail_when_data_corrupted(
7392 &testsuite_params, &unittest_params,
7393 &hmac_sha1_test_crypto_vector);
7397 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7399 return test_authentication_verify_fail_when_tag_corrupted(
7400 &testsuite_params, &unittest_params,
7401 &hmac_sha1_test_crypto_vector);
7405 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7407 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7408 &testsuite_params, &unittest_params,
7409 &aes128_gmac_test_vector);
7413 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7415 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7416 &testsuite_params, &unittest_params,
7417 &aes128_gmac_test_vector);
7421 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7423 return test_authenticated_decryption_fail_when_data_corrupted(
7426 &aes128cbc_hmac_sha1_test_vector);
7430 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7432 return test_authenticated_decryption_fail_when_tag_corrupted(
7435 &aes128cbc_hmac_sha1_test_vector);
7438 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7440 /* global AESNI slave IDs for the scheduler test */
7441 uint8_t aesni_ids[2];
7444 test_scheduler_attach_slave_op(void)
7446 struct crypto_testsuite_params *ts_params = &testsuite_params;
7447 uint8_t sched_id = ts_params->valid_devs[0];
7448 uint32_t nb_devs, i, nb_devs_attached = 0;
7451 /* create 2 AESNI_MB if necessary */
7452 nb_devs = rte_cryptodev_count_devtype(
7453 RTE_CRYPTODEV_AESNI_MB_PMD);
7455 for (i = nb_devs; i < 2; i++) {
7456 ret = rte_eal_vdev_init(
7457 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
7459 TEST_ASSERT(ret == 0,
7460 "Failed to create instance %u of"
7462 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7466 /* attach 2 AESNI_MB cdevs */
7467 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7469 struct rte_cryptodev_info info;
7471 rte_cryptodev_info_get(i, &info);
7472 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7475 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7478 TEST_ASSERT(ret == 0,
7479 "Failed to attach device %u of pmd : %s", i,
7480 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7482 aesni_ids[nb_devs_attached] = (uint8_t)i;
7491 test_scheduler_detach_slave_op(void)
7493 struct crypto_testsuite_params *ts_params = &testsuite_params;
7494 uint8_t sched_id = ts_params->valid_devs[0];
7498 for (i = 0; i < 2; i++) {
7499 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7501 TEST_ASSERT(ret == 0,
7502 "Failed to detach device %u", aesni_ids[i]);
7509 test_scheduler_mode_op(void)
7511 struct crypto_testsuite_params *ts_params = &testsuite_params;
7512 uint8_t sched_id = ts_params->valid_devs[0];
7513 struct rte_cryptodev_scheduler_ops op = {0};
7514 struct rte_cryptodev_scheduler dummy_scheduler = {
7515 .description = "dummy scheduler to test mode",
7516 .name = "dummy scheduler",
7517 .mode = CDEV_SCHED_MODE_USERDEFINED,
7522 /* set user defined mode */
7523 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7525 TEST_ASSERT(ret == 0,
7526 "Failed to set cdev %u to user defined mode", sched_id);
7528 /* set round robin mode */
7529 ret = rte_crpytodev_scheduler_mode_set(sched_id,
7530 CDEV_SCHED_MODE_ROUNDROBIN);
7531 TEST_ASSERT(ret == 0,
7532 "Failed to set cdev %u to round-robin mode", sched_id);
7533 TEST_ASSERT(rte_crpytodev_scheduler_mode_get(sched_id) ==
7534 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7540 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7541 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7542 .setup = testsuite_setup,
7543 .teardown = testsuite_teardown,
7544 .unit_test_cases = {
7545 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7546 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7547 TEST_CASE_ST(ut_setup, ut_teardown,
7548 test_AES_chain_scheduler_all),
7549 TEST_CASE_ST(ut_setup, ut_teardown,
7550 test_AES_cipheronly_scheduler_all),
7551 TEST_CASE_ST(ut_setup, ut_teardown,
7552 test_authonly_scheduler_all),
7553 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7554 TEST_CASES_END() /**< NULL terminate unit test array */
7558 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7560 static struct unit_test_suite cryptodev_qat_testsuite = {
7561 .suite_name = "Crypto QAT Unit Test Suite",
7562 .setup = testsuite_setup,
7563 .teardown = testsuite_teardown,
7564 .unit_test_cases = {
7565 TEST_CASE_ST(ut_setup, ut_teardown,
7566 test_device_configure_invalid_dev_id),
7567 TEST_CASE_ST(ut_setup, ut_teardown,
7568 test_device_configure_invalid_queue_pair_ids),
7569 TEST_CASE_ST(ut_setup, ut_teardown,
7570 test_queue_pair_descriptor_setup),
7571 TEST_CASE_ST(ut_setup, ut_teardown,
7572 test_multi_session),
7574 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7575 TEST_CASE_ST(ut_setup, ut_teardown,
7576 test_AES_cipheronly_qat_all),
7577 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7578 TEST_CASE_ST(ut_setup, ut_teardown,
7579 test_3DES_cipheronly_qat_all),
7580 TEST_CASE_ST(ut_setup, ut_teardown,
7581 test_DES_cipheronly_qat_all),
7582 TEST_CASE_ST(ut_setup, ut_teardown,
7583 test_AES_docsis_qat_all),
7584 TEST_CASE_ST(ut_setup, ut_teardown,
7585 test_DES_docsis_qat_all),
7586 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7588 /** AES GCM Authenticated Encryption */
7589 TEST_CASE_ST(ut_setup, ut_teardown,
7590 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7591 TEST_CASE_ST(ut_setup, ut_teardown,
7592 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7593 TEST_CASE_ST(ut_setup, ut_teardown,
7594 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7595 TEST_CASE_ST(ut_setup, ut_teardown,
7596 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7597 TEST_CASE_ST(ut_setup, ut_teardown,
7598 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7599 TEST_CASE_ST(ut_setup, ut_teardown,
7600 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7601 TEST_CASE_ST(ut_setup, ut_teardown,
7602 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7603 TEST_CASE_ST(ut_setup, ut_teardown,
7604 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7605 TEST_CASE_ST(ut_setup, ut_teardown,
7606 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7607 TEST_CASE_ST(ut_setup, ut_teardown,
7608 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7610 /** AES GCM Authenticated Decryption */
7611 TEST_CASE_ST(ut_setup, ut_teardown,
7612 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7613 TEST_CASE_ST(ut_setup, ut_teardown,
7614 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7615 TEST_CASE_ST(ut_setup, ut_teardown,
7616 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7617 TEST_CASE_ST(ut_setup, ut_teardown,
7618 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7619 TEST_CASE_ST(ut_setup, ut_teardown,
7620 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7621 TEST_CASE_ST(ut_setup, ut_teardown,
7622 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7623 TEST_CASE_ST(ut_setup, ut_teardown,
7624 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7626 /** AES GMAC Authentication */
7627 TEST_CASE_ST(ut_setup, ut_teardown,
7628 test_AES_GMAC_authentication_test_case_1),
7629 TEST_CASE_ST(ut_setup, ut_teardown,
7630 test_AES_GMAC_authentication_verify_test_case_1),
7631 TEST_CASE_ST(ut_setup, ut_teardown,
7632 test_AES_GMAC_authentication_test_case_2),
7633 TEST_CASE_ST(ut_setup, ut_teardown,
7634 test_AES_GMAC_authentication_verify_test_case_2),
7635 TEST_CASE_ST(ut_setup, ut_teardown,
7636 test_AES_GMAC_authentication_test_case_3),
7637 TEST_CASE_ST(ut_setup, ut_teardown,
7638 test_AES_GMAC_authentication_verify_test_case_3),
7640 /** SNOW 3G encrypt only (UEA2) */
7641 TEST_CASE_ST(ut_setup, ut_teardown,
7642 test_snow3g_encryption_test_case_1),
7643 TEST_CASE_ST(ut_setup, ut_teardown,
7644 test_snow3g_encryption_test_case_2),
7645 TEST_CASE_ST(ut_setup, ut_teardown,
7646 test_snow3g_encryption_test_case_3),
7647 TEST_CASE_ST(ut_setup, ut_teardown,
7648 test_snow3g_encryption_test_case_4),
7649 TEST_CASE_ST(ut_setup, ut_teardown,
7650 test_snow3g_encryption_test_case_5),
7652 TEST_CASE_ST(ut_setup, ut_teardown,
7653 test_snow3g_encryption_test_case_1_oop),
7654 TEST_CASE_ST(ut_setup, ut_teardown,
7655 test_snow3g_decryption_test_case_1_oop),
7657 /** SNOW 3G decrypt only (UEA2) */
7658 TEST_CASE_ST(ut_setup, ut_teardown,
7659 test_snow3g_decryption_test_case_1),
7660 TEST_CASE_ST(ut_setup, ut_teardown,
7661 test_snow3g_decryption_test_case_2),
7662 TEST_CASE_ST(ut_setup, ut_teardown,
7663 test_snow3g_decryption_test_case_3),
7664 TEST_CASE_ST(ut_setup, ut_teardown,
7665 test_snow3g_decryption_test_case_4),
7666 TEST_CASE_ST(ut_setup, ut_teardown,
7667 test_snow3g_decryption_test_case_5),
7668 TEST_CASE_ST(ut_setup, ut_teardown,
7669 test_snow3g_hash_generate_test_case_1),
7670 TEST_CASE_ST(ut_setup, ut_teardown,
7671 test_snow3g_hash_generate_test_case_2),
7672 TEST_CASE_ST(ut_setup, ut_teardown,
7673 test_snow3g_hash_generate_test_case_3),
7674 TEST_CASE_ST(ut_setup, ut_teardown,
7675 test_snow3g_hash_verify_test_case_1),
7676 TEST_CASE_ST(ut_setup, ut_teardown,
7677 test_snow3g_hash_verify_test_case_2),
7678 TEST_CASE_ST(ut_setup, ut_teardown,
7679 test_snow3g_hash_verify_test_case_3),
7680 TEST_CASE_ST(ut_setup, ut_teardown,
7681 test_snow3g_cipher_auth_test_case_1),
7682 TEST_CASE_ST(ut_setup, ut_teardown,
7683 test_snow3g_auth_cipher_test_case_1),
7685 /** HMAC_MD5 Authentication */
7686 TEST_CASE_ST(ut_setup, ut_teardown,
7687 test_MD5_HMAC_generate_case_1),
7688 TEST_CASE_ST(ut_setup, ut_teardown,
7689 test_MD5_HMAC_verify_case_1),
7690 TEST_CASE_ST(ut_setup, ut_teardown,
7691 test_MD5_HMAC_generate_case_2),
7692 TEST_CASE_ST(ut_setup, ut_teardown,
7693 test_MD5_HMAC_verify_case_2),
7696 TEST_CASE_ST(ut_setup, ut_teardown,
7697 test_null_auth_only_operation),
7698 TEST_CASE_ST(ut_setup, ut_teardown,
7699 test_null_cipher_only_operation),
7700 TEST_CASE_ST(ut_setup, ut_teardown,
7701 test_null_cipher_auth_operation),
7702 TEST_CASE_ST(ut_setup, ut_teardown,
7703 test_null_auth_cipher_operation),
7705 TEST_CASE_ST(ut_setup, ut_teardown,
7706 test_kasumi_hash_generate_test_case_6),
7709 TEST_CASE_ST(ut_setup, ut_teardown,
7710 test_kasumi_encryption_test_case_1),
7711 TEST_CASE_ST(ut_setup, ut_teardown,
7712 test_kasumi_encryption_test_case_3),
7713 TEST_CASE_ST(ut_setup, ut_teardown,
7714 test_kasumi_auth_cipher_test_case_1),
7715 TEST_CASE_ST(ut_setup, ut_teardown,
7716 test_kasumi_cipher_auth_test_case_1),
7718 /** Negative tests */
7719 TEST_CASE_ST(ut_setup, ut_teardown,
7720 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7721 TEST_CASE_ST(ut_setup, ut_teardown,
7722 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7723 TEST_CASE_ST(ut_setup, ut_teardown,
7724 authentication_verify_AES128_GMAC_fail_data_corrupt),
7725 TEST_CASE_ST(ut_setup, ut_teardown,
7726 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7727 TEST_CASE_ST(ut_setup, ut_teardown,
7728 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7729 TEST_CASE_ST(ut_setup, ut_teardown,
7730 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7732 TEST_CASES_END() /**< NULL terminate unit test array */
7736 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7737 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7738 .setup = testsuite_setup,
7739 .teardown = testsuite_teardown,
7740 .unit_test_cases = {
7741 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7742 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7743 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7744 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7746 TEST_CASES_END() /**< NULL terminate unit test array */
7750 static struct unit_test_suite cryptodev_openssl_testsuite = {
7751 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7752 .setup = testsuite_setup,
7753 .teardown = testsuite_teardown,
7754 .unit_test_cases = {
7755 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7756 TEST_CASE_ST(ut_setup, ut_teardown,
7757 test_multi_session_random_usage),
7758 TEST_CASE_ST(ut_setup, ut_teardown,
7759 test_AES_chain_openssl_all),
7760 TEST_CASE_ST(ut_setup, ut_teardown,
7761 test_AES_cipheronly_openssl_all),
7762 TEST_CASE_ST(ut_setup, ut_teardown,
7763 test_3DES_chain_openssl_all),
7764 TEST_CASE_ST(ut_setup, ut_teardown,
7765 test_3DES_cipheronly_openssl_all),
7766 TEST_CASE_ST(ut_setup, ut_teardown,
7767 test_DES_docsis_openssl_all),
7768 TEST_CASE_ST(ut_setup, ut_teardown,
7769 test_authonly_openssl_all),
7771 /** AES GCM Authenticated Encryption */
7772 TEST_CASE_ST(ut_setup, ut_teardown,
7773 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7774 TEST_CASE_ST(ut_setup, ut_teardown,
7775 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7776 TEST_CASE_ST(ut_setup, ut_teardown,
7777 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7778 TEST_CASE_ST(ut_setup, ut_teardown,
7779 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7780 TEST_CASE_ST(ut_setup, ut_teardown,
7781 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7784 TEST_CASE_ST(ut_setup, ut_teardown,
7785 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7787 /** AES GCM Authenticated Decryption */
7788 TEST_CASE_ST(ut_setup, ut_teardown,
7789 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7790 TEST_CASE_ST(ut_setup, ut_teardown,
7791 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7792 TEST_CASE_ST(ut_setup, ut_teardown,
7793 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7794 TEST_CASE_ST(ut_setup, ut_teardown,
7795 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7796 TEST_CASE_ST(ut_setup, ut_teardown,
7797 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7798 TEST_CASE_ST(ut_setup, ut_teardown,
7799 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7800 TEST_CASE_ST(ut_setup, ut_teardown,
7801 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7803 /** AES GMAC Authentication */
7804 TEST_CASE_ST(ut_setup, ut_teardown,
7805 test_AES_GMAC_authentication_test_case_1),
7806 TEST_CASE_ST(ut_setup, ut_teardown,
7807 test_AES_GMAC_authentication_verify_test_case_1),
7808 TEST_CASE_ST(ut_setup, ut_teardown,
7809 test_AES_GMAC_authentication_test_case_2),
7810 TEST_CASE_ST(ut_setup, ut_teardown,
7811 test_AES_GMAC_authentication_verify_test_case_2),
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_AES_GMAC_authentication_test_case_3),
7814 TEST_CASE_ST(ut_setup, ut_teardown,
7815 test_AES_GMAC_authentication_verify_test_case_3),
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_AES_GMAC_authentication_test_case_4),
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_AES_GMAC_authentication_verify_test_case_4),
7821 /** Scatter-Gather */
7822 TEST_CASE_ST(ut_setup, ut_teardown,
7823 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7825 /** Negative tests */
7826 TEST_CASE_ST(ut_setup, ut_teardown,
7827 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7828 TEST_CASE_ST(ut_setup, ut_teardown,
7829 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7830 TEST_CASE_ST(ut_setup, ut_teardown,
7831 authentication_verify_AES128_GMAC_fail_data_corrupt),
7832 TEST_CASE_ST(ut_setup, ut_teardown,
7833 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7834 TEST_CASE_ST(ut_setup, ut_teardown,
7835 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7836 TEST_CASE_ST(ut_setup, ut_teardown,
7837 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7839 TEST_CASES_END() /**< NULL terminate unit test array */
7843 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
7844 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
7845 .setup = testsuite_setup,
7846 .teardown = testsuite_teardown,
7847 .unit_test_cases = {
7848 /** AES GCM Authenticated Encryption */
7849 TEST_CASE_ST(ut_setup, ut_teardown,
7850 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7851 TEST_CASE_ST(ut_setup, ut_teardown,
7852 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7857 TEST_CASE_ST(ut_setup, ut_teardown,
7858 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7859 TEST_CASE_ST(ut_setup, ut_teardown,
7860 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7861 TEST_CASE_ST(ut_setup, ut_teardown,
7862 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7864 /** AES GCM Authenticated Decryption */
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7875 TEST_CASE_ST(ut_setup, ut_teardown,
7876 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7877 TEST_CASE_ST(ut_setup, ut_teardown,
7878 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7880 /** AES GCM Authenticated Encryption 256 bits key */
7881 TEST_CASE_ST(ut_setup, ut_teardown,
7882 test_mb_AES_GCM_auth_encryption_test_case_256_1),
7883 TEST_CASE_ST(ut_setup, ut_teardown,
7884 test_mb_AES_GCM_auth_encryption_test_case_256_2),
7885 TEST_CASE_ST(ut_setup, ut_teardown,
7886 test_mb_AES_GCM_auth_encryption_test_case_256_3),
7887 TEST_CASE_ST(ut_setup, ut_teardown,
7888 test_mb_AES_GCM_auth_encryption_test_case_256_4),
7889 TEST_CASE_ST(ut_setup, ut_teardown,
7890 test_mb_AES_GCM_auth_encryption_test_case_256_5),
7891 TEST_CASE_ST(ut_setup, ut_teardown,
7892 test_mb_AES_GCM_auth_encryption_test_case_256_6),
7893 TEST_CASE_ST(ut_setup, ut_teardown,
7894 test_mb_AES_GCM_auth_encryption_test_case_256_7),
7896 /** AES GCM Authenticated Decryption 256 bits key */
7897 TEST_CASE_ST(ut_setup, ut_teardown,
7898 test_mb_AES_GCM_auth_decryption_test_case_256_1),
7899 TEST_CASE_ST(ut_setup, ut_teardown,
7900 test_mb_AES_GCM_auth_decryption_test_case_256_2),
7901 TEST_CASE_ST(ut_setup, ut_teardown,
7902 test_mb_AES_GCM_auth_decryption_test_case_256_3),
7903 TEST_CASE_ST(ut_setup, ut_teardown,
7904 test_mb_AES_GCM_auth_decryption_test_case_256_4),
7905 TEST_CASE_ST(ut_setup, ut_teardown,
7906 test_mb_AES_GCM_auth_decryption_test_case_256_5),
7907 TEST_CASE_ST(ut_setup, ut_teardown,
7908 test_mb_AES_GCM_auth_decryption_test_case_256_6),
7909 TEST_CASE_ST(ut_setup, ut_teardown,
7910 test_mb_AES_GCM_auth_decryption_test_case_256_7),
7912 /** AES GCM Authenticated Encryption big aad size */
7913 TEST_CASE_ST(ut_setup, ut_teardown,
7914 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
7915 TEST_CASE_ST(ut_setup, ut_teardown,
7916 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
7918 /** AES GCM Authenticated Decryption big aad size */
7919 TEST_CASE_ST(ut_setup, ut_teardown,
7920 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
7921 TEST_CASE_ST(ut_setup, ut_teardown,
7922 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
7924 /** AES GMAC Authentication */
7925 TEST_CASE_ST(ut_setup, ut_teardown,
7926 test_AES_GMAC_authentication_test_case_1),
7927 TEST_CASE_ST(ut_setup, ut_teardown,
7928 test_AES_GMAC_authentication_verify_test_case_1),
7929 TEST_CASE_ST(ut_setup, ut_teardown,
7930 test_AES_GMAC_authentication_test_case_3),
7931 TEST_CASE_ST(ut_setup, ut_teardown,
7932 test_AES_GMAC_authentication_verify_test_case_3),
7933 TEST_CASE_ST(ut_setup, ut_teardown,
7934 test_AES_GMAC_authentication_test_case_4),
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_AES_GMAC_authentication_verify_test_case_4),
7938 /** Negative tests */
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 authentication_verify_AES128_GMAC_fail_data_corrupt),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7944 /** Out of place tests */
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_mb_AES_GCM_authenticated_encryption_oop),
7947 TEST_CASE_ST(ut_setup, ut_teardown,
7948 test_mb_AES_GCM_authenticated_decryption_oop),
7950 /** Session-less tests */
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_mb_AES_GCM_authenticated_encryption_sessionless),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_mb_AES_GCM_authenticated_decryption_sessionless),
7956 /** Scatter-Gather */
7957 TEST_CASE_ST(ut_setup, ut_teardown,
7958 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7960 TEST_CASES_END() /**< NULL terminate unit test array */
7964 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
7965 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
7966 .setup = testsuite_setup,
7967 .teardown = testsuite_teardown,
7968 .unit_test_cases = {
7969 /** KASUMI encrypt only (UEA1) */
7970 TEST_CASE_ST(ut_setup, ut_teardown,
7971 test_kasumi_encryption_test_case_1),
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_kasumi_encryption_test_case_1_sgl),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_kasumi_encryption_test_case_2),
7976 TEST_CASE_ST(ut_setup, ut_teardown,
7977 test_kasumi_encryption_test_case_3),
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_kasumi_encryption_test_case_4),
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 test_kasumi_encryption_test_case_5),
7982 /** KASUMI decrypt only (UEA1) */
7983 TEST_CASE_ST(ut_setup, ut_teardown,
7984 test_kasumi_decryption_test_case_1),
7985 TEST_CASE_ST(ut_setup, ut_teardown,
7986 test_kasumi_decryption_test_case_2),
7987 TEST_CASE_ST(ut_setup, ut_teardown,
7988 test_kasumi_decryption_test_case_3),
7989 TEST_CASE_ST(ut_setup, ut_teardown,
7990 test_kasumi_decryption_test_case_4),
7991 TEST_CASE_ST(ut_setup, ut_teardown,
7992 test_kasumi_decryption_test_case_5),
7994 TEST_CASE_ST(ut_setup, ut_teardown,
7995 test_kasumi_encryption_test_case_1_oop),
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_kasumi_encryption_test_case_1_oop_sgl),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_kasumi_decryption_test_case_1_oop),
8003 /** KASUMI hash only (UIA1) */
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_kasumi_hash_generate_test_case_1),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_kasumi_hash_generate_test_case_2),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 test_kasumi_hash_generate_test_case_3),
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 test_kasumi_hash_generate_test_case_4),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 test_kasumi_hash_generate_test_case_5),
8014 TEST_CASE_ST(ut_setup, ut_teardown,
8015 test_kasumi_hash_generate_test_case_6),
8016 TEST_CASE_ST(ut_setup, ut_teardown,
8017 test_kasumi_hash_verify_test_case_1),
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 test_kasumi_hash_verify_test_case_2),
8020 TEST_CASE_ST(ut_setup, ut_teardown,
8021 test_kasumi_hash_verify_test_case_3),
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 test_kasumi_hash_verify_test_case_4),
8024 TEST_CASE_ST(ut_setup, ut_teardown,
8025 test_kasumi_hash_verify_test_case_5),
8026 TEST_CASE_ST(ut_setup, ut_teardown,
8027 test_kasumi_auth_cipher_test_case_1),
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 test_kasumi_cipher_auth_test_case_1),
8030 TEST_CASES_END() /**< NULL terminate unit test array */
8033 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8034 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8035 .setup = testsuite_setup,
8036 .teardown = testsuite_teardown,
8037 .unit_test_cases = {
8038 /** SNOW 3G encrypt only (UEA2) */
8039 TEST_CASE_ST(ut_setup, ut_teardown,
8040 test_snow3g_encryption_test_case_1),
8041 TEST_CASE_ST(ut_setup, ut_teardown,
8042 test_snow3g_encryption_test_case_2),
8043 TEST_CASE_ST(ut_setup, ut_teardown,
8044 test_snow3g_encryption_test_case_3),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_snow3g_encryption_test_case_4),
8047 TEST_CASE_ST(ut_setup, ut_teardown,
8048 test_snow3g_encryption_test_case_5),
8050 TEST_CASE_ST(ut_setup, ut_teardown,
8051 test_snow3g_encryption_test_case_1_oop),
8052 TEST_CASE_ST(ut_setup, ut_teardown,
8053 test_snow3g_encryption_test_case_1_oop_sgl),
8054 TEST_CASE_ST(ut_setup, ut_teardown,
8055 test_snow3g_decryption_test_case_1_oop),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_snow3g_encryption_test_case_1_offset_oop),
8060 /** SNOW 3G decrypt only (UEA2) */
8061 TEST_CASE_ST(ut_setup, ut_teardown,
8062 test_snow3g_decryption_test_case_1),
8063 TEST_CASE_ST(ut_setup, ut_teardown,
8064 test_snow3g_decryption_test_case_2),
8065 TEST_CASE_ST(ut_setup, ut_teardown,
8066 test_snow3g_decryption_test_case_3),
8067 TEST_CASE_ST(ut_setup, ut_teardown,
8068 test_snow3g_decryption_test_case_4),
8069 TEST_CASE_ST(ut_setup, ut_teardown,
8070 test_snow3g_decryption_test_case_5),
8071 TEST_CASE_ST(ut_setup, ut_teardown,
8072 test_snow3g_hash_generate_test_case_1),
8073 TEST_CASE_ST(ut_setup, ut_teardown,
8074 test_snow3g_hash_generate_test_case_2),
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 test_snow3g_hash_generate_test_case_3),
8077 /* Tests with buffers which length is not byte-aligned */
8078 TEST_CASE_ST(ut_setup, ut_teardown,
8079 test_snow3g_hash_generate_test_case_4),
8080 TEST_CASE_ST(ut_setup, ut_teardown,
8081 test_snow3g_hash_generate_test_case_5),
8082 TEST_CASE_ST(ut_setup, ut_teardown,
8083 test_snow3g_hash_generate_test_case_6),
8084 TEST_CASE_ST(ut_setup, ut_teardown,
8085 test_snow3g_hash_verify_test_case_1),
8086 TEST_CASE_ST(ut_setup, ut_teardown,
8087 test_snow3g_hash_verify_test_case_2),
8088 TEST_CASE_ST(ut_setup, ut_teardown,
8089 test_snow3g_hash_verify_test_case_3),
8090 /* Tests with buffers which length is not byte-aligned */
8091 TEST_CASE_ST(ut_setup, ut_teardown,
8092 test_snow3g_hash_verify_test_case_4),
8093 TEST_CASE_ST(ut_setup, ut_teardown,
8094 test_snow3g_hash_verify_test_case_5),
8095 TEST_CASE_ST(ut_setup, ut_teardown,
8096 test_snow3g_hash_verify_test_case_6),
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 test_snow3g_cipher_auth_test_case_1),
8099 TEST_CASE_ST(ut_setup, ut_teardown,
8100 test_snow3g_auth_cipher_test_case_1),
8102 TEST_CASES_END() /**< NULL terminate unit test array */
8106 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8107 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8108 .setup = testsuite_setup,
8109 .teardown = testsuite_teardown,
8110 .unit_test_cases = {
8111 /** ZUC encrypt only (EEA3) */
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_zuc_encryption_test_case_1),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_zuc_encryption_test_case_2),
8116 TEST_CASE_ST(ut_setup, ut_teardown,
8117 test_zuc_encryption_test_case_3),
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_zuc_encryption_test_case_4),
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 test_zuc_encryption_test_case_5),
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_zuc_hash_generate_test_case_1),
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_zuc_hash_generate_test_case_2),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_zuc_hash_generate_test_case_3),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_zuc_hash_generate_test_case_4),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_zuc_hash_generate_test_case_5),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 test_zuc_encryption_test_case_6_sgl),
8134 TEST_CASES_END() /**< NULL terminate unit test array */
8138 static struct unit_test_suite cryptodev_null_testsuite = {
8139 .suite_name = "Crypto Device NULL Unit Test Suite",
8140 .setup = testsuite_setup,
8141 .teardown = testsuite_teardown,
8142 .unit_test_cases = {
8143 TEST_CASE_ST(ut_setup, ut_teardown,
8144 test_null_auth_only_operation),
8145 TEST_CASE_ST(ut_setup, ut_teardown,
8146 test_null_cipher_only_operation),
8147 TEST_CASE_ST(ut_setup, ut_teardown,
8148 test_null_cipher_auth_operation),
8149 TEST_CASE_ST(ut_setup, ut_teardown,
8150 test_null_auth_cipher_operation),
8151 TEST_CASE_ST(ut_setup, ut_teardown,
8152 test_null_invalid_operation),
8153 TEST_CASE_ST(ut_setup, ut_teardown,
8154 test_null_burst_operation),
8156 TEST_CASES_END() /**< NULL terminate unit test array */
8160 static struct unit_test_suite cryptodev_armv8_testsuite = {
8161 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8162 .setup = testsuite_setup,
8163 .teardown = testsuite_teardown,
8164 .unit_test_cases = {
8165 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8167 /** Negative tests */
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8170 TEST_CASE_ST(ut_setup, ut_teardown,
8171 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8173 TEST_CASES_END() /**< NULL terminate unit test array */
8178 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8180 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8181 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8185 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8187 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8189 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8193 test_cryptodev_openssl(void)
8195 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8197 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8201 test_cryptodev_aesni_gcm(void)
8203 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8205 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8209 test_cryptodev_null(void)
8211 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8213 return unit_test_suite_runner(&cryptodev_null_testsuite);
8217 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8219 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8221 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8225 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8227 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8229 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8233 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8235 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8237 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8241 test_cryptodev_armv8(void)
8243 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8245 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8248 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8251 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8253 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8254 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8257 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8261 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8262 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8263 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8264 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8265 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8266 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8267 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8268 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8269 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);