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 /* For OOP operation both buffers must have the same size */
1740 if (ut_params->obuf)
1741 rte_pktmbuf_prepend(ut_params->obuf, iv_pad_len);
1743 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1744 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1745 sym_op->cipher.iv.length = iv_pad_len;
1747 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1748 sym_op->cipher.data.length = cipher_len;
1749 sym_op->cipher.data.offset = cipher_offset;
1754 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1755 enum rte_crypto_cipher_operation cipher_op,
1756 enum rte_crypto_auth_operation auth_op,
1757 enum rte_crypto_auth_algorithm auth_algo,
1758 enum rte_crypto_cipher_algorithm cipher_algo,
1759 const uint8_t *key, const uint8_t key_len,
1760 const uint8_t aad_len, const uint8_t auth_len)
1763 uint8_t cipher_auth_key[key_len];
1765 struct crypto_unittest_params *ut_params = &unittest_params;
1767 memcpy(cipher_auth_key, key, key_len);
1769 /* Setup Authentication Parameters */
1770 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1771 ut_params->auth_xform.next = NULL;
1773 ut_params->auth_xform.auth.op = auth_op;
1774 ut_params->auth_xform.auth.algo = auth_algo;
1775 ut_params->auth_xform.auth.key.length = key_len;
1776 /* Hash key = cipher key */
1777 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1778 ut_params->auth_xform.auth.digest_length = auth_len;
1779 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1781 /* Setup Cipher Parameters */
1782 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1783 ut_params->cipher_xform.next = &ut_params->auth_xform;
1785 ut_params->cipher_xform.cipher.algo = cipher_algo;
1786 ut_params->cipher_xform.cipher.op = cipher_op;
1787 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1788 ut_params->cipher_xform.cipher.key.length = key_len;
1790 TEST_HEXDUMP(stdout, "key:", key, key_len);
1792 /* Create Crypto session*/
1793 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1794 &ut_params->cipher_xform);
1796 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1801 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1802 enum rte_crypto_cipher_operation cipher_op,
1803 enum rte_crypto_auth_operation auth_op,
1804 enum rte_crypto_auth_algorithm auth_algo,
1805 enum rte_crypto_cipher_algorithm cipher_algo,
1806 const uint8_t *key, const uint8_t key_len,
1807 const uint8_t aad_len, const uint8_t auth_len)
1809 uint8_t auth_cipher_key[key_len];
1811 struct crypto_unittest_params *ut_params = &unittest_params;
1813 memcpy(auth_cipher_key, key, key_len);
1815 /* Setup Authentication Parameters */
1816 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1817 ut_params->auth_xform.auth.op = auth_op;
1818 ut_params->auth_xform.next = &ut_params->cipher_xform;
1819 ut_params->auth_xform.auth.algo = auth_algo;
1820 ut_params->auth_xform.auth.key.length = key_len;
1821 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1822 ut_params->auth_xform.auth.digest_length = auth_len;
1823 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1825 /* Setup Cipher Parameters */
1826 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1827 ut_params->cipher_xform.next = NULL;
1828 ut_params->cipher_xform.cipher.algo = cipher_algo;
1829 ut_params->cipher_xform.cipher.op = cipher_op;
1830 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1831 ut_params->cipher_xform.cipher.key.length = key_len;
1833 TEST_HEXDUMP(stdout, "key:", key, key_len);
1835 /* Create Crypto session*/
1836 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1837 &ut_params->auth_xform);
1839 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1845 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1846 const unsigned auth_tag_len,
1847 const uint8_t *aad, const unsigned aad_len,
1848 unsigned data_pad_len,
1849 enum rte_crypto_auth_operation op,
1850 enum rte_crypto_auth_algorithm algo,
1851 const unsigned auth_len, const unsigned auth_offset)
1853 struct crypto_testsuite_params *ts_params = &testsuite_params;
1855 struct crypto_unittest_params *ut_params = &unittest_params;
1857 unsigned aad_buffer_len;
1859 /* Generate Crypto op data structure */
1860 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1861 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1862 TEST_ASSERT_NOT_NULL(ut_params->op,
1863 "Failed to allocate pktmbuf offload");
1865 /* Set crypto operation data parameters */
1866 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1868 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1870 /* set crypto operation source mbuf */
1871 sym_op->m_src = ut_params->ibuf;
1875 * Always allocate the aad up to the block size.
1876 * The cryptodev API calls out -
1877 * - the array must be big enough to hold the AAD, plus any
1878 * space to round this up to the nearest multiple of the
1879 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1881 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1882 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1884 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1885 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1886 ut_params->ibuf, aad_buffer_len);
1887 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1888 "no room to prepend aad");
1889 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1891 sym_op->auth.aad.length = aad_len;
1893 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1894 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1896 TEST_HEXDUMP(stdout, "aad:",
1897 sym_op->auth.aad.data, aad_len);
1900 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1901 ut_params->ibuf, auth_tag_len);
1903 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1904 "no room to append auth tag");
1905 ut_params->digest = sym_op->auth.digest.data;
1906 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1907 ut_params->ibuf, data_pad_len + aad_len);
1908 sym_op->auth.digest.length = auth_tag_len;
1909 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1910 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1912 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1914 TEST_HEXDUMP(stdout, "digest:",
1915 sym_op->auth.digest.data,
1916 sym_op->auth.digest.length);
1918 sym_op->auth.data.length = auth_len;
1919 sym_op->auth.data.offset = auth_offset;
1925 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1926 const unsigned auth_tag_len,
1927 const uint8_t *aad, const uint8_t aad_len,
1928 unsigned data_pad_len,
1929 enum rte_crypto_auth_operation op,
1930 enum rte_crypto_auth_algorithm auth_algo,
1931 enum rte_crypto_cipher_algorithm cipher_algo,
1932 const uint8_t *iv, const uint8_t iv_len,
1933 const unsigned cipher_len, const unsigned cipher_offset,
1934 const unsigned auth_len, const unsigned auth_offset)
1936 struct crypto_testsuite_params *ts_params = &testsuite_params;
1937 struct crypto_unittest_params *ut_params = &unittest_params;
1939 unsigned iv_pad_len = 0;
1940 unsigned aad_buffer_len;
1942 /* Generate Crypto op data structure */
1943 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1944 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1945 TEST_ASSERT_NOT_NULL(ut_params->op,
1946 "Failed to allocate pktmbuf offload");
1947 /* Set crypto operation data parameters */
1948 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1950 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1952 /* set crypto operation source mbuf */
1953 sym_op->m_src = ut_params->ibuf;
1956 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1957 ut_params->ibuf, auth_tag_len);
1959 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1960 "no room to append auth tag");
1961 ut_params->digest = sym_op->auth.digest.data;
1962 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1963 ut_params->ibuf, data_pad_len);
1964 sym_op->auth.digest.length = auth_tag_len;
1965 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1966 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1968 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1970 TEST_HEXDUMP(stdout, "digest:",
1971 sym_op->auth.digest.data,
1972 sym_op->auth.digest.length);
1976 * Always allocate the aad up to the block size.
1977 * The cryptodev API calls out -
1978 * - the array must be big enough to hold the AAD, plus any
1979 * space to round this up to the nearest multiple of the
1980 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1982 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1983 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1985 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1986 sym_op->auth.aad.data =
1987 (uint8_t *)rte_pktmbuf_prepend(
1988 ut_params->ibuf, aad_buffer_len);
1989 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1990 "no room to prepend aad");
1991 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1993 sym_op->auth.aad.length = aad_len;
1994 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1995 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1996 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1999 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2000 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2002 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2003 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2004 ut_params->ibuf, iv_pad_len);
2006 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2007 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2008 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2009 sym_op->cipher.iv.length = iv_pad_len;
2010 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2011 sym_op->cipher.data.length = cipher_len;
2012 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2013 sym_op->auth.data.length = auth_len;
2014 sym_op->auth.data.offset = auth_offset + cipher_offset;
2020 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2021 const uint8_t *iv, const uint8_t iv_len,
2022 const uint8_t *aad, const uint8_t aad_len,
2023 unsigned data_pad_len,
2024 const unsigned cipher_len, const unsigned cipher_offset,
2025 const unsigned auth_len, const unsigned auth_offset,
2026 enum rte_crypto_auth_algorithm auth_algo,
2027 enum rte_crypto_cipher_algorithm cipher_algo)
2029 struct crypto_testsuite_params *ts_params = &testsuite_params;
2030 struct crypto_unittest_params *ut_params = &unittest_params;
2032 unsigned iv_pad_len = 0;
2033 unsigned aad_buffer_len = 0;
2035 /* Generate Crypto op data structure */
2036 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2037 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2038 TEST_ASSERT_NOT_NULL(ut_params->op,
2039 "Failed to allocate pktmbuf offload");
2041 /* Set crypto operation data parameters */
2042 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2044 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2046 /* set crypto operation source mbuf */
2047 sym_op->m_src = ut_params->ibuf;
2050 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2051 ut_params->ibuf, auth_tag_len);
2053 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2054 "no room to append auth tag");
2056 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2057 ut_params->ibuf, data_pad_len);
2058 sym_op->auth.digest.length = auth_tag_len;
2060 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2062 TEST_HEXDUMP(stdout, "digest:",
2063 sym_op->auth.digest.data,
2064 sym_op->auth.digest.length);
2068 * Always allocate the aad up to the block size.
2069 * The cryptodev API calls out -
2070 * - the array must be big enough to hold the AAD, plus any
2071 * space to round this up to the nearest multiple of the
2072 * block size (8 bytes for KASUMI 16 bytes).
2074 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2075 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2077 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2078 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2079 ut_params->ibuf, aad_buffer_len);
2080 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2081 "no room to prepend aad");
2082 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2084 sym_op->auth.aad.length = aad_len;
2085 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2086 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2087 TEST_HEXDUMP(stdout, "aad:",
2088 sym_op->auth.aad.data, aad_len);
2091 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2092 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2094 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2096 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2097 ut_params->ibuf, iv_pad_len);
2098 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2100 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2101 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2102 sym_op->cipher.iv.length = iv_pad_len;
2104 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2106 sym_op->cipher.data.length = cipher_len;
2107 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2109 sym_op->auth.data.length = auth_len;
2110 sym_op->auth.data.offset = auth_offset + cipher_offset;
2116 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2118 struct crypto_testsuite_params *ts_params = &testsuite_params;
2119 struct crypto_unittest_params *ut_params = &unittest_params;
2122 unsigned plaintext_pad_len;
2123 unsigned plaintext_len;
2126 /* Create SNOW 3G session */
2127 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2128 tdata->key.data, tdata->key.len,
2129 tdata->aad.len, tdata->digest.len,
2130 RTE_CRYPTO_AUTH_OP_GENERATE,
2131 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2135 /* alloc mbuf and set payload */
2136 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2138 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2139 rte_pktmbuf_tailroom(ut_params->ibuf));
2141 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2142 /* Append data which is padded to a multiple of */
2143 /* the algorithms block size */
2144 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2145 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2147 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2149 /* Create SNOW 3G operation */
2150 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2151 tdata->aad.data, tdata->aad.len,
2152 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2153 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2154 tdata->validAuthLenInBits.len,
2155 tdata->validAuthOffsetLenInBits.len);
2159 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2161 ut_params->obuf = ut_params->op->sym->m_src;
2162 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2163 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2164 + plaintext_pad_len + tdata->aad.len;
2167 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2170 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2171 "SNOW 3G Generated auth tag not as expected");
2177 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2179 struct crypto_testsuite_params *ts_params = &testsuite_params;
2180 struct crypto_unittest_params *ut_params = &unittest_params;
2183 unsigned plaintext_pad_len;
2184 unsigned plaintext_len;
2187 /* Create SNOW 3G session */
2188 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2189 tdata->key.data, tdata->key.len,
2190 tdata->aad.len, tdata->digest.len,
2191 RTE_CRYPTO_AUTH_OP_VERIFY,
2192 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2195 /* alloc mbuf and set payload */
2196 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2198 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2199 rte_pktmbuf_tailroom(ut_params->ibuf));
2201 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2202 /* Append data which is padded to a multiple of */
2203 /* the algorithms block size */
2204 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2205 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2207 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2209 /* Create SNOW 3G operation */
2210 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2212 tdata->aad.data, tdata->aad.len,
2214 RTE_CRYPTO_AUTH_OP_VERIFY,
2215 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2216 tdata->validAuthLenInBits.len,
2217 tdata->validAuthOffsetLenInBits.len);
2221 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2223 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2224 ut_params->obuf = ut_params->op->sym->m_src;
2225 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2226 + plaintext_pad_len + tdata->aad.len;
2229 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2238 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2240 struct crypto_testsuite_params *ts_params = &testsuite_params;
2241 struct crypto_unittest_params *ut_params = &unittest_params;
2244 unsigned plaintext_pad_len;
2245 unsigned plaintext_len;
2248 /* Create KASUMI session */
2249 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2250 tdata->key.data, tdata->key.len,
2251 tdata->aad.len, tdata->digest.len,
2252 RTE_CRYPTO_AUTH_OP_GENERATE,
2253 RTE_CRYPTO_AUTH_KASUMI_F9);
2257 /* alloc mbuf and set payload */
2258 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2260 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2261 rte_pktmbuf_tailroom(ut_params->ibuf));
2263 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2264 /* Append data which is padded to a multiple of */
2265 /* the algorithms block size */
2266 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2267 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2269 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2271 /* Create KASUMI operation */
2272 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2273 tdata->aad.data, tdata->aad.len,
2274 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2275 RTE_CRYPTO_AUTH_KASUMI_F9,
2276 tdata->validAuthLenInBits.len,
2277 tdata->validAuthOffsetLenInBits.len);
2281 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2283 ut_params->obuf = ut_params->op->sym->m_src;
2284 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2285 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2286 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2289 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2292 DIGEST_BYTE_LENGTH_KASUMI_F9,
2293 "KASUMI Generated auth tag not as expected");
2299 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2301 struct crypto_testsuite_params *ts_params = &testsuite_params;
2302 struct crypto_unittest_params *ut_params = &unittest_params;
2305 unsigned plaintext_pad_len;
2306 unsigned plaintext_len;
2309 /* Create KASUMI session */
2310 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2311 tdata->key.data, tdata->key.len,
2312 tdata->aad.len, tdata->digest.len,
2313 RTE_CRYPTO_AUTH_OP_VERIFY,
2314 RTE_CRYPTO_AUTH_KASUMI_F9);
2317 /* alloc mbuf and set payload */
2318 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2320 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2321 rte_pktmbuf_tailroom(ut_params->ibuf));
2323 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2324 /* Append data which is padded to a multiple */
2325 /* of the algorithms block size */
2326 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2327 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2329 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2331 /* Create KASUMI operation */
2332 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2334 tdata->aad.data, tdata->aad.len,
2336 RTE_CRYPTO_AUTH_OP_VERIFY,
2337 RTE_CRYPTO_AUTH_KASUMI_F9,
2338 tdata->validAuthLenInBits.len,
2339 tdata->validAuthOffsetLenInBits.len);
2343 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2345 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2346 ut_params->obuf = ut_params->op->sym->m_src;
2347 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2348 + plaintext_pad_len + tdata->aad.len;
2351 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2360 test_snow3g_hash_generate_test_case_1(void)
2362 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2366 test_snow3g_hash_generate_test_case_2(void)
2368 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2372 test_snow3g_hash_generate_test_case_3(void)
2374 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2378 test_snow3g_hash_generate_test_case_4(void)
2380 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2384 test_snow3g_hash_generate_test_case_5(void)
2386 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2390 test_snow3g_hash_generate_test_case_6(void)
2392 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2396 test_snow3g_hash_verify_test_case_1(void)
2398 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2403 test_snow3g_hash_verify_test_case_2(void)
2405 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2409 test_snow3g_hash_verify_test_case_3(void)
2411 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2415 test_snow3g_hash_verify_test_case_4(void)
2417 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2421 test_snow3g_hash_verify_test_case_5(void)
2423 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2427 test_snow3g_hash_verify_test_case_6(void)
2429 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2433 test_kasumi_hash_generate_test_case_1(void)
2435 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2439 test_kasumi_hash_generate_test_case_2(void)
2441 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2445 test_kasumi_hash_generate_test_case_3(void)
2447 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2451 test_kasumi_hash_generate_test_case_4(void)
2453 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2457 test_kasumi_hash_generate_test_case_5(void)
2459 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2463 test_kasumi_hash_generate_test_case_6(void)
2465 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2469 test_kasumi_hash_verify_test_case_1(void)
2471 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2475 test_kasumi_hash_verify_test_case_2(void)
2477 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2481 test_kasumi_hash_verify_test_case_3(void)
2483 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2487 test_kasumi_hash_verify_test_case_4(void)
2489 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2493 test_kasumi_hash_verify_test_case_5(void)
2495 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2499 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2501 struct crypto_testsuite_params *ts_params = &testsuite_params;
2502 struct crypto_unittest_params *ut_params = &unittest_params;
2505 uint8_t *plaintext, *ciphertext;
2506 unsigned plaintext_pad_len;
2507 unsigned plaintext_len;
2509 /* Create KASUMI session */
2510 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2511 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2512 RTE_CRYPTO_CIPHER_KASUMI_F8,
2513 tdata->key.data, tdata->key.len);
2517 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2519 /* Clear mbuf payload */
2520 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2521 rte_pktmbuf_tailroom(ut_params->ibuf));
2523 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2524 /* Append data which is padded to a multiple */
2525 /* of the algorithms block size */
2526 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2527 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2529 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2531 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2533 /* Create KASUMI operation */
2534 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2535 tdata->plaintext.len,
2536 tdata->validCipherOffsetLenInBits.len,
2537 RTE_CRYPTO_CIPHER_KASUMI_F8);
2541 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2543 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2545 ut_params->obuf = ut_params->op->sym->m_dst;
2546 if (ut_params->obuf)
2547 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2550 ciphertext = plaintext;
2552 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2555 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2557 tdata->ciphertext.data,
2558 tdata->validCipherLenInBits.len,
2559 "KASUMI Ciphertext data not as expected");
2564 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2566 struct crypto_testsuite_params *ts_params = &testsuite_params;
2567 struct crypto_unittest_params *ut_params = &unittest_params;
2571 unsigned int plaintext_pad_len;
2572 unsigned int plaintext_len;
2574 uint8_t buffer[10000];
2575 const uint8_t *ciphertext;
2577 struct rte_cryptodev_info dev_info;
2579 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2580 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2581 printf("Device doesn't support scatter-gather. "
2586 /* Create KASUMI session */
2587 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2588 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2589 RTE_CRYPTO_CIPHER_KASUMI_F8,
2590 tdata->key.data, tdata->key.len);
2594 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2597 /* Append data which is padded to a multiple */
2598 /* of the algorithms block size */
2599 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2601 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2602 plaintext_pad_len, 10, 0);
2604 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2606 /* Create KASUMI operation */
2607 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2609 tdata->plaintext.len,
2610 tdata->validCipherOffsetLenInBits.len,
2611 RTE_CRYPTO_CIPHER_KASUMI_F8);
2615 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2617 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2619 ut_params->obuf = ut_params->op->sym->m_dst;
2621 if (ut_params->obuf)
2622 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2623 plaintext_len, buffer);
2625 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2626 plaintext_len, buffer);
2629 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2632 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2634 tdata->ciphertext.data,
2635 tdata->validCipherLenInBits.len,
2636 "KASUMI Ciphertext data not as expected");
2641 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2643 struct crypto_testsuite_params *ts_params = &testsuite_params;
2644 struct crypto_unittest_params *ut_params = &unittest_params;
2647 uint8_t *plaintext, *ciphertext;
2648 unsigned plaintext_pad_len;
2649 unsigned plaintext_len;
2651 /* Create KASUMI session */
2652 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2653 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2654 RTE_CRYPTO_CIPHER_KASUMI_F8,
2655 tdata->key.data, tdata->key.len);
2659 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2660 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2662 /* Clear mbuf payload */
2663 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2664 rte_pktmbuf_tailroom(ut_params->ibuf));
2666 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2667 /* Append data which is padded to a multiple */
2668 /* of the algorithms block size */
2669 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2670 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2672 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2673 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2675 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2677 /* Create KASUMI operation */
2678 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2680 tdata->plaintext.len,
2681 tdata->validCipherOffsetLenInBits.len,
2682 RTE_CRYPTO_CIPHER_KASUMI_F8);
2686 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2688 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2690 ut_params->obuf = ut_params->op->sym->m_dst;
2691 if (ut_params->obuf)
2692 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2695 ciphertext = plaintext;
2697 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2700 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2702 tdata->ciphertext.data,
2703 tdata->validCipherLenInBits.len,
2704 "KASUMI Ciphertext data not as expected");
2709 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2711 struct crypto_testsuite_params *ts_params = &testsuite_params;
2712 struct crypto_unittest_params *ut_params = &unittest_params;
2715 unsigned int plaintext_pad_len;
2716 unsigned int plaintext_len;
2718 const uint8_t *ciphertext;
2719 uint8_t buffer[2048];
2721 struct rte_cryptodev_info dev_info;
2723 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2724 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2725 printf("Device doesn't support scatter-gather. "
2730 /* Create KASUMI session */
2731 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2732 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2733 RTE_CRYPTO_CIPHER_KASUMI_F8,
2734 tdata->key.data, tdata->key.len);
2738 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2739 /* Append data which is padded to a multiple */
2740 /* of the algorithms block size */
2741 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2743 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2744 plaintext_pad_len, 10, 0);
2745 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2746 plaintext_pad_len, 3, 0);
2748 /* Append data which is padded to a multiple */
2749 /* of the algorithms block size */
2750 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2752 /* Create KASUMI operation */
2753 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2755 tdata->plaintext.len,
2756 tdata->validCipherOffsetLenInBits.len,
2757 RTE_CRYPTO_CIPHER_KASUMI_F8);
2761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2763 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2765 ut_params->obuf = ut_params->op->sym->m_dst;
2766 if (ut_params->obuf)
2767 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2768 plaintext_pad_len, buffer);
2770 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2771 plaintext_pad_len, buffer);
2774 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2776 tdata->ciphertext.data,
2777 tdata->validCipherLenInBits.len,
2778 "KASUMI Ciphertext data not as expected");
2784 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2786 struct crypto_testsuite_params *ts_params = &testsuite_params;
2787 struct crypto_unittest_params *ut_params = &unittest_params;
2790 uint8_t *ciphertext, *plaintext;
2791 unsigned ciphertext_pad_len;
2792 unsigned ciphertext_len;
2794 /* Create KASUMI session */
2795 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2796 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2797 RTE_CRYPTO_CIPHER_KASUMI_F8,
2798 tdata->key.data, tdata->key.len);
2802 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2803 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2805 /* Clear mbuf payload */
2806 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2807 rte_pktmbuf_tailroom(ut_params->ibuf));
2809 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2810 /* Append data which is padded to a multiple */
2811 /* of the algorithms block size */
2812 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2813 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2814 ciphertext_pad_len);
2815 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2816 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2818 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2820 /* Create KASUMI operation */
2821 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2823 tdata->ciphertext.len,
2824 tdata->validCipherOffsetLenInBits.len,
2825 RTE_CRYPTO_CIPHER_KASUMI_F8);
2829 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2831 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2833 ut_params->obuf = ut_params->op->sym->m_dst;
2834 if (ut_params->obuf)
2835 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2838 plaintext = ciphertext;
2840 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2843 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2845 tdata->plaintext.data,
2846 tdata->validCipherLenInBits.len,
2847 "KASUMI Plaintext data not as expected");
2852 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2854 struct crypto_testsuite_params *ts_params = &testsuite_params;
2855 struct crypto_unittest_params *ut_params = &unittest_params;
2858 uint8_t *ciphertext, *plaintext;
2859 unsigned ciphertext_pad_len;
2860 unsigned ciphertext_len;
2862 /* Create KASUMI session */
2863 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2864 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2865 RTE_CRYPTO_CIPHER_KASUMI_F8,
2866 tdata->key.data, tdata->key.len);
2870 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2872 /* Clear mbuf payload */
2873 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2874 rte_pktmbuf_tailroom(ut_params->ibuf));
2876 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2877 /* Append data which is padded to a multiple */
2878 /* of the algorithms block size */
2879 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2880 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2881 ciphertext_pad_len);
2882 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2884 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2886 /* Create KASUMI operation */
2887 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2889 tdata->ciphertext.len,
2890 tdata->validCipherOffsetLenInBits.len,
2891 RTE_CRYPTO_CIPHER_KASUMI_F8);
2895 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2897 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2899 ut_params->obuf = ut_params->op->sym->m_dst;
2900 if (ut_params->obuf)
2901 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2904 plaintext = ciphertext;
2906 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2909 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2911 tdata->plaintext.data,
2912 tdata->validCipherLenInBits.len,
2913 "KASUMI Plaintext data not as expected");
2918 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2920 struct crypto_testsuite_params *ts_params = &testsuite_params;
2921 struct crypto_unittest_params *ut_params = &unittest_params;
2924 uint8_t *plaintext, *ciphertext;
2925 unsigned plaintext_pad_len;
2926 unsigned plaintext_len;
2928 /* Create SNOW 3G session */
2929 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2930 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2931 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2932 tdata->key.data, tdata->key.len);
2936 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2938 /* Clear mbuf payload */
2939 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2940 rte_pktmbuf_tailroom(ut_params->ibuf));
2942 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2943 /* Append data which is padded to a multiple of */
2944 /* the algorithms block size */
2945 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2946 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2948 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2950 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2952 /* Create SNOW 3G operation */
2953 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2954 tdata->validCipherLenInBits.len,
2955 tdata->validCipherOffsetLenInBits.len,
2956 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2960 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2962 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2964 ut_params->obuf = ut_params->op->sym->m_dst;
2965 if (ut_params->obuf)
2966 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2969 ciphertext = plaintext;
2971 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2974 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2976 tdata->ciphertext.data,
2977 tdata->validDataLenInBits.len,
2978 "SNOW 3G Ciphertext data not as expected");
2984 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2986 struct crypto_testsuite_params *ts_params = &testsuite_params;
2987 struct crypto_unittest_params *ut_params = &unittest_params;
2988 uint8_t *plaintext, *ciphertext;
2991 unsigned plaintext_pad_len;
2992 unsigned plaintext_len;
2994 /* Create SNOW 3G session */
2995 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2996 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2997 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2998 tdata->key.data, tdata->key.len);
3002 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3003 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3005 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3006 "Failed to allocate input buffer in mempool");
3007 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3008 "Failed to allocate output buffer in mempool");
3010 /* Clear mbuf payload */
3011 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3012 rte_pktmbuf_tailroom(ut_params->ibuf));
3014 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3015 /* Append data which is padded to a multiple of */
3016 /* the algorithms block size */
3017 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3018 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3020 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3021 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3023 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3025 /* Create SNOW 3G operation */
3026 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3028 tdata->validCipherLenInBits.len,
3029 tdata->validCipherOffsetLenInBits.len,
3030 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3034 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3036 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3038 ut_params->obuf = ut_params->op->sym->m_dst;
3039 if (ut_params->obuf)
3040 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3043 ciphertext = plaintext;
3045 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3048 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3050 tdata->ciphertext.data,
3051 tdata->validDataLenInBits.len,
3052 "SNOW 3G Ciphertext data not as expected");
3057 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3059 struct crypto_testsuite_params *ts_params = &testsuite_params;
3060 struct crypto_unittest_params *ut_params = &unittest_params;
3063 unsigned int plaintext_pad_len;
3064 unsigned int plaintext_len;
3065 uint8_t buffer[10000];
3066 const uint8_t *ciphertext;
3068 struct rte_cryptodev_info dev_info;
3070 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3071 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3072 printf("Device doesn't support scatter-gather. "
3077 /* Create SNOW 3G session */
3078 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3079 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3080 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3081 tdata->key.data, tdata->key.len);
3085 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3086 /* Append data which is padded to a multiple of */
3087 /* the algorithms block size */
3088 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3090 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3091 plaintext_pad_len, 10, 0);
3092 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3093 plaintext_pad_len, 3, 0);
3095 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3096 "Failed to allocate input buffer in mempool");
3097 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3098 "Failed to allocate output buffer in mempool");
3100 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3102 /* Create SNOW 3G operation */
3103 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3105 tdata->validCipherLenInBits.len,
3106 tdata->validCipherOffsetLenInBits.len,
3107 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3111 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3113 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3115 ut_params->obuf = ut_params->op->sym->m_dst;
3116 if (ut_params->obuf)
3117 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3118 plaintext_len, buffer);
3120 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3121 plaintext_len, buffer);
3123 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3126 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3128 tdata->ciphertext.data,
3129 tdata->validDataLenInBits.len,
3130 "SNOW 3G Ciphertext data not as expected");
3135 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3137 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3139 uint8_t curr_byte, prev_byte;
3140 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3141 uint8_t lower_byte_mask = (1 << offset) - 1;
3144 prev_byte = buffer[0];
3145 buffer[0] >>= offset;
3147 for (i = 1; i < length_in_bytes; i++) {
3148 curr_byte = buffer[i];
3149 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3150 (curr_byte >> offset);
3151 prev_byte = curr_byte;
3156 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3158 struct crypto_testsuite_params *ts_params = &testsuite_params;
3159 struct crypto_unittest_params *ut_params = &unittest_params;
3160 uint8_t *plaintext, *ciphertext;
3162 uint32_t plaintext_len;
3163 uint32_t plaintext_pad_len;
3164 uint8_t extra_offset = 4;
3165 uint8_t *expected_ciphertext_shifted;
3167 /* Create SNOW 3G session */
3168 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3169 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3170 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3171 tdata->key.data, tdata->key.len);
3175 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3176 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3178 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3179 "Failed to allocate input buffer in mempool");
3180 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3181 "Failed to allocate output buffer in mempool");
3183 /* Clear mbuf payload */
3184 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3185 rte_pktmbuf_tailroom(ut_params->ibuf));
3187 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3189 * Append data which is padded to a
3190 * multiple of the algorithms block size
3192 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3194 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3197 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3199 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3200 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3202 #ifdef RTE_APP_TEST_DEBUG
3203 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3205 /* Create SNOW 3G operation */
3206 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3208 tdata->validCipherLenInBits.len,
3209 tdata->validCipherOffsetLenInBits.len +
3211 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3215 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3217 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3219 ut_params->obuf = ut_params->op->sym->m_dst;
3220 if (ut_params->obuf)
3221 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3224 ciphertext = plaintext;
3226 #ifdef RTE_APP_TEST_DEBUG
3227 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3230 expected_ciphertext_shifted = rte_malloc(NULL,
3231 ceil_byte_length(plaintext_len + extra_offset), 0);
3233 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3234 "failed to reserve memory for ciphertext shifted\n");
3236 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3237 ceil_byte_length(tdata->ciphertext.len));
3238 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3241 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3243 expected_ciphertext_shifted,
3244 tdata->validDataLenInBits.len,
3246 "SNOW 3G Ciphertext data not as expected");
3250 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3252 struct crypto_testsuite_params *ts_params = &testsuite_params;
3253 struct crypto_unittest_params *ut_params = &unittest_params;
3257 uint8_t *plaintext, *ciphertext;
3258 unsigned ciphertext_pad_len;
3259 unsigned ciphertext_len;
3261 /* Create SNOW 3G session */
3262 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3263 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3264 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3265 tdata->key.data, tdata->key.len);
3269 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3271 /* Clear mbuf payload */
3272 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3273 rte_pktmbuf_tailroom(ut_params->ibuf));
3275 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3276 /* Append data which is padded to a multiple of */
3277 /* the algorithms block size */
3278 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3279 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3280 ciphertext_pad_len);
3281 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3283 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3285 /* Create SNOW 3G operation */
3286 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3287 tdata->validCipherLenInBits.len,
3288 tdata->validCipherOffsetLenInBits.len,
3289 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3293 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3295 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3296 ut_params->obuf = ut_params->op->sym->m_dst;
3297 if (ut_params->obuf)
3298 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3301 plaintext = ciphertext;
3303 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3307 tdata->plaintext.data,
3308 tdata->validDataLenInBits.len,
3309 "SNOW 3G Plaintext data not as expected");
3313 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3315 struct crypto_testsuite_params *ts_params = &testsuite_params;
3316 struct crypto_unittest_params *ut_params = &unittest_params;
3320 uint8_t *plaintext, *ciphertext;
3321 unsigned ciphertext_pad_len;
3322 unsigned ciphertext_len;
3324 /* Create SNOW 3G session */
3325 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3326 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3327 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3328 tdata->key.data, tdata->key.len);
3332 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3333 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3335 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3336 "Failed to allocate input buffer");
3337 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3338 "Failed to allocate output buffer");
3340 /* Clear mbuf payload */
3341 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3342 rte_pktmbuf_tailroom(ut_params->ibuf));
3344 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3345 rte_pktmbuf_tailroom(ut_params->obuf));
3347 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3348 /* Append data which is padded to a multiple of */
3349 /* the algorithms block size */
3350 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3351 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3352 ciphertext_pad_len);
3353 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3354 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3356 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3358 /* Create SNOW 3G operation */
3359 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3361 tdata->validCipherLenInBits.len,
3362 tdata->validCipherOffsetLenInBits.len,
3363 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3367 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3369 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3370 ut_params->obuf = ut_params->op->sym->m_dst;
3371 if (ut_params->obuf)
3372 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3375 plaintext = ciphertext;
3377 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3380 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3381 tdata->plaintext.data,
3382 tdata->validDataLenInBits.len,
3383 "SNOW 3G Plaintext data not as expected");
3388 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3390 struct crypto_testsuite_params *ts_params = &testsuite_params;
3391 struct crypto_unittest_params *ut_params = &unittest_params;
3395 uint8_t *plaintext, *ciphertext;
3396 unsigned plaintext_pad_len;
3397 unsigned plaintext_len;
3399 /* Create SNOW 3G session */
3400 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3401 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3402 RTE_CRYPTO_AUTH_OP_GENERATE,
3403 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3404 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3405 tdata->key.data, tdata->key.len,
3406 tdata->aad.len, tdata->digest.len);
3409 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3411 /* clear mbuf payload */
3412 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3413 rte_pktmbuf_tailroom(ut_params->ibuf));
3415 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3416 /* Append data which is padded to a multiple of */
3417 /* the algorithms block size */
3418 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3419 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3421 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3423 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3425 /* Create SNOW 3G operation */
3426 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3427 tdata->digest.len, tdata->aad.data,
3428 tdata->aad.len, /*tdata->plaintext.len,*/
3429 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3430 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3431 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3432 tdata->iv.data, tdata->iv.len,
3433 tdata->validCipherLenInBits.len,
3434 tdata->validCipherOffsetLenInBits.len,
3435 tdata->validAuthLenInBits.len,
3436 tdata->validAuthOffsetLenInBits.len
3441 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3443 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3444 ut_params->obuf = ut_params->op->sym->m_src;
3445 if (ut_params->obuf)
3446 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3447 + tdata->iv.len + tdata->aad.len;
3449 ciphertext = plaintext;
3451 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3453 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3455 tdata->ciphertext.data,
3456 tdata->validDataLenInBits.len,
3457 "SNOW 3G Ciphertext data not as expected");
3459 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3460 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3463 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3466 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3467 "SNOW 3G Generated auth tag not as expected");
3471 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3473 struct crypto_testsuite_params *ts_params = &testsuite_params;
3474 struct crypto_unittest_params *ut_params = &unittest_params;
3478 uint8_t *plaintext, *ciphertext;
3479 unsigned plaintext_pad_len;
3480 unsigned plaintext_len;
3482 /* Create SNOW 3G session */
3483 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3484 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3485 RTE_CRYPTO_AUTH_OP_GENERATE,
3486 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3487 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3488 tdata->key.data, tdata->key.len,
3489 tdata->aad.len, tdata->digest.len);
3493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3495 /* clear mbuf payload */
3496 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3497 rte_pktmbuf_tailroom(ut_params->ibuf));
3499 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3500 /* Append data which is padded to a multiple of */
3501 /* the algorithms block size */
3502 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3503 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3505 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3507 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3509 /* Create SNOW 3G operation */
3510 retval = create_wireless_algo_auth_cipher_operation(
3512 tdata->iv.data, tdata->iv.len,
3513 tdata->aad.data, tdata->aad.len,
3515 tdata->validCipherLenInBits.len,
3516 tdata->validCipherOffsetLenInBits.len,
3517 tdata->validAuthLenInBits.len,
3518 tdata->validAuthOffsetLenInBits.len,
3519 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3520 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3526 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3528 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3529 ut_params->obuf = ut_params->op->sym->m_src;
3530 if (ut_params->obuf)
3531 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3532 + tdata->aad.len + tdata->iv.len;
3534 ciphertext = plaintext;
3536 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3537 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3538 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3541 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3543 tdata->ciphertext.data,
3544 tdata->validDataLenInBits.len,
3545 "SNOW 3G Ciphertext data not as expected");
3548 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3551 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3552 "SNOW 3G Generated auth tag not as expected");
3557 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3559 struct crypto_testsuite_params *ts_params = &testsuite_params;
3560 struct crypto_unittest_params *ut_params = &unittest_params;
3564 uint8_t *plaintext, *ciphertext;
3565 unsigned plaintext_pad_len;
3566 unsigned plaintext_len;
3568 /* Create KASUMI session */
3569 retval = create_wireless_algo_auth_cipher_session(
3570 ts_params->valid_devs[0],
3571 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3572 RTE_CRYPTO_AUTH_OP_GENERATE,
3573 RTE_CRYPTO_AUTH_KASUMI_F9,
3574 RTE_CRYPTO_CIPHER_KASUMI_F8,
3575 tdata->key.data, tdata->key.len,
3576 tdata->aad.len, tdata->digest.len);
3579 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3581 /* clear mbuf payload */
3582 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3583 rte_pktmbuf_tailroom(ut_params->ibuf));
3585 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3586 /* Append data which is padded to a multiple of */
3587 /* the algorithms block size */
3588 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3589 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3591 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3593 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3595 /* Create KASUMI operation */
3596 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3597 tdata->iv.data, tdata->iv.len,
3598 tdata->aad.data, tdata->aad.len,
3600 tdata->validCipherLenInBits.len,
3601 tdata->validCipherOffsetLenInBits.len,
3602 tdata->validAuthLenInBits.len,
3603 tdata->validAuthOffsetLenInBits.len,
3604 RTE_CRYPTO_AUTH_KASUMI_F9,
3605 RTE_CRYPTO_CIPHER_KASUMI_F8
3611 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3613 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3614 ut_params->obuf = ut_params->op->sym->m_src;
3615 if (ut_params->obuf)
3616 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3617 + tdata->iv.len + tdata->aad.len;
3619 ciphertext = plaintext;
3622 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3624 tdata->ciphertext.data,
3625 tdata->validCipherLenInBits.len,
3626 "KASUMI Ciphertext data not as expected");
3627 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3628 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3631 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3634 DIGEST_BYTE_LENGTH_KASUMI_F9,
3635 "KASUMI Generated auth tag not as expected");
3640 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3642 struct crypto_testsuite_params *ts_params = &testsuite_params;
3643 struct crypto_unittest_params *ut_params = &unittest_params;
3647 uint8_t *plaintext, *ciphertext;
3648 unsigned plaintext_pad_len;
3649 unsigned plaintext_len;
3651 /* Create KASUMI session */
3652 retval = create_wireless_algo_cipher_auth_session(
3653 ts_params->valid_devs[0],
3654 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3655 RTE_CRYPTO_AUTH_OP_GENERATE,
3656 RTE_CRYPTO_AUTH_KASUMI_F9,
3657 RTE_CRYPTO_CIPHER_KASUMI_F8,
3658 tdata->key.data, tdata->key.len,
3659 tdata->aad.len, tdata->digest.len);
3663 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3665 /* clear mbuf payload */
3666 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3667 rte_pktmbuf_tailroom(ut_params->ibuf));
3669 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3670 /* Append data which is padded to a multiple of */
3671 /* the algorithms block size */
3672 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3673 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3675 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3677 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3679 /* Create KASUMI operation */
3680 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3681 tdata->digest.len, tdata->aad.data,
3683 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3684 RTE_CRYPTO_AUTH_KASUMI_F9,
3685 RTE_CRYPTO_CIPHER_KASUMI_F8,
3686 tdata->iv.data, tdata->iv.len,
3687 tdata->validCipherLenInBits.len,
3688 tdata->validCipherOffsetLenInBits.len,
3689 tdata->validAuthLenInBits.len,
3690 tdata->validAuthOffsetLenInBits.len
3695 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3697 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3698 ut_params->obuf = ut_params->op->sym->m_src;
3699 if (ut_params->obuf)
3700 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3701 + tdata->aad.len + tdata->iv.len;
3703 ciphertext = plaintext;
3705 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3706 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3709 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3711 tdata->ciphertext.data,
3712 tdata->validCipherLenInBits.len,
3713 "KASUMI Ciphertext data not as expected");
3716 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3719 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3720 "KASUMI Generated auth tag not as expected");
3725 test_zuc_encryption(const struct zuc_test_data *tdata)
3727 struct crypto_testsuite_params *ts_params = &testsuite_params;
3728 struct crypto_unittest_params *ut_params = &unittest_params;
3731 uint8_t *plaintext, *ciphertext;
3732 unsigned plaintext_pad_len;
3733 unsigned plaintext_len;
3735 /* Create ZUC session */
3736 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3737 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3738 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3739 tdata->key.data, tdata->key.len);
3743 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3745 /* Clear mbuf payload */
3746 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3747 rte_pktmbuf_tailroom(ut_params->ibuf));
3749 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3750 /* Append data which is padded to a multiple */
3751 /* of the algorithms block size */
3752 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3753 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3755 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3757 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3759 /* Create ZUC operation */
3760 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3761 tdata->plaintext.len,
3762 tdata->validCipherOffsetLenInBits.len,
3763 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3767 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3769 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3771 ut_params->obuf = ut_params->op->sym->m_dst;
3772 if (ut_params->obuf)
3773 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3776 ciphertext = plaintext;
3778 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3781 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3783 tdata->ciphertext.data,
3784 tdata->validCipherLenInBits.len,
3785 "ZUC Ciphertext data not as expected");
3790 test_zuc_encryption_sgl(const struct zuc_test_data *tdata)
3792 struct crypto_testsuite_params *ts_params = &testsuite_params;
3793 struct crypto_unittest_params *ut_params = &unittest_params;
3797 unsigned int plaintext_pad_len;
3798 unsigned int plaintext_len;
3799 const uint8_t *ciphertext;
3800 uint8_t ciphertext_buffer[2048];
3801 struct rte_cryptodev_info dev_info;
3803 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3804 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3805 printf("Device doesn't support scatter-gather. "
3810 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3812 /* Append data which is padded to a multiple */
3813 /* of the algorithms block size */
3814 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3816 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3817 plaintext_pad_len, 10, 0);
3819 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
3820 tdata->plaintext.data);
3822 /* Create ZUC session */
3823 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3824 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3825 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3826 tdata->key.data, tdata->key.len);
3830 /* Clear mbuf payload */
3832 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3834 /* Create ZUC operation */
3835 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3836 tdata->iv.len, tdata->plaintext.len,
3837 tdata->validCipherOffsetLenInBits.len,
3838 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3842 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3844 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3846 ut_params->obuf = ut_params->op->sym->m_dst;
3847 if (ut_params->obuf)
3848 ciphertext = rte_pktmbuf_read(ut_params->obuf,
3849 tdata->iv.len, plaintext_len, ciphertext_buffer);
3851 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3852 tdata->iv.len, plaintext_len, ciphertext_buffer);
3855 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3858 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3860 tdata->ciphertext.data,
3861 tdata->validCipherLenInBits.len,
3862 "ZUC Ciphertext data not as expected");
3868 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3870 struct crypto_testsuite_params *ts_params = &testsuite_params;
3871 struct crypto_unittest_params *ut_params = &unittest_params;
3874 unsigned plaintext_pad_len;
3875 unsigned plaintext_len;
3878 /* Create ZUC session */
3879 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3880 tdata->key.data, tdata->key.len,
3881 tdata->aad.len, tdata->digest.len,
3882 RTE_CRYPTO_AUTH_OP_GENERATE,
3883 RTE_CRYPTO_AUTH_ZUC_EIA3);
3887 /* alloc mbuf and set payload */
3888 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3890 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3891 rte_pktmbuf_tailroom(ut_params->ibuf));
3893 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3894 /* Append data which is padded to a multiple of */
3895 /* the algorithms block size */
3896 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3897 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3899 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3901 /* Create ZUC operation */
3902 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3903 tdata->aad.data, tdata->aad.len,
3904 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3905 RTE_CRYPTO_AUTH_ZUC_EIA3,
3906 tdata->validAuthLenInBits.len,
3907 tdata->validAuthOffsetLenInBits.len);
3911 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3913 ut_params->obuf = ut_params->op->sym->m_src;
3914 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3915 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3916 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3919 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3922 DIGEST_BYTE_LENGTH_KASUMI_F9,
3923 "ZUC Generated auth tag not as expected");
3929 test_kasumi_encryption_test_case_1(void)
3931 return test_kasumi_encryption(&kasumi_test_case_1);
3935 test_kasumi_encryption_test_case_1_sgl(void)
3937 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
3941 test_kasumi_encryption_test_case_1_oop(void)
3943 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3947 test_kasumi_encryption_test_case_1_oop_sgl(void)
3949 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
3953 test_kasumi_encryption_test_case_2(void)
3955 return test_kasumi_encryption(&kasumi_test_case_2);
3959 test_kasumi_encryption_test_case_3(void)
3961 return test_kasumi_encryption(&kasumi_test_case_3);
3965 test_kasumi_encryption_test_case_4(void)
3967 return test_kasumi_encryption(&kasumi_test_case_4);
3971 test_kasumi_encryption_test_case_5(void)
3973 return test_kasumi_encryption(&kasumi_test_case_5);
3977 test_kasumi_decryption_test_case_1(void)
3979 return test_kasumi_decryption(&kasumi_test_case_1);
3983 test_kasumi_decryption_test_case_1_oop(void)
3985 return test_kasumi_decryption_oop(&kasumi_test_case_1);
3989 test_kasumi_decryption_test_case_2(void)
3991 return test_kasumi_decryption(&kasumi_test_case_2);
3995 test_kasumi_decryption_test_case_3(void)
3997 return test_kasumi_decryption(&kasumi_test_case_3);
4001 test_kasumi_decryption_test_case_4(void)
4003 return test_kasumi_decryption(&kasumi_test_case_4);
4007 test_kasumi_decryption_test_case_5(void)
4009 return test_kasumi_decryption(&kasumi_test_case_5);
4012 test_snow3g_encryption_test_case_1(void)
4014 return test_snow3g_encryption(&snow3g_test_case_1);
4018 test_snow3g_encryption_test_case_1_oop(void)
4020 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4024 test_snow3g_encryption_test_case_1_oop_sgl(void)
4026 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4031 test_snow3g_encryption_test_case_1_offset_oop(void)
4033 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4037 test_snow3g_encryption_test_case_2(void)
4039 return test_snow3g_encryption(&snow3g_test_case_2);
4043 test_snow3g_encryption_test_case_3(void)
4045 return test_snow3g_encryption(&snow3g_test_case_3);
4049 test_snow3g_encryption_test_case_4(void)
4051 return test_snow3g_encryption(&snow3g_test_case_4);
4055 test_snow3g_encryption_test_case_5(void)
4057 return test_snow3g_encryption(&snow3g_test_case_5);
4061 test_snow3g_decryption_test_case_1(void)
4063 return test_snow3g_decryption(&snow3g_test_case_1);
4067 test_snow3g_decryption_test_case_1_oop(void)
4069 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4073 test_snow3g_decryption_test_case_2(void)
4075 return test_snow3g_decryption(&snow3g_test_case_2);
4079 test_snow3g_decryption_test_case_3(void)
4081 return test_snow3g_decryption(&snow3g_test_case_3);
4085 test_snow3g_decryption_test_case_4(void)
4087 return test_snow3g_decryption(&snow3g_test_case_4);
4091 test_snow3g_decryption_test_case_5(void)
4093 return test_snow3g_decryption(&snow3g_test_case_5);
4096 test_snow3g_cipher_auth_test_case_1(void)
4098 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4102 test_snow3g_auth_cipher_test_case_1(void)
4104 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4108 test_kasumi_auth_cipher_test_case_1(void)
4110 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4114 test_kasumi_cipher_auth_test_case_1(void)
4116 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4120 test_zuc_encryption_test_case_1(void)
4122 return test_zuc_encryption(&zuc_test_case_1);
4126 test_zuc_encryption_test_case_2(void)
4128 return test_zuc_encryption(&zuc_test_case_2);
4132 test_zuc_encryption_test_case_3(void)
4134 return test_zuc_encryption(&zuc_test_case_3);
4138 test_zuc_encryption_test_case_4(void)
4140 return test_zuc_encryption(&zuc_test_case_4);
4144 test_zuc_encryption_test_case_5(void)
4146 return test_zuc_encryption(&zuc_test_case_5);
4150 test_zuc_encryption_test_case_6_sgl(void)
4152 return test_zuc_encryption_sgl(&zuc_test_case_1);
4156 test_zuc_hash_generate_test_case_1(void)
4158 return test_zuc_authentication(&zuc_hash_test_case_1);
4162 test_zuc_hash_generate_test_case_2(void)
4164 return test_zuc_authentication(&zuc_hash_test_case_2);
4168 test_zuc_hash_generate_test_case_3(void)
4170 return test_zuc_authentication(&zuc_hash_test_case_3);
4174 test_zuc_hash_generate_test_case_4(void)
4176 return test_zuc_authentication(&zuc_hash_test_case_4);
4180 test_zuc_hash_generate_test_case_5(void)
4182 return test_zuc_authentication(&zuc_hash_test_case_5);
4186 test_3DES_chain_qat_all(void)
4188 struct crypto_testsuite_params *ts_params = &testsuite_params;
4191 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4192 ts_params->op_mpool, ts_params->valid_devs[0],
4193 RTE_CRYPTODEV_QAT_SYM_PMD,
4194 BLKCIPHER_3DES_CHAIN_TYPE);
4196 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4198 return TEST_SUCCESS;
4202 test_DES_cipheronly_qat_all(void)
4204 struct crypto_testsuite_params *ts_params = &testsuite_params;
4207 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4208 ts_params->op_mpool, ts_params->valid_devs[0],
4209 RTE_CRYPTODEV_QAT_SYM_PMD,
4210 BLKCIPHER_DES_CIPHERONLY_TYPE);
4212 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4214 return TEST_SUCCESS;
4218 test_3DES_cipheronly_qat_all(void)
4220 struct crypto_testsuite_params *ts_params = &testsuite_params;
4223 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4224 ts_params->op_mpool, ts_params->valid_devs[0],
4225 RTE_CRYPTODEV_QAT_SYM_PMD,
4226 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4228 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4230 return TEST_SUCCESS;
4234 test_3DES_chain_openssl_all(void)
4236 struct crypto_testsuite_params *ts_params = &testsuite_params;
4239 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4240 ts_params->op_mpool, ts_params->valid_devs[0],
4241 RTE_CRYPTODEV_OPENSSL_PMD,
4242 BLKCIPHER_3DES_CHAIN_TYPE);
4244 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4246 return TEST_SUCCESS;
4250 test_3DES_cipheronly_openssl_all(void)
4252 struct crypto_testsuite_params *ts_params = &testsuite_params;
4255 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4256 ts_params->op_mpool, ts_params->valid_devs[0],
4257 RTE_CRYPTODEV_OPENSSL_PMD,
4258 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4260 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4262 return TEST_SUCCESS;
4265 /* ***** AES-GCM Tests ***** */
4268 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4269 const uint8_t *key, const uint8_t key_len,
4270 const uint8_t aad_len, const uint8_t auth_len,
4271 enum rte_crypto_auth_operation auth_op)
4273 uint8_t cipher_key[key_len];
4275 struct crypto_unittest_params *ut_params = &unittest_params;
4277 memcpy(cipher_key, key, key_len);
4279 /* Setup Cipher Parameters */
4280 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4281 ut_params->cipher_xform.next = NULL;
4283 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4284 ut_params->auth_xform.auth.op = auth_op;
4285 ut_params->cipher_xform.cipher.op = op;
4286 ut_params->cipher_xform.cipher.key.data = cipher_key;
4287 ut_params->cipher_xform.cipher.key.length = key_len;
4289 TEST_HEXDUMP(stdout, "key:", key, key_len);
4291 /* Setup Authentication Parameters */
4292 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4293 ut_params->auth_xform.next = NULL;
4295 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4297 ut_params->auth_xform.auth.digest_length = auth_len;
4298 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4299 ut_params->auth_xform.auth.key.length = 0;
4300 ut_params->auth_xform.auth.key.data = NULL;
4302 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4303 ut_params->cipher_xform.next = &ut_params->auth_xform;
4305 /* Create Crypto session*/
4306 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4307 &ut_params->cipher_xform);
4308 } else {/* Create Crypto session*/
4309 ut_params->auth_xform.next = &ut_params->cipher_xform;
4310 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4311 &ut_params->auth_xform);
4314 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4320 create_gcm_xforms(struct rte_crypto_op *op,
4321 enum rte_crypto_cipher_operation cipher_op,
4322 uint8_t *key, const uint8_t key_len,
4323 const uint8_t aad_len, const uint8_t auth_len,
4324 enum rte_crypto_auth_operation auth_op)
4326 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4327 "failed to allocate space for crypto transforms");
4329 struct rte_crypto_sym_op *sym_op = op->sym;
4331 /* Setup Cipher Parameters */
4332 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4333 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4334 sym_op->xform->cipher.op = cipher_op;
4335 sym_op->xform->cipher.key.data = key;
4336 sym_op->xform->cipher.key.length = key_len;
4338 TEST_HEXDUMP(stdout, "key:", key, key_len);
4340 /* Setup Authentication Parameters */
4341 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4342 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4343 sym_op->xform->next->auth.op = auth_op;
4344 sym_op->xform->next->auth.digest_length = auth_len;
4345 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4346 sym_op->xform->next->auth.key.length = 0;
4347 sym_op->xform->next->auth.key.data = NULL;
4348 sym_op->xform->next->next = NULL;
4354 create_gcm_operation(enum rte_crypto_cipher_operation op,
4355 const struct gcm_test_data *tdata)
4357 struct crypto_testsuite_params *ts_params = &testsuite_params;
4358 struct crypto_unittest_params *ut_params = &unittest_params;
4360 uint8_t *plaintext, *ciphertext;
4361 unsigned int iv_pad_len, aad_pad_len, plaintext_pad_len;
4363 /* Generate Crypto op data structure */
4364 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4365 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4366 TEST_ASSERT_NOT_NULL(ut_params->op,
4367 "Failed to allocate symmetric crypto operation struct");
4369 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4371 /* Append aad data */
4372 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4373 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4375 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4376 "no room to append aad");
4378 sym_op->auth.aad.length = tdata->aad.len;
4379 sym_op->auth.aad.phys_addr =
4380 rte_pktmbuf_mtophys(ut_params->ibuf);
4381 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4382 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4383 sym_op->auth.aad.length);
4386 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
4387 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4388 ut_params->ibuf, iv_pad_len);
4389 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4391 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4392 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4393 sym_op->cipher.iv.length = tdata->iv.len;
4395 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4396 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
4397 sym_op->cipher.iv.length);
4399 /* Append plaintext/ciphertext */
4400 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4401 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4402 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4404 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4406 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4407 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4408 tdata->plaintext.len);
4410 if (ut_params->obuf) {
4411 ciphertext = (uint8_t *)rte_pktmbuf_append(
4413 plaintext_pad_len + aad_pad_len +
4415 TEST_ASSERT_NOT_NULL(ciphertext,
4416 "no room to append ciphertext");
4418 memset(ciphertext + aad_pad_len + iv_pad_len, 0,
4419 tdata->ciphertext.len);
4422 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4423 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4425 TEST_ASSERT_NOT_NULL(ciphertext,
4426 "no room to append ciphertext");
4428 memcpy(ciphertext, tdata->ciphertext.data,
4429 tdata->ciphertext.len);
4430 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4431 tdata->ciphertext.len);
4433 if (ut_params->obuf) {
4434 plaintext = (uint8_t *)rte_pktmbuf_append(
4436 plaintext_pad_len + aad_pad_len +
4438 TEST_ASSERT_NOT_NULL(plaintext,
4439 "no room to append plaintext");
4441 memset(plaintext + aad_pad_len + iv_pad_len, 0,
4442 tdata->plaintext.len);
4446 /* Append digest data */
4447 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4448 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4449 ut_params->obuf ? ut_params->obuf :
4451 tdata->auth_tag.len);
4452 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4453 "no room to append digest");
4454 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4455 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4456 ut_params->obuf ? ut_params->obuf :
4459 aad_pad_len + iv_pad_len);
4460 sym_op->auth.digest.length = tdata->auth_tag.len;
4462 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4463 ut_params->ibuf, tdata->auth_tag.len);
4464 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4465 "no room to append digest");
4466 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4468 plaintext_pad_len + aad_pad_len + iv_pad_len);
4469 sym_op->auth.digest.length = tdata->auth_tag.len;
4471 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4472 tdata->auth_tag.len);
4473 TEST_HEXDUMP(stdout, "digest:",
4474 sym_op->auth.digest.data,
4475 sym_op->auth.digest.length);
4478 sym_op->cipher.data.length = tdata->plaintext.len;
4479 sym_op->cipher.data.offset = aad_pad_len + iv_pad_len;
4481 sym_op->auth.data.length = tdata->plaintext.len;
4482 sym_op->auth.data.offset = aad_pad_len + iv_pad_len;
4488 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4490 struct crypto_testsuite_params *ts_params = &testsuite_params;
4491 struct crypto_unittest_params *ut_params = &unittest_params;
4494 uint8_t *ciphertext, *auth_tag;
4495 uint16_t plaintext_pad_len;
4498 /* Create GCM session */
4499 retval = create_gcm_session(ts_params->valid_devs[0],
4500 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4501 tdata->key.data, tdata->key.len,
4502 tdata->aad.len, tdata->auth_tag.len,
4503 RTE_CRYPTO_AUTH_OP_GENERATE);
4507 if (tdata->aad.len > MBUF_SIZE) {
4508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4509 /* Populate full size of add data */
4510 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4511 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4513 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4515 /* clear mbuf payload */
4516 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4517 rte_pktmbuf_tailroom(ut_params->ibuf));
4519 /* Create GCM operation */
4520 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4524 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4526 ut_params->op->sym->m_src = ut_params->ibuf;
4528 /* Process crypto operation */
4529 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4530 ut_params->op), "failed to process sym crypto op");
4532 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4533 "crypto op processing failed");
4535 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4537 if (ut_params->op->sym->m_dst) {
4538 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4540 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4541 uint8_t *, plaintext_pad_len);
4543 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4545 ut_params->op->sym->cipher.data.offset);
4546 auth_tag = ciphertext + plaintext_pad_len;
4549 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4550 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4553 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4555 tdata->ciphertext.data,
4556 tdata->ciphertext.len,
4557 "GCM Ciphertext data not as expected");
4559 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4561 tdata->auth_tag.data,
4562 tdata->auth_tag.len,
4563 "GCM Generated auth tag not as expected");
4570 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4572 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4576 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4578 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4582 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4584 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4588 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4590 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4594 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4596 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4600 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4602 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4606 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4608 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4612 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4614 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4618 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4620 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4624 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4626 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4630 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
4632 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
4636 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
4638 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
4642 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
4644 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
4648 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
4650 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
4654 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
4656 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
4660 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
4662 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
4666 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4668 struct crypto_testsuite_params *ts_params = &testsuite_params;
4669 struct crypto_unittest_params *ut_params = &unittest_params;
4675 /* Create GCM session */
4676 retval = create_gcm_session(ts_params->valid_devs[0],
4677 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4678 tdata->key.data, tdata->key.len,
4679 tdata->aad.len, tdata->auth_tag.len,
4680 RTE_CRYPTO_AUTH_OP_VERIFY);
4684 /* alloc mbuf and set payload */
4685 if (tdata->aad.len > MBUF_SIZE) {
4686 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4687 /* Populate full size of add data */
4688 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4689 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4691 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4693 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4694 rte_pktmbuf_tailroom(ut_params->ibuf));
4696 /* Create GCM operation */
4697 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
4701 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4703 ut_params->op->sym->m_src = ut_params->ibuf;
4705 /* Process crypto operation */
4706 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4707 ut_params->op), "failed to process sym crypto op");
4709 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4710 "crypto op processing failed");
4712 if (ut_params->op->sym->m_dst)
4713 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4716 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4718 ut_params->op->sym->cipher.data.offset);
4720 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4723 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4725 tdata->plaintext.data,
4726 tdata->plaintext.len,
4727 "GCM plaintext data not as expected");
4729 TEST_ASSERT_EQUAL(ut_params->op->status,
4730 RTE_CRYPTO_OP_STATUS_SUCCESS,
4731 "GCM authentication failed");
4736 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4738 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4742 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4744 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4748 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4750 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4754 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4756 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4760 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4762 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4766 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4768 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4772 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4774 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4778 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
4780 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
4784 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
4786 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
4790 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
4792 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
4796 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
4798 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
4802 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
4804 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
4808 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
4810 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
4814 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
4816 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
4820 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
4822 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
4826 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
4828 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
4832 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
4834 struct crypto_testsuite_params *ts_params = &testsuite_params;
4835 struct crypto_unittest_params *ut_params = &unittest_params;
4838 uint8_t *ciphertext, *auth_tag;
4839 uint16_t plaintext_pad_len;
4841 /* Create GCM session */
4842 retval = create_gcm_session(ts_params->valid_devs[0],
4843 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4844 tdata->key.data, tdata->key.len,
4845 tdata->aad.len, tdata->auth_tag.len,
4846 RTE_CRYPTO_AUTH_OP_GENERATE);
4850 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4851 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4853 /* clear mbuf payload */
4854 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4855 rte_pktmbuf_tailroom(ut_params->ibuf));
4856 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4857 rte_pktmbuf_tailroom(ut_params->obuf));
4859 /* Create GCM operation */
4860 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4864 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4866 ut_params->op->sym->m_src = ut_params->ibuf;
4867 ut_params->op->sym->m_dst = ut_params->obuf;
4869 /* Process crypto operation */
4870 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4871 ut_params->op), "failed to process sym crypto op");
4873 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4874 "crypto op processing failed");
4876 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4878 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4879 ut_params->op->sym->cipher.data.offset);
4880 auth_tag = ciphertext + plaintext_pad_len;
4882 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4883 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4886 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4888 tdata->ciphertext.data,
4889 tdata->ciphertext.len,
4890 "GCM Ciphertext data not as expected");
4892 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4894 tdata->auth_tag.data,
4895 tdata->auth_tag.len,
4896 "GCM Generated auth tag not as expected");
4903 test_mb_AES_GCM_authenticated_encryption_oop(void)
4905 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
4909 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
4911 struct crypto_testsuite_params *ts_params = &testsuite_params;
4912 struct crypto_unittest_params *ut_params = &unittest_params;
4917 /* Create GCM session */
4918 retval = create_gcm_session(ts_params->valid_devs[0],
4919 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4920 tdata->key.data, tdata->key.len,
4921 tdata->aad.len, tdata->auth_tag.len,
4922 RTE_CRYPTO_AUTH_OP_VERIFY);
4926 /* alloc mbuf and set payload */
4927 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4928 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4930 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4931 rte_pktmbuf_tailroom(ut_params->ibuf));
4932 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4933 rte_pktmbuf_tailroom(ut_params->obuf));
4935 /* Create GCM operation */
4936 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
4940 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4942 ut_params->op->sym->m_src = ut_params->ibuf;
4943 ut_params->op->sym->m_dst = ut_params->obuf;
4945 /* Process crypto operation */
4946 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4947 ut_params->op), "failed to process sym crypto op");
4949 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4950 "crypto op processing failed");
4952 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4953 ut_params->op->sym->cipher.data.offset);
4955 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4958 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4960 tdata->plaintext.data,
4961 tdata->plaintext.len,
4962 "GCM plaintext data not as expected");
4964 TEST_ASSERT_EQUAL(ut_params->op->status,
4965 RTE_CRYPTO_OP_STATUS_SUCCESS,
4966 "GCM authentication failed");
4971 test_mb_AES_GCM_authenticated_decryption_oop(void)
4973 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
4977 test_AES_GCM_authenticated_encryption_sessionless(
4978 const struct gcm_test_data *tdata)
4980 struct crypto_testsuite_params *ts_params = &testsuite_params;
4981 struct crypto_unittest_params *ut_params = &unittest_params;
4984 uint8_t *ciphertext, *auth_tag;
4985 uint16_t plaintext_pad_len;
4986 uint8_t key[tdata->key.len + 1];
4988 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4990 /* clear mbuf payload */
4991 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4992 rte_pktmbuf_tailroom(ut_params->ibuf));
4994 /* Create GCM operation */
4995 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4999 /* Create GCM xforms */
5000 memcpy(key, tdata->key.data, tdata->key.len);
5001 retval = create_gcm_xforms(ut_params->op,
5002 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5003 key, tdata->key.len,
5004 tdata->aad.len, tdata->auth_tag.len,
5005 RTE_CRYPTO_AUTH_OP_GENERATE);
5009 ut_params->op->sym->m_src = ut_params->ibuf;
5011 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5012 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5013 "crypto op session type not sessionless");
5015 /* Process crypto operation */
5016 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5017 ut_params->op), "failed to process sym crypto op");
5019 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5021 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5022 "crypto op status not success");
5024 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5026 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5027 ut_params->op->sym->cipher.data.offset);
5028 auth_tag = ciphertext + plaintext_pad_len;
5030 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5031 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5034 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5036 tdata->ciphertext.data,
5037 tdata->ciphertext.len,
5038 "GCM Ciphertext data not as expected");
5040 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5042 tdata->auth_tag.data,
5043 tdata->auth_tag.len,
5044 "GCM Generated auth tag not as expected");
5051 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5053 return test_AES_GCM_authenticated_encryption_sessionless(
5058 test_AES_GCM_authenticated_decryption_sessionless(
5059 const struct gcm_test_data *tdata)
5061 struct crypto_testsuite_params *ts_params = &testsuite_params;
5062 struct crypto_unittest_params *ut_params = &unittest_params;
5066 uint8_t key[tdata->key.len + 1];
5068 /* alloc mbuf and set payload */
5069 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5071 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5072 rte_pktmbuf_tailroom(ut_params->ibuf));
5074 /* Create GCM operation */
5075 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5079 /* Create GCM xforms */
5080 memcpy(key, tdata->key.data, tdata->key.len);
5081 retval = create_gcm_xforms(ut_params->op,
5082 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5083 key, tdata->key.len,
5084 tdata->aad.len, tdata->auth_tag.len,
5085 RTE_CRYPTO_AUTH_OP_VERIFY);
5089 ut_params->op->sym->m_src = ut_params->ibuf;
5091 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5092 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5093 "crypto op session type not sessionless");
5095 /* Process crypto operation */
5096 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5097 ut_params->op), "failed to process sym crypto op");
5099 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5101 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5102 "crypto op status not success");
5104 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5105 ut_params->op->sym->cipher.data.offset);
5107 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5110 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5112 tdata->plaintext.data,
5113 tdata->plaintext.len,
5114 "GCM plaintext data not as expected");
5116 TEST_ASSERT_EQUAL(ut_params->op->status,
5117 RTE_CRYPTO_OP_STATUS_SUCCESS,
5118 "GCM authentication failed");
5123 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5125 return test_AES_GCM_authenticated_decryption_sessionless(
5132 struct crypto_testsuite_params *ts_params = &testsuite_params;
5133 struct rte_cryptodev_stats stats;
5134 struct rte_cryptodev *dev;
5135 cryptodev_stats_get_t temp_pfn;
5137 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5138 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5139 &stats) == -ENODEV),
5140 "rte_cryptodev_stats_get invalid dev failed");
5141 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5142 "rte_cryptodev_stats_get invalid Param failed");
5143 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5144 temp_pfn = dev->dev_ops->stats_get;
5145 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5146 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5148 "rte_cryptodev_stats_get invalid Param failed");
5149 dev->dev_ops->stats_get = temp_pfn;
5151 /* Test expected values */
5153 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5155 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5157 "rte_cryptodev_stats_get failed");
5158 TEST_ASSERT((stats.enqueued_count == 1),
5159 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5160 TEST_ASSERT((stats.dequeued_count == 1),
5161 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5162 TEST_ASSERT((stats.enqueue_err_count == 0),
5163 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5164 TEST_ASSERT((stats.dequeue_err_count == 0),
5165 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5167 /* invalid device but should ignore and not reset device stats*/
5168 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5169 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5171 "rte_cryptodev_stats_get failed");
5172 TEST_ASSERT((stats.enqueued_count == 1),
5173 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5175 /* check that a valid reset clears stats */
5176 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5177 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5179 "rte_cryptodev_stats_get failed");
5180 TEST_ASSERT((stats.enqueued_count == 0),
5181 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5182 TEST_ASSERT((stats.dequeued_count == 0),
5183 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5185 return TEST_SUCCESS;
5188 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5189 struct crypto_unittest_params *ut_params,
5190 enum rte_crypto_auth_operation op,
5191 const struct HMAC_MD5_vector *test_case)
5195 memcpy(key, test_case->key.data, test_case->key.len);
5197 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5198 ut_params->auth_xform.next = NULL;
5199 ut_params->auth_xform.auth.op = op;
5201 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5203 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5204 ut_params->auth_xform.auth.add_auth_data_length = 0;
5205 ut_params->auth_xform.auth.key.length = test_case->key.len;
5206 ut_params->auth_xform.auth.key.data = key;
5208 ut_params->sess = rte_cryptodev_sym_session_create(
5209 ts_params->valid_devs[0], &ut_params->auth_xform);
5211 if (ut_params->sess == NULL)
5214 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5216 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5217 rte_pktmbuf_tailroom(ut_params->ibuf));
5222 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5223 const struct HMAC_MD5_vector *test_case,
5224 uint8_t **plaintext)
5226 uint16_t plaintext_pad_len;
5228 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5230 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5233 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5235 memcpy(*plaintext, test_case->plaintext.data,
5236 test_case->plaintext.len);
5238 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5239 ut_params->ibuf, MD5_DIGEST_LEN);
5240 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5241 "no room to append digest");
5242 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5243 ut_params->ibuf, plaintext_pad_len);
5244 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5246 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5247 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5248 test_case->auth_tag.len);
5251 sym_op->auth.data.offset = 0;
5252 sym_op->auth.data.length = test_case->plaintext.len;
5254 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5255 ut_params->op->sym->m_src = ut_params->ibuf;
5261 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5263 uint16_t plaintext_pad_len;
5264 uint8_t *plaintext, *auth_tag;
5266 struct crypto_testsuite_params *ts_params = &testsuite_params;
5267 struct crypto_unittest_params *ut_params = &unittest_params;
5269 if (MD5_HMAC_create_session(ts_params, ut_params,
5270 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5273 /* Generate Crypto op data structure */
5274 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5275 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5276 TEST_ASSERT_NOT_NULL(ut_params->op,
5277 "Failed to allocate symmetric crypto operation struct");
5279 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5282 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5285 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5286 ut_params->op), "failed to process sym crypto op");
5288 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5289 "crypto op processing failed");
5291 if (ut_params->op->sym->m_dst) {
5292 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5293 uint8_t *, plaintext_pad_len);
5295 auth_tag = plaintext + plaintext_pad_len;
5298 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5300 test_case->auth_tag.data,
5301 test_case->auth_tag.len,
5302 "HMAC_MD5 generated tag not as expected");
5304 return TEST_SUCCESS;
5308 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5312 struct crypto_testsuite_params *ts_params = &testsuite_params;
5313 struct crypto_unittest_params *ut_params = &unittest_params;
5315 if (MD5_HMAC_create_session(ts_params, ut_params,
5316 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5320 /* Generate Crypto op data structure */
5321 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5322 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5323 TEST_ASSERT_NOT_NULL(ut_params->op,
5324 "Failed to allocate symmetric crypto operation struct");
5326 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5329 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5330 ut_params->op), "failed to process sym crypto op");
5332 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5333 "HMAC_MD5 crypto op processing failed");
5335 return TEST_SUCCESS;
5339 test_MD5_HMAC_generate_case_1(void)
5341 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5345 test_MD5_HMAC_verify_case_1(void)
5347 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5351 test_MD5_HMAC_generate_case_2(void)
5353 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5357 test_MD5_HMAC_verify_case_2(void)
5359 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5363 test_multi_session(void)
5365 struct crypto_testsuite_params *ts_params = &testsuite_params;
5366 struct crypto_unittest_params *ut_params = &unittest_params;
5368 struct rte_cryptodev_info dev_info;
5369 struct rte_cryptodev_sym_session **sessions;
5373 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5374 aes_cbc_key, hmac_sha512_key);
5377 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5379 sessions = rte_malloc(NULL,
5380 (sizeof(struct rte_cryptodev_sym_session *) *
5381 dev_info.sym.max_nb_sessions) + 1, 0);
5383 /* Create multiple crypto sessions*/
5384 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5385 sessions[i] = rte_cryptodev_sym_session_create(
5386 ts_params->valid_devs[0],
5387 &ut_params->auth_xform);
5388 TEST_ASSERT_NOT_NULL(sessions[i],
5389 "Session creation failed at session number %u",
5392 /* Attempt to send a request on each session */
5393 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5397 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5398 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5400 "Failed to perform decrypt on request number %u.", i);
5401 /* free crypto operation structure */
5403 rte_crypto_op_free(ut_params->op);
5406 * free mbuf - both obuf and ibuf are usually the same,
5407 * so check if they point at the same address is necessary,
5408 * to avoid freeing the mbuf twice.
5410 if (ut_params->obuf) {
5411 rte_pktmbuf_free(ut_params->obuf);
5412 if (ut_params->ibuf == ut_params->obuf)
5413 ut_params->ibuf = 0;
5414 ut_params->obuf = 0;
5416 if (ut_params->ibuf) {
5417 rte_pktmbuf_free(ut_params->ibuf);
5418 ut_params->ibuf = 0;
5422 /* Next session create should fail */
5423 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5424 &ut_params->auth_xform);
5425 TEST_ASSERT_NULL(sessions[i],
5426 "Session creation succeeded unexpectedly!");
5428 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5429 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5434 return TEST_SUCCESS;
5437 struct multi_session_params {
5438 struct crypto_unittest_params ut_params;
5439 uint8_t *cipher_key;
5441 const uint8_t *cipher;
5442 const uint8_t *digest;
5446 #define MB_SESSION_NUMBER 3
5449 test_multi_session_random_usage(void)
5451 struct crypto_testsuite_params *ts_params = &testsuite_params;
5452 struct rte_cryptodev_info dev_info;
5453 struct rte_cryptodev_sym_session **sessions;
5455 struct multi_session_params ut_paramz[] = {
5458 .cipher_key = ms_aes_cbc_key0,
5459 .hmac_key = ms_hmac_key0,
5460 .cipher = ms_aes_cbc_cipher0,
5461 .digest = ms_hmac_digest0,
5462 .iv = ms_aes_cbc_iv0
5465 .cipher_key = ms_aes_cbc_key1,
5466 .hmac_key = ms_hmac_key1,
5467 .cipher = ms_aes_cbc_cipher1,
5468 .digest = ms_hmac_digest1,
5469 .iv = ms_aes_cbc_iv1
5472 .cipher_key = ms_aes_cbc_key2,
5473 .hmac_key = ms_hmac_key2,
5474 .cipher = ms_aes_cbc_cipher2,
5475 .digest = ms_hmac_digest2,
5476 .iv = ms_aes_cbc_iv2
5481 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5483 sessions = rte_malloc(NULL,
5484 (sizeof(struct rte_cryptodev_sym_session *)
5485 * dev_info.sym.max_nb_sessions) + 1, 0);
5487 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5488 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5489 sizeof(struct crypto_unittest_params));
5491 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5492 &ut_paramz[i].ut_params,
5493 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5495 /* Create multiple crypto sessions*/
5496 sessions[i] = rte_cryptodev_sym_session_create(
5497 ts_params->valid_devs[0],
5498 &ut_paramz[i].ut_params.auth_xform);
5500 TEST_ASSERT_NOT_NULL(sessions[i],
5501 "Session creation failed at session number %u",
5507 for (i = 0; i < 40000; i++) {
5509 j = rand() % MB_SESSION_NUMBER;
5511 TEST_ASSERT_SUCCESS(
5512 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5514 &ut_paramz[j].ut_params,
5515 ts_params, ut_paramz[j].cipher,
5516 ut_paramz[j].digest,
5518 "Failed to perform decrypt on request number %u.", i);
5520 if (ut_paramz[j].ut_params.op)
5521 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5524 * free mbuf - both obuf and ibuf are usually the same,
5525 * so check if they point at the same address is necessary,
5526 * to avoid freeing the mbuf twice.
5528 if (ut_paramz[j].ut_params.obuf) {
5529 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5530 if (ut_paramz[j].ut_params.ibuf
5531 == ut_paramz[j].ut_params.obuf)
5532 ut_paramz[j].ut_params.ibuf = 0;
5533 ut_paramz[j].ut_params.obuf = 0;
5535 if (ut_paramz[j].ut_params.ibuf) {
5536 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5537 ut_paramz[j].ut_params.ibuf = 0;
5541 for (i = 0; i < MB_SESSION_NUMBER; i++)
5542 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5547 return TEST_SUCCESS;
5551 test_null_cipher_only_operation(void)
5553 struct crypto_testsuite_params *ts_params = &testsuite_params;
5554 struct crypto_unittest_params *ut_params = &unittest_params;
5556 /* Generate test mbuf data and space for digest */
5557 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5558 catch_22_quote, QUOTE_512_BYTES, 0);
5560 /* Setup Cipher Parameters */
5561 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5562 ut_params->cipher_xform.next = NULL;
5564 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5565 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5567 /* Create Crypto session*/
5568 ut_params->sess = rte_cryptodev_sym_session_create(
5569 ts_params->valid_devs[0], &ut_params->cipher_xform);
5570 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5572 /* Generate Crypto op data structure */
5573 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5574 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5575 TEST_ASSERT_NOT_NULL(ut_params->op,
5576 "Failed to allocate symmetric crypto operation struct");
5578 /* Set crypto operation data parameters */
5579 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5581 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5583 /* set crypto operation source mbuf */
5584 sym_op->m_src = ut_params->ibuf;
5586 sym_op->cipher.data.offset = 0;
5587 sym_op->cipher.data.length = QUOTE_512_BYTES;
5589 /* Process crypto operation */
5590 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5592 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5594 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5595 "crypto operation processing failed");
5598 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5599 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5602 "Ciphertext data not as expected");
5604 return TEST_SUCCESS;
5608 test_null_auth_only_operation(void)
5610 struct crypto_testsuite_params *ts_params = &testsuite_params;
5611 struct crypto_unittest_params *ut_params = &unittest_params;
5613 /* Generate test mbuf data and space for digest */
5614 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5615 catch_22_quote, QUOTE_512_BYTES, 0);
5617 /* Setup HMAC Parameters */
5618 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5619 ut_params->auth_xform.next = NULL;
5621 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5622 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5624 /* Create Crypto session*/
5625 ut_params->sess = rte_cryptodev_sym_session_create(
5626 ts_params->valid_devs[0], &ut_params->auth_xform);
5627 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5629 /* Generate Crypto op data structure */
5630 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5631 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5632 TEST_ASSERT_NOT_NULL(ut_params->op,
5633 "Failed to allocate symmetric crypto operation struct");
5635 /* Set crypto operation data parameters */
5636 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5638 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5640 sym_op->m_src = ut_params->ibuf;
5642 sym_op->auth.data.offset = 0;
5643 sym_op->auth.data.length = QUOTE_512_BYTES;
5645 /* Process crypto operation */
5646 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5648 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5650 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5651 "crypto operation processing failed");
5653 return TEST_SUCCESS;
5657 test_null_cipher_auth_operation(void)
5659 struct crypto_testsuite_params *ts_params = &testsuite_params;
5660 struct crypto_unittest_params *ut_params = &unittest_params;
5662 /* Generate test mbuf data and space for digest */
5663 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5664 catch_22_quote, QUOTE_512_BYTES, 0);
5666 /* Setup Cipher Parameters */
5667 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5668 ut_params->cipher_xform.next = &ut_params->auth_xform;
5670 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5671 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5673 /* Setup HMAC Parameters */
5674 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5675 ut_params->auth_xform.next = NULL;
5677 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5678 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5680 /* Create Crypto session*/
5681 ut_params->sess = rte_cryptodev_sym_session_create(
5682 ts_params->valid_devs[0], &ut_params->cipher_xform);
5683 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5685 /* Generate Crypto op data structure */
5686 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5687 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5688 TEST_ASSERT_NOT_NULL(ut_params->op,
5689 "Failed to allocate symmetric crypto operation struct");
5691 /* Set crypto operation data parameters */
5692 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5694 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5696 sym_op->m_src = ut_params->ibuf;
5698 sym_op->cipher.data.offset = 0;
5699 sym_op->cipher.data.length = QUOTE_512_BYTES;
5701 sym_op->auth.data.offset = 0;
5702 sym_op->auth.data.length = QUOTE_512_BYTES;
5704 /* Process crypto operation */
5705 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5707 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5709 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5710 "crypto operation processing failed");
5713 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5714 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5717 "Ciphertext data not as expected");
5719 return TEST_SUCCESS;
5723 test_null_auth_cipher_operation(void)
5725 struct crypto_testsuite_params *ts_params = &testsuite_params;
5726 struct crypto_unittest_params *ut_params = &unittest_params;
5728 /* Generate test mbuf data and space for digest */
5729 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5730 catch_22_quote, QUOTE_512_BYTES, 0);
5732 /* Setup Cipher Parameters */
5733 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5734 ut_params->cipher_xform.next = NULL;
5736 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5737 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5739 /* Setup HMAC Parameters */
5740 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5741 ut_params->auth_xform.next = &ut_params->cipher_xform;
5743 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5744 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5746 /* Create Crypto session*/
5747 ut_params->sess = rte_cryptodev_sym_session_create(
5748 ts_params->valid_devs[0], &ut_params->cipher_xform);
5749 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5751 /* Generate Crypto op data structure */
5752 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5753 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5754 TEST_ASSERT_NOT_NULL(ut_params->op,
5755 "Failed to allocate symmetric crypto operation struct");
5757 /* Set crypto operation data parameters */
5758 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5760 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5762 sym_op->m_src = ut_params->ibuf;
5764 sym_op->cipher.data.offset = 0;
5765 sym_op->cipher.data.length = QUOTE_512_BYTES;
5767 sym_op->auth.data.offset = 0;
5768 sym_op->auth.data.length = QUOTE_512_BYTES;
5770 /* Process crypto operation */
5771 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5773 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5775 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5776 "crypto operation processing failed");
5779 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5780 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5783 "Ciphertext data not as expected");
5785 return TEST_SUCCESS;
5790 test_null_invalid_operation(void)
5792 struct crypto_testsuite_params *ts_params = &testsuite_params;
5793 struct crypto_unittest_params *ut_params = &unittest_params;
5795 /* Setup Cipher Parameters */
5796 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5797 ut_params->cipher_xform.next = NULL;
5799 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
5800 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5802 /* Create Crypto session*/
5803 ut_params->sess = rte_cryptodev_sym_session_create(
5804 ts_params->valid_devs[0], &ut_params->cipher_xform);
5805 TEST_ASSERT_NULL(ut_params->sess,
5806 "Session creation succeeded unexpectedly");
5809 /* Setup HMAC Parameters */
5810 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5811 ut_params->auth_xform.next = NULL;
5813 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
5814 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5816 /* Create Crypto session*/
5817 ut_params->sess = rte_cryptodev_sym_session_create(
5818 ts_params->valid_devs[0], &ut_params->auth_xform);
5819 TEST_ASSERT_NULL(ut_params->sess,
5820 "Session creation succeeded unexpectedly");
5822 return TEST_SUCCESS;
5826 #define NULL_BURST_LENGTH (32)
5829 test_null_burst_operation(void)
5831 struct crypto_testsuite_params *ts_params = &testsuite_params;
5832 struct crypto_unittest_params *ut_params = &unittest_params;
5834 unsigned i, burst_len = NULL_BURST_LENGTH;
5836 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
5837 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
5839 /* Setup Cipher Parameters */
5840 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5841 ut_params->cipher_xform.next = &ut_params->auth_xform;
5843 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5844 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5846 /* Setup HMAC Parameters */
5847 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5848 ut_params->auth_xform.next = NULL;
5850 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5851 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5853 /* Create Crypto session*/
5854 ut_params->sess = rte_cryptodev_sym_session_create(
5855 ts_params->valid_devs[0], &ut_params->cipher_xform);
5856 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5858 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
5859 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
5860 burst_len, "failed to generate burst of crypto ops");
5862 /* Generate an operation for each mbuf in burst */
5863 for (i = 0; i < burst_len; i++) {
5864 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5866 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
5868 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
5872 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
5874 burst[i]->sym->m_src = m;
5877 /* Process crypto operation */
5878 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
5879 0, burst, burst_len),
5881 "Error enqueuing burst");
5883 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
5884 0, burst_dequeued, burst_len),
5886 "Error dequeuing burst");
5889 for (i = 0; i < burst_len; i++) {
5891 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
5892 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
5894 "data not as expected");
5896 rte_pktmbuf_free(burst[i]->sym->m_src);
5897 rte_crypto_op_free(burst[i]);
5900 return TEST_SUCCESS;
5904 generate_gmac_large_plaintext(uint8_t *data)
5908 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5909 memcpy(&data[i], &data[0], 32);
5913 create_gmac_operation(enum rte_crypto_auth_operation op,
5914 const struct gmac_test_data *tdata)
5916 struct crypto_testsuite_params *ts_params = &testsuite_params;
5917 struct crypto_unittest_params *ut_params = &unittest_params;
5918 struct rte_crypto_sym_op *sym_op;
5920 unsigned iv_pad_len;
5921 unsigned aad_pad_len;
5923 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5924 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5927 * Runtime generate the large plain text instead of use hard code
5928 * plain text vector. It is done to avoid create huge source file
5929 * with the test vector.
5931 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5932 generate_gmac_large_plaintext(tdata->aad.data);
5934 /* Generate Crypto op data structure */
5935 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5936 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5937 TEST_ASSERT_NOT_NULL(ut_params->op,
5938 "Failed to allocate symmetric crypto operation struct");
5940 sym_op = ut_params->op->sym;
5941 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5943 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5944 "no room to append aad");
5946 sym_op->auth.aad.length = tdata->aad.len;
5947 sym_op->auth.aad.phys_addr =
5948 rte_pktmbuf_mtophys(ut_params->ibuf);
5949 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5951 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5952 ut_params->ibuf, tdata->gmac_tag.len);
5953 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5954 "no room to append digest");
5956 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5957 ut_params->ibuf, aad_pad_len);
5958 sym_op->auth.digest.length = tdata->gmac_tag.len;
5960 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5961 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
5962 tdata->gmac_tag.len);
5963 TEST_HEXDUMP(stdout, "digest:",
5964 sym_op->auth.digest.data,
5965 sym_op->auth.digest.length);
5968 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5969 ut_params->ibuf, iv_pad_len);
5970 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5972 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5973 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5974 sym_op->cipher.iv.length = tdata->iv.len;
5976 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
5978 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
5980 sym_op->cipher.data.length = 0;
5981 sym_op->cipher.data.offset = 0;
5983 sym_op->auth.data.offset = 0;
5984 sym_op->auth.data.length = 0;
5989 static int create_gmac_session(uint8_t dev_id,
5990 enum rte_crypto_cipher_operation op,
5991 const struct gmac_test_data *tdata,
5992 enum rte_crypto_auth_operation auth_op)
5994 uint8_t cipher_key[tdata->key.len];
5996 struct crypto_unittest_params *ut_params = &unittest_params;
5998 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6000 /* For GMAC we setup cipher parameters */
6001 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6002 ut_params->cipher_xform.next = NULL;
6003 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6004 ut_params->cipher_xform.cipher.op = op;
6005 ut_params->cipher_xform.cipher.key.data = cipher_key;
6006 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6008 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6009 ut_params->auth_xform.next = NULL;
6011 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6012 ut_params->auth_xform.auth.op = auth_op;
6013 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6014 ut_params->auth_xform.auth.add_auth_data_length = 0;
6015 ut_params->auth_xform.auth.key.length = 0;
6016 ut_params->auth_xform.auth.key.data = NULL;
6018 ut_params->cipher_xform.next = &ut_params->auth_xform;
6020 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6021 &ut_params->cipher_xform);
6023 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6029 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6031 struct crypto_testsuite_params *ts_params = &testsuite_params;
6032 struct crypto_unittest_params *ut_params = &unittest_params;
6036 uint8_t *auth_tag, *p;
6037 uint16_t aad_pad_len;
6039 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6040 "No GMAC length in the source data");
6042 retval = create_gmac_session(ts_params->valid_devs[0],
6043 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6044 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6049 if (tdata->aad.len > MBUF_SIZE)
6050 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6052 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6053 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6054 "Failed to allocate input buffer in mempool");
6056 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6057 rte_pktmbuf_tailroom(ut_params->ibuf));
6059 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6061 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6063 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6069 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6071 ut_params->op->sym->m_src = ut_params->ibuf;
6073 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6074 ut_params->op), "failed to process sym crypto op");
6076 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6077 "crypto op processing failed");
6079 if (ut_params->op->sym->m_dst) {
6080 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6081 uint8_t *, aad_pad_len);
6083 auth_tag = p + aad_pad_len;
6086 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6088 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6090 tdata->gmac_tag.data,
6091 tdata->gmac_tag.len,
6092 "GMAC Generated auth tag not as expected");
6098 test_AES_GMAC_authentication_test_case_1(void)
6100 return test_AES_GMAC_authentication(&gmac_test_case_1);
6104 test_AES_GMAC_authentication_test_case_2(void)
6106 return test_AES_GMAC_authentication(&gmac_test_case_2);
6110 test_AES_GMAC_authentication_test_case_3(void)
6112 return test_AES_GMAC_authentication(&gmac_test_case_3);
6116 test_AES_GMAC_authentication_test_case_4(void)
6118 return test_AES_GMAC_authentication(&gmac_test_case_4);
6122 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6124 struct crypto_testsuite_params *ts_params = &testsuite_params;
6125 struct crypto_unittest_params *ut_params = &unittest_params;
6128 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6129 "No GMAC length in the source data");
6131 retval = create_gmac_session(ts_params->valid_devs[0],
6132 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6133 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6138 if (tdata->aad.len > MBUF_SIZE)
6139 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6141 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6142 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6143 "Failed to allocate input buffer in mempool");
6145 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6146 rte_pktmbuf_tailroom(ut_params->ibuf));
6148 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6154 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6156 ut_params->op->sym->m_src = ut_params->ibuf;
6158 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6159 ut_params->op), "failed to process sym crypto op");
6161 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6162 "crypto op processing failed");
6169 test_AES_GMAC_authentication_verify_test_case_1(void)
6171 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6175 test_AES_GMAC_authentication_verify_test_case_2(void)
6177 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6181 test_AES_GMAC_authentication_verify_test_case_3(void)
6183 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6187 test_AES_GMAC_authentication_verify_test_case_4(void)
6189 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6192 struct test_crypto_vector {
6193 enum rte_crypto_cipher_algorithm crypto_algo;
6206 const uint8_t *data;
6211 const uint8_t *data;
6215 enum rte_crypto_auth_algorithm auth_algo;
6223 const uint8_t *data;
6233 static const struct test_crypto_vector
6234 hmac_sha1_test_crypto_vector = {
6235 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6237 .data = plaintext_hash,
6242 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6243 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6244 0xDE, 0xF4, 0xDE, 0xAD
6250 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6251 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6252 0x3F, 0x91, 0x64, 0x59
6258 static const struct test_crypto_vector
6259 aes128_gmac_test_vector = {
6260 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6261 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6263 .data = plaintext_hash,
6268 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6269 0x08, 0x09, 0x0A, 0x0B
6275 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6276 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6282 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6283 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6289 static const struct test_crypto_vector
6290 aes128cbc_hmac_sha1_test_vector = {
6291 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6294 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6295 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6301 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6302 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6307 .data = plaintext_hash,
6311 .data = ciphertext512_aes128cbc,
6314 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6317 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6318 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6319 0xDE, 0xF4, 0xDE, 0xAD
6325 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6326 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6327 0x18, 0x8C, 0x1D, 0x32
6334 data_corruption(uint8_t *data)
6340 tag_corruption(uint8_t *data, unsigned int tag_offset)
6342 data[tag_offset] += 1;
6346 create_auth_session(struct crypto_unittest_params *ut_params,
6348 const struct test_crypto_vector *reference,
6349 enum rte_crypto_auth_operation auth_op)
6351 uint8_t auth_key[reference->auth_key.len + 1];
6353 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6355 /* Setup Authentication Parameters */
6356 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6357 ut_params->auth_xform.auth.op = auth_op;
6358 ut_params->auth_xform.next = NULL;
6359 ut_params->auth_xform.auth.algo = reference->auth_algo;
6360 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6361 ut_params->auth_xform.auth.key.data = auth_key;
6362 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6363 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6365 /* Create Crypto session*/
6366 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6367 &ut_params->auth_xform);
6369 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6375 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6377 const struct test_crypto_vector *reference,
6378 enum rte_crypto_auth_operation auth_op,
6379 enum rte_crypto_cipher_operation cipher_op)
6381 uint8_t cipher_key[reference->cipher_key.len + 1];
6382 uint8_t auth_key[reference->auth_key.len + 1];
6384 memcpy(cipher_key, reference->cipher_key.data,
6385 reference->cipher_key.len);
6386 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6388 /* Setup Authentication Parameters */
6389 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6390 ut_params->auth_xform.auth.op = auth_op;
6391 ut_params->auth_xform.next = &ut_params->cipher_xform;
6392 ut_params->auth_xform.auth.algo = reference->auth_algo;
6393 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6394 ut_params->auth_xform.auth.key.data = auth_key;
6395 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6396 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6398 /* Setup Cipher Parameters */
6399 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6400 ut_params->cipher_xform.next = NULL;
6401 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6402 ut_params->cipher_xform.cipher.op = cipher_op;
6403 ut_params->cipher_xform.cipher.key.data = cipher_key;
6404 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6406 /* Create Crypto session*/
6407 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6408 &ut_params->auth_xform);
6410 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6416 create_auth_operation(struct crypto_testsuite_params *ts_params,
6417 struct crypto_unittest_params *ut_params,
6418 const struct test_crypto_vector *reference,
6419 unsigned int auth_generate)
6421 /* Generate Crypto op data structure */
6422 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6423 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6424 TEST_ASSERT_NOT_NULL(ut_params->op,
6425 "Failed to allocate pktmbuf offload");
6427 /* Set crypto operation data parameters */
6428 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6430 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6432 /* set crypto operation source mbuf */
6433 sym_op->m_src = ut_params->ibuf;
6436 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6437 ut_params->ibuf, reference->digest.len);
6439 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6440 "no room to append auth tag");
6442 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6443 ut_params->ibuf, reference->plaintext.len);
6444 sym_op->auth.digest.length = reference->digest.len;
6447 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6449 memcpy(sym_op->auth.digest.data,
6450 reference->digest.data,
6451 reference->digest.len);
6453 TEST_HEXDUMP(stdout, "digest:",
6454 sym_op->auth.digest.data,
6455 sym_op->auth.digest.length);
6457 sym_op->auth.data.length = reference->plaintext.len;
6458 sym_op->auth.data.offset = 0;
6464 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6465 struct crypto_unittest_params *ut_params,
6466 const struct test_crypto_vector *reference,
6467 unsigned int auth_generate)
6469 /* Generate Crypto op data structure */
6470 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6471 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6472 TEST_ASSERT_NOT_NULL(ut_params->op,
6473 "Failed to allocate pktmbuf offload");
6475 /* Set crypto operation data parameters */
6476 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6478 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6480 /* set crypto operation source mbuf */
6481 sym_op->m_src = ut_params->ibuf;
6484 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6485 reference->aad.len);
6486 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6487 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6489 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6491 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6492 sym_op->auth.aad.length = reference->aad.len;
6495 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6496 ut_params->ibuf, reference->digest.len);
6498 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6499 "no room to append auth tag");
6501 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6502 ut_params->ibuf, reference->ciphertext.len);
6503 sym_op->auth.digest.length = reference->digest.len;
6506 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6508 memcpy(sym_op->auth.digest.data,
6509 reference->digest.data,
6510 reference->digest.len);
6512 TEST_HEXDUMP(stdout, "digest:",
6513 sym_op->auth.digest.data,
6514 sym_op->auth.digest.length);
6516 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6517 ut_params->ibuf, reference->iv.len);
6518 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6520 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6521 sym_op->cipher.iv.length = reference->iv.len;
6523 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6525 sym_op->cipher.data.length = 0;
6526 sym_op->cipher.data.offset = 0;
6528 sym_op->auth.data.length = 0;
6529 sym_op->auth.data.offset = 0;
6535 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6536 struct crypto_unittest_params *ut_params,
6537 const struct test_crypto_vector *reference,
6538 unsigned int auth_generate)
6540 /* Generate Crypto op data structure */
6541 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6542 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6543 TEST_ASSERT_NOT_NULL(ut_params->op,
6544 "Failed to allocate pktmbuf offload");
6546 /* Set crypto operation data parameters */
6547 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6549 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6551 /* set crypto operation source mbuf */
6552 sym_op->m_src = ut_params->ibuf;
6555 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6556 ut_params->ibuf, reference->digest.len);
6558 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6559 "no room to append auth tag");
6561 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6562 ut_params->ibuf, reference->ciphertext.len);
6563 sym_op->auth.digest.length = reference->digest.len;
6566 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6568 memcpy(sym_op->auth.digest.data,
6569 reference->digest.data,
6570 reference->digest.len);
6572 TEST_HEXDUMP(stdout, "digest:",
6573 sym_op->auth.digest.data,
6574 sym_op->auth.digest.length);
6576 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6577 ut_params->ibuf, reference->iv.len);
6578 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6580 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6581 sym_op->cipher.iv.length = reference->iv.len;
6583 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6585 sym_op->cipher.data.length = reference->ciphertext.len;
6586 sym_op->cipher.data.offset = reference->iv.len;
6588 sym_op->auth.data.length = reference->ciphertext.len;
6589 sym_op->auth.data.offset = reference->iv.len;
6595 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6596 struct crypto_unittest_params *ut_params,
6597 const struct test_crypto_vector *reference)
6599 return create_auth_operation(ts_params, ut_params, reference, 0);
6603 create_auth_verify_GMAC_operation(
6604 struct crypto_testsuite_params *ts_params,
6605 struct crypto_unittest_params *ut_params,
6606 const struct test_crypto_vector *reference)
6608 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6612 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6613 struct crypto_unittest_params *ut_params,
6614 const struct test_crypto_vector *reference)
6616 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6620 test_authentication_verify_fail_when_data_corruption(
6621 struct crypto_testsuite_params *ts_params,
6622 struct crypto_unittest_params *ut_params,
6623 const struct test_crypto_vector *reference,
6624 unsigned int data_corrupted)
6630 /* Create session */
6631 retval = create_auth_session(ut_params,
6632 ts_params->valid_devs[0],
6634 RTE_CRYPTO_AUTH_OP_VERIFY);
6638 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6639 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6640 "Failed to allocate input buffer in mempool");
6642 /* clear mbuf payload */
6643 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6644 rte_pktmbuf_tailroom(ut_params->ibuf));
6646 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6647 reference->plaintext.len);
6648 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6649 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6651 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6653 /* Create operation */
6654 retval = create_auth_verify_operation(ts_params, ut_params, reference);
6660 data_corruption(plaintext);
6662 tag_corruption(plaintext, reference->plaintext.len);
6664 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6666 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6667 TEST_ASSERT_EQUAL(ut_params->op->status,
6668 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6669 "authentication not failed");
6671 ut_params->obuf = ut_params->op->sym->m_src;
6672 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6678 test_authentication_verify_GMAC_fail_when_corruption(
6679 struct crypto_testsuite_params *ts_params,
6680 struct crypto_unittest_params *ut_params,
6681 const struct test_crypto_vector *reference,
6682 unsigned int data_corrupted)
6686 /* Create session */
6687 retval = create_auth_cipher_session(ut_params,
6688 ts_params->valid_devs[0],
6690 RTE_CRYPTO_AUTH_OP_VERIFY,
6691 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6695 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6696 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6697 "Failed to allocate input buffer in mempool");
6699 /* clear mbuf payload */
6700 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6701 rte_pktmbuf_tailroom(ut_params->ibuf));
6703 /* Create operation */
6704 retval = create_auth_verify_GMAC_operation(ts_params,
6712 data_corruption(ut_params->op->sym->auth.aad.data);
6714 tag_corruption(ut_params->op->sym->auth.aad.data,
6715 reference->aad.len);
6717 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6719 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6720 TEST_ASSERT_EQUAL(ut_params->op->status,
6721 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6722 "authentication not failed");
6724 ut_params->obuf = ut_params->op->sym->m_src;
6725 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6731 test_authenticated_decryption_fail_when_corruption(
6732 struct crypto_testsuite_params *ts_params,
6733 struct crypto_unittest_params *ut_params,
6734 const struct test_crypto_vector *reference,
6735 unsigned int data_corrupted)
6739 uint8_t *ciphertext;
6741 /* Create session */
6742 retval = create_auth_cipher_session(ut_params,
6743 ts_params->valid_devs[0],
6745 RTE_CRYPTO_AUTH_OP_VERIFY,
6746 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6750 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6751 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6752 "Failed to allocate input buffer in mempool");
6754 /* clear mbuf payload */
6755 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6756 rte_pktmbuf_tailroom(ut_params->ibuf));
6758 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6759 reference->ciphertext.len);
6760 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
6761 memcpy(ciphertext, reference->ciphertext.data,
6762 reference->ciphertext.len);
6764 /* Create operation */
6765 retval = create_cipher_auth_verify_operation(ts_params,
6773 data_corruption(ciphertext);
6775 tag_corruption(ciphertext, reference->ciphertext.len);
6777 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6780 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6781 TEST_ASSERT_EQUAL(ut_params->op->status,
6782 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6783 "authentication not failed");
6785 ut_params->obuf = ut_params->op->sym->m_src;
6786 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6792 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
6793 const struct gcm_test_data *tdata,
6794 void *digest_mem, uint64_t digest_phys)
6796 struct crypto_testsuite_params *ts_params = &testsuite_params;
6797 struct crypto_unittest_params *ut_params = &unittest_params;
6799 const unsigned int auth_tag_len = tdata->auth_tag.len;
6800 const unsigned int iv_len = tdata->iv.len;
6801 const unsigned int aad_len = tdata->aad.len;
6803 unsigned int iv_pad_len = 0;
6805 /* Generate Crypto op data structure */
6806 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6807 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6808 TEST_ASSERT_NOT_NULL(ut_params->op,
6809 "Failed to allocate symmetric crypto operation struct");
6811 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6813 sym_op->auth.digest.data = digest_mem;
6815 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6816 "no room to append digest");
6818 sym_op->auth.digest.phys_addr = digest_phys;
6819 sym_op->auth.digest.length = auth_tag_len;
6821 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
6822 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
6824 TEST_HEXDUMP(stdout, "digest:",
6825 sym_op->auth.digest.data,
6826 sym_op->auth.digest.length);
6829 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
6831 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6832 ut_params->ibuf, iv_pad_len);
6834 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
6835 "no room to prepend iv");
6837 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6838 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6839 sym_op->cipher.iv.length = iv_len;
6841 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
6843 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
6844 ut_params->ibuf, aad_len);
6845 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6846 "no room to prepend aad");
6847 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
6849 sym_op->auth.aad.length = aad_len;
6851 memset(sym_op->auth.aad.data, 0, aad_len);
6852 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
6854 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6855 TEST_HEXDUMP(stdout, "aad:",
6856 sym_op->auth.aad.data, aad_len);
6858 sym_op->cipher.data.length = tdata->plaintext.len;
6859 sym_op->cipher.data.offset = aad_len + iv_pad_len;
6861 sym_op->auth.data.offset = aad_len + iv_pad_len;
6862 sym_op->auth.data.length = tdata->plaintext.len;
6867 #define SGL_MAX_NO 16
6870 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
6871 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
6873 struct crypto_testsuite_params *ts_params = &testsuite_params;
6874 struct crypto_unittest_params *ut_params = &unittest_params;
6875 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
6878 int to_trn_tbl[SGL_MAX_NO];
6880 unsigned int trn_data = 0;
6881 uint8_t *plaintext, *ciphertext, *auth_tag;
6883 if (fragsz > tdata->plaintext.len)
6884 fragsz = tdata->plaintext.len;
6886 uint16_t plaintext_len = fragsz;
6887 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
6889 if (fragsz_oop > tdata->plaintext.len)
6890 frag_size_oop = tdata->plaintext.len;
6893 void *digest_mem = NULL;
6895 uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
6898 if (tdata->plaintext.len % fragsz != 0) {
6899 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
6902 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
6907 * For out-op-place we need to alloc another mbuf
6910 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6911 rte_pktmbuf_append(ut_params->obuf,
6912 frag_size_oop + prepend_len);
6913 buf_oop = ut_params->obuf;
6916 /* Create GCM session */
6917 retval = create_gcm_session(ts_params->valid_devs[0],
6918 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6919 tdata->key.data, tdata->key.len,
6920 tdata->aad.len, tdata->auth_tag.len,
6921 RTE_CRYPTO_AUTH_OP_GENERATE);
6925 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6927 /* clear mbuf payload */
6928 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6929 rte_pktmbuf_tailroom(ut_params->ibuf));
6931 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6934 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6936 trn_data += plaintext_len;
6938 buf = ut_params->ibuf;
6941 * Loop until no more fragments
6944 while (trn_data < tdata->plaintext.len) {
6946 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
6947 (tdata->plaintext.len - trn_data) : fragsz;
6949 to_trn_tbl[ecx++] = to_trn;
6951 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6954 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
6955 rte_pktmbuf_tailroom(buf));
6958 if (oop && !fragsz_oop) {
6959 buf_last_oop = buf_oop->next =
6960 rte_pktmbuf_alloc(ts_params->mbuf_pool);
6961 buf_oop = buf_oop->next;
6962 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
6963 0, rte_pktmbuf_tailroom(buf_oop));
6964 rte_pktmbuf_append(buf_oop, to_trn);
6967 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
6970 memcpy(plaintext, tdata->plaintext.data + trn_data,
6973 if (trn_data == tdata->plaintext.len) {
6976 digest_mem = rte_pktmbuf_append(buf_oop,
6977 tdata->auth_tag.len);
6979 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
6980 tdata->auth_tag.len);
6984 uint64_t digest_phys = 0;
6986 ut_params->ibuf->nb_segs = segs;
6989 if (fragsz_oop && oop) {
6993 if (frag_size_oop == tdata->plaintext.len) {
6994 digest_mem = rte_pktmbuf_append(ut_params->obuf,
6995 tdata->auth_tag.len);
6997 digest_phys = rte_pktmbuf_mtophys_offset(
6999 tdata->plaintext.len + prepend_len);
7002 trn_data = frag_size_oop;
7003 while (trn_data < tdata->plaintext.len) {
7006 (tdata->plaintext.len - trn_data <
7008 (tdata->plaintext.len - trn_data) :
7011 to_trn_tbl[ecx++] = to_trn;
7013 buf_last_oop = buf_oop->next =
7014 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7015 buf_oop = buf_oop->next;
7016 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7017 0, rte_pktmbuf_tailroom(buf_oop));
7018 rte_pktmbuf_append(buf_oop, to_trn);
7022 if (trn_data == tdata->plaintext.len) {
7023 digest_mem = rte_pktmbuf_append(buf_oop,
7024 tdata->auth_tag.len);
7028 ut_params->obuf->nb_segs = segs;
7032 * Place digest at the end of the last buffer
7035 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7036 if (oop && buf_last_oop)
7037 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7039 if (!digest_mem && !oop) {
7040 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7041 + tdata->auth_tag.len);
7042 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7043 tdata->plaintext.len);
7046 /* Create GCM opertaion */
7047 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7048 tdata, digest_mem, digest_phys);
7053 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7055 ut_params->op->sym->m_src = ut_params->ibuf;
7057 ut_params->op->sym->m_dst = ut_params->obuf;
7059 /* Process crypto operation */
7060 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7061 ut_params->op), "failed to process sym crypto op");
7063 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7064 "crypto op processing failed");
7067 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7068 uint8_t *, prepend_len);
7070 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7071 uint8_t *, prepend_len);
7075 fragsz = fragsz_oop;
7077 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7079 tdata->ciphertext.data,
7081 "GCM Ciphertext data not as expected");
7083 buf = ut_params->op->sym->m_src->next;
7085 buf = ut_params->op->sym->m_dst->next;
7087 unsigned int off = fragsz;
7091 ciphertext = rte_pktmbuf_mtod(buf,
7094 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7096 tdata->ciphertext.data + off,
7098 "GCM Ciphertext data not as expected");
7100 off += to_trn_tbl[ecx++];
7104 auth_tag = digest_mem;
7105 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7107 tdata->auth_tag.data,
7108 tdata->auth_tag.len,
7109 "GCM Generated auth tag not as expected");
7115 #define OUT_OF_PLACE 1
7118 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7120 return test_AES_GCM_authenticated_encryption_SGL(
7121 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7125 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7127 return test_AES_GCM_authenticated_encryption_SGL(
7128 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7132 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7134 return test_AES_GCM_authenticated_encryption_SGL(
7135 &gcm_test_case_8, OUT_OF_PLACE, 400,
7136 gcm_test_case_8.plaintext.len);
7140 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7143 return test_AES_GCM_authenticated_encryption_SGL(
7144 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7148 test_authentication_verify_fail_when_data_corrupted(
7149 struct crypto_testsuite_params *ts_params,
7150 struct crypto_unittest_params *ut_params,
7151 const struct test_crypto_vector *reference)
7153 return test_authentication_verify_fail_when_data_corruption(
7154 ts_params, ut_params, reference, 1);
7158 test_authentication_verify_fail_when_tag_corrupted(
7159 struct crypto_testsuite_params *ts_params,
7160 struct crypto_unittest_params *ut_params,
7161 const struct test_crypto_vector *reference)
7163 return test_authentication_verify_fail_when_data_corruption(
7164 ts_params, ut_params, reference, 0);
7168 test_authentication_verify_GMAC_fail_when_data_corrupted(
7169 struct crypto_testsuite_params *ts_params,
7170 struct crypto_unittest_params *ut_params,
7171 const struct test_crypto_vector *reference)
7173 return test_authentication_verify_GMAC_fail_when_corruption(
7174 ts_params, ut_params, reference, 1);
7178 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7179 struct crypto_testsuite_params *ts_params,
7180 struct crypto_unittest_params *ut_params,
7181 const struct test_crypto_vector *reference)
7183 return test_authentication_verify_GMAC_fail_when_corruption(
7184 ts_params, ut_params, reference, 0);
7188 test_authenticated_decryption_fail_when_data_corrupted(
7189 struct crypto_testsuite_params *ts_params,
7190 struct crypto_unittest_params *ut_params,
7191 const struct test_crypto_vector *reference)
7193 return test_authenticated_decryption_fail_when_corruption(
7194 ts_params, ut_params, reference, 1);
7198 test_authenticated_decryption_fail_when_tag_corrupted(
7199 struct crypto_testsuite_params *ts_params,
7200 struct crypto_unittest_params *ut_params,
7201 const struct test_crypto_vector *reference)
7203 return test_authenticated_decryption_fail_when_corruption(
7204 ts_params, ut_params, reference, 0);
7208 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7210 return test_authentication_verify_fail_when_data_corrupted(
7211 &testsuite_params, &unittest_params,
7212 &hmac_sha1_test_crypto_vector);
7216 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7218 return test_authentication_verify_fail_when_tag_corrupted(
7219 &testsuite_params, &unittest_params,
7220 &hmac_sha1_test_crypto_vector);
7224 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7226 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7227 &testsuite_params, &unittest_params,
7228 &aes128_gmac_test_vector);
7232 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7234 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7235 &testsuite_params, &unittest_params,
7236 &aes128_gmac_test_vector);
7240 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7242 return test_authenticated_decryption_fail_when_data_corrupted(
7245 &aes128cbc_hmac_sha1_test_vector);
7249 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7251 return test_authenticated_decryption_fail_when_tag_corrupted(
7254 &aes128cbc_hmac_sha1_test_vector);
7257 static struct unit_test_suite cryptodev_qat_testsuite = {
7258 .suite_name = "Crypto QAT Unit Test Suite",
7259 .setup = testsuite_setup,
7260 .teardown = testsuite_teardown,
7261 .unit_test_cases = {
7262 TEST_CASE_ST(ut_setup, ut_teardown,
7263 test_device_configure_invalid_dev_id),
7264 TEST_CASE_ST(ut_setup, ut_teardown,
7265 test_device_configure_invalid_queue_pair_ids),
7266 TEST_CASE_ST(ut_setup, ut_teardown,
7267 test_queue_pair_descriptor_setup),
7268 TEST_CASE_ST(ut_setup, ut_teardown,
7269 test_multi_session),
7271 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7272 TEST_CASE_ST(ut_setup, ut_teardown,
7273 test_AES_cipheronly_qat_all),
7274 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7275 TEST_CASE_ST(ut_setup, ut_teardown,
7276 test_3DES_cipheronly_qat_all),
7277 TEST_CASE_ST(ut_setup, ut_teardown,
7278 test_DES_cipheronly_qat_all),
7279 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7281 /** AES GCM Authenticated Encryption */
7282 TEST_CASE_ST(ut_setup, ut_teardown,
7283 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7284 TEST_CASE_ST(ut_setup, ut_teardown,
7285 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7286 TEST_CASE_ST(ut_setup, ut_teardown,
7287 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7288 TEST_CASE_ST(ut_setup, ut_teardown,
7289 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7290 TEST_CASE_ST(ut_setup, ut_teardown,
7291 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7292 TEST_CASE_ST(ut_setup, ut_teardown,
7293 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7294 TEST_CASE_ST(ut_setup, ut_teardown,
7295 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7296 TEST_CASE_ST(ut_setup, ut_teardown,
7297 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7298 TEST_CASE_ST(ut_setup, ut_teardown,
7299 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7300 TEST_CASE_ST(ut_setup, ut_teardown,
7301 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7303 /** AES GCM Authenticated Decryption */
7304 TEST_CASE_ST(ut_setup, ut_teardown,
7305 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7306 TEST_CASE_ST(ut_setup, ut_teardown,
7307 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7308 TEST_CASE_ST(ut_setup, ut_teardown,
7309 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7310 TEST_CASE_ST(ut_setup, ut_teardown,
7311 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7312 TEST_CASE_ST(ut_setup, ut_teardown,
7313 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7314 TEST_CASE_ST(ut_setup, ut_teardown,
7315 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7316 TEST_CASE_ST(ut_setup, ut_teardown,
7317 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7319 /** AES GMAC Authentication */
7320 TEST_CASE_ST(ut_setup, ut_teardown,
7321 test_AES_GMAC_authentication_test_case_1),
7322 TEST_CASE_ST(ut_setup, ut_teardown,
7323 test_AES_GMAC_authentication_verify_test_case_1),
7324 TEST_CASE_ST(ut_setup, ut_teardown,
7325 test_AES_GMAC_authentication_test_case_2),
7326 TEST_CASE_ST(ut_setup, ut_teardown,
7327 test_AES_GMAC_authentication_verify_test_case_2),
7328 TEST_CASE_ST(ut_setup, ut_teardown,
7329 test_AES_GMAC_authentication_test_case_3),
7330 TEST_CASE_ST(ut_setup, ut_teardown,
7331 test_AES_GMAC_authentication_verify_test_case_3),
7333 /** SNOW 3G encrypt only (UEA2) */
7334 TEST_CASE_ST(ut_setup, ut_teardown,
7335 test_snow3g_encryption_test_case_1),
7336 TEST_CASE_ST(ut_setup, ut_teardown,
7337 test_snow3g_encryption_test_case_2),
7338 TEST_CASE_ST(ut_setup, ut_teardown,
7339 test_snow3g_encryption_test_case_3),
7340 TEST_CASE_ST(ut_setup, ut_teardown,
7341 test_snow3g_encryption_test_case_4),
7342 TEST_CASE_ST(ut_setup, ut_teardown,
7343 test_snow3g_encryption_test_case_5),
7345 TEST_CASE_ST(ut_setup, ut_teardown,
7346 test_snow3g_encryption_test_case_1_oop),
7347 TEST_CASE_ST(ut_setup, ut_teardown,
7348 test_snow3g_decryption_test_case_1_oop),
7350 /** SNOW 3G decrypt only (UEA2) */
7351 TEST_CASE_ST(ut_setup, ut_teardown,
7352 test_snow3g_decryption_test_case_1),
7353 TEST_CASE_ST(ut_setup, ut_teardown,
7354 test_snow3g_decryption_test_case_2),
7355 TEST_CASE_ST(ut_setup, ut_teardown,
7356 test_snow3g_decryption_test_case_3),
7357 TEST_CASE_ST(ut_setup, ut_teardown,
7358 test_snow3g_decryption_test_case_4),
7359 TEST_CASE_ST(ut_setup, ut_teardown,
7360 test_snow3g_decryption_test_case_5),
7361 TEST_CASE_ST(ut_setup, ut_teardown,
7362 test_snow3g_hash_generate_test_case_1),
7363 TEST_CASE_ST(ut_setup, ut_teardown,
7364 test_snow3g_hash_generate_test_case_2),
7365 TEST_CASE_ST(ut_setup, ut_teardown,
7366 test_snow3g_hash_generate_test_case_3),
7367 TEST_CASE_ST(ut_setup, ut_teardown,
7368 test_snow3g_hash_verify_test_case_1),
7369 TEST_CASE_ST(ut_setup, ut_teardown,
7370 test_snow3g_hash_verify_test_case_2),
7371 TEST_CASE_ST(ut_setup, ut_teardown,
7372 test_snow3g_hash_verify_test_case_3),
7373 TEST_CASE_ST(ut_setup, ut_teardown,
7374 test_snow3g_cipher_auth_test_case_1),
7375 TEST_CASE_ST(ut_setup, ut_teardown,
7376 test_snow3g_auth_cipher_test_case_1),
7378 /** HMAC_MD5 Authentication */
7379 TEST_CASE_ST(ut_setup, ut_teardown,
7380 test_MD5_HMAC_generate_case_1),
7381 TEST_CASE_ST(ut_setup, ut_teardown,
7382 test_MD5_HMAC_verify_case_1),
7383 TEST_CASE_ST(ut_setup, ut_teardown,
7384 test_MD5_HMAC_generate_case_2),
7385 TEST_CASE_ST(ut_setup, ut_teardown,
7386 test_MD5_HMAC_verify_case_2),
7389 TEST_CASE_ST(ut_setup, ut_teardown,
7390 test_null_auth_only_operation),
7391 TEST_CASE_ST(ut_setup, ut_teardown,
7392 test_null_cipher_only_operation),
7393 TEST_CASE_ST(ut_setup, ut_teardown,
7394 test_null_cipher_auth_operation),
7395 TEST_CASE_ST(ut_setup, ut_teardown,
7396 test_null_auth_cipher_operation),
7398 TEST_CASE_ST(ut_setup, ut_teardown,
7399 test_kasumi_hash_generate_test_case_6),
7402 TEST_CASE_ST(ut_setup, ut_teardown,
7403 test_kasumi_encryption_test_case_1),
7404 TEST_CASE_ST(ut_setup, ut_teardown,
7405 test_kasumi_encryption_test_case_3),
7406 TEST_CASE_ST(ut_setup, ut_teardown,
7407 test_kasumi_auth_cipher_test_case_1),
7408 TEST_CASE_ST(ut_setup, ut_teardown,
7409 test_kasumi_cipher_auth_test_case_1),
7411 /** Negative tests */
7412 TEST_CASE_ST(ut_setup, ut_teardown,
7413 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7414 TEST_CASE_ST(ut_setup, ut_teardown,
7415 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7416 TEST_CASE_ST(ut_setup, ut_teardown,
7417 authentication_verify_AES128_GMAC_fail_data_corrupt),
7418 TEST_CASE_ST(ut_setup, ut_teardown,
7419 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7420 TEST_CASE_ST(ut_setup, ut_teardown,
7421 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7422 TEST_CASE_ST(ut_setup, ut_teardown,
7423 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7425 TEST_CASES_END() /**< NULL terminate unit test array */
7429 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7430 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7431 .setup = testsuite_setup,
7432 .teardown = testsuite_teardown,
7433 .unit_test_cases = {
7434 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7435 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7436 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7438 TEST_CASES_END() /**< NULL terminate unit test array */
7442 static struct unit_test_suite cryptodev_openssl_testsuite = {
7443 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7444 .setup = testsuite_setup,
7445 .teardown = testsuite_teardown,
7446 .unit_test_cases = {
7447 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7448 TEST_CASE_ST(ut_setup, ut_teardown,
7449 test_multi_session_random_usage),
7450 TEST_CASE_ST(ut_setup, ut_teardown,
7451 test_AES_chain_openssl_all),
7452 TEST_CASE_ST(ut_setup, ut_teardown,
7453 test_AES_cipheronly_openssl_all),
7454 TEST_CASE_ST(ut_setup, ut_teardown,
7455 test_3DES_chain_openssl_all),
7456 TEST_CASE_ST(ut_setup, ut_teardown,
7457 test_3DES_cipheronly_openssl_all),
7458 TEST_CASE_ST(ut_setup, ut_teardown,
7459 test_authonly_openssl_all),
7461 /** AES GCM Authenticated Encryption */
7462 TEST_CASE_ST(ut_setup, ut_teardown,
7463 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7464 TEST_CASE_ST(ut_setup, ut_teardown,
7465 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7466 TEST_CASE_ST(ut_setup, ut_teardown,
7467 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7468 TEST_CASE_ST(ut_setup, ut_teardown,
7469 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7470 TEST_CASE_ST(ut_setup, ut_teardown,
7471 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7472 TEST_CASE_ST(ut_setup, ut_teardown,
7473 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7474 TEST_CASE_ST(ut_setup, ut_teardown,
7475 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7477 /** AES GCM Authenticated Decryption */
7478 TEST_CASE_ST(ut_setup, ut_teardown,
7479 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7480 TEST_CASE_ST(ut_setup, ut_teardown,
7481 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7482 TEST_CASE_ST(ut_setup, ut_teardown,
7483 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7484 TEST_CASE_ST(ut_setup, ut_teardown,
7485 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7486 TEST_CASE_ST(ut_setup, ut_teardown,
7487 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7488 TEST_CASE_ST(ut_setup, ut_teardown,
7489 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7490 TEST_CASE_ST(ut_setup, ut_teardown,
7491 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7493 /** AES GMAC Authentication */
7494 TEST_CASE_ST(ut_setup, ut_teardown,
7495 test_AES_GMAC_authentication_test_case_1),
7496 TEST_CASE_ST(ut_setup, ut_teardown,
7497 test_AES_GMAC_authentication_verify_test_case_1),
7498 TEST_CASE_ST(ut_setup, ut_teardown,
7499 test_AES_GMAC_authentication_test_case_2),
7500 TEST_CASE_ST(ut_setup, ut_teardown,
7501 test_AES_GMAC_authentication_verify_test_case_2),
7502 TEST_CASE_ST(ut_setup, ut_teardown,
7503 test_AES_GMAC_authentication_test_case_3),
7504 TEST_CASE_ST(ut_setup, ut_teardown,
7505 test_AES_GMAC_authentication_verify_test_case_3),
7506 TEST_CASE_ST(ut_setup, ut_teardown,
7507 test_AES_GMAC_authentication_test_case_4),
7508 TEST_CASE_ST(ut_setup, ut_teardown,
7509 test_AES_GMAC_authentication_verify_test_case_4),
7511 /** Scatter-Gather */
7512 TEST_CASE_ST(ut_setup, ut_teardown,
7513 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7515 /** Negative tests */
7516 TEST_CASE_ST(ut_setup, ut_teardown,
7517 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7518 TEST_CASE_ST(ut_setup, ut_teardown,
7519 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7520 TEST_CASE_ST(ut_setup, ut_teardown,
7521 authentication_verify_AES128_GMAC_fail_data_corrupt),
7522 TEST_CASE_ST(ut_setup, ut_teardown,
7523 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7524 TEST_CASE_ST(ut_setup, ut_teardown,
7525 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7526 TEST_CASE_ST(ut_setup, ut_teardown,
7527 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7529 TEST_CASES_END() /**< NULL terminate unit test array */
7533 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
7534 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
7535 .setup = testsuite_setup,
7536 .teardown = testsuite_teardown,
7537 .unit_test_cases = {
7538 /** AES GCM Authenticated Encryption */
7539 TEST_CASE_ST(ut_setup, ut_teardown,
7540 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7541 TEST_CASE_ST(ut_setup, ut_teardown,
7542 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7543 TEST_CASE_ST(ut_setup, ut_teardown,
7544 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7545 TEST_CASE_ST(ut_setup, ut_teardown,
7546 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7547 TEST_CASE_ST(ut_setup, ut_teardown,
7548 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7549 TEST_CASE_ST(ut_setup, ut_teardown,
7550 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7551 TEST_CASE_ST(ut_setup, ut_teardown,
7552 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7554 /** AES GCM Authenticated Decryption */
7555 TEST_CASE_ST(ut_setup, ut_teardown,
7556 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7557 TEST_CASE_ST(ut_setup, ut_teardown,
7558 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7559 TEST_CASE_ST(ut_setup, ut_teardown,
7560 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7561 TEST_CASE_ST(ut_setup, ut_teardown,
7562 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7563 TEST_CASE_ST(ut_setup, ut_teardown,
7564 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7565 TEST_CASE_ST(ut_setup, ut_teardown,
7566 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7567 TEST_CASE_ST(ut_setup, ut_teardown,
7568 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7570 /** AES GCM Authenticated Encryption 256 bits key */
7571 TEST_CASE_ST(ut_setup, ut_teardown,
7572 test_mb_AES_GCM_auth_encryption_test_case_256_1),
7573 TEST_CASE_ST(ut_setup, ut_teardown,
7574 test_mb_AES_GCM_auth_encryption_test_case_256_2),
7575 TEST_CASE_ST(ut_setup, ut_teardown,
7576 test_mb_AES_GCM_auth_encryption_test_case_256_3),
7577 TEST_CASE_ST(ut_setup, ut_teardown,
7578 test_mb_AES_GCM_auth_encryption_test_case_256_4),
7579 TEST_CASE_ST(ut_setup, ut_teardown,
7580 test_mb_AES_GCM_auth_encryption_test_case_256_5),
7581 TEST_CASE_ST(ut_setup, ut_teardown,
7582 test_mb_AES_GCM_auth_encryption_test_case_256_6),
7583 TEST_CASE_ST(ut_setup, ut_teardown,
7584 test_mb_AES_GCM_auth_encryption_test_case_256_7),
7586 /** AES GCM Authenticated Decryption 256 bits key */
7587 TEST_CASE_ST(ut_setup, ut_teardown,
7588 test_mb_AES_GCM_auth_decryption_test_case_256_1),
7589 TEST_CASE_ST(ut_setup, ut_teardown,
7590 test_mb_AES_GCM_auth_decryption_test_case_256_2),
7591 TEST_CASE_ST(ut_setup, ut_teardown,
7592 test_mb_AES_GCM_auth_decryption_test_case_256_3),
7593 TEST_CASE_ST(ut_setup, ut_teardown,
7594 test_mb_AES_GCM_auth_decryption_test_case_256_4),
7595 TEST_CASE_ST(ut_setup, ut_teardown,
7596 test_mb_AES_GCM_auth_decryption_test_case_256_5),
7597 TEST_CASE_ST(ut_setup, ut_teardown,
7598 test_mb_AES_GCM_auth_decryption_test_case_256_6),
7599 TEST_CASE_ST(ut_setup, ut_teardown,
7600 test_mb_AES_GCM_auth_decryption_test_case_256_7),
7602 /** AES GCM Authenticated Encryption big aad size */
7603 TEST_CASE_ST(ut_setup, ut_teardown,
7604 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
7605 TEST_CASE_ST(ut_setup, ut_teardown,
7606 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
7608 /** AES GCM Authenticated Decryption big aad size */
7609 TEST_CASE_ST(ut_setup, ut_teardown,
7610 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
7611 TEST_CASE_ST(ut_setup, ut_teardown,
7612 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
7614 /** AES GMAC Authentication */
7615 TEST_CASE_ST(ut_setup, ut_teardown,
7616 test_AES_GMAC_authentication_test_case_1),
7617 TEST_CASE_ST(ut_setup, ut_teardown,
7618 test_AES_GMAC_authentication_verify_test_case_1),
7619 TEST_CASE_ST(ut_setup, ut_teardown,
7620 test_AES_GMAC_authentication_test_case_3),
7621 TEST_CASE_ST(ut_setup, ut_teardown,
7622 test_AES_GMAC_authentication_verify_test_case_3),
7623 TEST_CASE_ST(ut_setup, ut_teardown,
7624 test_AES_GMAC_authentication_test_case_4),
7625 TEST_CASE_ST(ut_setup, ut_teardown,
7626 test_AES_GMAC_authentication_verify_test_case_4),
7628 /** Negative tests */
7629 TEST_CASE_ST(ut_setup, ut_teardown,
7630 authentication_verify_AES128_GMAC_fail_data_corrupt),
7631 TEST_CASE_ST(ut_setup, ut_teardown,
7632 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7634 /** Out of place tests */
7635 TEST_CASE_ST(ut_setup, ut_teardown,
7636 test_mb_AES_GCM_authenticated_encryption_oop),
7637 TEST_CASE_ST(ut_setup, ut_teardown,
7638 test_mb_AES_GCM_authenticated_decryption_oop),
7640 /** Session-less tests */
7641 TEST_CASE_ST(ut_setup, ut_teardown,
7642 test_mb_AES_GCM_authenticated_encryption_sessionless),
7643 TEST_CASE_ST(ut_setup, ut_teardown,
7644 test_mb_AES_GCM_authenticated_decryption_sessionless),
7646 /** Scatter-Gather */
7647 TEST_CASE_ST(ut_setup, ut_teardown,
7648 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7650 TEST_CASES_END() /**< NULL terminate unit test array */
7654 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
7655 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
7656 .setup = testsuite_setup,
7657 .teardown = testsuite_teardown,
7658 .unit_test_cases = {
7659 /** KASUMI encrypt only (UEA1) */
7660 TEST_CASE_ST(ut_setup, ut_teardown,
7661 test_kasumi_encryption_test_case_1),
7662 TEST_CASE_ST(ut_setup, ut_teardown,
7663 test_kasumi_encryption_test_case_1_sgl),
7664 TEST_CASE_ST(ut_setup, ut_teardown,
7665 test_kasumi_encryption_test_case_2),
7666 TEST_CASE_ST(ut_setup, ut_teardown,
7667 test_kasumi_encryption_test_case_3),
7668 TEST_CASE_ST(ut_setup, ut_teardown,
7669 test_kasumi_encryption_test_case_4),
7670 TEST_CASE_ST(ut_setup, ut_teardown,
7671 test_kasumi_encryption_test_case_5),
7672 /** KASUMI decrypt only (UEA1) */
7673 TEST_CASE_ST(ut_setup, ut_teardown,
7674 test_kasumi_decryption_test_case_1),
7675 TEST_CASE_ST(ut_setup, ut_teardown,
7676 test_kasumi_decryption_test_case_2),
7677 TEST_CASE_ST(ut_setup, ut_teardown,
7678 test_kasumi_decryption_test_case_3),
7679 TEST_CASE_ST(ut_setup, ut_teardown,
7680 test_kasumi_decryption_test_case_4),
7681 TEST_CASE_ST(ut_setup, ut_teardown,
7682 test_kasumi_decryption_test_case_5),
7684 TEST_CASE_ST(ut_setup, ut_teardown,
7685 test_kasumi_encryption_test_case_1_oop),
7686 TEST_CASE_ST(ut_setup, ut_teardown,
7687 test_kasumi_encryption_test_case_1_oop_sgl),
7690 TEST_CASE_ST(ut_setup, ut_teardown,
7691 test_kasumi_decryption_test_case_1_oop),
7693 /** KASUMI hash only (UIA1) */
7694 TEST_CASE_ST(ut_setup, ut_teardown,
7695 test_kasumi_hash_generate_test_case_1),
7696 TEST_CASE_ST(ut_setup, ut_teardown,
7697 test_kasumi_hash_generate_test_case_2),
7698 TEST_CASE_ST(ut_setup, ut_teardown,
7699 test_kasumi_hash_generate_test_case_3),
7700 TEST_CASE_ST(ut_setup, ut_teardown,
7701 test_kasumi_hash_generate_test_case_4),
7702 TEST_CASE_ST(ut_setup, ut_teardown,
7703 test_kasumi_hash_generate_test_case_5),
7704 TEST_CASE_ST(ut_setup, ut_teardown,
7705 test_kasumi_hash_generate_test_case_6),
7706 TEST_CASE_ST(ut_setup, ut_teardown,
7707 test_kasumi_hash_verify_test_case_1),
7708 TEST_CASE_ST(ut_setup, ut_teardown,
7709 test_kasumi_hash_verify_test_case_2),
7710 TEST_CASE_ST(ut_setup, ut_teardown,
7711 test_kasumi_hash_verify_test_case_3),
7712 TEST_CASE_ST(ut_setup, ut_teardown,
7713 test_kasumi_hash_verify_test_case_4),
7714 TEST_CASE_ST(ut_setup, ut_teardown,
7715 test_kasumi_hash_verify_test_case_5),
7716 TEST_CASE_ST(ut_setup, ut_teardown,
7717 test_kasumi_auth_cipher_test_case_1),
7718 TEST_CASE_ST(ut_setup, ut_teardown,
7719 test_kasumi_cipher_auth_test_case_1),
7720 TEST_CASES_END() /**< NULL terminate unit test array */
7723 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
7724 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
7725 .setup = testsuite_setup,
7726 .teardown = testsuite_teardown,
7727 .unit_test_cases = {
7728 /** SNOW 3G encrypt only (UEA2) */
7729 TEST_CASE_ST(ut_setup, ut_teardown,
7730 test_snow3g_encryption_test_case_1),
7731 TEST_CASE_ST(ut_setup, ut_teardown,
7732 test_snow3g_encryption_test_case_2),
7733 TEST_CASE_ST(ut_setup, ut_teardown,
7734 test_snow3g_encryption_test_case_3),
7735 TEST_CASE_ST(ut_setup, ut_teardown,
7736 test_snow3g_encryption_test_case_4),
7737 TEST_CASE_ST(ut_setup, ut_teardown,
7738 test_snow3g_encryption_test_case_5),
7740 TEST_CASE_ST(ut_setup, ut_teardown,
7741 test_snow3g_encryption_test_case_1_oop),
7742 TEST_CASE_ST(ut_setup, ut_teardown,
7743 test_snow3g_encryption_test_case_1_oop_sgl),
7744 TEST_CASE_ST(ut_setup, ut_teardown,
7745 test_snow3g_decryption_test_case_1_oop),
7747 TEST_CASE_ST(ut_setup, ut_teardown,
7748 test_snow3g_encryption_test_case_1_offset_oop),
7750 /** SNOW 3G decrypt only (UEA2) */
7751 TEST_CASE_ST(ut_setup, ut_teardown,
7752 test_snow3g_decryption_test_case_1),
7753 TEST_CASE_ST(ut_setup, ut_teardown,
7754 test_snow3g_decryption_test_case_2),
7755 TEST_CASE_ST(ut_setup, ut_teardown,
7756 test_snow3g_decryption_test_case_3),
7757 TEST_CASE_ST(ut_setup, ut_teardown,
7758 test_snow3g_decryption_test_case_4),
7759 TEST_CASE_ST(ut_setup, ut_teardown,
7760 test_snow3g_decryption_test_case_5),
7761 TEST_CASE_ST(ut_setup, ut_teardown,
7762 test_snow3g_hash_generate_test_case_1),
7763 TEST_CASE_ST(ut_setup, ut_teardown,
7764 test_snow3g_hash_generate_test_case_2),
7765 TEST_CASE_ST(ut_setup, ut_teardown,
7766 test_snow3g_hash_generate_test_case_3),
7767 /* Tests with buffers which length is not byte-aligned */
7768 TEST_CASE_ST(ut_setup, ut_teardown,
7769 test_snow3g_hash_generate_test_case_4),
7770 TEST_CASE_ST(ut_setup, ut_teardown,
7771 test_snow3g_hash_generate_test_case_5),
7772 TEST_CASE_ST(ut_setup, ut_teardown,
7773 test_snow3g_hash_generate_test_case_6),
7774 TEST_CASE_ST(ut_setup, ut_teardown,
7775 test_snow3g_hash_verify_test_case_1),
7776 TEST_CASE_ST(ut_setup, ut_teardown,
7777 test_snow3g_hash_verify_test_case_2),
7778 TEST_CASE_ST(ut_setup, ut_teardown,
7779 test_snow3g_hash_verify_test_case_3),
7780 /* Tests with buffers which length is not byte-aligned */
7781 TEST_CASE_ST(ut_setup, ut_teardown,
7782 test_snow3g_hash_verify_test_case_4),
7783 TEST_CASE_ST(ut_setup, ut_teardown,
7784 test_snow3g_hash_verify_test_case_5),
7785 TEST_CASE_ST(ut_setup, ut_teardown,
7786 test_snow3g_hash_verify_test_case_6),
7787 TEST_CASE_ST(ut_setup, ut_teardown,
7788 test_snow3g_cipher_auth_test_case_1),
7789 TEST_CASE_ST(ut_setup, ut_teardown,
7790 test_snow3g_auth_cipher_test_case_1),
7792 TEST_CASES_END() /**< NULL terminate unit test array */
7796 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
7797 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
7798 .setup = testsuite_setup,
7799 .teardown = testsuite_teardown,
7800 .unit_test_cases = {
7801 /** ZUC encrypt only (EEA3) */
7802 TEST_CASE_ST(ut_setup, ut_teardown,
7803 test_zuc_encryption_test_case_1),
7804 TEST_CASE_ST(ut_setup, ut_teardown,
7805 test_zuc_encryption_test_case_2),
7806 TEST_CASE_ST(ut_setup, ut_teardown,
7807 test_zuc_encryption_test_case_3),
7808 TEST_CASE_ST(ut_setup, ut_teardown,
7809 test_zuc_encryption_test_case_4),
7810 TEST_CASE_ST(ut_setup, ut_teardown,
7811 test_zuc_encryption_test_case_5),
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_zuc_hash_generate_test_case_1),
7814 TEST_CASE_ST(ut_setup, ut_teardown,
7815 test_zuc_hash_generate_test_case_2),
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_zuc_hash_generate_test_case_3),
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_zuc_hash_generate_test_case_4),
7820 TEST_CASE_ST(ut_setup, ut_teardown,
7821 test_zuc_hash_generate_test_case_5),
7822 TEST_CASE_ST(ut_setup, ut_teardown,
7823 test_zuc_encryption_test_case_6_sgl),
7824 TEST_CASES_END() /**< NULL terminate unit test array */
7828 static struct unit_test_suite cryptodev_null_testsuite = {
7829 .suite_name = "Crypto Device NULL Unit Test Suite",
7830 .setup = testsuite_setup,
7831 .teardown = testsuite_teardown,
7832 .unit_test_cases = {
7833 TEST_CASE_ST(ut_setup, ut_teardown,
7834 test_null_auth_only_operation),
7835 TEST_CASE_ST(ut_setup, ut_teardown,
7836 test_null_cipher_only_operation),
7837 TEST_CASE_ST(ut_setup, ut_teardown,
7838 test_null_cipher_auth_operation),
7839 TEST_CASE_ST(ut_setup, ut_teardown,
7840 test_null_auth_cipher_operation),
7841 TEST_CASE_ST(ut_setup, ut_teardown,
7842 test_null_invalid_operation),
7843 TEST_CASE_ST(ut_setup, ut_teardown,
7844 test_null_burst_operation),
7846 TEST_CASES_END() /**< NULL terminate unit test array */
7851 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
7853 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
7854 return unit_test_suite_runner(&cryptodev_qat_testsuite);
7858 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
7860 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
7862 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
7866 test_cryptodev_openssl(void)
7868 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
7870 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
7874 test_cryptodev_aesni_gcm(void)
7876 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
7878 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
7882 test_cryptodev_null(void)
7884 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
7886 return unit_test_suite_runner(&cryptodev_null_testsuite);
7890 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
7892 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
7894 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
7898 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
7900 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
7902 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
7906 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
7908 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
7910 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
7913 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
7914 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
7915 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
7916 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
7917 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
7918 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
7919 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
7920 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);