4 * Copyright(c) 2015-2016 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>
44 #include "test_cryptodev.h"
46 #include "test_cryptodev_blockcipher.h"
47 #include "test_cryptodev_aes_test_vectors.h"
48 #include "test_cryptodev_des_test_vectors.h"
49 #include "test_cryptodev_hash_test_vectors.h"
50 #include "test_cryptodev_kasumi_test_vectors.h"
51 #include "test_cryptodev_kasumi_hash_test_vectors.h"
52 #include "test_cryptodev_snow3g_test_vectors.h"
53 #include "test_cryptodev_snow3g_hash_test_vectors.h"
54 #include "test_cryptodev_zuc_test_vectors.h"
55 #include "test_cryptodev_zuc_hash_test_vectors.h"
56 #include "test_cryptodev_gcm_test_vectors.h"
57 #include "test_cryptodev_hmac_test_vectors.h"
59 static enum rte_cryptodev_type gbl_cryptodev_type;
61 struct crypto_testsuite_params {
62 struct rte_mempool *mbuf_pool;
63 struct rte_mempool *large_mbuf_pool;
64 struct rte_mempool *op_mpool;
65 struct rte_cryptodev_config conf;
66 struct rte_cryptodev_qp_conf qp_conf;
68 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
69 uint8_t valid_dev_count;
72 struct crypto_unittest_params {
73 struct rte_crypto_sym_xform cipher_xform;
74 struct rte_crypto_sym_xform auth_xform;
76 struct rte_cryptodev_sym_session *sess;
78 struct rte_crypto_op *op;
80 struct rte_mbuf *obuf, *ibuf;
85 #define ALIGN_POW2_ROUNDUP(num, align) \
86 (((num) + (align) - 1) & ~((align) - 1))
89 * Forward declarations.
92 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
93 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
97 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
98 struct crypto_unittest_params *ut_params,
99 struct crypto_testsuite_params *ts_param,
100 const uint8_t *cipher,
101 const uint8_t *digest,
104 static struct rte_mbuf *
105 setup_test_string(struct rte_mempool *mpool,
106 const char *string, size_t len, uint8_t blocksize)
108 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
109 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
111 memset(m->buf_addr, 0, m->buf_len);
113 char *dst = rte_pktmbuf_append(m, t_len);
120 rte_memcpy(dst, string, t_len);
122 memset(dst, 0, t_len);
128 /* Get number of bytes in X bits (rounding up) */
130 ceil_byte_length(uint32_t num_bits)
133 return ((num_bits >> 3) + 1);
135 return (num_bits >> 3);
138 static struct rte_crypto_op *
139 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
141 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
142 printf("Error sending packet for encryption");
148 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
154 static struct crypto_testsuite_params testsuite_params = { NULL };
155 static struct crypto_unittest_params unittest_params;
158 testsuite_setup(void)
160 struct crypto_testsuite_params *ts_params = &testsuite_params;
161 struct rte_cryptodev_info info;
162 unsigned i, nb_devs, dev_id;
166 memset(ts_params, 0, sizeof(*ts_params));
168 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
169 if (ts_params->mbuf_pool == NULL) {
170 /* Not already created so create */
171 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
173 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
175 if (ts_params->mbuf_pool == NULL) {
176 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
181 ts_params->large_mbuf_pool = rte_mempool_lookup(
182 "CRYPTO_LARGE_MBUFPOOL");
183 if (ts_params->large_mbuf_pool == NULL) {
184 /* Not already created so create */
185 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
186 "CRYPTO_LARGE_MBUFPOOL",
189 if (ts_params->large_mbuf_pool == NULL) {
191 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
196 ts_params->op_mpool = rte_crypto_op_pool_create(
197 "MBUF_CRYPTO_SYM_OP_POOL",
198 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
199 NUM_MBUFS, MBUF_CACHE_SIZE,
201 sizeof(struct rte_crypto_sym_xform),
203 if (ts_params->op_mpool == NULL) {
204 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
208 /* Create 2 AESNI MB devices if required */
209 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
210 #ifndef RTE_LIBRTE_PMD_AESNI_MB
211 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
212 " enabled in config file to run this testsuite.\n");
215 nb_devs = rte_cryptodev_count_devtype(
216 RTE_CRYPTODEV_AESNI_MB_PMD);
218 for (i = nb_devs; i < 2; i++) {
219 ret = rte_eal_vdev_init(
220 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
222 TEST_ASSERT(ret == 0,
223 "Failed to create instance %u of"
225 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
230 /* Create 2 AESNI GCM devices if required */
231 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
232 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
233 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
234 " enabled in config file to run this testsuite.\n");
237 nb_devs = rte_cryptodev_count_devtype(
238 RTE_CRYPTODEV_AESNI_GCM_PMD);
240 for (i = nb_devs; i < 2; i++) {
241 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
242 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
243 "Failed to create instance %u of"
245 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
250 /* Create 2 SNOW 3G devices if required */
251 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
252 #ifndef RTE_LIBRTE_PMD_SNOW3G
253 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
254 " enabled in config file to run this testsuite.\n");
257 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
259 for (i = nb_devs; i < 2; i++) {
260 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
261 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
262 "Failed to create instance %u of"
264 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
269 /* Create 2 KASUMI devices if required */
270 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
271 #ifndef RTE_LIBRTE_PMD_KASUMI
272 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
273 " enabled in config file to run this testsuite.\n");
276 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
278 for (i = nb_devs; i < 2; i++) {
279 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
280 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
281 "Failed to create instance %u of"
283 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
288 /* Create 2 ZUC devices if required */
289 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
290 #ifndef RTE_LIBRTE_PMD_ZUC
291 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
292 " enabled in config file to run this testsuite.\n");
295 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
297 for (i = nb_devs; i < 2; i++) {
298 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
299 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
300 "Failed to create instance %u of"
302 i, RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
307 /* Create 2 NULL devices if required */
308 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
309 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
310 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
311 " enabled in config file to run this testsuite.\n");
314 nb_devs = rte_cryptodev_count_devtype(
315 RTE_CRYPTODEV_NULL_PMD);
317 for (i = nb_devs; i < 2; i++) {
318 int dev_id = rte_eal_vdev_init(
319 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
321 TEST_ASSERT(dev_id >= 0,
322 "Failed to create instance %u of"
324 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
329 /* Create 2 OPENSSL devices if required */
330 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
331 #ifndef RTE_LIBRTE_PMD_OPENSSL
332 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
333 " enabled in config file to run this testsuite.\n");
336 nb_devs = rte_cryptodev_count_devtype(
337 RTE_CRYPTODEV_OPENSSL_PMD);
339 for (i = nb_devs; i < 2; i++) {
340 ret = rte_eal_vdev_init(
341 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
344 TEST_ASSERT(ret == 0, "Failed to create "
345 "instance %u of pmd : %s", i,
346 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
351 #ifndef RTE_LIBRTE_PMD_QAT
352 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
353 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
354 "in config file to run this testsuite.\n");
359 nb_devs = rte_cryptodev_count();
361 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
365 /* Create list of valid crypto devs */
366 for (i = 0; i < nb_devs; i++) {
367 rte_cryptodev_info_get(i, &info);
368 if (info.dev_type == gbl_cryptodev_type)
369 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
372 if (ts_params->valid_dev_count < 1)
375 /* Set up all the qps on the first of the valid devices found */
377 dev_id = ts_params->valid_devs[0];
379 rte_cryptodev_info_get(dev_id, &info);
381 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
382 ts_params->conf.socket_id = SOCKET_ID_ANY;
383 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
385 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
387 "Failed to configure cryptodev %u with %u qps",
388 dev_id, ts_params->conf.nb_queue_pairs);
390 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
392 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
393 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
394 dev_id, qp_id, &ts_params->qp_conf,
395 rte_cryptodev_socket_id(dev_id)),
396 "Failed to setup queue pair %u on cryptodev %u",
404 testsuite_teardown(void)
406 struct crypto_testsuite_params *ts_params = &testsuite_params;
408 if (ts_params->mbuf_pool != NULL) {
409 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
410 rte_mempool_avail_count(ts_params->mbuf_pool));
413 if (ts_params->op_mpool != NULL) {
414 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
415 rte_mempool_avail_count(ts_params->op_mpool));
423 struct crypto_testsuite_params *ts_params = &testsuite_params;
424 struct crypto_unittest_params *ut_params = &unittest_params;
428 /* Clear unit test parameters before running test */
429 memset(ut_params, 0, sizeof(*ut_params));
431 /* Reconfigure device to default parameters */
432 ts_params->conf.socket_id = SOCKET_ID_ANY;
433 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
435 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
437 "Failed to configure cryptodev %u",
438 ts_params->valid_devs[0]);
440 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
441 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
442 ts_params->valid_devs[0], qp_id,
444 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
445 "Failed to setup queue pair %u on cryptodev %u",
446 qp_id, ts_params->valid_devs[0]);
450 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
452 /* Start the device */
453 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
454 "Failed to start cryptodev %u",
455 ts_params->valid_devs[0]);
463 struct crypto_testsuite_params *ts_params = &testsuite_params;
464 struct crypto_unittest_params *ut_params = &unittest_params;
465 struct rte_cryptodev_stats stats;
467 /* free crypto session structure */
468 if (ut_params->sess) {
469 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
471 ut_params->sess = NULL;
474 /* free crypto operation structure */
476 rte_crypto_op_free(ut_params->op);
479 * free mbuf - both obuf and ibuf are usually the same,
480 * so check if they point at the same address is necessary,
481 * to avoid freeing the mbuf twice.
483 if (ut_params->obuf) {
484 rte_pktmbuf_free(ut_params->obuf);
485 if (ut_params->ibuf == ut_params->obuf)
489 if (ut_params->ibuf) {
490 rte_pktmbuf_free(ut_params->ibuf);
494 if (ts_params->mbuf_pool != NULL)
495 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
496 rte_mempool_avail_count(ts_params->mbuf_pool));
498 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
500 /* Stop the device */
501 rte_cryptodev_stop(ts_params->valid_devs[0]);
505 test_device_configure_invalid_dev_id(void)
507 struct crypto_testsuite_params *ts_params = &testsuite_params;
508 uint16_t dev_id, num_devs = 0;
510 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
511 "Need at least %d devices for test", 1);
513 /* valid dev_id values */
514 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
516 /* Stop the device in case it's started so it can be configured */
517 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
519 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
520 "Failed test for rte_cryptodev_configure: "
521 "invalid dev_num %u", dev_id);
523 /* invalid dev_id values */
526 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
527 "Failed test for rte_cryptodev_configure: "
528 "invalid dev_num %u", dev_id);
532 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
533 "Failed test for rte_cryptodev_configure:"
534 "invalid dev_num %u", dev_id);
540 test_device_configure_invalid_queue_pair_ids(void)
542 struct crypto_testsuite_params *ts_params = &testsuite_params;
543 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
545 /* Stop the device in case it's started so it can be configured */
546 rte_cryptodev_stop(ts_params->valid_devs[0]);
548 /* valid - one queue pairs */
549 ts_params->conf.nb_queue_pairs = 1;
551 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
553 "Failed to configure cryptodev: dev_id %u, qp_id %u",
554 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
557 /* valid - max value queue pairs */
558 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
560 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
562 "Failed to configure cryptodev: dev_id %u, qp_id %u",
563 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
566 /* invalid - zero queue pairs */
567 ts_params->conf.nb_queue_pairs = 0;
569 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
571 "Failed test for rte_cryptodev_configure, dev_id %u,"
573 ts_params->valid_devs[0],
574 ts_params->conf.nb_queue_pairs);
577 /* invalid - max value supported by field queue pairs */
578 ts_params->conf.nb_queue_pairs = UINT16_MAX;
580 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
582 "Failed test for rte_cryptodev_configure, dev_id %u,"
584 ts_params->valid_devs[0],
585 ts_params->conf.nb_queue_pairs);
588 /* invalid - max value + 1 queue pairs */
589 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
591 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
593 "Failed test for rte_cryptodev_configure, dev_id %u,"
595 ts_params->valid_devs[0],
596 ts_params->conf.nb_queue_pairs);
598 /* revert to original testsuite value */
599 ts_params->conf.nb_queue_pairs = orig_nb_qps;
605 test_queue_pair_descriptor_setup(void)
607 struct crypto_testsuite_params *ts_params = &testsuite_params;
608 struct rte_cryptodev_info dev_info;
609 struct rte_cryptodev_qp_conf qp_conf = {
610 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
615 /* Stop the device in case it's started so it can be configured */
616 rte_cryptodev_stop(ts_params->valid_devs[0]);
619 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
621 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
623 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
624 &ts_params->conf), "Failed to configure cryptodev %u",
625 ts_params->valid_devs[0]);
629 * Test various ring sizes on this device. memzones can't be
630 * freed so are re-used if ring is released and re-created.
632 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
634 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
635 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
636 ts_params->valid_devs[0], qp_id, &qp_conf,
637 rte_cryptodev_socket_id(
638 ts_params->valid_devs[0])),
640 "rte_cryptodev_queue_pair_setup: num_inflights "
641 "%u on qp %u on cryptodev %u",
642 qp_conf.nb_descriptors, qp_id,
643 ts_params->valid_devs[0]);
646 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
648 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
649 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
650 ts_params->valid_devs[0], qp_id, &qp_conf,
651 rte_cryptodev_socket_id(
652 ts_params->valid_devs[0])),
654 " rte_cryptodev_queue_pair_setup: num_inflights"
655 " %u on qp %u on cryptodev %u",
656 qp_conf.nb_descriptors, qp_id,
657 ts_params->valid_devs[0]);
660 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
662 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
663 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
664 ts_params->valid_devs[0], qp_id, &qp_conf,
665 rte_cryptodev_socket_id(
666 ts_params->valid_devs[0])),
668 "rte_cryptodev_queue_pair_setup: num_inflights"
669 " %u on qp %u on cryptodev %u",
670 qp_conf.nb_descriptors, qp_id,
671 ts_params->valid_devs[0]);
674 /* invalid number of descriptors - max supported + 2 */
675 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
677 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
678 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
679 ts_params->valid_devs[0], qp_id, &qp_conf,
680 rte_cryptodev_socket_id(
681 ts_params->valid_devs[0])),
682 "Unexpectedly passed test for "
683 "rte_cryptodev_queue_pair_setup:"
684 "num_inflights %u on qp %u on cryptodev %u",
685 qp_conf.nb_descriptors, qp_id,
686 ts_params->valid_devs[0]);
689 /* invalid number of descriptors - max value of parameter */
690 qp_conf.nb_descriptors = UINT32_MAX-1;
692 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
693 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
694 ts_params->valid_devs[0], qp_id, &qp_conf,
695 rte_cryptodev_socket_id(
696 ts_params->valid_devs[0])),
697 "Unexpectedly passed test for "
698 "rte_cryptodev_queue_pair_setup:"
699 "num_inflights %u on qp %u on cryptodev %u",
700 qp_conf.nb_descriptors, qp_id,
701 ts_params->valid_devs[0]);
704 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
706 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
707 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
708 ts_params->valid_devs[0], qp_id, &qp_conf,
709 rte_cryptodev_socket_id(
710 ts_params->valid_devs[0])),
712 " rte_cryptodev_queue_pair_setup:"
713 "num_inflights %u on qp %u on cryptodev %u",
714 qp_conf.nb_descriptors, qp_id,
715 ts_params->valid_devs[0]);
718 /* invalid number of descriptors - max supported + 1 */
719 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
721 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
722 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
723 ts_params->valid_devs[0], qp_id, &qp_conf,
724 rte_cryptodev_socket_id(
725 ts_params->valid_devs[0])),
726 "Unexpectedly passed test for "
727 "rte_cryptodev_queue_pair_setup:"
728 "num_inflights %u on qp %u on cryptodev %u",
729 qp_conf.nb_descriptors, qp_id,
730 ts_params->valid_devs[0]);
733 /* test invalid queue pair id */
734 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
736 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
738 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
739 ts_params->valid_devs[0],
741 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
742 "Failed test for rte_cryptodev_queue_pair_setup:"
743 "invalid qp %u on cryptodev %u",
744 qp_id, ts_params->valid_devs[0]);
746 qp_id = 0xffff; /*invalid*/
748 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
749 ts_params->valid_devs[0],
751 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
752 "Failed test for rte_cryptodev_queue_pair_setup:"
753 "invalid qp %u on cryptodev %u",
754 qp_id, ts_params->valid_devs[0]);
759 /* ***** Plaintext data for tests ***** */
761 const char catch_22_quote_1[] =
762 "There was only one catch and that was Catch-22, which "
763 "specified that a concern for one's safety in the face of "
764 "dangers that were real and immediate was the process of a "
765 "rational mind. Orr was crazy and could be grounded. All he "
766 "had to do was ask; and as soon as he did, he would no longer "
767 "be crazy and would have to fly more missions. Orr would be "
768 "crazy to fly more missions and sane if he didn't, but if he "
769 "was sane he had to fly them. If he flew them he was crazy "
770 "and didn't have to; but if he didn't want to he was sane and "
771 "had to. Yossarian was moved very deeply by the absolute "
772 "simplicity of this clause of Catch-22 and let out a "
773 "respectful whistle. \"That's some catch, that Catch-22\", he "
774 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
776 const char catch_22_quote[] =
777 "What a lousy earth! He wondered how many people were "
778 "destitute that same night even in his own prosperous country, "
779 "how many homes were shanties, how many husbands were drunk "
780 "and wives socked, and how many children were bullied, abused, "
781 "or abandoned. How many families hungered for food they could "
782 "not afford to buy? How many hearts were broken? How many "
783 "suicides would take place that same night, how many people "
784 "would go insane? How many cockroaches and landlords would "
785 "triumph? How many winners were losers, successes failures, "
786 "and rich men poor men? How many wise guys were stupid? How "
787 "many happy endings were unhappy endings? How many honest men "
788 "were liars, brave men cowards, loyal men traitors, how many "
789 "sainted men were corrupt, how many people in positions of "
790 "trust had sold their souls to bodyguards, how many had never "
791 "had souls? How many straight-and-narrow paths were crooked "
792 "paths? How many best families were worst families and how "
793 "many good people were bad people? When you added them all up "
794 "and then subtracted, you might be left with only the children, "
795 "and perhaps with Albert Einstein and an old violinist or "
796 "sculptor somewhere.";
798 #define QUOTE_480_BYTES (480)
799 #define QUOTE_512_BYTES (512)
800 #define QUOTE_768_BYTES (768)
801 #define QUOTE_1024_BYTES (1024)
805 /* ***** SHA1 Hash Tests ***** */
807 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
809 static uint8_t hmac_sha1_key[] = {
810 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
811 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
812 0xDE, 0xF4, 0xDE, 0xAD };
814 /* ***** SHA224 Hash Tests ***** */
816 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
819 /* ***** AES-CBC Cipher Tests ***** */
821 #define CIPHER_KEY_LENGTH_AES_CBC (16)
822 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
824 static uint8_t aes_cbc_key[] = {
825 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
826 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
828 static uint8_t aes_cbc_iv[] = {
829 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
830 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
833 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
835 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
836 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
837 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
838 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
839 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
840 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
841 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
842 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
843 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
844 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
845 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
846 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
847 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
848 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
849 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
850 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
851 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
852 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
853 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
854 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
855 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
856 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
857 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
858 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
859 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
860 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
861 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
862 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
863 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
864 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
865 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
866 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
867 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
868 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
869 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
870 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
871 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
872 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
873 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
874 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
875 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
876 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
877 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
878 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
879 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
880 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
881 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
882 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
883 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
884 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
885 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
886 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
887 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
888 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
889 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
890 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
891 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
892 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
893 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
894 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
895 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
896 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
897 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
898 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
899 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
902 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
903 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
904 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
905 0x18, 0x8c, 0x1d, 0x32
909 /* Multisession Vector context Test */
911 static uint8_t ms_aes_cbc_key0[] = {
912 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
913 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
916 static uint8_t ms_aes_cbc_iv0[] = {
917 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
918 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
921 static const uint8_t ms_aes_cbc_cipher0[] = {
922 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
923 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
924 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
925 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
926 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
927 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
928 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
929 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
930 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
931 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
932 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
933 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
934 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
935 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
936 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
937 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
938 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
939 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
940 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
941 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
942 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
943 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
944 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
945 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
946 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
947 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
948 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
949 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
950 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
951 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
952 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
953 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
954 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
955 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
956 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
957 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
958 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
959 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
960 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
961 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
962 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
963 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
964 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
965 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
966 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
967 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
968 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
969 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
970 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
971 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
972 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
973 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
974 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
975 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
976 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
977 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
978 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
979 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
980 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
981 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
982 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
983 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
984 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
985 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
989 static uint8_t ms_hmac_key0[] = {
990 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
991 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
992 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
993 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
994 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
995 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
996 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
997 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1000 static const uint8_t ms_hmac_digest0[] = {
1001 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1002 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1003 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1004 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1005 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1006 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1007 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1008 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1012 /* Begin session 1 */
1014 static uint8_t ms_aes_cbc_key1[] = {
1015 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1016 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1019 static uint8_t ms_aes_cbc_iv1[] = {
1020 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1021 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1024 static const uint8_t ms_aes_cbc_cipher1[] = {
1025 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1026 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1027 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1028 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1029 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1030 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1031 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1032 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1033 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1034 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1035 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1036 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1037 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1038 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1039 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1040 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1041 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1042 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1043 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1044 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1045 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1046 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1047 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1048 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1049 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1050 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1051 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1052 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1053 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1054 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1055 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1056 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1057 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1058 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1059 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1060 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1061 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1062 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1063 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1064 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1065 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1066 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1067 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1068 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1069 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1070 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1071 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1072 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1073 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1074 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1075 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1076 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1077 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1078 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1079 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1080 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1081 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1082 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1083 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1084 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1085 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1086 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1087 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1088 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1092 static uint8_t ms_hmac_key1[] = {
1093 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1094 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1095 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1096 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1097 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1098 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1099 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1100 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1103 static const uint8_t ms_hmac_digest1[] = {
1104 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1105 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1106 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1107 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1108 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1109 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1110 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1111 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1114 /* Begin Session 2 */
1115 static uint8_t ms_aes_cbc_key2[] = {
1116 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1117 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1120 static uint8_t ms_aes_cbc_iv2[] = {
1121 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1122 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1125 static const uint8_t ms_aes_cbc_cipher2[] = {
1126 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1127 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1128 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1129 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1130 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1131 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1132 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1133 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1134 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1135 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1136 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1137 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1138 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1139 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1140 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1141 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1142 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1143 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1144 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1145 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1146 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1147 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1148 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1149 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1150 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1151 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1152 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1153 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1154 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1155 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1156 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1157 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1158 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1159 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1160 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1161 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1162 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1163 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1164 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1165 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1166 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1167 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1168 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1169 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1170 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1171 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1172 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1173 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1174 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1175 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1176 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1177 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1178 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1179 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1180 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1181 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1182 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1183 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1184 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1185 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1186 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1187 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1188 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1189 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1192 static uint8_t ms_hmac_key2[] = {
1193 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1194 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1195 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1196 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1197 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1198 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1199 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1200 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1203 static const uint8_t ms_hmac_digest2[] = {
1204 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1205 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1206 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1207 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1208 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1209 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1210 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1211 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1218 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1220 struct crypto_testsuite_params *ts_params = &testsuite_params;
1221 struct crypto_unittest_params *ut_params = &unittest_params;
1223 /* Generate test mbuf data and space for digest */
1224 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1225 catch_22_quote, QUOTE_512_BYTES, 0);
1227 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1228 DIGEST_BYTE_LENGTH_SHA1);
1229 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1231 /* Setup Cipher Parameters */
1232 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1233 ut_params->cipher_xform.next = &ut_params->auth_xform;
1235 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1236 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1237 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1238 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1240 /* Setup HMAC Parameters */
1241 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1243 ut_params->auth_xform.next = NULL;
1245 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1246 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1247 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1248 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1249 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1251 /* Create crypto session*/
1252 ut_params->sess = rte_cryptodev_sym_session_create(
1253 ts_params->valid_devs[0],
1254 &ut_params->cipher_xform);
1255 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1257 /* Generate crypto op data structure */
1258 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1259 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1260 TEST_ASSERT_NOT_NULL(ut_params->op,
1261 "Failed to allocate symmetric crypto operation struct");
1263 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1265 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1267 /* set crypto operation source mbuf */
1268 sym_op->m_src = ut_params->ibuf;
1270 /* Set crypto operation authentication parameters */
1271 sym_op->auth.digest.data = ut_params->digest;
1272 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1273 ut_params->ibuf, QUOTE_512_BYTES);
1274 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1276 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1277 sym_op->auth.data.length = QUOTE_512_BYTES;
1279 /* Set crypto operation cipher parameters */
1280 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1281 CIPHER_IV_LENGTH_AES_CBC);
1282 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1283 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1285 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1286 CIPHER_IV_LENGTH_AES_CBC);
1288 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1289 sym_op->cipher.data.length = QUOTE_512_BYTES;
1291 /* Process crypto operation */
1292 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1293 ut_params->op), "failed to process sym crypto op");
1295 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1296 "crypto op processing failed");
1299 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1300 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1302 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1303 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1305 "ciphertext data not as expected");
1307 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1309 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1310 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1311 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1312 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1313 DIGEST_BYTE_LENGTH_SHA1,
1314 "Generated digest data not as expected");
1316 return TEST_SUCCESS;
1319 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1321 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1323 static uint8_t hmac_sha512_key[] = {
1324 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1325 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1326 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1327 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1328 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1329 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1330 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1331 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1333 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1334 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1335 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1336 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1337 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1338 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1339 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1340 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1341 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1346 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1347 struct crypto_unittest_params *ut_params,
1348 uint8_t *cipher_key,
1352 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1353 struct crypto_unittest_params *ut_params,
1354 struct crypto_testsuite_params *ts_params,
1355 const uint8_t *cipher,
1356 const uint8_t *digest,
1361 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1362 struct crypto_unittest_params *ut_params,
1363 uint8_t *cipher_key,
1367 /* Setup Cipher Parameters */
1368 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1369 ut_params->cipher_xform.next = NULL;
1371 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1372 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1373 ut_params->cipher_xform.cipher.key.data = cipher_key;
1374 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1376 /* Setup HMAC Parameters */
1377 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1378 ut_params->auth_xform.next = &ut_params->cipher_xform;
1380 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1381 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1382 ut_params->auth_xform.auth.key.data = hmac_key;
1383 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1384 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1386 return TEST_SUCCESS;
1391 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1392 struct crypto_unittest_params *ut_params,
1393 struct crypto_testsuite_params *ts_params,
1394 const uint8_t *cipher,
1395 const uint8_t *digest,
1398 /* Generate test mbuf data and digest */
1399 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1402 QUOTE_512_BYTES, 0);
1404 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1405 DIGEST_BYTE_LENGTH_SHA512);
1406 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1408 rte_memcpy(ut_params->digest,
1410 DIGEST_BYTE_LENGTH_SHA512);
1412 /* Generate Crypto op data structure */
1413 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1414 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1415 TEST_ASSERT_NOT_NULL(ut_params->op,
1416 "Failed to allocate symmetric crypto operation struct");
1418 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1420 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1422 /* set crypto operation source mbuf */
1423 sym_op->m_src = ut_params->ibuf;
1425 sym_op->auth.digest.data = ut_params->digest;
1426 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1427 ut_params->ibuf, QUOTE_512_BYTES);
1428 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1430 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1431 sym_op->auth.data.length = QUOTE_512_BYTES;
1433 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1434 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1435 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1436 ut_params->ibuf, 0);
1437 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1439 rte_memcpy(sym_op->cipher.iv.data, iv,
1440 CIPHER_IV_LENGTH_AES_CBC);
1442 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1443 sym_op->cipher.data.length = QUOTE_512_BYTES;
1445 /* Process crypto operation */
1446 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1447 ut_params->op), "failed to process sym crypto op");
1449 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1450 "crypto op processing failed");
1452 ut_params->obuf = ut_params->op->sym->m_src;
1455 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1456 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1457 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1459 "Plaintext data not as expected");
1462 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1463 "Digest verification failed");
1465 return TEST_SUCCESS;
1469 test_AES_cipheronly_mb_all(void)
1471 struct crypto_testsuite_params *ts_params = &testsuite_params;
1474 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1475 ts_params->op_mpool, ts_params->valid_devs[0],
1476 RTE_CRYPTODEV_AESNI_MB_PMD,
1477 BLKCIPHER_AES_CIPHERONLY_TYPE);
1479 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1481 return TEST_SUCCESS;
1485 test_authonly_mb_all(void)
1487 struct crypto_testsuite_params *ts_params = &testsuite_params;
1490 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1491 ts_params->op_mpool, ts_params->valid_devs[0],
1492 RTE_CRYPTODEV_AESNI_MB_PMD,
1493 BLKCIPHER_AUTHONLY_TYPE);
1495 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1497 return TEST_SUCCESS;
1501 test_AES_chain_mb_all(void)
1503 struct crypto_testsuite_params *ts_params = &testsuite_params;
1506 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1507 ts_params->op_mpool, ts_params->valid_devs[0],
1508 RTE_CRYPTODEV_AESNI_MB_PMD,
1509 BLKCIPHER_AES_CHAIN_TYPE);
1511 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1513 return TEST_SUCCESS;
1517 test_AES_chain_openssl_all(void)
1519 struct crypto_testsuite_params *ts_params = &testsuite_params;
1522 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1523 ts_params->op_mpool, ts_params->valid_devs[0],
1524 RTE_CRYPTODEV_OPENSSL_PMD,
1525 BLKCIPHER_AES_CHAIN_TYPE);
1527 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1529 return TEST_SUCCESS;
1533 test_AES_cipheronly_openssl_all(void)
1535 struct crypto_testsuite_params *ts_params = &testsuite_params;
1538 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1539 ts_params->op_mpool, ts_params->valid_devs[0],
1540 RTE_CRYPTODEV_OPENSSL_PMD,
1541 BLKCIPHER_AES_CIPHERONLY_TYPE);
1543 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1545 return TEST_SUCCESS;
1549 test_AES_chain_qat_all(void)
1551 struct crypto_testsuite_params *ts_params = &testsuite_params;
1554 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1555 ts_params->op_mpool, ts_params->valid_devs[0],
1556 RTE_CRYPTODEV_QAT_SYM_PMD,
1557 BLKCIPHER_AES_CHAIN_TYPE);
1559 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1561 return TEST_SUCCESS;
1565 test_AES_cipheronly_qat_all(void)
1567 struct crypto_testsuite_params *ts_params = &testsuite_params;
1570 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1571 ts_params->op_mpool, ts_params->valid_devs[0],
1572 RTE_CRYPTODEV_QAT_SYM_PMD,
1573 BLKCIPHER_AES_CIPHERONLY_TYPE);
1575 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1577 return TEST_SUCCESS;
1581 test_authonly_openssl_all(void)
1583 struct crypto_testsuite_params *ts_params = &testsuite_params;
1586 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1587 ts_params->op_mpool, ts_params->valid_devs[0],
1588 RTE_CRYPTODEV_OPENSSL_PMD,
1589 BLKCIPHER_AUTHONLY_TYPE);
1591 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1593 return TEST_SUCCESS;
1596 /* ***** SNOW 3G Tests ***** */
1598 create_wireless_algo_hash_session(uint8_t dev_id,
1599 const uint8_t *key, const uint8_t key_len,
1600 const uint8_t aad_len, const uint8_t auth_len,
1601 enum rte_crypto_auth_operation op,
1602 enum rte_crypto_auth_algorithm algo)
1604 uint8_t hash_key[key_len];
1606 struct crypto_unittest_params *ut_params = &unittest_params;
1608 memcpy(hash_key, key, key_len);
1610 TEST_HEXDUMP(stdout, "key:", key, key_len);
1612 /* Setup Authentication Parameters */
1613 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1614 ut_params->auth_xform.next = NULL;
1616 ut_params->auth_xform.auth.op = op;
1617 ut_params->auth_xform.auth.algo = algo;
1618 ut_params->auth_xform.auth.key.length = key_len;
1619 ut_params->auth_xform.auth.key.data = hash_key;
1620 ut_params->auth_xform.auth.digest_length = auth_len;
1621 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1622 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1623 &ut_params->auth_xform);
1624 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1629 create_wireless_algo_cipher_session(uint8_t dev_id,
1630 enum rte_crypto_cipher_operation op,
1631 enum rte_crypto_cipher_algorithm algo,
1632 const uint8_t *key, const uint8_t key_len)
1634 uint8_t cipher_key[key_len];
1636 struct crypto_unittest_params *ut_params = &unittest_params;
1638 memcpy(cipher_key, key, key_len);
1640 /* Setup Cipher Parameters */
1641 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1642 ut_params->cipher_xform.next = NULL;
1644 ut_params->cipher_xform.cipher.algo = algo;
1645 ut_params->cipher_xform.cipher.op = op;
1646 ut_params->cipher_xform.cipher.key.data = cipher_key;
1647 ut_params->cipher_xform.cipher.key.length = key_len;
1649 TEST_HEXDUMP(stdout, "key:", key, key_len);
1651 /* Create Crypto session */
1652 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1655 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1660 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1661 const unsigned cipher_len,
1662 const unsigned cipher_offset,
1663 enum rte_crypto_cipher_algorithm algo)
1665 struct crypto_testsuite_params *ts_params = &testsuite_params;
1666 struct crypto_unittest_params *ut_params = &unittest_params;
1667 unsigned iv_pad_len = 0;
1669 /* Generate Crypto op data structure */
1670 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1671 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1672 TEST_ASSERT_NOT_NULL(ut_params->op,
1673 "Failed to allocate pktmbuf offload");
1675 /* Set crypto operation data parameters */
1676 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1678 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1680 /* set crypto operation source mbuf */
1681 sym_op->m_src = ut_params->ibuf;
1684 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1685 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1687 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1689 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1692 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1694 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1695 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1696 sym_op->cipher.iv.length = iv_pad_len;
1698 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1699 sym_op->cipher.data.length = cipher_len;
1700 sym_op->cipher.data.offset = cipher_offset;
1705 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1706 const unsigned cipher_len,
1707 const unsigned cipher_offset,
1708 enum rte_crypto_cipher_algorithm algo)
1710 struct crypto_testsuite_params *ts_params = &testsuite_params;
1711 struct crypto_unittest_params *ut_params = &unittest_params;
1712 unsigned iv_pad_len = 0;
1714 /* Generate Crypto op data structure */
1715 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1716 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1717 TEST_ASSERT_NOT_NULL(ut_params->op,
1718 "Failed to allocate pktmbuf offload");
1720 /* Set crypto operation data parameters */
1721 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1723 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1725 /* set crypto operation source mbuf */
1726 sym_op->m_src = ut_params->ibuf;
1727 sym_op->m_dst = ut_params->obuf;
1730 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1731 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1733 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1734 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1737 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1739 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1740 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1741 sym_op->cipher.iv.length = iv_pad_len;
1743 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1744 sym_op->cipher.data.length = cipher_len;
1745 sym_op->cipher.data.offset = cipher_offset;
1750 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1751 enum rte_crypto_cipher_operation cipher_op,
1752 enum rte_crypto_auth_operation auth_op,
1753 enum rte_crypto_auth_algorithm auth_algo,
1754 enum rte_crypto_cipher_algorithm cipher_algo,
1755 const uint8_t *key, const uint8_t key_len,
1756 const uint8_t aad_len, const uint8_t auth_len)
1759 uint8_t cipher_auth_key[key_len];
1761 struct crypto_unittest_params *ut_params = &unittest_params;
1763 memcpy(cipher_auth_key, key, key_len);
1765 /* Setup Authentication Parameters */
1766 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1767 ut_params->auth_xform.next = NULL;
1769 ut_params->auth_xform.auth.op = auth_op;
1770 ut_params->auth_xform.auth.algo = auth_algo;
1771 ut_params->auth_xform.auth.key.length = key_len;
1772 /* Hash key = cipher key */
1773 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1774 ut_params->auth_xform.auth.digest_length = auth_len;
1775 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1777 /* Setup Cipher Parameters */
1778 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1779 ut_params->cipher_xform.next = &ut_params->auth_xform;
1781 ut_params->cipher_xform.cipher.algo = cipher_algo;
1782 ut_params->cipher_xform.cipher.op = cipher_op;
1783 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1784 ut_params->cipher_xform.cipher.key.length = key_len;
1786 TEST_HEXDUMP(stdout, "key:", key, key_len);
1788 /* Create Crypto session*/
1789 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1790 &ut_params->cipher_xform);
1792 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1797 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1798 enum rte_crypto_cipher_operation cipher_op,
1799 enum rte_crypto_auth_operation auth_op,
1800 enum rte_crypto_auth_algorithm auth_algo,
1801 enum rte_crypto_cipher_algorithm cipher_algo,
1802 const uint8_t *key, const uint8_t key_len,
1803 const uint8_t aad_len, const uint8_t auth_len)
1805 uint8_t auth_cipher_key[key_len];
1807 struct crypto_unittest_params *ut_params = &unittest_params;
1809 memcpy(auth_cipher_key, key, key_len);
1811 /* Setup Authentication Parameters */
1812 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1813 ut_params->auth_xform.auth.op = auth_op;
1814 ut_params->auth_xform.next = &ut_params->cipher_xform;
1815 ut_params->auth_xform.auth.algo = auth_algo;
1816 ut_params->auth_xform.auth.key.length = key_len;
1817 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1818 ut_params->auth_xform.auth.digest_length = auth_len;
1819 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1821 /* Setup Cipher Parameters */
1822 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1823 ut_params->cipher_xform.next = NULL;
1824 ut_params->cipher_xform.cipher.algo = cipher_algo;
1825 ut_params->cipher_xform.cipher.op = cipher_op;
1826 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1827 ut_params->cipher_xform.cipher.key.length = key_len;
1829 TEST_HEXDUMP(stdout, "key:", key, key_len);
1831 /* Create Crypto session*/
1832 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1833 &ut_params->auth_xform);
1835 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1841 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1842 const unsigned auth_tag_len,
1843 const uint8_t *aad, const unsigned aad_len,
1844 unsigned data_pad_len,
1845 enum rte_crypto_auth_operation op,
1846 enum rte_crypto_auth_algorithm algo,
1847 const unsigned auth_len, const unsigned auth_offset)
1849 struct crypto_testsuite_params *ts_params = &testsuite_params;
1851 struct crypto_unittest_params *ut_params = &unittest_params;
1853 unsigned aad_buffer_len;
1855 /* Generate Crypto op data structure */
1856 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1857 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1858 TEST_ASSERT_NOT_NULL(ut_params->op,
1859 "Failed to allocate pktmbuf offload");
1861 /* Set crypto operation data parameters */
1862 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1864 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1866 /* set crypto operation source mbuf */
1867 sym_op->m_src = ut_params->ibuf;
1871 * Always allocate the aad up to the block size.
1872 * The cryptodev API calls out -
1873 * - the array must be big enough to hold the AAD, plus any
1874 * space to round this up to the nearest multiple of the
1875 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1877 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1878 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1880 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1881 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1882 ut_params->ibuf, aad_buffer_len);
1883 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1884 "no room to prepend aad");
1885 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1887 sym_op->auth.aad.length = aad_len;
1889 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1890 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1892 TEST_HEXDUMP(stdout, "aad:",
1893 sym_op->auth.aad.data, aad_len);
1896 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1897 ut_params->ibuf, auth_tag_len);
1899 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1900 "no room to append auth tag");
1901 ut_params->digest = sym_op->auth.digest.data;
1902 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1903 ut_params->ibuf, data_pad_len + aad_len);
1904 sym_op->auth.digest.length = auth_tag_len;
1905 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1906 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1908 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1910 TEST_HEXDUMP(stdout, "digest:",
1911 sym_op->auth.digest.data,
1912 sym_op->auth.digest.length);
1914 sym_op->auth.data.length = auth_len;
1915 sym_op->auth.data.offset = auth_offset;
1921 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1922 const unsigned auth_tag_len,
1923 const uint8_t *aad, const uint8_t aad_len,
1924 unsigned data_pad_len,
1925 enum rte_crypto_auth_operation op,
1926 enum rte_crypto_auth_algorithm auth_algo,
1927 enum rte_crypto_cipher_algorithm cipher_algo,
1928 const uint8_t *iv, const uint8_t iv_len,
1929 const unsigned cipher_len, const unsigned cipher_offset,
1930 const unsigned auth_len, const unsigned auth_offset)
1932 struct crypto_testsuite_params *ts_params = &testsuite_params;
1933 struct crypto_unittest_params *ut_params = &unittest_params;
1935 unsigned iv_pad_len = 0;
1936 unsigned aad_buffer_len;
1938 /* Generate Crypto op data structure */
1939 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1940 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1941 TEST_ASSERT_NOT_NULL(ut_params->op,
1942 "Failed to allocate pktmbuf offload");
1943 /* Set crypto operation data parameters */
1944 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1946 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1948 /* set crypto operation source mbuf */
1949 sym_op->m_src = ut_params->ibuf;
1952 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1953 ut_params->ibuf, auth_tag_len);
1955 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1956 "no room to append auth tag");
1957 ut_params->digest = sym_op->auth.digest.data;
1958 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1959 ut_params->ibuf, data_pad_len);
1960 sym_op->auth.digest.length = auth_tag_len;
1961 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1962 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1964 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1966 TEST_HEXDUMP(stdout, "digest:",
1967 sym_op->auth.digest.data,
1968 sym_op->auth.digest.length);
1972 * Always allocate the aad up to the block size.
1973 * The cryptodev API calls out -
1974 * - the array must be big enough to hold the AAD, plus any
1975 * space to round this up to the nearest multiple of the
1976 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1978 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1979 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1981 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1982 sym_op->auth.aad.data =
1983 (uint8_t *)rte_pktmbuf_prepend(
1984 ut_params->ibuf, aad_buffer_len);
1985 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1986 "no room to prepend aad");
1987 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1989 sym_op->auth.aad.length = aad_len;
1990 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1991 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1992 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1995 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1996 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1998 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1999 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2000 ut_params->ibuf, iv_pad_len);
2002 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2003 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2004 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2005 sym_op->cipher.iv.length = iv_pad_len;
2006 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2007 sym_op->cipher.data.length = cipher_len;
2008 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2009 sym_op->auth.data.length = auth_len;
2010 sym_op->auth.data.offset = auth_offset + cipher_offset;
2016 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2017 const uint8_t *iv, const uint8_t iv_len,
2018 const uint8_t *aad, const uint8_t aad_len,
2019 unsigned data_pad_len,
2020 const unsigned cipher_len, const unsigned cipher_offset,
2021 const unsigned auth_len, const unsigned auth_offset,
2022 enum rte_crypto_auth_algorithm auth_algo,
2023 enum rte_crypto_cipher_algorithm cipher_algo)
2025 struct crypto_testsuite_params *ts_params = &testsuite_params;
2026 struct crypto_unittest_params *ut_params = &unittest_params;
2028 unsigned iv_pad_len = 0;
2029 unsigned aad_buffer_len = 0;
2031 /* Generate Crypto op data structure */
2032 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2033 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2034 TEST_ASSERT_NOT_NULL(ut_params->op,
2035 "Failed to allocate pktmbuf offload");
2037 /* Set crypto operation data parameters */
2038 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2040 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2042 /* set crypto operation source mbuf */
2043 sym_op->m_src = ut_params->ibuf;
2046 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2047 ut_params->ibuf, auth_tag_len);
2049 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2050 "no room to append auth tag");
2052 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2053 ut_params->ibuf, data_pad_len);
2054 sym_op->auth.digest.length = auth_tag_len;
2056 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2058 TEST_HEXDUMP(stdout, "digest:",
2059 sym_op->auth.digest.data,
2060 sym_op->auth.digest.length);
2064 * Always allocate the aad up to the block size.
2065 * The cryptodev API calls out -
2066 * - the array must be big enough to hold the AAD, plus any
2067 * space to round this up to the nearest multiple of the
2068 * block size (8 bytes for KASUMI 16 bytes).
2070 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2071 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2073 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2074 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2075 ut_params->ibuf, aad_buffer_len);
2076 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2077 "no room to prepend aad");
2078 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2080 sym_op->auth.aad.length = aad_len;
2081 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2082 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2083 TEST_HEXDUMP(stdout, "aad:",
2084 sym_op->auth.aad.data, aad_len);
2087 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2088 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2090 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2092 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2093 ut_params->ibuf, iv_pad_len);
2094 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2096 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2097 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2098 sym_op->cipher.iv.length = iv_pad_len;
2100 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2102 sym_op->cipher.data.length = cipher_len;
2103 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2105 sym_op->auth.data.length = auth_len;
2106 sym_op->auth.data.offset = auth_offset + cipher_offset;
2112 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2114 struct crypto_testsuite_params *ts_params = &testsuite_params;
2115 struct crypto_unittest_params *ut_params = &unittest_params;
2118 unsigned plaintext_pad_len;
2119 unsigned plaintext_len;
2122 /* Create SNOW 3G session */
2123 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2124 tdata->key.data, tdata->key.len,
2125 tdata->aad.len, tdata->digest.len,
2126 RTE_CRYPTO_AUTH_OP_GENERATE,
2127 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2131 /* alloc mbuf and set payload */
2132 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2134 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2135 rte_pktmbuf_tailroom(ut_params->ibuf));
2137 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2138 /* Append data which is padded to a multiple of */
2139 /* the algorithms block size */
2140 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2141 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2143 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2145 /* Create SNOW 3G operation */
2146 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2147 tdata->aad.data, tdata->aad.len,
2148 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2149 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2150 tdata->validAuthLenInBits.len,
2151 tdata->validAuthOffsetLenInBits.len);
2155 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2157 ut_params->obuf = ut_params->op->sym->m_src;
2158 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2159 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2160 + plaintext_pad_len + tdata->aad.len;
2163 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2166 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2167 "SNOW 3G Generated auth tag not as expected");
2173 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2175 struct crypto_testsuite_params *ts_params = &testsuite_params;
2176 struct crypto_unittest_params *ut_params = &unittest_params;
2179 unsigned plaintext_pad_len;
2180 unsigned plaintext_len;
2183 /* Create SNOW 3G session */
2184 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2185 tdata->key.data, tdata->key.len,
2186 tdata->aad.len, tdata->digest.len,
2187 RTE_CRYPTO_AUTH_OP_VERIFY,
2188 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2191 /* alloc mbuf and set payload */
2192 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2195 rte_pktmbuf_tailroom(ut_params->ibuf));
2197 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2198 /* Append data which is padded to a multiple of */
2199 /* the algorithms block size */
2200 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2201 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2203 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2205 /* Create SNOW 3G operation */
2206 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2208 tdata->aad.data, tdata->aad.len,
2210 RTE_CRYPTO_AUTH_OP_VERIFY,
2211 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2212 tdata->validAuthLenInBits.len,
2213 tdata->validAuthOffsetLenInBits.len);
2217 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2219 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2220 ut_params->obuf = ut_params->op->sym->m_src;
2221 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2222 + plaintext_pad_len + tdata->aad.len;
2225 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2234 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2236 struct crypto_testsuite_params *ts_params = &testsuite_params;
2237 struct crypto_unittest_params *ut_params = &unittest_params;
2240 unsigned plaintext_pad_len;
2241 unsigned plaintext_len;
2244 /* Create KASUMI session */
2245 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2246 tdata->key.data, tdata->key.len,
2247 tdata->aad.len, tdata->digest.len,
2248 RTE_CRYPTO_AUTH_OP_GENERATE,
2249 RTE_CRYPTO_AUTH_KASUMI_F9);
2253 /* alloc mbuf and set payload */
2254 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2257 rte_pktmbuf_tailroom(ut_params->ibuf));
2259 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2260 /* Append data which is padded to a multiple of */
2261 /* the algorithms block size */
2262 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2263 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2265 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2267 /* Create KASUMI operation */
2268 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2269 tdata->aad.data, tdata->aad.len,
2270 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2271 RTE_CRYPTO_AUTH_KASUMI_F9,
2272 tdata->validAuthLenInBits.len,
2273 tdata->validAuthOffsetLenInBits.len);
2277 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2279 ut_params->obuf = ut_params->op->sym->m_src;
2280 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2281 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2282 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2285 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2288 DIGEST_BYTE_LENGTH_KASUMI_F9,
2289 "KASUMI Generated auth tag not as expected");
2295 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2297 struct crypto_testsuite_params *ts_params = &testsuite_params;
2298 struct crypto_unittest_params *ut_params = &unittest_params;
2301 unsigned plaintext_pad_len;
2302 unsigned plaintext_len;
2305 /* Create KASUMI session */
2306 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2307 tdata->key.data, tdata->key.len,
2308 tdata->aad.len, tdata->digest.len,
2309 RTE_CRYPTO_AUTH_OP_VERIFY,
2310 RTE_CRYPTO_AUTH_KASUMI_F9);
2313 /* alloc mbuf and set payload */
2314 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2317 rte_pktmbuf_tailroom(ut_params->ibuf));
2319 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2320 /* Append data which is padded to a multiple */
2321 /* of the algorithms block size */
2322 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2323 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2325 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2327 /* Create KASUMI operation */
2328 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2330 tdata->aad.data, tdata->aad.len,
2332 RTE_CRYPTO_AUTH_OP_VERIFY,
2333 RTE_CRYPTO_AUTH_KASUMI_F9,
2334 tdata->validAuthLenInBits.len,
2335 tdata->validAuthOffsetLenInBits.len);
2339 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2341 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2342 ut_params->obuf = ut_params->op->sym->m_src;
2343 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2344 + plaintext_pad_len + tdata->aad.len;
2347 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2356 test_snow3g_hash_generate_test_case_1(void)
2358 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2362 test_snow3g_hash_generate_test_case_2(void)
2364 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2368 test_snow3g_hash_generate_test_case_3(void)
2370 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2374 test_snow3g_hash_generate_test_case_4(void)
2376 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2380 test_snow3g_hash_generate_test_case_5(void)
2382 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2386 test_snow3g_hash_generate_test_case_6(void)
2388 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2392 test_snow3g_hash_verify_test_case_1(void)
2394 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2399 test_snow3g_hash_verify_test_case_2(void)
2401 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2405 test_snow3g_hash_verify_test_case_3(void)
2407 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2411 test_snow3g_hash_verify_test_case_4(void)
2413 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2417 test_snow3g_hash_verify_test_case_5(void)
2419 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2423 test_snow3g_hash_verify_test_case_6(void)
2425 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2429 test_kasumi_hash_generate_test_case_1(void)
2431 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2435 test_kasumi_hash_generate_test_case_2(void)
2437 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2441 test_kasumi_hash_generate_test_case_3(void)
2443 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2447 test_kasumi_hash_generate_test_case_4(void)
2449 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2453 test_kasumi_hash_generate_test_case_5(void)
2455 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2459 test_kasumi_hash_generate_test_case_6(void)
2461 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2465 test_kasumi_hash_verify_test_case_1(void)
2467 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2471 test_kasumi_hash_verify_test_case_2(void)
2473 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2477 test_kasumi_hash_verify_test_case_3(void)
2479 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2483 test_kasumi_hash_verify_test_case_4(void)
2485 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2489 test_kasumi_hash_verify_test_case_5(void)
2491 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2495 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2497 struct crypto_testsuite_params *ts_params = &testsuite_params;
2498 struct crypto_unittest_params *ut_params = &unittest_params;
2501 uint8_t *plaintext, *ciphertext;
2502 unsigned plaintext_pad_len;
2503 unsigned plaintext_len;
2505 /* Create KASUMI session */
2506 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2507 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2508 RTE_CRYPTO_CIPHER_KASUMI_F8,
2509 tdata->key.data, tdata->key.len);
2513 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2515 /* Clear mbuf payload */
2516 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2517 rte_pktmbuf_tailroom(ut_params->ibuf));
2519 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2520 /* Append data which is padded to a multiple */
2521 /* of the algorithms block size */
2522 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2523 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2525 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2527 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2529 /* Create KASUMI operation */
2530 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2531 tdata->plaintext.len,
2532 tdata->validCipherOffsetLenInBits.len,
2533 RTE_CRYPTO_CIPHER_KASUMI_F8);
2537 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2539 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2541 ut_params->obuf = ut_params->op->sym->m_dst;
2542 if (ut_params->obuf)
2543 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2546 ciphertext = plaintext;
2548 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2551 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2553 tdata->ciphertext.data,
2554 tdata->validCipherLenInBits.len,
2555 "KASUMI Ciphertext data not as expected");
2560 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2562 struct crypto_testsuite_params *ts_params = &testsuite_params;
2563 struct crypto_unittest_params *ut_params = &unittest_params;
2566 uint8_t *plaintext, *ciphertext;
2567 unsigned plaintext_pad_len;
2568 unsigned plaintext_len;
2570 /* Create KASUMI session */
2571 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2572 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2573 RTE_CRYPTO_CIPHER_KASUMI_F8,
2574 tdata->key.data, tdata->key.len);
2578 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2579 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2581 /* Clear mbuf payload */
2582 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2583 rte_pktmbuf_tailroom(ut_params->ibuf));
2585 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2586 /* Append data which is padded to a multiple */
2587 /* of the algorithms block size */
2588 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2589 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2591 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2592 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2594 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2596 /* Create KASUMI operation */
2597 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2599 tdata->plaintext.len,
2600 tdata->validCipherOffsetLenInBits.len,
2601 RTE_CRYPTO_CIPHER_KASUMI_F8);
2605 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2607 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2609 ut_params->obuf = ut_params->op->sym->m_dst;
2610 if (ut_params->obuf)
2611 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2614 ciphertext = plaintext;
2616 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2619 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2621 tdata->ciphertext.data,
2622 tdata->validCipherLenInBits.len,
2623 "KASUMI Ciphertext data not as expected");
2628 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2630 struct crypto_testsuite_params *ts_params = &testsuite_params;
2631 struct crypto_unittest_params *ut_params = &unittest_params;
2634 uint8_t *ciphertext, *plaintext;
2635 unsigned ciphertext_pad_len;
2636 unsigned ciphertext_len;
2638 /* Create KASUMI session */
2639 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2640 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2641 RTE_CRYPTO_CIPHER_KASUMI_F8,
2642 tdata->key.data, tdata->key.len);
2646 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2647 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2649 /* Clear mbuf payload */
2650 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2651 rte_pktmbuf_tailroom(ut_params->ibuf));
2653 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2654 /* Append data which is padded to a multiple */
2655 /* of the algorithms block size */
2656 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2657 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2658 ciphertext_pad_len);
2659 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2660 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2662 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2664 /* Create KASUMI operation */
2665 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2667 tdata->ciphertext.len,
2668 tdata->validCipherOffsetLenInBits.len,
2669 RTE_CRYPTO_CIPHER_KASUMI_F8);
2673 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2675 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2677 ut_params->obuf = ut_params->op->sym->m_dst;
2678 if (ut_params->obuf)
2679 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2682 plaintext = ciphertext;
2684 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2687 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2689 tdata->plaintext.data,
2690 tdata->validCipherLenInBits.len,
2691 "KASUMI Plaintext data not as expected");
2696 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2698 struct crypto_testsuite_params *ts_params = &testsuite_params;
2699 struct crypto_unittest_params *ut_params = &unittest_params;
2702 uint8_t *ciphertext, *plaintext;
2703 unsigned ciphertext_pad_len;
2704 unsigned ciphertext_len;
2706 /* Create KASUMI session */
2707 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2708 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2709 RTE_CRYPTO_CIPHER_KASUMI_F8,
2710 tdata->key.data, tdata->key.len);
2714 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2716 /* Clear mbuf payload */
2717 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2718 rte_pktmbuf_tailroom(ut_params->ibuf));
2720 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2721 /* Append data which is padded to a multiple */
2722 /* of the algorithms block size */
2723 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2724 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2725 ciphertext_pad_len);
2726 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2728 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2730 /* Create KASUMI operation */
2731 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2733 tdata->ciphertext.len,
2734 tdata->validCipherOffsetLenInBits.len,
2735 RTE_CRYPTO_CIPHER_KASUMI_F8);
2739 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2741 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2743 ut_params->obuf = ut_params->op->sym->m_dst;
2744 if (ut_params->obuf)
2745 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2748 plaintext = ciphertext;
2750 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2753 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2755 tdata->plaintext.data,
2756 tdata->validCipherLenInBits.len,
2757 "KASUMI Plaintext data not as expected");
2762 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2764 struct crypto_testsuite_params *ts_params = &testsuite_params;
2765 struct crypto_unittest_params *ut_params = &unittest_params;
2768 uint8_t *plaintext, *ciphertext;
2769 unsigned plaintext_pad_len;
2770 unsigned plaintext_len;
2772 /* Create SNOW 3G session */
2773 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2774 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2775 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2776 tdata->key.data, tdata->key.len);
2780 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2782 /* Clear mbuf payload */
2783 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2784 rte_pktmbuf_tailroom(ut_params->ibuf));
2786 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2787 /* Append data which is padded to a multiple of */
2788 /* the algorithms block size */
2789 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2790 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2792 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2794 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2796 /* Create SNOW 3G operation */
2797 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2798 tdata->validCipherLenInBits.len,
2799 tdata->validCipherOffsetLenInBits.len,
2800 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2804 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2806 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2808 ut_params->obuf = ut_params->op->sym->m_dst;
2809 if (ut_params->obuf)
2810 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2813 ciphertext = plaintext;
2815 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2818 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2820 tdata->ciphertext.data,
2821 tdata->validDataLenInBits.len,
2822 "SNOW 3G Ciphertext data not as expected");
2828 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2830 struct crypto_testsuite_params *ts_params = &testsuite_params;
2831 struct crypto_unittest_params *ut_params = &unittest_params;
2832 uint8_t *plaintext, *ciphertext;
2835 unsigned plaintext_pad_len;
2836 unsigned plaintext_len;
2838 /* Create SNOW 3G session */
2839 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2840 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2841 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2842 tdata->key.data, tdata->key.len);
2846 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2847 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2849 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2850 "Failed to allocate input buffer in mempool");
2851 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2852 "Failed to allocate output buffer in mempool");
2854 /* Clear mbuf payload */
2855 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2856 rte_pktmbuf_tailroom(ut_params->ibuf));
2858 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2859 /* Append data which is padded to a multiple of */
2860 /* the algorithms block size */
2861 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2862 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2864 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2865 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2867 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2869 /* Create SNOW 3G operation */
2870 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2872 tdata->validCipherLenInBits.len,
2873 tdata->validCipherOffsetLenInBits.len,
2874 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2878 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2880 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2882 ut_params->obuf = ut_params->op->sym->m_dst;
2883 if (ut_params->obuf)
2884 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2887 ciphertext = plaintext;
2889 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2892 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2894 tdata->ciphertext.data,
2895 tdata->validDataLenInBits.len,
2896 "SNOW 3G Ciphertext data not as expected");
2900 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2902 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2904 uint8_t curr_byte, prev_byte;
2905 uint32_t length_in_bytes = ceil_byte_length(length + offset);
2906 uint8_t lower_byte_mask = (1 << offset) - 1;
2909 prev_byte = buffer[0];
2910 buffer[0] >>= offset;
2912 for (i = 1; i < length_in_bytes; i++) {
2913 curr_byte = buffer[i];
2914 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2915 (curr_byte >> offset);
2916 prev_byte = curr_byte;
2921 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2923 struct crypto_testsuite_params *ts_params = &testsuite_params;
2924 struct crypto_unittest_params *ut_params = &unittest_params;
2925 uint8_t *plaintext, *ciphertext;
2927 uint32_t plaintext_len;
2928 uint32_t plaintext_pad_len;
2929 uint8_t extra_offset = 4;
2930 uint8_t *expected_ciphertext_shifted;
2932 /* Create SNOW 3G session */
2933 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2934 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2935 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2936 tdata->key.data, tdata->key.len);
2940 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2941 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2943 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2944 "Failed to allocate input buffer in mempool");
2945 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2946 "Failed to allocate output buffer in mempool");
2948 /* Clear mbuf payload */
2949 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2950 rte_pktmbuf_tailroom(ut_params->ibuf));
2952 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2954 * Append data which is padded to a
2955 * multiple of the algorithms block size
2957 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2959 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2962 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2964 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2965 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2967 #ifdef RTE_APP_TEST_DEBUG
2968 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2970 /* Create SNOW 3G operation */
2971 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2973 tdata->validCipherLenInBits.len,
2974 tdata->validCipherOffsetLenInBits.len +
2976 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2980 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2982 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2984 ut_params->obuf = ut_params->op->sym->m_dst;
2985 if (ut_params->obuf)
2986 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2989 ciphertext = plaintext;
2991 #ifdef RTE_APP_TEST_DEBUG
2992 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2995 expected_ciphertext_shifted = rte_malloc(NULL,
2996 ceil_byte_length(plaintext_len + extra_offset), 0);
2998 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2999 "failed to reserve memory for ciphertext shifted\n");
3001 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3002 ceil_byte_length(tdata->ciphertext.len));
3003 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3006 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3008 expected_ciphertext_shifted,
3009 tdata->validDataLenInBits.len,
3011 "SNOW 3G Ciphertext data not as expected");
3015 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3017 struct crypto_testsuite_params *ts_params = &testsuite_params;
3018 struct crypto_unittest_params *ut_params = &unittest_params;
3022 uint8_t *plaintext, *ciphertext;
3023 unsigned ciphertext_pad_len;
3024 unsigned ciphertext_len;
3026 /* Create SNOW 3G session */
3027 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3028 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3029 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3030 tdata->key.data, tdata->key.len);
3034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3036 /* Clear mbuf payload */
3037 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3038 rte_pktmbuf_tailroom(ut_params->ibuf));
3040 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3041 /* Append data which is padded to a multiple of */
3042 /* the algorithms block size */
3043 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3044 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3045 ciphertext_pad_len);
3046 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3048 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3050 /* Create SNOW 3G operation */
3051 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3052 tdata->validCipherLenInBits.len,
3053 tdata->validCipherOffsetLenInBits.len,
3054 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3058 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3060 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3061 ut_params->obuf = ut_params->op->sym->m_dst;
3062 if (ut_params->obuf)
3063 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3066 plaintext = ciphertext;
3068 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3071 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3072 tdata->plaintext.data,
3073 tdata->validDataLenInBits.len,
3074 "SNOW 3G Plaintext data not as expected");
3078 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3080 struct crypto_testsuite_params *ts_params = &testsuite_params;
3081 struct crypto_unittest_params *ut_params = &unittest_params;
3085 uint8_t *plaintext, *ciphertext;
3086 unsigned ciphertext_pad_len;
3087 unsigned ciphertext_len;
3089 /* Create SNOW 3G session */
3090 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3091 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3092 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3093 tdata->key.data, tdata->key.len);
3097 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3098 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3100 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3101 "Failed to allocate input buffer");
3102 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3103 "Failed to allocate output buffer");
3105 /* Clear mbuf payload */
3106 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3107 rte_pktmbuf_tailroom(ut_params->ibuf));
3109 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3110 rte_pktmbuf_tailroom(ut_params->obuf));
3112 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3113 /* Append data which is padded to a multiple of */
3114 /* the algorithms block size */
3115 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3116 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3117 ciphertext_pad_len);
3118 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3119 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3121 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3123 /* Create SNOW 3G operation */
3124 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3126 tdata->validCipherLenInBits.len,
3127 tdata->validCipherOffsetLenInBits.len,
3128 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3132 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3134 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3135 ut_params->obuf = ut_params->op->sym->m_dst;
3136 if (ut_params->obuf)
3137 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3140 plaintext = ciphertext;
3142 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3145 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3146 tdata->plaintext.data,
3147 tdata->validDataLenInBits.len,
3148 "SNOW 3G Plaintext data not as expected");
3153 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3155 struct crypto_testsuite_params *ts_params = &testsuite_params;
3156 struct crypto_unittest_params *ut_params = &unittest_params;
3160 uint8_t *plaintext, *ciphertext;
3161 unsigned plaintext_pad_len;
3162 unsigned plaintext_len;
3164 /* Create SNOW 3G session */
3165 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3166 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3167 RTE_CRYPTO_AUTH_OP_GENERATE,
3168 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3169 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3170 tdata->key.data, tdata->key.len,
3171 tdata->aad.len, tdata->digest.len);
3174 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3176 /* clear mbuf payload */
3177 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3178 rte_pktmbuf_tailroom(ut_params->ibuf));
3180 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3181 /* Append data which is padded to a multiple of */
3182 /* the algorithms block size */
3183 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3184 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
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_hash_operation(tdata->digest.data,
3192 tdata->digest.len, tdata->aad.data,
3193 tdata->aad.len, /*tdata->plaintext.len,*/
3194 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3195 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3196 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3197 tdata->iv.data, tdata->iv.len,
3198 tdata->validCipherLenInBits.len,
3199 tdata->validCipherOffsetLenInBits.len,
3200 tdata->validAuthLenInBits.len,
3201 tdata->validAuthOffsetLenInBits.len
3206 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3208 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3209 ut_params->obuf = ut_params->op->sym->m_src;
3210 if (ut_params->obuf)
3211 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3212 + tdata->iv.len + tdata->aad.len;
3214 ciphertext = plaintext;
3216 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3218 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3220 tdata->ciphertext.data,
3221 tdata->validDataLenInBits.len,
3222 "SNOW 3G Ciphertext data not as expected");
3224 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3225 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3228 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3231 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3232 "SNOW 3G Generated auth tag not as expected");
3236 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3238 struct crypto_testsuite_params *ts_params = &testsuite_params;
3239 struct crypto_unittest_params *ut_params = &unittest_params;
3243 uint8_t *plaintext, *ciphertext;
3244 unsigned plaintext_pad_len;
3245 unsigned plaintext_len;
3247 /* Create SNOW 3G session */
3248 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3249 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3250 RTE_CRYPTO_AUTH_OP_GENERATE,
3251 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3252 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3253 tdata->key.data, tdata->key.len,
3254 tdata->aad.len, tdata->digest.len);
3258 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3260 /* clear mbuf payload */
3261 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3262 rte_pktmbuf_tailroom(ut_params->ibuf));
3264 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3265 /* Append data which is padded to a multiple of */
3266 /* the algorithms block size */
3267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3268 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3270 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3272 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3274 /* Create SNOW 3G operation */
3275 retval = create_wireless_algo_auth_cipher_operation(
3277 tdata->iv.data, tdata->iv.len,
3278 tdata->aad.data, tdata->aad.len,
3280 tdata->validCipherLenInBits.len,
3281 tdata->validCipherOffsetLenInBits.len,
3282 tdata->validAuthLenInBits.len,
3283 tdata->validAuthOffsetLenInBits.len,
3284 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3285 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3291 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3294 ut_params->obuf = ut_params->op->sym->m_src;
3295 if (ut_params->obuf)
3296 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3297 + tdata->aad.len + tdata->iv.len;
3299 ciphertext = plaintext;
3301 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3302 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3303 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3308 tdata->ciphertext.data,
3309 tdata->validDataLenInBits.len,
3310 "SNOW 3G Ciphertext data not as expected");
3313 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3316 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3317 "SNOW 3G Generated auth tag not as expected");
3322 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3324 struct crypto_testsuite_params *ts_params = &testsuite_params;
3325 struct crypto_unittest_params *ut_params = &unittest_params;
3329 uint8_t *plaintext, *ciphertext;
3330 unsigned plaintext_pad_len;
3331 unsigned plaintext_len;
3333 /* Create KASUMI session */
3334 retval = create_wireless_algo_auth_cipher_session(
3335 ts_params->valid_devs[0],
3336 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3337 RTE_CRYPTO_AUTH_OP_GENERATE,
3338 RTE_CRYPTO_AUTH_KASUMI_F9,
3339 RTE_CRYPTO_CIPHER_KASUMI_F8,
3340 tdata->key.data, tdata->key.len,
3341 tdata->aad.len, tdata->digest.len);
3344 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3346 /* clear mbuf payload */
3347 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3348 rte_pktmbuf_tailroom(ut_params->ibuf));
3350 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3351 /* Append data which is padded to a multiple of */
3352 /* the algorithms block size */
3353 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3354 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3356 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3358 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3360 /* Create KASUMI operation */
3361 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3362 tdata->iv.data, tdata->iv.len,
3363 tdata->aad.data, tdata->aad.len,
3365 tdata->validCipherLenInBits.len,
3366 tdata->validCipherOffsetLenInBits.len,
3367 tdata->validAuthLenInBits.len,
3368 tdata->validAuthOffsetLenInBits.len,
3369 RTE_CRYPTO_AUTH_KASUMI_F9,
3370 RTE_CRYPTO_CIPHER_KASUMI_F8
3376 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3378 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3379 ut_params->obuf = ut_params->op->sym->m_src;
3380 if (ut_params->obuf)
3381 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3382 + tdata->iv.len + tdata->aad.len;
3384 ciphertext = plaintext;
3387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3389 tdata->ciphertext.data,
3390 tdata->validCipherLenInBits.len,
3391 "KASUMI Ciphertext data not as expected");
3392 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3393 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3396 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3399 DIGEST_BYTE_LENGTH_KASUMI_F9,
3400 "KASUMI Generated auth tag not as expected");
3405 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3407 struct crypto_testsuite_params *ts_params = &testsuite_params;
3408 struct crypto_unittest_params *ut_params = &unittest_params;
3412 uint8_t *plaintext, *ciphertext;
3413 unsigned plaintext_pad_len;
3414 unsigned plaintext_len;
3416 /* Create KASUMI session */
3417 retval = create_wireless_algo_cipher_auth_session(
3418 ts_params->valid_devs[0],
3419 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3420 RTE_CRYPTO_AUTH_OP_GENERATE,
3421 RTE_CRYPTO_AUTH_KASUMI_F9,
3422 RTE_CRYPTO_CIPHER_KASUMI_F8,
3423 tdata->key.data, tdata->key.len,
3424 tdata->aad.len, tdata->digest.len);
3428 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3430 /* clear mbuf payload */
3431 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3432 rte_pktmbuf_tailroom(ut_params->ibuf));
3434 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3435 /* Append data which is padded to a multiple of */
3436 /* the algorithms block size */
3437 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3438 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3440 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3442 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3444 /* Create KASUMI operation */
3445 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3446 tdata->digest.len, tdata->aad.data,
3448 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3449 RTE_CRYPTO_AUTH_KASUMI_F9,
3450 RTE_CRYPTO_CIPHER_KASUMI_F8,
3451 tdata->iv.data, tdata->iv.len,
3452 tdata->validCipherLenInBits.len,
3453 tdata->validCipherOffsetLenInBits.len,
3454 tdata->validAuthLenInBits.len,
3455 tdata->validAuthOffsetLenInBits.len
3460 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3462 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3463 ut_params->obuf = ut_params->op->sym->m_src;
3464 if (ut_params->obuf)
3465 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3466 + tdata->aad.len + tdata->iv.len;
3468 ciphertext = plaintext;
3470 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3471 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3474 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3476 tdata->ciphertext.data,
3477 tdata->validCipherLenInBits.len,
3478 "KASUMI Ciphertext data not as expected");
3481 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3484 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3485 "KASUMI Generated auth tag not as expected");
3490 test_zuc_encryption(const struct zuc_test_data *tdata)
3492 struct crypto_testsuite_params *ts_params = &testsuite_params;
3493 struct crypto_unittest_params *ut_params = &unittest_params;
3496 uint8_t *plaintext, *ciphertext;
3497 unsigned plaintext_pad_len;
3498 unsigned plaintext_len;
3500 /* Create ZUC session */
3501 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3502 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3503 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3504 tdata->key.data, tdata->key.len);
3508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3510 /* Clear mbuf payload */
3511 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3512 rte_pktmbuf_tailroom(ut_params->ibuf));
3514 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3515 /* Append data which is padded to a multiple */
3516 /* of the algorithms block size */
3517 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3518 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3520 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3522 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3524 /* Create ZUC operation */
3525 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3526 tdata->plaintext.len,
3527 tdata->validCipherOffsetLenInBits.len,
3528 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3532 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3534 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3536 ut_params->obuf = ut_params->op->sym->m_dst;
3537 if (ut_params->obuf)
3538 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3541 ciphertext = plaintext;
3543 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3546 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3548 tdata->ciphertext.data,
3549 tdata->validCipherLenInBits.len,
3550 "ZUC Ciphertext data not as expected");
3555 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3557 struct crypto_testsuite_params *ts_params = &testsuite_params;
3558 struct crypto_unittest_params *ut_params = &unittest_params;
3561 unsigned plaintext_pad_len;
3562 unsigned plaintext_len;
3565 /* Create ZUC session */
3566 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3567 tdata->key.data, tdata->key.len,
3568 tdata->aad.len, tdata->digest.len,
3569 RTE_CRYPTO_AUTH_OP_GENERATE,
3570 RTE_CRYPTO_AUTH_ZUC_EIA3);
3574 /* alloc mbuf and set payload */
3575 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
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, 8);
3584 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3586 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3588 /* Create ZUC operation */
3589 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3590 tdata->aad.data, tdata->aad.len,
3591 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3592 RTE_CRYPTO_AUTH_ZUC_EIA3,
3593 tdata->validAuthLenInBits.len,
3594 tdata->validAuthOffsetLenInBits.len);
3598 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3600 ut_params->obuf = ut_params->op->sym->m_src;
3601 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3602 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3603 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3606 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3609 DIGEST_BYTE_LENGTH_KASUMI_F9,
3610 "ZUC Generated auth tag not as expected");
3616 test_kasumi_encryption_test_case_1(void)
3618 return test_kasumi_encryption(&kasumi_test_case_1);
3622 test_kasumi_encryption_test_case_1_oop(void)
3624 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3628 test_kasumi_encryption_test_case_2(void)
3630 return test_kasumi_encryption(&kasumi_test_case_2);
3634 test_kasumi_encryption_test_case_3(void)
3636 return test_kasumi_encryption(&kasumi_test_case_3);
3640 test_kasumi_encryption_test_case_4(void)
3642 return test_kasumi_encryption(&kasumi_test_case_4);
3646 test_kasumi_encryption_test_case_5(void)
3648 return test_kasumi_encryption(&kasumi_test_case_5);
3652 test_kasumi_decryption_test_case_1(void)
3654 return test_kasumi_decryption(&kasumi_test_case_1);
3658 test_kasumi_decryption_test_case_1_oop(void)
3660 return test_kasumi_decryption_oop(&kasumi_test_case_1);
3664 test_kasumi_decryption_test_case_2(void)
3666 return test_kasumi_decryption(&kasumi_test_case_2);
3670 test_kasumi_decryption_test_case_3(void)
3672 return test_kasumi_decryption(&kasumi_test_case_3);
3676 test_kasumi_decryption_test_case_4(void)
3678 return test_kasumi_decryption(&kasumi_test_case_4);
3682 test_kasumi_decryption_test_case_5(void)
3684 return test_kasumi_decryption(&kasumi_test_case_5);
3687 test_snow3g_encryption_test_case_1(void)
3689 return test_snow3g_encryption(&snow3g_test_case_1);
3693 test_snow3g_encryption_test_case_1_oop(void)
3695 return test_snow3g_encryption_oop(&snow3g_test_case_1);
3699 test_snow3g_encryption_test_case_1_offset_oop(void)
3701 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
3705 test_snow3g_encryption_test_case_2(void)
3707 return test_snow3g_encryption(&snow3g_test_case_2);
3711 test_snow3g_encryption_test_case_3(void)
3713 return test_snow3g_encryption(&snow3g_test_case_3);
3717 test_snow3g_encryption_test_case_4(void)
3719 return test_snow3g_encryption(&snow3g_test_case_4);
3723 test_snow3g_encryption_test_case_5(void)
3725 return test_snow3g_encryption(&snow3g_test_case_5);
3729 test_snow3g_decryption_test_case_1(void)
3731 return test_snow3g_decryption(&snow3g_test_case_1);
3735 test_snow3g_decryption_test_case_1_oop(void)
3737 return test_snow3g_decryption_oop(&snow3g_test_case_1);
3741 test_snow3g_decryption_test_case_2(void)
3743 return test_snow3g_decryption(&snow3g_test_case_2);
3747 test_snow3g_decryption_test_case_3(void)
3749 return test_snow3g_decryption(&snow3g_test_case_3);
3753 test_snow3g_decryption_test_case_4(void)
3755 return test_snow3g_decryption(&snow3g_test_case_4);
3759 test_snow3g_decryption_test_case_5(void)
3761 return test_snow3g_decryption(&snow3g_test_case_5);
3764 test_snow3g_cipher_auth_test_case_1(void)
3766 return test_snow3g_cipher_auth(&snow3g_test_case_3);
3770 test_snow3g_auth_cipher_test_case_1(void)
3772 return test_snow3g_auth_cipher(&snow3g_test_case_6);
3776 test_kasumi_auth_cipher_test_case_1(void)
3778 return test_kasumi_auth_cipher(&kasumi_test_case_3);
3782 test_kasumi_cipher_auth_test_case_1(void)
3784 return test_kasumi_cipher_auth(&kasumi_test_case_6);
3788 test_zuc_encryption_test_case_1(void)
3790 return test_zuc_encryption(&zuc_test_case_1);
3794 test_zuc_encryption_test_case_2(void)
3796 return test_zuc_encryption(&zuc_test_case_2);
3800 test_zuc_encryption_test_case_3(void)
3802 return test_zuc_encryption(&zuc_test_case_3);
3806 test_zuc_encryption_test_case_4(void)
3808 return test_zuc_encryption(&zuc_test_case_4);
3812 test_zuc_encryption_test_case_5(void)
3814 return test_zuc_encryption(&zuc_test_case_5);
3818 test_zuc_hash_generate_test_case_1(void)
3820 return test_zuc_authentication(&zuc_hash_test_case_1);
3824 test_zuc_hash_generate_test_case_2(void)
3826 return test_zuc_authentication(&zuc_hash_test_case_2);
3830 test_zuc_hash_generate_test_case_3(void)
3832 return test_zuc_authentication(&zuc_hash_test_case_3);
3836 test_zuc_hash_generate_test_case_4(void)
3838 return test_zuc_authentication(&zuc_hash_test_case_4);
3842 test_zuc_hash_generate_test_case_5(void)
3844 return test_zuc_authentication(&zuc_hash_test_case_5);
3848 test_3DES_chain_qat_all(void)
3850 struct crypto_testsuite_params *ts_params = &testsuite_params;
3853 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3854 ts_params->op_mpool, ts_params->valid_devs[0],
3855 RTE_CRYPTODEV_QAT_SYM_PMD,
3856 BLKCIPHER_3DES_CHAIN_TYPE);
3858 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3860 return TEST_SUCCESS;
3864 test_DES_cipheronly_qat_all(void)
3866 struct crypto_testsuite_params *ts_params = &testsuite_params;
3869 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3870 ts_params->op_mpool, ts_params->valid_devs[0],
3871 RTE_CRYPTODEV_QAT_SYM_PMD,
3872 BLKCIPHER_DES_CIPHERONLY_TYPE);
3874 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3876 return TEST_SUCCESS;
3880 test_3DES_cipheronly_qat_all(void)
3882 struct crypto_testsuite_params *ts_params = &testsuite_params;
3885 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3886 ts_params->op_mpool, ts_params->valid_devs[0],
3887 RTE_CRYPTODEV_QAT_SYM_PMD,
3888 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3890 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3892 return TEST_SUCCESS;
3896 test_3DES_chain_openssl_all(void)
3898 struct crypto_testsuite_params *ts_params = &testsuite_params;
3901 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3902 ts_params->op_mpool, ts_params->valid_devs[0],
3903 RTE_CRYPTODEV_OPENSSL_PMD,
3904 BLKCIPHER_3DES_CHAIN_TYPE);
3906 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3908 return TEST_SUCCESS;
3912 test_3DES_cipheronly_openssl_all(void)
3914 struct crypto_testsuite_params *ts_params = &testsuite_params;
3917 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3918 ts_params->op_mpool, ts_params->valid_devs[0],
3919 RTE_CRYPTODEV_OPENSSL_PMD,
3920 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3922 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3924 return TEST_SUCCESS;
3927 /* ***** AES-GCM Tests ***** */
3930 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3931 const uint8_t *key, const uint8_t key_len,
3932 const uint8_t aad_len, const uint8_t auth_len,
3933 enum rte_crypto_auth_operation auth_op)
3935 uint8_t cipher_key[key_len];
3937 struct crypto_unittest_params *ut_params = &unittest_params;
3939 memcpy(cipher_key, key, key_len);
3941 /* Setup Cipher Parameters */
3942 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3943 ut_params->cipher_xform.next = NULL;
3945 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3946 ut_params->auth_xform.auth.op = auth_op;
3947 ut_params->cipher_xform.cipher.op = op;
3948 ut_params->cipher_xform.cipher.key.data = cipher_key;
3949 ut_params->cipher_xform.cipher.key.length = key_len;
3951 TEST_HEXDUMP(stdout, "key:", key, key_len);
3953 /* Setup Authentication Parameters */
3954 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3955 ut_params->auth_xform.next = NULL;
3957 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3959 ut_params->auth_xform.auth.digest_length = auth_len;
3960 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3961 ut_params->auth_xform.auth.key.length = 0;
3962 ut_params->auth_xform.auth.key.data = NULL;
3964 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3965 ut_params->cipher_xform.next = &ut_params->auth_xform;
3967 /* Create Crypto session*/
3968 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3969 &ut_params->cipher_xform);
3970 } else {/* Create Crypto session*/
3971 ut_params->auth_xform.next = &ut_params->cipher_xform;
3972 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3973 &ut_params->auth_xform);
3976 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3982 create_gcm_operation(enum rte_crypto_cipher_operation op,
3983 const uint8_t *auth_tag, const unsigned auth_tag_len,
3984 const uint8_t *iv, const unsigned iv_len,
3985 const uint8_t *aad, const unsigned aad_len,
3986 const unsigned data_len, unsigned data_pad_len)
3988 struct crypto_testsuite_params *ts_params = &testsuite_params;
3989 struct crypto_unittest_params *ut_params = &unittest_params;
3991 unsigned iv_pad_len = 0, aad_buffer_len;
3993 /* Generate Crypto op data structure */
3994 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3995 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3996 TEST_ASSERT_NOT_NULL(ut_params->op,
3997 "Failed to allocate symmetric crypto operation struct");
3999 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4001 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4002 ut_params->ibuf, auth_tag_len);
4003 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4004 "no room to append digest");
4005 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4006 ut_params->ibuf, data_pad_len);
4007 sym_op->auth.digest.length = auth_tag_len;
4009 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
4010 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
4011 TEST_HEXDUMP(stdout, "digest:",
4012 sym_op->auth.digest.data,
4013 sym_op->auth.digest.length);
4017 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
4019 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4020 ut_params->ibuf, iv_pad_len);
4021 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4023 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4024 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4025 sym_op->cipher.iv.length = iv_len;
4027 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
4030 * Always allocate the aad up to the block size.
4031 * The cryptodev API calls out -
4032 * - the array must be big enough to hold the AAD, plus any
4033 * space to round this up to the nearest multiple of the
4034 * block size (16 bytes).
4036 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
4038 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
4039 ut_params->ibuf, aad_buffer_len);
4040 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4041 "no room to prepend aad");
4042 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
4044 sym_op->auth.aad.length = aad_len;
4046 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
4047 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
4049 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
4050 TEST_HEXDUMP(stdout, "aad:",
4051 sym_op->auth.aad.data, aad_len);
4053 sym_op->cipher.data.length = data_len;
4054 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
4056 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
4057 sym_op->auth.data.length = data_len;
4063 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4065 struct crypto_testsuite_params *ts_params = &testsuite_params;
4066 struct crypto_unittest_params *ut_params = &unittest_params;
4070 uint8_t *plaintext, *ciphertext, *auth_tag;
4071 uint16_t plaintext_pad_len;
4073 /* Create GCM session */
4074 retval = create_gcm_session(ts_params->valid_devs[0],
4075 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4076 tdata->key.data, tdata->key.len,
4077 tdata->aad.len, tdata->auth_tag.len,
4078 RTE_CRYPTO_AUTH_OP_GENERATE);
4083 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4085 /* clear mbuf payload */
4086 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4087 rte_pktmbuf_tailroom(ut_params->ibuf));
4090 * Append data which is padded to a multiple
4091 * of the algorithms block size
4093 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4095 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4097 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4099 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4101 /* Create GCM opertaion */
4102 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4103 tdata->auth_tag.data, tdata->auth_tag.len,
4104 tdata->iv.data, tdata->iv.len,
4105 tdata->aad.data, tdata->aad.len,
4106 tdata->plaintext.len, plaintext_pad_len);
4110 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4112 ut_params->op->sym->m_src = ut_params->ibuf;
4114 /* Process crypto operation */
4115 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4116 ut_params->op), "failed to process sym crypto op");
4118 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4119 "crypto op processing failed");
4121 if (ut_params->op->sym->m_dst) {
4122 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4124 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4125 uint8_t *, plaintext_pad_len);
4127 ciphertext = plaintext;
4128 auth_tag = plaintext + plaintext_pad_len;
4131 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4132 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4135 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4137 tdata->ciphertext.data,
4138 tdata->ciphertext.len,
4139 "GCM Ciphertext data not as expected");
4141 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4143 tdata->auth_tag.data,
4144 tdata->auth_tag.len,
4145 "GCM Generated auth tag not as expected");
4152 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4154 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4158 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4160 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4164 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4166 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4170 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4172 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4176 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4178 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4182 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4184 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4188 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4190 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4194 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4196 struct crypto_testsuite_params *ts_params = &testsuite_params;
4197 struct crypto_unittest_params *ut_params = &unittest_params;
4201 uint8_t *plaintext, *ciphertext;
4202 uint16_t ciphertext_pad_len;
4204 /* Create GCM session */
4205 retval = create_gcm_session(ts_params->valid_devs[0],
4206 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4207 tdata->key.data, tdata->key.len,
4208 tdata->aad.len, tdata->auth_tag.len,
4209 RTE_CRYPTO_AUTH_OP_VERIFY);
4214 /* alloc mbuf and set payload */
4215 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4217 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4218 rte_pktmbuf_tailroom(ut_params->ibuf));
4220 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4222 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4223 ciphertext_pad_len);
4224 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
4226 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4228 /* Create GCM opertaion */
4229 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
4230 tdata->auth_tag.data, tdata->auth_tag.len,
4231 tdata->iv.data, tdata->iv.len,
4232 tdata->aad.data, tdata->aad.len,
4233 tdata->ciphertext.len, ciphertext_pad_len);
4238 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4240 ut_params->op->sym->m_src = ut_params->ibuf;
4242 /* Process crypto operation */
4243 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4244 ut_params->op), "failed to process sym crypto op");
4246 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4247 "crypto op processing failed");
4249 if (ut_params->op->sym->m_dst)
4250 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4253 plaintext = ciphertext;
4255 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4258 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4260 tdata->plaintext.data,
4261 tdata->plaintext.len,
4262 "GCM plaintext data not as expected");
4264 TEST_ASSERT_EQUAL(ut_params->op->status,
4265 RTE_CRYPTO_OP_STATUS_SUCCESS,
4266 "GCM authentication failed");
4271 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4273 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4277 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4279 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4283 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4285 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4289 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4291 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4295 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4297 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4301 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4303 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4307 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4309 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4315 struct crypto_testsuite_params *ts_params = &testsuite_params;
4316 struct rte_cryptodev_stats stats;
4317 struct rte_cryptodev *dev;
4318 cryptodev_stats_get_t temp_pfn;
4320 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4321 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
4322 &stats) == -ENODEV),
4323 "rte_cryptodev_stats_get invalid dev failed");
4324 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
4325 "rte_cryptodev_stats_get invalid Param failed");
4326 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
4327 temp_pfn = dev->dev_ops->stats_get;
4328 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
4329 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
4331 "rte_cryptodev_stats_get invalid Param failed");
4332 dev->dev_ops->stats_get = temp_pfn;
4334 /* Test expected values */
4336 test_AES_CBC_HMAC_SHA1_encrypt_digest();
4338 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4340 "rte_cryptodev_stats_get failed");
4341 TEST_ASSERT((stats.enqueued_count == 1),
4342 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4343 TEST_ASSERT((stats.dequeued_count == 1),
4344 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4345 TEST_ASSERT((stats.enqueue_err_count == 0),
4346 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4347 TEST_ASSERT((stats.dequeue_err_count == 0),
4348 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4350 /* invalid device but should ignore and not reset device stats*/
4351 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
4352 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4354 "rte_cryptodev_stats_get failed");
4355 TEST_ASSERT((stats.enqueued_count == 1),
4356 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4358 /* check that a valid reset clears stats */
4359 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4360 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4362 "rte_cryptodev_stats_get failed");
4363 TEST_ASSERT((stats.enqueued_count == 0),
4364 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4365 TEST_ASSERT((stats.dequeued_count == 0),
4366 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4368 return TEST_SUCCESS;
4371 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
4372 struct crypto_unittest_params *ut_params,
4373 enum rte_crypto_auth_operation op,
4374 const struct HMAC_MD5_vector *test_case)
4378 memcpy(key, test_case->key.data, test_case->key.len);
4380 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4381 ut_params->auth_xform.next = NULL;
4382 ut_params->auth_xform.auth.op = op;
4384 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
4386 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
4387 ut_params->auth_xform.auth.add_auth_data_length = 0;
4388 ut_params->auth_xform.auth.key.length = test_case->key.len;
4389 ut_params->auth_xform.auth.key.data = key;
4391 ut_params->sess = rte_cryptodev_sym_session_create(
4392 ts_params->valid_devs[0], &ut_params->auth_xform);
4394 if (ut_params->sess == NULL)
4397 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4399 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4400 rte_pktmbuf_tailroom(ut_params->ibuf));
4405 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
4406 const struct HMAC_MD5_vector *test_case,
4407 uint8_t **plaintext)
4409 uint16_t plaintext_pad_len;
4411 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4413 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4416 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4418 memcpy(*plaintext, test_case->plaintext.data,
4419 test_case->plaintext.len);
4421 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4422 ut_params->ibuf, MD5_DIGEST_LEN);
4423 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4424 "no room to append digest");
4425 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4426 ut_params->ibuf, plaintext_pad_len);
4427 sym_op->auth.digest.length = MD5_DIGEST_LEN;
4429 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
4430 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
4431 test_case->auth_tag.len);
4434 sym_op->auth.data.offset = 0;
4435 sym_op->auth.data.length = test_case->plaintext.len;
4437 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4438 ut_params->op->sym->m_src = ut_params->ibuf;
4444 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
4446 uint16_t plaintext_pad_len;
4447 uint8_t *plaintext, *auth_tag;
4449 struct crypto_testsuite_params *ts_params = &testsuite_params;
4450 struct crypto_unittest_params *ut_params = &unittest_params;
4452 if (MD5_HMAC_create_session(ts_params, ut_params,
4453 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
4456 /* Generate Crypto op data structure */
4457 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4458 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4459 TEST_ASSERT_NOT_NULL(ut_params->op,
4460 "Failed to allocate symmetric crypto operation struct");
4462 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4465 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4468 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4469 ut_params->op), "failed to process sym crypto op");
4471 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4472 "crypto op processing failed");
4474 if (ut_params->op->sym->m_dst) {
4475 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4476 uint8_t *, plaintext_pad_len);
4478 auth_tag = plaintext + plaintext_pad_len;
4481 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4483 test_case->auth_tag.data,
4484 test_case->auth_tag.len,
4485 "HMAC_MD5 generated tag not as expected");
4487 return TEST_SUCCESS;
4491 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
4495 struct crypto_testsuite_params *ts_params = &testsuite_params;
4496 struct crypto_unittest_params *ut_params = &unittest_params;
4498 if (MD5_HMAC_create_session(ts_params, ut_params,
4499 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
4503 /* Generate Crypto op data structure */
4504 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4505 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4506 TEST_ASSERT_NOT_NULL(ut_params->op,
4507 "Failed to allocate symmetric crypto operation struct");
4509 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4512 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4513 ut_params->op), "failed to process sym crypto op");
4515 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4516 "HMAC_MD5 crypto op processing failed");
4518 return TEST_SUCCESS;
4522 test_MD5_HMAC_generate_case_1(void)
4524 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
4528 test_MD5_HMAC_verify_case_1(void)
4530 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
4534 test_MD5_HMAC_generate_case_2(void)
4536 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
4540 test_MD5_HMAC_verify_case_2(void)
4542 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
4546 test_multi_session(void)
4548 struct crypto_testsuite_params *ts_params = &testsuite_params;
4549 struct crypto_unittest_params *ut_params = &unittest_params;
4551 struct rte_cryptodev_info dev_info;
4552 struct rte_cryptodev_sym_session **sessions;
4556 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
4557 aes_cbc_key, hmac_sha512_key);
4560 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4562 sessions = rte_malloc(NULL,
4563 (sizeof(struct rte_cryptodev_sym_session *) *
4564 dev_info.sym.max_nb_sessions) + 1, 0);
4566 /* Create multiple crypto sessions*/
4567 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
4568 sessions[i] = rte_cryptodev_sym_session_create(
4569 ts_params->valid_devs[0],
4570 &ut_params->auth_xform);
4571 TEST_ASSERT_NOT_NULL(sessions[i],
4572 "Session creation failed at session number %u",
4575 /* Attempt to send a request on each session */
4576 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
4580 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
4581 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
4583 "Failed to perform decrypt on request number %u.", i);
4584 /* free crypto operation structure */
4586 rte_crypto_op_free(ut_params->op);
4589 * free mbuf - both obuf and ibuf are usually the same,
4590 * so check if they point at the same address is necessary,
4591 * to avoid freeing the mbuf twice.
4593 if (ut_params->obuf) {
4594 rte_pktmbuf_free(ut_params->obuf);
4595 if (ut_params->ibuf == ut_params->obuf)
4596 ut_params->ibuf = 0;
4597 ut_params->obuf = 0;
4599 if (ut_params->ibuf) {
4600 rte_pktmbuf_free(ut_params->ibuf);
4601 ut_params->ibuf = 0;
4605 /* Next session create should fail */
4606 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
4607 &ut_params->auth_xform);
4608 TEST_ASSERT_NULL(sessions[i],
4609 "Session creation succeeded unexpectedly!");
4611 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
4612 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4617 return TEST_SUCCESS;
4620 struct multi_session_params {
4621 struct crypto_unittest_params ut_params;
4622 uint8_t *cipher_key;
4624 const uint8_t *cipher;
4625 const uint8_t *digest;
4629 #define MB_SESSION_NUMBER 3
4632 test_multi_session_random_usage(void)
4634 struct crypto_testsuite_params *ts_params = &testsuite_params;
4635 struct rte_cryptodev_info dev_info;
4636 struct rte_cryptodev_sym_session **sessions;
4638 struct multi_session_params ut_paramz[] = {
4641 .cipher_key = ms_aes_cbc_key0,
4642 .hmac_key = ms_hmac_key0,
4643 .cipher = ms_aes_cbc_cipher0,
4644 .digest = ms_hmac_digest0,
4645 .iv = ms_aes_cbc_iv0
4648 .cipher_key = ms_aes_cbc_key1,
4649 .hmac_key = ms_hmac_key1,
4650 .cipher = ms_aes_cbc_cipher1,
4651 .digest = ms_hmac_digest1,
4652 .iv = ms_aes_cbc_iv1
4655 .cipher_key = ms_aes_cbc_key2,
4656 .hmac_key = ms_hmac_key2,
4657 .cipher = ms_aes_cbc_cipher2,
4658 .digest = ms_hmac_digest2,
4659 .iv = ms_aes_cbc_iv2
4664 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4666 sessions = rte_malloc(NULL,
4667 (sizeof(struct rte_cryptodev_sym_session *)
4668 * dev_info.sym.max_nb_sessions) + 1, 0);
4670 for (i = 0; i < MB_SESSION_NUMBER; i++) {
4671 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
4672 sizeof(struct crypto_unittest_params));
4674 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
4675 &ut_paramz[i].ut_params,
4676 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
4678 /* Create multiple crypto sessions*/
4679 sessions[i] = rte_cryptodev_sym_session_create(
4680 ts_params->valid_devs[0],
4681 &ut_paramz[i].ut_params.auth_xform);
4683 TEST_ASSERT_NOT_NULL(sessions[i],
4684 "Session creation failed at session number %u",
4690 for (i = 0; i < 40000; i++) {
4692 j = rand() % MB_SESSION_NUMBER;
4694 TEST_ASSERT_SUCCESS(
4695 test_AES_CBC_HMAC_SHA512_decrypt_perform(
4697 &ut_paramz[j].ut_params,
4698 ts_params, ut_paramz[j].cipher,
4699 ut_paramz[j].digest,
4701 "Failed to perform decrypt on request number %u.", i);
4703 if (ut_paramz[j].ut_params.op)
4704 rte_crypto_op_free(ut_paramz[j].ut_params.op);
4707 * free mbuf - both obuf and ibuf are usually the same,
4708 * so check if they point at the same address is necessary,
4709 * to avoid freeing the mbuf twice.
4711 if (ut_paramz[j].ut_params.obuf) {
4712 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
4713 if (ut_paramz[j].ut_params.ibuf
4714 == ut_paramz[j].ut_params.obuf)
4715 ut_paramz[j].ut_params.ibuf = 0;
4716 ut_paramz[j].ut_params.obuf = 0;
4718 if (ut_paramz[j].ut_params.ibuf) {
4719 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
4720 ut_paramz[j].ut_params.ibuf = 0;
4724 for (i = 0; i < MB_SESSION_NUMBER; i++)
4725 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4730 return TEST_SUCCESS;
4734 test_null_cipher_only_operation(void)
4736 struct crypto_testsuite_params *ts_params = &testsuite_params;
4737 struct crypto_unittest_params *ut_params = &unittest_params;
4739 /* Generate test mbuf data and space for digest */
4740 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4741 catch_22_quote, QUOTE_512_BYTES, 0);
4743 /* Setup Cipher Parameters */
4744 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4745 ut_params->cipher_xform.next = NULL;
4747 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4748 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4750 /* Create Crypto session*/
4751 ut_params->sess = rte_cryptodev_sym_session_create(
4752 ts_params->valid_devs[0], &ut_params->cipher_xform);
4753 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4755 /* Generate Crypto op data structure */
4756 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4757 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4758 TEST_ASSERT_NOT_NULL(ut_params->op,
4759 "Failed to allocate symmetric crypto operation struct");
4761 /* Set crypto operation data parameters */
4762 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4764 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4766 /* set crypto operation source mbuf */
4767 sym_op->m_src = ut_params->ibuf;
4769 sym_op->cipher.data.offset = 0;
4770 sym_op->cipher.data.length = QUOTE_512_BYTES;
4772 /* Process crypto operation */
4773 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4775 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4777 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4778 "crypto operation processing failed");
4781 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4782 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4785 "Ciphertext data not as expected");
4787 return TEST_SUCCESS;
4791 test_null_auth_only_operation(void)
4793 struct crypto_testsuite_params *ts_params = &testsuite_params;
4794 struct crypto_unittest_params *ut_params = &unittest_params;
4796 /* Generate test mbuf data and space for digest */
4797 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4798 catch_22_quote, QUOTE_512_BYTES, 0);
4800 /* Setup HMAC Parameters */
4801 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4802 ut_params->auth_xform.next = NULL;
4804 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4805 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4807 /* Create Crypto session*/
4808 ut_params->sess = rte_cryptodev_sym_session_create(
4809 ts_params->valid_devs[0], &ut_params->auth_xform);
4810 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4812 /* Generate Crypto op data structure */
4813 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4814 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4815 TEST_ASSERT_NOT_NULL(ut_params->op,
4816 "Failed to allocate symmetric crypto operation struct");
4818 /* Set crypto operation data parameters */
4819 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4821 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4823 sym_op->m_src = ut_params->ibuf;
4825 sym_op->auth.data.offset = 0;
4826 sym_op->auth.data.length = QUOTE_512_BYTES;
4828 /* Process crypto operation */
4829 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4831 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4833 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4834 "crypto operation processing failed");
4836 return TEST_SUCCESS;
4840 test_null_cipher_auth_operation(void)
4842 struct crypto_testsuite_params *ts_params = &testsuite_params;
4843 struct crypto_unittest_params *ut_params = &unittest_params;
4845 /* Generate test mbuf data and space for digest */
4846 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4847 catch_22_quote, QUOTE_512_BYTES, 0);
4849 /* Setup Cipher Parameters */
4850 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4851 ut_params->cipher_xform.next = &ut_params->auth_xform;
4853 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4854 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4856 /* Setup HMAC Parameters */
4857 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4858 ut_params->auth_xform.next = NULL;
4860 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4861 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4863 /* Create Crypto session*/
4864 ut_params->sess = rte_cryptodev_sym_session_create(
4865 ts_params->valid_devs[0], &ut_params->cipher_xform);
4866 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4868 /* Generate Crypto op data structure */
4869 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4870 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4871 TEST_ASSERT_NOT_NULL(ut_params->op,
4872 "Failed to allocate symmetric crypto operation struct");
4874 /* Set crypto operation data parameters */
4875 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4877 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4879 sym_op->m_src = ut_params->ibuf;
4881 sym_op->cipher.data.offset = 0;
4882 sym_op->cipher.data.length = QUOTE_512_BYTES;
4884 sym_op->auth.data.offset = 0;
4885 sym_op->auth.data.length = QUOTE_512_BYTES;
4887 /* Process crypto operation */
4888 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4890 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4892 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4893 "crypto operation processing failed");
4896 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4897 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4900 "Ciphertext data not as expected");
4902 return TEST_SUCCESS;
4906 test_null_auth_cipher_operation(void)
4908 struct crypto_testsuite_params *ts_params = &testsuite_params;
4909 struct crypto_unittest_params *ut_params = &unittest_params;
4911 /* Generate test mbuf data and space for digest */
4912 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4913 catch_22_quote, QUOTE_512_BYTES, 0);
4915 /* Setup Cipher Parameters */
4916 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4917 ut_params->cipher_xform.next = NULL;
4919 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4920 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4922 /* Setup HMAC Parameters */
4923 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4924 ut_params->auth_xform.next = &ut_params->cipher_xform;
4926 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4927 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4929 /* Create Crypto session*/
4930 ut_params->sess = rte_cryptodev_sym_session_create(
4931 ts_params->valid_devs[0], &ut_params->cipher_xform);
4932 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4934 /* Generate Crypto op data structure */
4935 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4936 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4937 TEST_ASSERT_NOT_NULL(ut_params->op,
4938 "Failed to allocate symmetric crypto operation struct");
4940 /* Set crypto operation data parameters */
4941 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4943 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4945 sym_op->m_src = ut_params->ibuf;
4947 sym_op->cipher.data.offset = 0;
4948 sym_op->cipher.data.length = QUOTE_512_BYTES;
4950 sym_op->auth.data.offset = 0;
4951 sym_op->auth.data.length = QUOTE_512_BYTES;
4953 /* Process crypto operation */
4954 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4956 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4958 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4959 "crypto operation processing failed");
4962 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4963 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4966 "Ciphertext data not as expected");
4968 return TEST_SUCCESS;
4973 test_null_invalid_operation(void)
4975 struct crypto_testsuite_params *ts_params = &testsuite_params;
4976 struct crypto_unittest_params *ut_params = &unittest_params;
4978 /* Setup Cipher Parameters */
4979 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4980 ut_params->cipher_xform.next = NULL;
4982 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
4983 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4985 /* Create Crypto session*/
4986 ut_params->sess = rte_cryptodev_sym_session_create(
4987 ts_params->valid_devs[0], &ut_params->cipher_xform);
4988 TEST_ASSERT_NULL(ut_params->sess,
4989 "Session creation succeeded unexpectedly");
4992 /* Setup HMAC Parameters */
4993 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4994 ut_params->auth_xform.next = NULL;
4996 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
4997 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4999 /* Create Crypto session*/
5000 ut_params->sess = rte_cryptodev_sym_session_create(
5001 ts_params->valid_devs[0], &ut_params->auth_xform);
5002 TEST_ASSERT_NULL(ut_params->sess,
5003 "Session creation succeeded unexpectedly");
5005 return TEST_SUCCESS;
5009 #define NULL_BURST_LENGTH (32)
5012 test_null_burst_operation(void)
5014 struct crypto_testsuite_params *ts_params = &testsuite_params;
5015 struct crypto_unittest_params *ut_params = &unittest_params;
5017 unsigned i, burst_len = NULL_BURST_LENGTH;
5019 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
5020 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
5022 /* Setup Cipher Parameters */
5023 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5024 ut_params->cipher_xform.next = &ut_params->auth_xform;
5026 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5027 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5029 /* Setup HMAC Parameters */
5030 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5031 ut_params->auth_xform.next = NULL;
5033 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5034 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5036 /* Create Crypto session*/
5037 ut_params->sess = rte_cryptodev_sym_session_create(
5038 ts_params->valid_devs[0], &ut_params->cipher_xform);
5039 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5041 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
5042 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
5043 burst_len, "failed to generate burst of crypto ops");
5045 /* Generate an operation for each mbuf in burst */
5046 for (i = 0; i < burst_len; i++) {
5047 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5049 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
5051 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
5055 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
5057 burst[i]->sym->m_src = m;
5060 /* Process crypto operation */
5061 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
5062 0, burst, burst_len),
5064 "Error enqueuing burst");
5066 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
5067 0, burst_dequeued, burst_len),
5069 "Error dequeuing burst");
5072 for (i = 0; i < burst_len; i++) {
5074 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
5075 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
5077 "data not as expected");
5079 rte_pktmbuf_free(burst[i]->sym->m_src);
5080 rte_crypto_op_free(burst[i]);
5083 return TEST_SUCCESS;
5087 generate_gmac_large_plaintext(uint8_t *data)
5091 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5092 memcpy(&data[i], &data[0], 32);
5096 create_gmac_operation(enum rte_crypto_auth_operation op,
5097 const struct gmac_test_data *tdata)
5099 struct crypto_testsuite_params *ts_params = &testsuite_params;
5100 struct crypto_unittest_params *ut_params = &unittest_params;
5101 struct rte_crypto_sym_op *sym_op;
5103 unsigned iv_pad_len;
5104 unsigned aad_pad_len;
5106 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5107 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5110 * Runtime generate the large plain text instead of use hard code
5111 * plain text vector. It is done to avoid create huge source file
5112 * with the test vector.
5114 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5115 generate_gmac_large_plaintext(tdata->aad.data);
5117 /* Generate Crypto op data structure */
5118 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5119 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5120 TEST_ASSERT_NOT_NULL(ut_params->op,
5121 "Failed to allocate symmetric crypto operation struct");
5123 sym_op = ut_params->op->sym;
5124 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5126 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5127 "no room to append aad");
5129 sym_op->auth.aad.length = tdata->aad.len;
5130 sym_op->auth.aad.phys_addr =
5131 rte_pktmbuf_mtophys(ut_params->ibuf);
5132 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5134 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5135 ut_params->ibuf, tdata->gmac_tag.len);
5136 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5137 "no room to append digest");
5139 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5140 ut_params->ibuf, aad_pad_len);
5141 sym_op->auth.digest.length = tdata->gmac_tag.len;
5143 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5144 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
5145 tdata->gmac_tag.len);
5146 TEST_HEXDUMP(stdout, "digest:",
5147 sym_op->auth.digest.data,
5148 sym_op->auth.digest.length);
5151 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5152 ut_params->ibuf, iv_pad_len);
5153 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5155 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5156 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5157 sym_op->cipher.iv.length = tdata->iv.len;
5159 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
5161 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
5163 sym_op->cipher.data.length = 0;
5164 sym_op->cipher.data.offset = 0;
5166 sym_op->auth.data.offset = 0;
5167 sym_op->auth.data.length = 0;
5172 static int create_gmac_session(uint8_t dev_id,
5173 enum rte_crypto_cipher_operation op,
5174 const struct gmac_test_data *tdata,
5175 enum rte_crypto_auth_operation auth_op)
5177 uint8_t cipher_key[tdata->key.len];
5179 struct crypto_unittest_params *ut_params = &unittest_params;
5181 memcpy(cipher_key, tdata->key.data, tdata->key.len);
5183 /* For GMAC we setup cipher parameters */
5184 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5185 ut_params->cipher_xform.next = NULL;
5186 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
5187 ut_params->cipher_xform.cipher.op = op;
5188 ut_params->cipher_xform.cipher.key.data = cipher_key;
5189 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
5191 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5192 ut_params->auth_xform.next = NULL;
5194 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
5195 ut_params->auth_xform.auth.op = auth_op;
5196 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
5197 ut_params->auth_xform.auth.add_auth_data_length = 0;
5198 ut_params->auth_xform.auth.key.length = 0;
5199 ut_params->auth_xform.auth.key.data = NULL;
5201 ut_params->cipher_xform.next = &ut_params->auth_xform;
5203 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5204 &ut_params->cipher_xform);
5206 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5212 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
5214 struct crypto_testsuite_params *ts_params = &testsuite_params;
5215 struct crypto_unittest_params *ut_params = &unittest_params;
5219 uint8_t *auth_tag, *p;
5220 uint16_t aad_pad_len;
5222 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5223 "No GMAC length in the source data");
5225 retval = create_gmac_session(ts_params->valid_devs[0],
5226 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5227 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
5232 if (tdata->aad.len > MBUF_SIZE)
5233 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5235 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5236 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5237 "Failed to allocate input buffer in mempool");
5239 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5240 rte_pktmbuf_tailroom(ut_params->ibuf));
5242 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5244 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
5246 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
5252 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5254 ut_params->op->sym->m_src = ut_params->ibuf;
5256 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5257 ut_params->op), "failed to process sym crypto op");
5259 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5260 "crypto op processing failed");
5262 if (ut_params->op->sym->m_dst) {
5263 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5264 uint8_t *, aad_pad_len);
5266 auth_tag = p + aad_pad_len;
5269 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
5271 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5273 tdata->gmac_tag.data,
5274 tdata->gmac_tag.len,
5275 "GMAC Generated auth tag not as expected");
5281 test_AES_GMAC_authentication_test_case_1(void)
5283 return test_AES_GMAC_authentication(&gmac_test_case_1);
5287 test_AES_GMAC_authentication_test_case_2(void)
5289 return test_AES_GMAC_authentication(&gmac_test_case_2);
5293 test_AES_GMAC_authentication_test_case_3(void)
5295 return test_AES_GMAC_authentication(&gmac_test_case_3);
5299 test_AES_GMAC_authentication_test_case_4(void)
5301 return test_AES_GMAC_authentication(&gmac_test_case_4);
5305 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
5307 struct crypto_testsuite_params *ts_params = &testsuite_params;
5308 struct crypto_unittest_params *ut_params = &unittest_params;
5311 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5312 "No GMAC length in the source data");
5314 retval = create_gmac_session(ts_params->valid_devs[0],
5315 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5316 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
5321 if (tdata->aad.len > MBUF_SIZE)
5322 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5325 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5326 "Failed to allocate input buffer in mempool");
5328 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5329 rte_pktmbuf_tailroom(ut_params->ibuf));
5331 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
5337 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5339 ut_params->op->sym->m_src = ut_params->ibuf;
5341 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5342 ut_params->op), "failed to process sym crypto op");
5344 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5345 "crypto op processing failed");
5352 test_AES_GMAC_authentication_verify_test_case_1(void)
5354 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
5358 test_AES_GMAC_authentication_verify_test_case_2(void)
5360 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
5364 test_AES_GMAC_authentication_verify_test_case_3(void)
5366 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
5370 test_AES_GMAC_authentication_verify_test_case_4(void)
5372 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
5375 struct test_crypto_vector {
5376 enum rte_crypto_cipher_algorithm crypto_algo;
5389 const uint8_t *data;
5394 const uint8_t *data;
5398 enum rte_crypto_auth_algorithm auth_algo;
5406 const uint8_t *data;
5416 static const struct test_crypto_vector
5417 hmac_sha1_test_crypto_vector = {
5418 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5420 .data = plaintext_hash,
5425 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5426 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5427 0xDE, 0xF4, 0xDE, 0xAD
5433 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
5434 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
5435 0x3F, 0x91, 0x64, 0x59
5441 static const struct test_crypto_vector
5442 aes128_gmac_test_vector = {
5443 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
5444 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
5446 .data = plaintext_hash,
5451 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5452 0x08, 0x09, 0x0A, 0x0B
5458 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5459 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
5465 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
5466 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
5472 static const struct test_crypto_vector
5473 aes128cbc_hmac_sha1_test_vector = {
5474 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
5477 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
5478 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
5484 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5485 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
5490 .data = plaintext_hash,
5494 .data = ciphertext512_aes128cbc,
5497 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5500 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5501 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5502 0xDE, 0xF4, 0xDE, 0xAD
5508 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
5509 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5510 0x18, 0x8C, 0x1D, 0x32
5517 data_corruption(uint8_t *data)
5523 tag_corruption(uint8_t *data, unsigned int tag_offset)
5525 data[tag_offset] += 1;
5529 create_auth_session(struct crypto_unittest_params *ut_params,
5531 const struct test_crypto_vector *reference,
5532 enum rte_crypto_auth_operation auth_op)
5534 uint8_t auth_key[reference->auth_key.len + 1];
5536 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5538 /* Setup Authentication Parameters */
5539 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5540 ut_params->auth_xform.auth.op = auth_op;
5541 ut_params->auth_xform.next = NULL;
5542 ut_params->auth_xform.auth.algo = reference->auth_algo;
5543 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5544 ut_params->auth_xform.auth.key.data = auth_key;
5545 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5546 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5548 /* Create Crypto session*/
5549 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5550 &ut_params->auth_xform);
5552 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5558 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
5560 const struct test_crypto_vector *reference,
5561 enum rte_crypto_auth_operation auth_op,
5562 enum rte_crypto_cipher_operation cipher_op)
5564 uint8_t cipher_key[reference->cipher_key.len + 1];
5565 uint8_t auth_key[reference->auth_key.len + 1];
5567 memcpy(cipher_key, reference->cipher_key.data,
5568 reference->cipher_key.len);
5569 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5571 /* Setup Authentication Parameters */
5572 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5573 ut_params->auth_xform.auth.op = auth_op;
5574 ut_params->auth_xform.next = &ut_params->cipher_xform;
5575 ut_params->auth_xform.auth.algo = reference->auth_algo;
5576 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5577 ut_params->auth_xform.auth.key.data = auth_key;
5578 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5579 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5581 /* Setup Cipher Parameters */
5582 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5583 ut_params->cipher_xform.next = NULL;
5584 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
5585 ut_params->cipher_xform.cipher.op = cipher_op;
5586 ut_params->cipher_xform.cipher.key.data = cipher_key;
5587 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
5589 /* Create Crypto session*/
5590 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5591 &ut_params->auth_xform);
5593 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5599 create_auth_operation(struct crypto_testsuite_params *ts_params,
5600 struct crypto_unittest_params *ut_params,
5601 const struct test_crypto_vector *reference,
5602 unsigned int auth_generate)
5604 /* Generate Crypto op data structure */
5605 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5606 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5607 TEST_ASSERT_NOT_NULL(ut_params->op,
5608 "Failed to allocate pktmbuf offload");
5610 /* Set crypto operation data parameters */
5611 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5613 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5615 /* set crypto operation source mbuf */
5616 sym_op->m_src = ut_params->ibuf;
5619 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5620 ut_params->ibuf, reference->digest.len);
5622 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5623 "no room to append auth tag");
5625 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5626 ut_params->ibuf, reference->plaintext.len);
5627 sym_op->auth.digest.length = reference->digest.len;
5630 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5632 memcpy(sym_op->auth.digest.data,
5633 reference->digest.data,
5634 reference->digest.len);
5636 TEST_HEXDUMP(stdout, "digest:",
5637 sym_op->auth.digest.data,
5638 sym_op->auth.digest.length);
5640 sym_op->auth.data.length = reference->plaintext.len;
5641 sym_op->auth.data.offset = 0;
5647 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
5648 struct crypto_unittest_params *ut_params,
5649 const struct test_crypto_vector *reference,
5650 unsigned int auth_generate)
5652 /* Generate Crypto op data structure */
5653 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5654 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5655 TEST_ASSERT_NOT_NULL(ut_params->op,
5656 "Failed to allocate pktmbuf offload");
5658 /* Set crypto operation data parameters */
5659 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5661 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5663 /* set crypto operation source mbuf */
5664 sym_op->m_src = ut_params->ibuf;
5667 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5668 reference->aad.len);
5669 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
5670 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
5672 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
5674 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5675 sym_op->auth.aad.length = reference->aad.len;
5678 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5679 ut_params->ibuf, reference->digest.len);
5681 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5682 "no room to append auth tag");
5684 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5685 ut_params->ibuf, reference->ciphertext.len);
5686 sym_op->auth.digest.length = reference->digest.len;
5689 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5691 memcpy(sym_op->auth.digest.data,
5692 reference->digest.data,
5693 reference->digest.len);
5695 TEST_HEXDUMP(stdout, "digest:",
5696 sym_op->auth.digest.data,
5697 sym_op->auth.digest.length);
5699 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5700 ut_params->ibuf, reference->iv.len);
5701 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5703 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5704 sym_op->cipher.iv.length = reference->iv.len;
5706 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5708 sym_op->cipher.data.length = 0;
5709 sym_op->cipher.data.offset = 0;
5711 sym_op->auth.data.length = 0;
5712 sym_op->auth.data.offset = 0;
5718 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
5719 struct crypto_unittest_params *ut_params,
5720 const struct test_crypto_vector *reference,
5721 unsigned int auth_generate)
5723 /* Generate Crypto op data structure */
5724 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5725 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5726 TEST_ASSERT_NOT_NULL(ut_params->op,
5727 "Failed to allocate pktmbuf offload");
5729 /* Set crypto operation data parameters */
5730 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5732 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5734 /* set crypto operation source mbuf */
5735 sym_op->m_src = ut_params->ibuf;
5738 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5739 ut_params->ibuf, reference->digest.len);
5741 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5742 "no room to append auth tag");
5744 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5745 ut_params->ibuf, reference->ciphertext.len);
5746 sym_op->auth.digest.length = reference->digest.len;
5749 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5751 memcpy(sym_op->auth.digest.data,
5752 reference->digest.data,
5753 reference->digest.len);
5755 TEST_HEXDUMP(stdout, "digest:",
5756 sym_op->auth.digest.data,
5757 sym_op->auth.digest.length);
5759 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5760 ut_params->ibuf, reference->iv.len);
5761 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5763 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5764 sym_op->cipher.iv.length = reference->iv.len;
5766 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5768 sym_op->cipher.data.length = reference->ciphertext.len;
5769 sym_op->cipher.data.offset = reference->iv.len;
5771 sym_op->auth.data.length = reference->ciphertext.len;
5772 sym_op->auth.data.offset = reference->iv.len;
5778 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5779 struct crypto_unittest_params *ut_params,
5780 const struct test_crypto_vector *reference)
5782 return create_auth_operation(ts_params, ut_params, reference, 0);
5786 create_auth_verify_GMAC_operation(
5787 struct crypto_testsuite_params *ts_params,
5788 struct crypto_unittest_params *ut_params,
5789 const struct test_crypto_vector *reference)
5791 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
5795 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5796 struct crypto_unittest_params *ut_params,
5797 const struct test_crypto_vector *reference)
5799 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
5803 test_authentication_verify_fail_when_data_corruption(
5804 struct crypto_testsuite_params *ts_params,
5805 struct crypto_unittest_params *ut_params,
5806 const struct test_crypto_vector *reference,
5807 unsigned int data_corrupted)
5813 /* Create session */
5814 retval = create_auth_session(ut_params,
5815 ts_params->valid_devs[0],
5817 RTE_CRYPTO_AUTH_OP_VERIFY);
5821 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5822 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5823 "Failed to allocate input buffer in mempool");
5825 /* clear mbuf payload */
5826 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5827 rte_pktmbuf_tailroom(ut_params->ibuf));
5829 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5830 reference->plaintext.len);
5831 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5832 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
5834 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
5836 /* Create operation */
5837 retval = create_auth_verify_operation(ts_params, ut_params, reference);
5843 data_corruption(plaintext);
5845 tag_corruption(plaintext, reference->plaintext.len);
5847 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5849 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5850 TEST_ASSERT_EQUAL(ut_params->op->status,
5851 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5852 "authentication not failed");
5854 ut_params->obuf = ut_params->op->sym->m_src;
5855 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5861 test_authentication_verify_GMAC_fail_when_corruption(
5862 struct crypto_testsuite_params *ts_params,
5863 struct crypto_unittest_params *ut_params,
5864 const struct test_crypto_vector *reference,
5865 unsigned int data_corrupted)
5869 /* Create session */
5870 retval = create_auth_cipher_session(ut_params,
5871 ts_params->valid_devs[0],
5873 RTE_CRYPTO_AUTH_OP_VERIFY,
5874 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5878 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5879 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5880 "Failed to allocate input buffer in mempool");
5882 /* clear mbuf payload */
5883 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5884 rte_pktmbuf_tailroom(ut_params->ibuf));
5886 /* Create operation */
5887 retval = create_auth_verify_GMAC_operation(ts_params,
5895 data_corruption(ut_params->op->sym->auth.aad.data);
5897 tag_corruption(ut_params->op->sym->auth.aad.data,
5898 reference->aad.len);
5900 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5902 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5903 TEST_ASSERT_EQUAL(ut_params->op->status,
5904 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5905 "authentication not failed");
5907 ut_params->obuf = ut_params->op->sym->m_src;
5908 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5914 test_authenticated_decryption_fail_when_corruption(
5915 struct crypto_testsuite_params *ts_params,
5916 struct crypto_unittest_params *ut_params,
5917 const struct test_crypto_vector *reference,
5918 unsigned int data_corrupted)
5922 uint8_t *ciphertext;
5924 /* Create session */
5925 retval = create_auth_cipher_session(ut_params,
5926 ts_params->valid_devs[0],
5928 RTE_CRYPTO_AUTH_OP_VERIFY,
5929 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5933 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5934 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5935 "Failed to allocate input buffer in mempool");
5937 /* clear mbuf payload */
5938 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5939 rte_pktmbuf_tailroom(ut_params->ibuf));
5941 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5942 reference->ciphertext.len);
5943 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
5944 memcpy(ciphertext, reference->ciphertext.data,
5945 reference->ciphertext.len);
5947 /* Create operation */
5948 retval = create_cipher_auth_verify_operation(ts_params,
5956 data_corruption(ciphertext);
5958 tag_corruption(ciphertext, reference->ciphertext.len);
5960 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5963 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5964 TEST_ASSERT_EQUAL(ut_params->op->status,
5965 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5966 "authentication not failed");
5968 ut_params->obuf = ut_params->op->sym->m_src;
5969 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5975 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
5976 const struct gcm_test_data *tdata,
5977 void *digest_mem, uint64_t digest_phys)
5979 struct crypto_testsuite_params *ts_params = &testsuite_params;
5980 struct crypto_unittest_params *ut_params = &unittest_params;
5982 const unsigned int auth_tag_len = tdata->auth_tag.len;
5983 const unsigned int iv_len = tdata->iv.len;
5984 const unsigned int aad_len = tdata->aad.len;
5986 unsigned int iv_pad_len = 0;
5988 /* Generate Crypto op data structure */
5989 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5990 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5991 TEST_ASSERT_NOT_NULL(ut_params->op,
5992 "Failed to allocate symmetric crypto operation struct");
5994 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5996 sym_op->auth.digest.data = digest_mem;
5998 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5999 "no room to append digest");
6001 sym_op->auth.digest.phys_addr = digest_phys;
6002 sym_op->auth.digest.length = auth_tag_len;
6004 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
6005 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
6007 TEST_HEXDUMP(stdout, "digest:",
6008 sym_op->auth.digest.data,
6009 sym_op->auth.digest.length);
6012 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
6014 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6015 ut_params->ibuf, iv_pad_len);
6017 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
6018 "no room to prepend iv");
6020 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6021 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6022 sym_op->cipher.iv.length = iv_len;
6024 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
6026 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
6027 ut_params->ibuf, aad_len);
6028 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6029 "no room to prepend aad");
6030 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
6032 sym_op->auth.aad.length = aad_len;
6034 memset(sym_op->auth.aad.data, 0, aad_len);
6035 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
6037 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6038 TEST_HEXDUMP(stdout, "aad:",
6039 sym_op->auth.aad.data, aad_len);
6041 sym_op->cipher.data.length = tdata->plaintext.len;
6042 sym_op->cipher.data.offset = aad_len + iv_pad_len;
6044 sym_op->auth.data.offset = aad_len + iv_pad_len;
6045 sym_op->auth.data.length = tdata->plaintext.len;
6050 #define SGL_MAX_NO 16
6053 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
6054 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
6056 struct crypto_testsuite_params *ts_params = &testsuite_params;
6057 struct crypto_unittest_params *ut_params = &unittest_params;
6058 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
6061 int to_trn_tbl[SGL_MAX_NO];
6063 unsigned int trn_data = 0;
6064 uint8_t *plaintext, *ciphertext, *auth_tag;
6066 if (fragsz > tdata->plaintext.len)
6067 fragsz = tdata->plaintext.len;
6069 uint16_t plaintext_len = fragsz;
6070 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
6072 if (fragsz_oop > tdata->plaintext.len)
6073 frag_size_oop = tdata->plaintext.len;
6076 void *digest_mem = NULL;
6078 uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
6081 if (tdata->plaintext.len % fragsz != 0) {
6082 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
6085 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
6090 * For out-op-place we need to alloc another mbuf
6093 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6094 rte_pktmbuf_append(ut_params->obuf,
6095 frag_size_oop + prepend_len);
6096 buf_oop = ut_params->obuf;
6099 /* Create GCM session */
6100 retval = create_gcm_session(ts_params->valid_devs[0],
6101 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6102 tdata->key.data, tdata->key.len,
6103 tdata->aad.len, tdata->auth_tag.len,
6104 RTE_CRYPTO_AUTH_OP_GENERATE);
6108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6110 /* clear mbuf payload */
6111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6112 rte_pktmbuf_tailroom(ut_params->ibuf));
6114 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6117 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6119 trn_data += plaintext_len;
6121 buf = ut_params->ibuf;
6124 * Loop until no more fragments
6127 while (trn_data < tdata->plaintext.len) {
6129 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
6130 (tdata->plaintext.len - trn_data) : fragsz;
6132 to_trn_tbl[ecx++] = to_trn;
6134 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6137 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
6138 rte_pktmbuf_tailroom(buf));
6141 if (oop && !fragsz_oop) {
6142 buf_last_oop = buf_oop->next =
6143 rte_pktmbuf_alloc(ts_params->mbuf_pool);
6144 buf_oop = buf_oop->next;
6145 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
6146 0, rte_pktmbuf_tailroom(buf_oop));
6147 rte_pktmbuf_append(buf_oop, to_trn);
6150 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
6153 memcpy(plaintext, tdata->plaintext.data + trn_data,
6156 if (trn_data == tdata->plaintext.len) {
6159 digest_mem = rte_pktmbuf_append(buf_oop,
6160 tdata->auth_tag.len);
6162 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
6163 tdata->auth_tag.len);
6167 uint64_t digest_phys = 0;
6169 ut_params->ibuf->nb_segs = segs;
6172 if (fragsz_oop && oop) {
6176 if (frag_size_oop == tdata->plaintext.len) {
6177 digest_mem = rte_pktmbuf_append(ut_params->obuf,
6178 tdata->auth_tag.len);
6180 digest_phys = rte_pktmbuf_mtophys_offset(
6182 tdata->plaintext.len + prepend_len);
6185 trn_data = frag_size_oop;
6186 while (trn_data < tdata->plaintext.len) {
6189 (tdata->plaintext.len - trn_data <
6191 (tdata->plaintext.len - trn_data) :
6194 to_trn_tbl[ecx++] = to_trn;
6196 buf_last_oop = buf_oop->next =
6197 rte_pktmbuf_alloc(ts_params->mbuf_pool);
6198 buf_oop = buf_oop->next;
6199 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
6200 0, rte_pktmbuf_tailroom(buf_oop));
6201 rte_pktmbuf_append(buf_oop, to_trn);
6205 if (trn_data == tdata->plaintext.len) {
6206 digest_mem = rte_pktmbuf_append(buf_oop,
6207 tdata->auth_tag.len);
6211 ut_params->obuf->nb_segs = segs;
6215 * Place digest at the end of the last buffer
6218 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
6219 if (oop && buf_last_oop)
6220 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
6222 if (!digest_mem && !oop) {
6223 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6224 + tdata->auth_tag.len);
6225 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
6226 tdata->plaintext.len);
6229 /* Create GCM opertaion */
6230 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6231 tdata, digest_mem, digest_phys);
6236 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6238 ut_params->op->sym->m_src = ut_params->ibuf;
6240 ut_params->op->sym->m_dst = ut_params->obuf;
6242 /* Process crypto operation */
6243 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6244 ut_params->op), "failed to process sym crypto op");
6246 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6247 "crypto op processing failed");
6250 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6251 uint8_t *, prepend_len);
6253 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6254 uint8_t *, prepend_len);
6258 fragsz = fragsz_oop;
6260 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6262 tdata->ciphertext.data,
6264 "GCM Ciphertext data not as expected");
6266 buf = ut_params->op->sym->m_src->next;
6268 buf = ut_params->op->sym->m_dst->next;
6270 unsigned int off = fragsz;
6274 ciphertext = rte_pktmbuf_mtod(buf,
6277 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6279 tdata->ciphertext.data + off,
6281 "GCM Ciphertext data not as expected");
6283 off += to_trn_tbl[ecx++];
6287 auth_tag = digest_mem;
6288 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6290 tdata->auth_tag.data,
6291 tdata->auth_tag.len,
6292 "GCM Generated auth tag not as expected");
6298 #define OUT_OF_PLACE 1
6301 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
6303 return test_AES_GCM_authenticated_encryption_SGL(
6304 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
6308 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
6310 return test_AES_GCM_authenticated_encryption_SGL(
6311 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
6315 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
6318 return test_AES_GCM_authenticated_encryption_SGL(
6319 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
6323 test_authentication_verify_fail_when_data_corrupted(
6324 struct crypto_testsuite_params *ts_params,
6325 struct crypto_unittest_params *ut_params,
6326 const struct test_crypto_vector *reference)
6328 return test_authentication_verify_fail_when_data_corruption(
6329 ts_params, ut_params, reference, 1);
6333 test_authentication_verify_fail_when_tag_corrupted(
6334 struct crypto_testsuite_params *ts_params,
6335 struct crypto_unittest_params *ut_params,
6336 const struct test_crypto_vector *reference)
6338 return test_authentication_verify_fail_when_data_corruption(
6339 ts_params, ut_params, reference, 0);
6343 test_authentication_verify_GMAC_fail_when_data_corrupted(
6344 struct crypto_testsuite_params *ts_params,
6345 struct crypto_unittest_params *ut_params,
6346 const struct test_crypto_vector *reference)
6348 return test_authentication_verify_GMAC_fail_when_corruption(
6349 ts_params, ut_params, reference, 1);
6353 test_authentication_verify_GMAC_fail_when_tag_corrupted(
6354 struct crypto_testsuite_params *ts_params,
6355 struct crypto_unittest_params *ut_params,
6356 const struct test_crypto_vector *reference)
6358 return test_authentication_verify_GMAC_fail_when_corruption(
6359 ts_params, ut_params, reference, 0);
6363 test_authenticated_decryption_fail_when_data_corrupted(
6364 struct crypto_testsuite_params *ts_params,
6365 struct crypto_unittest_params *ut_params,
6366 const struct test_crypto_vector *reference)
6368 return test_authenticated_decryption_fail_when_corruption(
6369 ts_params, ut_params, reference, 1);
6373 test_authenticated_decryption_fail_when_tag_corrupted(
6374 struct crypto_testsuite_params *ts_params,
6375 struct crypto_unittest_params *ut_params,
6376 const struct test_crypto_vector *reference)
6378 return test_authenticated_decryption_fail_when_corruption(
6379 ts_params, ut_params, reference, 0);
6383 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
6385 return test_authentication_verify_fail_when_data_corrupted(
6386 &testsuite_params, &unittest_params,
6387 &hmac_sha1_test_crypto_vector);
6391 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
6393 return test_authentication_verify_fail_when_tag_corrupted(
6394 &testsuite_params, &unittest_params,
6395 &hmac_sha1_test_crypto_vector);
6399 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
6401 return test_authentication_verify_GMAC_fail_when_data_corrupted(
6402 &testsuite_params, &unittest_params,
6403 &aes128_gmac_test_vector);
6407 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
6409 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
6410 &testsuite_params, &unittest_params,
6411 &aes128_gmac_test_vector);
6415 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
6417 return test_authenticated_decryption_fail_when_data_corrupted(
6420 &aes128cbc_hmac_sha1_test_vector);
6424 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
6426 return test_authenticated_decryption_fail_when_tag_corrupted(
6429 &aes128cbc_hmac_sha1_test_vector);
6432 static struct unit_test_suite cryptodev_qat_testsuite = {
6433 .suite_name = "Crypto QAT Unit Test Suite",
6434 .setup = testsuite_setup,
6435 .teardown = testsuite_teardown,
6436 .unit_test_cases = {
6437 TEST_CASE_ST(ut_setup, ut_teardown,
6438 test_device_configure_invalid_dev_id),
6439 TEST_CASE_ST(ut_setup, ut_teardown,
6440 test_device_configure_invalid_queue_pair_ids),
6441 TEST_CASE_ST(ut_setup, ut_teardown,
6442 test_queue_pair_descriptor_setup),
6443 TEST_CASE_ST(ut_setup, ut_teardown,
6444 test_multi_session),
6446 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
6447 TEST_CASE_ST(ut_setup, ut_teardown,
6448 test_AES_cipheronly_qat_all),
6449 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
6450 TEST_CASE_ST(ut_setup, ut_teardown,
6451 test_3DES_cipheronly_qat_all),
6452 TEST_CASE_ST(ut_setup, ut_teardown,
6453 test_DES_cipheronly_qat_all),
6454 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
6456 /** AES GCM Authenticated Encryption */
6457 TEST_CASE_ST(ut_setup, ut_teardown,
6458 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
6459 TEST_CASE_ST(ut_setup, ut_teardown,
6460 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
6461 TEST_CASE_ST(ut_setup, ut_teardown,
6462 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
6463 TEST_CASE_ST(ut_setup, ut_teardown,
6464 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6465 TEST_CASE_ST(ut_setup, ut_teardown,
6466 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6467 TEST_CASE_ST(ut_setup, ut_teardown,
6468 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6469 TEST_CASE_ST(ut_setup, ut_teardown,
6470 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6471 TEST_CASE_ST(ut_setup, ut_teardown,
6472 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6473 TEST_CASE_ST(ut_setup, ut_teardown,
6474 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6475 TEST_CASE_ST(ut_setup, ut_teardown,
6476 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6478 /** AES GCM Authenticated Decryption */
6479 TEST_CASE_ST(ut_setup, ut_teardown,
6480 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6481 TEST_CASE_ST(ut_setup, ut_teardown,
6482 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6483 TEST_CASE_ST(ut_setup, ut_teardown,
6484 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6485 TEST_CASE_ST(ut_setup, ut_teardown,
6486 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6487 TEST_CASE_ST(ut_setup, ut_teardown,
6488 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6489 TEST_CASE_ST(ut_setup, ut_teardown,
6490 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6491 TEST_CASE_ST(ut_setup, ut_teardown,
6492 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6494 /** AES GMAC Authentication */
6495 TEST_CASE_ST(ut_setup, ut_teardown,
6496 test_AES_GMAC_authentication_test_case_1),
6497 TEST_CASE_ST(ut_setup, ut_teardown,
6498 test_AES_GMAC_authentication_verify_test_case_1),
6499 TEST_CASE_ST(ut_setup, ut_teardown,
6500 test_AES_GMAC_authentication_test_case_2),
6501 TEST_CASE_ST(ut_setup, ut_teardown,
6502 test_AES_GMAC_authentication_verify_test_case_2),
6503 TEST_CASE_ST(ut_setup, ut_teardown,
6504 test_AES_GMAC_authentication_test_case_3),
6505 TEST_CASE_ST(ut_setup, ut_teardown,
6506 test_AES_GMAC_authentication_verify_test_case_3),
6508 /** SNOW 3G encrypt only (UEA2) */
6509 TEST_CASE_ST(ut_setup, ut_teardown,
6510 test_snow3g_encryption_test_case_1),
6511 TEST_CASE_ST(ut_setup, ut_teardown,
6512 test_snow3g_encryption_test_case_2),
6513 TEST_CASE_ST(ut_setup, ut_teardown,
6514 test_snow3g_encryption_test_case_3),
6515 TEST_CASE_ST(ut_setup, ut_teardown,
6516 test_snow3g_encryption_test_case_4),
6517 TEST_CASE_ST(ut_setup, ut_teardown,
6518 test_snow3g_encryption_test_case_5),
6520 TEST_CASE_ST(ut_setup, ut_teardown,
6521 test_snow3g_encryption_test_case_1_oop),
6522 TEST_CASE_ST(ut_setup, ut_teardown,
6523 test_snow3g_decryption_test_case_1_oop),
6525 /** SNOW 3G decrypt only (UEA2) */
6526 TEST_CASE_ST(ut_setup, ut_teardown,
6527 test_snow3g_decryption_test_case_1),
6528 TEST_CASE_ST(ut_setup, ut_teardown,
6529 test_snow3g_decryption_test_case_2),
6530 TEST_CASE_ST(ut_setup, ut_teardown,
6531 test_snow3g_decryption_test_case_3),
6532 TEST_CASE_ST(ut_setup, ut_teardown,
6533 test_snow3g_decryption_test_case_4),
6534 TEST_CASE_ST(ut_setup, ut_teardown,
6535 test_snow3g_decryption_test_case_5),
6536 TEST_CASE_ST(ut_setup, ut_teardown,
6537 test_snow3g_hash_generate_test_case_1),
6538 TEST_CASE_ST(ut_setup, ut_teardown,
6539 test_snow3g_hash_generate_test_case_2),
6540 TEST_CASE_ST(ut_setup, ut_teardown,
6541 test_snow3g_hash_generate_test_case_3),
6542 TEST_CASE_ST(ut_setup, ut_teardown,
6543 test_snow3g_hash_verify_test_case_1),
6544 TEST_CASE_ST(ut_setup, ut_teardown,
6545 test_snow3g_hash_verify_test_case_2),
6546 TEST_CASE_ST(ut_setup, ut_teardown,
6547 test_snow3g_hash_verify_test_case_3),
6548 TEST_CASE_ST(ut_setup, ut_teardown,
6549 test_snow3g_cipher_auth_test_case_1),
6550 TEST_CASE_ST(ut_setup, ut_teardown,
6551 test_snow3g_auth_cipher_test_case_1),
6553 /** HMAC_MD5 Authentication */
6554 TEST_CASE_ST(ut_setup, ut_teardown,
6555 test_MD5_HMAC_generate_case_1),
6556 TEST_CASE_ST(ut_setup, ut_teardown,
6557 test_MD5_HMAC_verify_case_1),
6558 TEST_CASE_ST(ut_setup, ut_teardown,
6559 test_MD5_HMAC_generate_case_2),
6560 TEST_CASE_ST(ut_setup, ut_teardown,
6561 test_MD5_HMAC_verify_case_2),
6564 TEST_CASE_ST(ut_setup, ut_teardown,
6565 test_null_auth_only_operation),
6566 TEST_CASE_ST(ut_setup, ut_teardown,
6567 test_null_cipher_only_operation),
6568 TEST_CASE_ST(ut_setup, ut_teardown,
6569 test_null_cipher_auth_operation),
6570 TEST_CASE_ST(ut_setup, ut_teardown,
6571 test_null_auth_cipher_operation),
6573 TEST_CASE_ST(ut_setup, ut_teardown,
6574 test_kasumi_hash_generate_test_case_6),
6577 TEST_CASE_ST(ut_setup, ut_teardown,
6578 test_kasumi_encryption_test_case_1),
6579 TEST_CASE_ST(ut_setup, ut_teardown,
6580 test_kasumi_encryption_test_case_3),
6581 TEST_CASE_ST(ut_setup, ut_teardown,
6582 test_kasumi_auth_cipher_test_case_1),
6583 TEST_CASE_ST(ut_setup, ut_teardown,
6584 test_kasumi_cipher_auth_test_case_1),
6586 /** Negative tests */
6587 TEST_CASE_ST(ut_setup, ut_teardown,
6588 authentication_verify_HMAC_SHA1_fail_data_corrupt),
6589 TEST_CASE_ST(ut_setup, ut_teardown,
6590 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6591 TEST_CASE_ST(ut_setup, ut_teardown,
6592 authentication_verify_AES128_GMAC_fail_data_corrupt),
6593 TEST_CASE_ST(ut_setup, ut_teardown,
6594 authentication_verify_AES128_GMAC_fail_tag_corrupt),
6595 TEST_CASE_ST(ut_setup, ut_teardown,
6596 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6597 TEST_CASE_ST(ut_setup, ut_teardown,
6598 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6600 TEST_CASES_END() /**< NULL terminate unit test array */
6604 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
6605 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
6606 .setup = testsuite_setup,
6607 .teardown = testsuite_teardown,
6608 .unit_test_cases = {
6609 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
6610 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
6611 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
6613 TEST_CASES_END() /**< NULL terminate unit test array */
6617 static struct unit_test_suite cryptodev_openssl_testsuite = {
6618 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
6619 .setup = testsuite_setup,
6620 .teardown = testsuite_teardown,
6621 .unit_test_cases = {
6622 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
6623 TEST_CASE_ST(ut_setup, ut_teardown,
6624 test_multi_session_random_usage),
6625 TEST_CASE_ST(ut_setup, ut_teardown,
6626 test_AES_chain_openssl_all),
6627 TEST_CASE_ST(ut_setup, ut_teardown,
6628 test_AES_cipheronly_openssl_all),
6629 TEST_CASE_ST(ut_setup, ut_teardown,
6630 test_3DES_chain_openssl_all),
6631 TEST_CASE_ST(ut_setup, ut_teardown,
6632 test_3DES_cipheronly_openssl_all),
6633 TEST_CASE_ST(ut_setup, ut_teardown,
6634 test_authonly_openssl_all),
6636 /** AES GCM Authenticated Encryption */
6637 TEST_CASE_ST(ut_setup, ut_teardown,
6638 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6639 TEST_CASE_ST(ut_setup, ut_teardown,
6640 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6641 TEST_CASE_ST(ut_setup, ut_teardown,
6642 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6643 TEST_CASE_ST(ut_setup, ut_teardown,
6644 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6645 TEST_CASE_ST(ut_setup, ut_teardown,
6646 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6647 TEST_CASE_ST(ut_setup, ut_teardown,
6648 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6649 TEST_CASE_ST(ut_setup, ut_teardown,
6650 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6652 /** AES GCM Authenticated Decryption */
6653 TEST_CASE_ST(ut_setup, ut_teardown,
6654 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6655 TEST_CASE_ST(ut_setup, ut_teardown,
6656 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6657 TEST_CASE_ST(ut_setup, ut_teardown,
6658 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6659 TEST_CASE_ST(ut_setup, ut_teardown,
6660 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6661 TEST_CASE_ST(ut_setup, ut_teardown,
6662 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6663 TEST_CASE_ST(ut_setup, ut_teardown,
6664 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6665 TEST_CASE_ST(ut_setup, ut_teardown,
6666 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6668 /** AES GMAC Authentication */
6669 TEST_CASE_ST(ut_setup, ut_teardown,
6670 test_AES_GMAC_authentication_test_case_1),
6671 TEST_CASE_ST(ut_setup, ut_teardown,
6672 test_AES_GMAC_authentication_verify_test_case_1),
6673 TEST_CASE_ST(ut_setup, ut_teardown,
6674 test_AES_GMAC_authentication_test_case_2),
6675 TEST_CASE_ST(ut_setup, ut_teardown,
6676 test_AES_GMAC_authentication_verify_test_case_2),
6677 TEST_CASE_ST(ut_setup, ut_teardown,
6678 test_AES_GMAC_authentication_test_case_3),
6679 TEST_CASE_ST(ut_setup, ut_teardown,
6680 test_AES_GMAC_authentication_verify_test_case_3),
6681 TEST_CASE_ST(ut_setup, ut_teardown,
6682 test_AES_GMAC_authentication_test_case_4),
6683 TEST_CASE_ST(ut_setup, ut_teardown,
6684 test_AES_GMAC_authentication_verify_test_case_4),
6686 /** Negative tests */
6687 TEST_CASE_ST(ut_setup, ut_teardown,
6688 authentication_verify_HMAC_SHA1_fail_data_corrupt),
6689 TEST_CASE_ST(ut_setup, ut_teardown,
6690 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6691 TEST_CASE_ST(ut_setup, ut_teardown,
6692 authentication_verify_AES128_GMAC_fail_data_corrupt),
6693 TEST_CASE_ST(ut_setup, ut_teardown,
6694 authentication_verify_AES128_GMAC_fail_tag_corrupt),
6695 TEST_CASE_ST(ut_setup, ut_teardown,
6696 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6697 TEST_CASE_ST(ut_setup, ut_teardown,
6698 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6700 TEST_CASES_END() /**< NULL terminate unit test array */
6704 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
6705 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
6706 .setup = testsuite_setup,
6707 .teardown = testsuite_teardown,
6708 .unit_test_cases = {
6709 /** AES GCM Authenticated Encryption */
6710 TEST_CASE_ST(ut_setup, ut_teardown,
6711 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6712 TEST_CASE_ST(ut_setup, ut_teardown,
6713 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6714 TEST_CASE_ST(ut_setup, ut_teardown,
6715 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6716 TEST_CASE_ST(ut_setup, ut_teardown,
6717 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6718 TEST_CASE_ST(ut_setup, ut_teardown,
6719 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6720 TEST_CASE_ST(ut_setup, ut_teardown,
6721 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6722 TEST_CASE_ST(ut_setup, ut_teardown,
6723 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6725 /** AES GCM Authenticated Decryption */
6726 TEST_CASE_ST(ut_setup, ut_teardown,
6727 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6728 TEST_CASE_ST(ut_setup, ut_teardown,
6729 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6730 TEST_CASE_ST(ut_setup, ut_teardown,
6731 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6732 TEST_CASE_ST(ut_setup, ut_teardown,
6733 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6734 TEST_CASE_ST(ut_setup, ut_teardown,
6735 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6736 TEST_CASE_ST(ut_setup, ut_teardown,
6737 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6738 TEST_CASE_ST(ut_setup, ut_teardown,
6739 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6741 TEST_CASES_END() /**< NULL terminate unit test array */
6745 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
6746 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
6747 .setup = testsuite_setup,
6748 .teardown = testsuite_teardown,
6749 .unit_test_cases = {
6750 /** KASUMI encrypt only (UEA1) */
6751 TEST_CASE_ST(ut_setup, ut_teardown,
6752 test_kasumi_encryption_test_case_1),
6753 TEST_CASE_ST(ut_setup, ut_teardown,
6754 test_kasumi_encryption_test_case_2),
6755 TEST_CASE_ST(ut_setup, ut_teardown,
6756 test_kasumi_encryption_test_case_3),
6757 TEST_CASE_ST(ut_setup, ut_teardown,
6758 test_kasumi_encryption_test_case_4),
6759 TEST_CASE_ST(ut_setup, ut_teardown,
6760 test_kasumi_encryption_test_case_5),
6761 /** KASUMI decrypt only (UEA1) */
6762 TEST_CASE_ST(ut_setup, ut_teardown,
6763 test_kasumi_decryption_test_case_1),
6764 TEST_CASE_ST(ut_setup, ut_teardown,
6765 test_kasumi_decryption_test_case_2),
6766 TEST_CASE_ST(ut_setup, ut_teardown,
6767 test_kasumi_decryption_test_case_3),
6768 TEST_CASE_ST(ut_setup, ut_teardown,
6769 test_kasumi_decryption_test_case_4),
6770 TEST_CASE_ST(ut_setup, ut_teardown,
6771 test_kasumi_decryption_test_case_5),
6773 TEST_CASE_ST(ut_setup, ut_teardown,
6774 test_kasumi_encryption_test_case_1_oop),
6775 TEST_CASE_ST(ut_setup, ut_teardown,
6776 test_kasumi_decryption_test_case_1_oop),
6778 /** KASUMI hash only (UIA1) */
6779 TEST_CASE_ST(ut_setup, ut_teardown,
6780 test_kasumi_hash_generate_test_case_1),
6781 TEST_CASE_ST(ut_setup, ut_teardown,
6782 test_kasumi_hash_generate_test_case_2),
6783 TEST_CASE_ST(ut_setup, ut_teardown,
6784 test_kasumi_hash_generate_test_case_3),
6785 TEST_CASE_ST(ut_setup, ut_teardown,
6786 test_kasumi_hash_generate_test_case_4),
6787 TEST_CASE_ST(ut_setup, ut_teardown,
6788 test_kasumi_hash_generate_test_case_5),
6789 TEST_CASE_ST(ut_setup, ut_teardown,
6790 test_kasumi_hash_generate_test_case_6),
6791 TEST_CASE_ST(ut_setup, ut_teardown,
6792 test_kasumi_hash_verify_test_case_1),
6793 TEST_CASE_ST(ut_setup, ut_teardown,
6794 test_kasumi_hash_verify_test_case_2),
6795 TEST_CASE_ST(ut_setup, ut_teardown,
6796 test_kasumi_hash_verify_test_case_3),
6797 TEST_CASE_ST(ut_setup, ut_teardown,
6798 test_kasumi_hash_verify_test_case_4),
6799 TEST_CASE_ST(ut_setup, ut_teardown,
6800 test_kasumi_hash_verify_test_case_5),
6801 TEST_CASE_ST(ut_setup, ut_teardown,
6802 test_kasumi_auth_cipher_test_case_1),
6803 TEST_CASE_ST(ut_setup, ut_teardown,
6804 test_kasumi_cipher_auth_test_case_1),
6805 TEST_CASES_END() /**< NULL terminate unit test array */
6808 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
6809 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
6810 .setup = testsuite_setup,
6811 .teardown = testsuite_teardown,
6812 .unit_test_cases = {
6813 /** SNOW 3G encrypt only (UEA2) */
6814 TEST_CASE_ST(ut_setup, ut_teardown,
6815 test_snow3g_encryption_test_case_1),
6816 TEST_CASE_ST(ut_setup, ut_teardown,
6817 test_snow3g_encryption_test_case_2),
6818 TEST_CASE_ST(ut_setup, ut_teardown,
6819 test_snow3g_encryption_test_case_3),
6820 TEST_CASE_ST(ut_setup, ut_teardown,
6821 test_snow3g_encryption_test_case_4),
6822 TEST_CASE_ST(ut_setup, ut_teardown,
6823 test_snow3g_encryption_test_case_5),
6825 TEST_CASE_ST(ut_setup, ut_teardown,
6826 test_snow3g_encryption_test_case_1_oop),
6827 TEST_CASE_ST(ut_setup, ut_teardown,
6828 test_snow3g_decryption_test_case_1_oop),
6830 TEST_CASE_ST(ut_setup, ut_teardown,
6831 test_snow3g_encryption_test_case_1_offset_oop),
6833 /** SNOW 3G decrypt only (UEA2) */
6834 TEST_CASE_ST(ut_setup, ut_teardown,
6835 test_snow3g_decryption_test_case_1),
6836 TEST_CASE_ST(ut_setup, ut_teardown,
6837 test_snow3g_decryption_test_case_2),
6838 TEST_CASE_ST(ut_setup, ut_teardown,
6839 test_snow3g_decryption_test_case_3),
6840 TEST_CASE_ST(ut_setup, ut_teardown,
6841 test_snow3g_decryption_test_case_4),
6842 TEST_CASE_ST(ut_setup, ut_teardown,
6843 test_snow3g_decryption_test_case_5),
6844 TEST_CASE_ST(ut_setup, ut_teardown,
6845 test_snow3g_hash_generate_test_case_1),
6846 TEST_CASE_ST(ut_setup, ut_teardown,
6847 test_snow3g_hash_generate_test_case_2),
6848 TEST_CASE_ST(ut_setup, ut_teardown,
6849 test_snow3g_hash_generate_test_case_3),
6850 /* Tests with buffers which length is not byte-aligned */
6851 TEST_CASE_ST(ut_setup, ut_teardown,
6852 test_snow3g_hash_generate_test_case_4),
6853 TEST_CASE_ST(ut_setup, ut_teardown,
6854 test_snow3g_hash_generate_test_case_5),
6855 TEST_CASE_ST(ut_setup, ut_teardown,
6856 test_snow3g_hash_generate_test_case_6),
6857 TEST_CASE_ST(ut_setup, ut_teardown,
6858 test_snow3g_hash_verify_test_case_1),
6859 TEST_CASE_ST(ut_setup, ut_teardown,
6860 test_snow3g_hash_verify_test_case_2),
6861 TEST_CASE_ST(ut_setup, ut_teardown,
6862 test_snow3g_hash_verify_test_case_3),
6863 /* Tests with buffers which length is not byte-aligned */
6864 TEST_CASE_ST(ut_setup, ut_teardown,
6865 test_snow3g_hash_verify_test_case_4),
6866 TEST_CASE_ST(ut_setup, ut_teardown,
6867 test_snow3g_hash_verify_test_case_5),
6868 TEST_CASE_ST(ut_setup, ut_teardown,
6869 test_snow3g_hash_verify_test_case_6),
6870 TEST_CASE_ST(ut_setup, ut_teardown,
6871 test_snow3g_cipher_auth_test_case_1),
6872 TEST_CASE_ST(ut_setup, ut_teardown,
6873 test_snow3g_auth_cipher_test_case_1),
6875 TEST_CASES_END() /**< NULL terminate unit test array */
6879 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
6880 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
6881 .setup = testsuite_setup,
6882 .teardown = testsuite_teardown,
6883 .unit_test_cases = {
6884 /** ZUC encrypt only (EEA3) */
6885 TEST_CASE_ST(ut_setup, ut_teardown,
6886 test_zuc_encryption_test_case_1),
6887 TEST_CASE_ST(ut_setup, ut_teardown,
6888 test_zuc_encryption_test_case_2),
6889 TEST_CASE_ST(ut_setup, ut_teardown,
6890 test_zuc_encryption_test_case_3),
6891 TEST_CASE_ST(ut_setup, ut_teardown,
6892 test_zuc_encryption_test_case_4),
6893 TEST_CASE_ST(ut_setup, ut_teardown,
6894 test_zuc_encryption_test_case_5),
6895 TEST_CASE_ST(ut_setup, ut_teardown,
6896 test_zuc_hash_generate_test_case_1),
6897 TEST_CASE_ST(ut_setup, ut_teardown,
6898 test_zuc_hash_generate_test_case_2),
6899 TEST_CASE_ST(ut_setup, ut_teardown,
6900 test_zuc_hash_generate_test_case_3),
6901 TEST_CASE_ST(ut_setup, ut_teardown,
6902 test_zuc_hash_generate_test_case_4),
6903 TEST_CASE_ST(ut_setup, ut_teardown,
6904 test_zuc_hash_generate_test_case_5),
6905 TEST_CASES_END() /**< NULL terminate unit test array */
6909 static struct unit_test_suite cryptodev_null_testsuite = {
6910 .suite_name = "Crypto Device NULL Unit Test Suite",
6911 .setup = testsuite_setup,
6912 .teardown = testsuite_teardown,
6913 .unit_test_cases = {
6914 TEST_CASE_ST(ut_setup, ut_teardown,
6915 test_null_auth_only_operation),
6916 TEST_CASE_ST(ut_setup, ut_teardown,
6917 test_null_cipher_only_operation),
6918 TEST_CASE_ST(ut_setup, ut_teardown,
6919 test_null_cipher_auth_operation),
6920 TEST_CASE_ST(ut_setup, ut_teardown,
6921 test_null_auth_cipher_operation),
6922 TEST_CASE_ST(ut_setup, ut_teardown,
6923 test_null_invalid_operation),
6924 TEST_CASE_ST(ut_setup, ut_teardown,
6925 test_null_burst_operation),
6927 TEST_CASES_END() /**< NULL terminate unit test array */
6932 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
6934 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
6935 return unit_test_suite_runner(&cryptodev_qat_testsuite);
6939 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
6941 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
6943 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
6947 test_cryptodev_openssl(void)
6949 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
6951 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
6955 test_cryptodev_aesni_gcm(void)
6957 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
6959 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
6963 test_cryptodev_null(void)
6965 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
6967 return unit_test_suite_runner(&cryptodev_null_testsuite);
6971 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
6973 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
6975 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
6979 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
6981 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
6983 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
6987 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
6989 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
6991 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
6994 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
6995 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
6996 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
6997 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
6998 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
6999 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
7000 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
7001 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);