4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
39 #include <rte_crypto.h>
40 #include <rte_cryptodev.h>
41 #include <rte_cryptodev_pmd.h>
43 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
44 #include <rte_cryptodev_scheduler.h>
45 #include <rte_cryptodev_scheduler_operations.h>
49 #include "test_cryptodev.h"
51 #include "test_cryptodev_blockcipher.h"
52 #include "test_cryptodev_aes_test_vectors.h"
53 #include "test_cryptodev_des_test_vectors.h"
54 #include "test_cryptodev_hash_test_vectors.h"
55 #include "test_cryptodev_kasumi_test_vectors.h"
56 #include "test_cryptodev_kasumi_hash_test_vectors.h"
57 #include "test_cryptodev_snow3g_test_vectors.h"
58 #include "test_cryptodev_snow3g_hash_test_vectors.h"
59 #include "test_cryptodev_zuc_test_vectors.h"
60 #include "test_cryptodev_zuc_hash_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static enum rte_cryptodev_type gbl_cryptodev_type;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_cryptodev_config conf;
71 struct rte_cryptodev_qp_conf qp_conf;
73 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
74 uint8_t valid_dev_count;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
81 struct rte_cryptodev_sym_session *sess;
83 struct rte_crypto_op *op;
85 struct rte_mbuf *obuf, *ibuf;
90 #define ALIGN_POW2_ROUNDUP(num, align) \
91 (((num) + (align) - 1) & ~((align) - 1))
94 * Forward declarations.
97 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
98 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
102 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
103 struct crypto_unittest_params *ut_params,
104 struct crypto_testsuite_params *ts_param,
105 const uint8_t *cipher,
106 const uint8_t *digest,
109 static struct rte_mbuf *
110 setup_test_string(struct rte_mempool *mpool,
111 const char *string, size_t len, uint8_t blocksize)
113 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
114 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
116 memset(m->buf_addr, 0, m->buf_len);
118 char *dst = rte_pktmbuf_append(m, t_len);
125 rte_memcpy(dst, string, t_len);
127 memset(dst, 0, t_len);
133 /* Get number of bytes in X bits (rounding up) */
135 ceil_byte_length(uint32_t num_bits)
138 return ((num_bits >> 3) + 1);
140 return (num_bits >> 3);
143 static struct rte_crypto_op *
144 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
146 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
147 printf("Error sending packet for encryption");
153 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
159 static struct crypto_testsuite_params testsuite_params = { NULL };
160 static struct crypto_unittest_params unittest_params;
163 testsuite_setup(void)
165 struct crypto_testsuite_params *ts_params = &testsuite_params;
166 struct rte_cryptodev_info info;
167 uint32_t i = 0, nb_devs, dev_id;
171 memset(ts_params, 0, sizeof(*ts_params));
173 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
174 if (ts_params->mbuf_pool == NULL) {
175 /* Not already created so create */
176 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
178 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
180 if (ts_params->mbuf_pool == NULL) {
181 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
186 ts_params->large_mbuf_pool = rte_mempool_lookup(
187 "CRYPTO_LARGE_MBUFPOOL");
188 if (ts_params->large_mbuf_pool == NULL) {
189 /* Not already created so create */
190 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
191 "CRYPTO_LARGE_MBUFPOOL",
194 if (ts_params->large_mbuf_pool == NULL) {
196 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
201 ts_params->op_mpool = rte_crypto_op_pool_create(
202 "MBUF_CRYPTO_SYM_OP_POOL",
203 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
204 NUM_MBUFS, MBUF_CACHE_SIZE,
206 sizeof(struct rte_crypto_sym_xform),
208 if (ts_params->op_mpool == NULL) {
209 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
213 /* Create 2 AESNI MB devices if required */
214 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
215 #ifndef RTE_LIBRTE_PMD_AESNI_MB
216 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
217 " enabled in config file to run this testsuite.\n");
220 nb_devs = rte_cryptodev_count_devtype(
221 RTE_CRYPTODEV_AESNI_MB_PMD);
223 for (i = nb_devs; i < 2; i++) {
224 ret = rte_eal_vdev_init(
225 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 TEST_ASSERT(ret == 0,
228 "Failed to create instance %u of"
230 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
235 /* Create 2 AESNI GCM devices if required */
236 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
237 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
238 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
239 " enabled in config file to run this testsuite.\n");
242 nb_devs = rte_cryptodev_count_devtype(
243 RTE_CRYPTODEV_AESNI_GCM_PMD);
245 for (i = nb_devs; i < 2; i++) {
246 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
247 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
248 "Failed to create instance %u of"
250 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
255 /* Create 2 SNOW 3G devices if required */
256 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
257 #ifndef RTE_LIBRTE_PMD_SNOW3G
258 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
259 " enabled in config file to run this testsuite.\n");
262 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
264 for (i = nb_devs; i < 2; i++) {
265 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
266 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
267 "Failed to create instance %u of"
269 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
274 /* Create 2 KASUMI devices if required */
275 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
276 #ifndef RTE_LIBRTE_PMD_KASUMI
277 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
278 " enabled in config file to run this testsuite.\n");
281 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
283 for (i = nb_devs; i < 2; i++) {
284 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
285 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
286 "Failed to create instance %u of"
288 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
293 /* Create 2 ZUC devices if required */
294 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
295 #ifndef RTE_LIBRTE_PMD_ZUC
296 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
297 " enabled in config file to run this testsuite.\n");
300 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
302 for (i = nb_devs; i < 2; i++) {
303 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
304 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
305 "Failed to create instance %u of"
307 i, RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
312 /* Create 2 NULL devices if required */
313 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
314 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
315 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
316 " enabled in config file to run this testsuite.\n");
319 nb_devs = rte_cryptodev_count_devtype(
320 RTE_CRYPTODEV_NULL_PMD);
322 for (i = nb_devs; i < 2; i++) {
323 int dev_id = rte_eal_vdev_init(
324 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
326 TEST_ASSERT(dev_id >= 0,
327 "Failed to create instance %u of"
329 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
334 /* Create 2 OPENSSL devices if required */
335 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
336 #ifndef RTE_LIBRTE_PMD_OPENSSL
337 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
338 " enabled in config file to run this testsuite.\n");
341 nb_devs = rte_cryptodev_count_devtype(
342 RTE_CRYPTODEV_OPENSSL_PMD);
344 for (i = nb_devs; i < 2; i++) {
345 ret = rte_eal_vdev_init(
346 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
349 TEST_ASSERT(ret == 0, "Failed to create "
350 "instance %u of pmd : %s", i,
351 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
356 /* Create 2 ARMv8 devices if required */
357 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
358 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
359 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
360 " enabled in config file to run this testsuite.\n");
363 nb_devs = rte_cryptodev_count_devtype(
364 RTE_CRYPTODEV_ARMV8_PMD);
366 for (i = nb_devs; i < 2; i++) {
367 ret = rte_eal_vdev_init(
368 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
371 TEST_ASSERT(ret == 0, "Failed to create "
372 "instance %u of pmd : %s", i,
373 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
378 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
379 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
381 #ifndef RTE_LIBRTE_PMD_AESNI_MB
382 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
383 " enabled in config file to run this testsuite.\n");
386 nb_devs = rte_cryptodev_count_devtype(
387 RTE_CRYPTODEV_SCHEDULER_PMD);
389 ret = rte_eal_vdev_init(
390 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
393 TEST_ASSERT(ret == 0,
394 "Failed to create instance %u of"
396 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
399 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
401 #ifndef RTE_LIBRTE_PMD_QAT
402 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
403 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
404 "in config file to run this testsuite.\n");
409 nb_devs = rte_cryptodev_count();
411 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
415 /* Create list of valid crypto devs */
416 for (i = 0; i < nb_devs; i++) {
417 rte_cryptodev_info_get(i, &info);
418 if (info.dev_type == gbl_cryptodev_type)
419 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
422 if (ts_params->valid_dev_count < 1)
425 /* Set up all the qps on the first of the valid devices found */
427 dev_id = ts_params->valid_devs[0];
429 rte_cryptodev_info_get(dev_id, &info);
431 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
432 ts_params->conf.socket_id = SOCKET_ID_ANY;
433 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
435 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
437 "Failed to configure cryptodev %u with %u qps",
438 dev_id, ts_params->conf.nb_queue_pairs);
440 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
442 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
443 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
444 dev_id, qp_id, &ts_params->qp_conf,
445 rte_cryptodev_socket_id(dev_id)),
446 "Failed to setup queue pair %u on cryptodev %u",
454 testsuite_teardown(void)
456 struct crypto_testsuite_params *ts_params = &testsuite_params;
458 if (ts_params->mbuf_pool != NULL) {
459 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
460 rte_mempool_avail_count(ts_params->mbuf_pool));
463 if (ts_params->op_mpool != NULL) {
464 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
465 rte_mempool_avail_count(ts_params->op_mpool));
473 struct crypto_testsuite_params *ts_params = &testsuite_params;
474 struct crypto_unittest_params *ut_params = &unittest_params;
478 /* Clear unit test parameters before running test */
479 memset(ut_params, 0, sizeof(*ut_params));
481 /* Reconfigure device to default parameters */
482 ts_params->conf.socket_id = SOCKET_ID_ANY;
483 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
485 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
487 "Failed to configure cryptodev %u",
488 ts_params->valid_devs[0]);
490 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
491 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
492 ts_params->valid_devs[0], qp_id,
494 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
495 "Failed to setup queue pair %u on cryptodev %u",
496 qp_id, ts_params->valid_devs[0]);
500 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
502 /* Start the device */
503 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
504 "Failed to start cryptodev %u",
505 ts_params->valid_devs[0]);
513 struct crypto_testsuite_params *ts_params = &testsuite_params;
514 struct crypto_unittest_params *ut_params = &unittest_params;
515 struct rte_cryptodev_stats stats;
517 /* free crypto session structure */
518 if (ut_params->sess) {
519 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
521 ut_params->sess = NULL;
524 /* free crypto operation structure */
526 rte_crypto_op_free(ut_params->op);
529 * free mbuf - both obuf and ibuf are usually the same,
530 * so check if they point at the same address is necessary,
531 * to avoid freeing the mbuf twice.
533 if (ut_params->obuf) {
534 rte_pktmbuf_free(ut_params->obuf);
535 if (ut_params->ibuf == ut_params->obuf)
539 if (ut_params->ibuf) {
540 rte_pktmbuf_free(ut_params->ibuf);
544 if (ts_params->mbuf_pool != NULL)
545 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
546 rte_mempool_avail_count(ts_params->mbuf_pool));
548 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
550 /* Stop the device */
551 rte_cryptodev_stop(ts_params->valid_devs[0]);
555 test_device_configure_invalid_dev_id(void)
557 struct crypto_testsuite_params *ts_params = &testsuite_params;
558 uint16_t dev_id, num_devs = 0;
560 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
561 "Need at least %d devices for test", 1);
563 /* valid dev_id values */
564 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
566 /* Stop the device in case it's started so it can be configured */
567 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
569 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
570 "Failed test for rte_cryptodev_configure: "
571 "invalid dev_num %u", dev_id);
573 /* invalid dev_id values */
576 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
577 "Failed test for rte_cryptodev_configure: "
578 "invalid dev_num %u", dev_id);
582 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
583 "Failed test for rte_cryptodev_configure:"
584 "invalid dev_num %u", dev_id);
590 test_device_configure_invalid_queue_pair_ids(void)
592 struct crypto_testsuite_params *ts_params = &testsuite_params;
593 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
595 /* Stop the device in case it's started so it can be configured */
596 rte_cryptodev_stop(ts_params->valid_devs[0]);
598 /* valid - one queue pairs */
599 ts_params->conf.nb_queue_pairs = 1;
601 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
603 "Failed to configure cryptodev: dev_id %u, qp_id %u",
604 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
607 /* valid - max value queue pairs */
608 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
610 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
612 "Failed to configure cryptodev: dev_id %u, qp_id %u",
613 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
616 /* invalid - zero queue pairs */
617 ts_params->conf.nb_queue_pairs = 0;
619 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
621 "Failed test for rte_cryptodev_configure, dev_id %u,"
623 ts_params->valid_devs[0],
624 ts_params->conf.nb_queue_pairs);
627 /* invalid - max value supported by field queue pairs */
628 ts_params->conf.nb_queue_pairs = UINT16_MAX;
630 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
632 "Failed test for rte_cryptodev_configure, dev_id %u,"
634 ts_params->valid_devs[0],
635 ts_params->conf.nb_queue_pairs);
638 /* invalid - max value + 1 queue pairs */
639 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
641 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
643 "Failed test for rte_cryptodev_configure, dev_id %u,"
645 ts_params->valid_devs[0],
646 ts_params->conf.nb_queue_pairs);
648 /* revert to original testsuite value */
649 ts_params->conf.nb_queue_pairs = orig_nb_qps;
655 test_queue_pair_descriptor_setup(void)
657 struct crypto_testsuite_params *ts_params = &testsuite_params;
658 struct rte_cryptodev_info dev_info;
659 struct rte_cryptodev_qp_conf qp_conf = {
660 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
665 /* Stop the device in case it's started so it can be configured */
666 rte_cryptodev_stop(ts_params->valid_devs[0]);
669 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
671 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
673 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
674 &ts_params->conf), "Failed to configure cryptodev %u",
675 ts_params->valid_devs[0]);
679 * Test various ring sizes on this device. memzones can't be
680 * freed so are re-used if ring is released and re-created.
682 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
684 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
685 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
686 ts_params->valid_devs[0], qp_id, &qp_conf,
687 rte_cryptodev_socket_id(
688 ts_params->valid_devs[0])),
690 "rte_cryptodev_queue_pair_setup: num_inflights "
691 "%u on qp %u on cryptodev %u",
692 qp_conf.nb_descriptors, qp_id,
693 ts_params->valid_devs[0]);
696 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
698 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
699 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
700 ts_params->valid_devs[0], qp_id, &qp_conf,
701 rte_cryptodev_socket_id(
702 ts_params->valid_devs[0])),
704 " rte_cryptodev_queue_pair_setup: num_inflights"
705 " %u on qp %u on cryptodev %u",
706 qp_conf.nb_descriptors, qp_id,
707 ts_params->valid_devs[0]);
710 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
712 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
713 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
714 ts_params->valid_devs[0], qp_id, &qp_conf,
715 rte_cryptodev_socket_id(
716 ts_params->valid_devs[0])),
718 "rte_cryptodev_queue_pair_setup: num_inflights"
719 " %u on qp %u on cryptodev %u",
720 qp_conf.nb_descriptors, qp_id,
721 ts_params->valid_devs[0]);
724 /* invalid number of descriptors - max supported + 2 */
725 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
727 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
728 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
729 ts_params->valid_devs[0], qp_id, &qp_conf,
730 rte_cryptodev_socket_id(
731 ts_params->valid_devs[0])),
732 "Unexpectedly passed test for "
733 "rte_cryptodev_queue_pair_setup:"
734 "num_inflights %u on qp %u on cryptodev %u",
735 qp_conf.nb_descriptors, qp_id,
736 ts_params->valid_devs[0]);
739 /* invalid number of descriptors - max value of parameter */
740 qp_conf.nb_descriptors = UINT32_MAX-1;
742 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
743 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
744 ts_params->valid_devs[0], qp_id, &qp_conf,
745 rte_cryptodev_socket_id(
746 ts_params->valid_devs[0])),
747 "Unexpectedly passed test for "
748 "rte_cryptodev_queue_pair_setup:"
749 "num_inflights %u on qp %u on cryptodev %u",
750 qp_conf.nb_descriptors, qp_id,
751 ts_params->valid_devs[0]);
754 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
756 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
757 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
758 ts_params->valid_devs[0], qp_id, &qp_conf,
759 rte_cryptodev_socket_id(
760 ts_params->valid_devs[0])),
762 " rte_cryptodev_queue_pair_setup:"
763 "num_inflights %u on qp %u on cryptodev %u",
764 qp_conf.nb_descriptors, qp_id,
765 ts_params->valid_devs[0]);
768 /* invalid number of descriptors - max supported + 1 */
769 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
771 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
772 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
773 ts_params->valid_devs[0], qp_id, &qp_conf,
774 rte_cryptodev_socket_id(
775 ts_params->valid_devs[0])),
776 "Unexpectedly passed test for "
777 "rte_cryptodev_queue_pair_setup:"
778 "num_inflights %u on qp %u on cryptodev %u",
779 qp_conf.nb_descriptors, qp_id,
780 ts_params->valid_devs[0]);
783 /* test invalid queue pair id */
784 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
786 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
788 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
789 ts_params->valid_devs[0],
791 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
792 "Failed test for rte_cryptodev_queue_pair_setup:"
793 "invalid qp %u on cryptodev %u",
794 qp_id, ts_params->valid_devs[0]);
796 qp_id = 0xffff; /*invalid*/
798 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
799 ts_params->valid_devs[0],
801 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
802 "Failed test for rte_cryptodev_queue_pair_setup:"
803 "invalid qp %u on cryptodev %u",
804 qp_id, ts_params->valid_devs[0]);
809 /* ***** Plaintext data for tests ***** */
811 const char catch_22_quote_1[] =
812 "There was only one catch and that was Catch-22, which "
813 "specified that a concern for one's safety in the face of "
814 "dangers that were real and immediate was the process of a "
815 "rational mind. Orr was crazy and could be grounded. All he "
816 "had to do was ask; and as soon as he did, he would no longer "
817 "be crazy and would have to fly more missions. Orr would be "
818 "crazy to fly more missions and sane if he didn't, but if he "
819 "was sane he had to fly them. If he flew them he was crazy "
820 "and didn't have to; but if he didn't want to he was sane and "
821 "had to. Yossarian was moved very deeply by the absolute "
822 "simplicity of this clause of Catch-22 and let out a "
823 "respectful whistle. \"That's some catch, that Catch-22\", he "
824 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
826 const char catch_22_quote[] =
827 "What a lousy earth! He wondered how many people were "
828 "destitute that same night even in his own prosperous country, "
829 "how many homes were shanties, how many husbands were drunk "
830 "and wives socked, and how many children were bullied, abused, "
831 "or abandoned. How many families hungered for food they could "
832 "not afford to buy? How many hearts were broken? How many "
833 "suicides would take place that same night, how many people "
834 "would go insane? How many cockroaches and landlords would "
835 "triumph? How many winners were losers, successes failures, "
836 "and rich men poor men? How many wise guys were stupid? How "
837 "many happy endings were unhappy endings? How many honest men "
838 "were liars, brave men cowards, loyal men traitors, how many "
839 "sainted men were corrupt, how many people in positions of "
840 "trust had sold their souls to bodyguards, how many had never "
841 "had souls? How many straight-and-narrow paths were crooked "
842 "paths? How many best families were worst families and how "
843 "many good people were bad people? When you added them all up "
844 "and then subtracted, you might be left with only the children, "
845 "and perhaps with Albert Einstein and an old violinist or "
846 "sculptor somewhere.";
848 #define QUOTE_480_BYTES (480)
849 #define QUOTE_512_BYTES (512)
850 #define QUOTE_768_BYTES (768)
851 #define QUOTE_1024_BYTES (1024)
855 /* ***** SHA1 Hash Tests ***** */
857 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
859 static uint8_t hmac_sha1_key[] = {
860 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
861 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
862 0xDE, 0xF4, 0xDE, 0xAD };
864 /* ***** SHA224 Hash Tests ***** */
866 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
869 /* ***** AES-CBC Cipher Tests ***** */
871 #define CIPHER_KEY_LENGTH_AES_CBC (16)
872 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
874 static uint8_t aes_cbc_key[] = {
875 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
876 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
878 static uint8_t aes_cbc_iv[] = {
879 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
880 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
883 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
885 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
886 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
887 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
888 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
889 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
890 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
891 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
892 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
893 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
894 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
895 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
896 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
897 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
898 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
899 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
900 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
901 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
902 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
903 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
904 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
905 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
906 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
907 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
908 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
909 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
910 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
911 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
912 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
913 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
914 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
915 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
916 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
917 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
918 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
919 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
920 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
921 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
922 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
923 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
924 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
925 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
926 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
927 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
928 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
929 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
930 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
931 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
932 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
933 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
934 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
935 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
936 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
937 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
938 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
939 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
940 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
941 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
942 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
943 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
944 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
945 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
946 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
947 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
948 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
949 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
952 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
953 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
954 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
955 0x18, 0x8c, 0x1d, 0x32
959 /* Multisession Vector context Test */
961 static uint8_t ms_aes_cbc_key0[] = {
962 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
963 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
966 static uint8_t ms_aes_cbc_iv0[] = {
967 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
968 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
971 static const uint8_t ms_aes_cbc_cipher0[] = {
972 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
973 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
974 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
975 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
976 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
977 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
978 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
979 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
980 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
981 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
982 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
983 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
984 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
985 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
986 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
987 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
988 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
989 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
990 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
991 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
992 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
993 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
994 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
995 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
996 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
997 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
998 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
999 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1000 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1001 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1002 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1003 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1004 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1005 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1006 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1007 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1008 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1009 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1010 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1011 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1012 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1013 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1014 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1015 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1016 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1017 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1018 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1019 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1020 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1021 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1022 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1023 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1024 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1025 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1026 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1027 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1028 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1029 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1030 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1031 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1032 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1033 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1034 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1035 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1039 static uint8_t ms_hmac_key0[] = {
1040 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1041 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1042 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1043 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1044 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1045 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1046 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1047 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1050 static const uint8_t ms_hmac_digest0[] = {
1051 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1052 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1053 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1054 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1055 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1056 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1057 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1058 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1062 /* Begin session 1 */
1064 static uint8_t ms_aes_cbc_key1[] = {
1065 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1066 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1069 static uint8_t ms_aes_cbc_iv1[] = {
1070 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1071 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1074 static const uint8_t ms_aes_cbc_cipher1[] = {
1075 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1076 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1077 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1078 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1079 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1080 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1081 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1082 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1083 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1084 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1085 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1086 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1087 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1088 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1089 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1090 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1091 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1092 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1093 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1094 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1095 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1096 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1097 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1098 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1099 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1100 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1101 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1102 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1103 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1104 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1105 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1106 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1107 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1108 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1109 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1110 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1111 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1112 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1113 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1114 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1115 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1116 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1117 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1118 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1119 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1120 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1121 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1122 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1123 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1124 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1125 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1126 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1127 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1128 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1129 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1130 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1131 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1132 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1133 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1134 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1135 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1136 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1137 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1138 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1142 static uint8_t ms_hmac_key1[] = {
1143 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1144 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1145 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1146 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1147 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1148 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1149 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1150 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1153 static const uint8_t ms_hmac_digest1[] = {
1154 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1155 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1156 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1157 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1158 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1159 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1160 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1161 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1164 /* Begin Session 2 */
1165 static uint8_t ms_aes_cbc_key2[] = {
1166 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1167 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1170 static uint8_t ms_aes_cbc_iv2[] = {
1171 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1172 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1175 static const uint8_t ms_aes_cbc_cipher2[] = {
1176 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1177 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1178 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1179 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1180 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1181 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1182 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1183 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1184 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1185 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1186 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1187 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1188 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1189 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1190 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1191 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1192 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1193 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1194 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1195 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1196 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1197 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1198 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1199 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1200 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1201 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1202 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1203 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1204 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1205 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1206 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1207 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1208 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1209 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1210 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1211 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1212 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1213 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1214 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1215 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1216 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1217 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1218 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1219 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1220 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1221 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1222 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1223 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1224 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1225 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1226 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1227 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1228 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1229 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1230 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1231 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1232 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1233 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1234 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1235 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1236 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1237 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1238 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1239 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1242 static uint8_t ms_hmac_key2[] = {
1243 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1244 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1245 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1246 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1247 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1248 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1249 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1250 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1253 static const uint8_t ms_hmac_digest2[] = {
1254 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1255 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1256 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1257 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1258 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1259 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1260 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1261 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1268 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1270 struct crypto_testsuite_params *ts_params = &testsuite_params;
1271 struct crypto_unittest_params *ut_params = &unittest_params;
1273 /* Generate test mbuf data and space for digest */
1274 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1275 catch_22_quote, QUOTE_512_BYTES, 0);
1277 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1278 DIGEST_BYTE_LENGTH_SHA1);
1279 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1281 /* Setup Cipher Parameters */
1282 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1283 ut_params->cipher_xform.next = &ut_params->auth_xform;
1285 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1286 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1287 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1288 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1290 /* Setup HMAC Parameters */
1291 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1293 ut_params->auth_xform.next = NULL;
1295 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1296 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1297 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1298 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1299 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1301 /* Create crypto session*/
1302 ut_params->sess = rte_cryptodev_sym_session_create(
1303 ts_params->valid_devs[0],
1304 &ut_params->cipher_xform);
1305 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1307 /* Generate crypto op data structure */
1308 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1309 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1310 TEST_ASSERT_NOT_NULL(ut_params->op,
1311 "Failed to allocate symmetric crypto operation struct");
1313 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1315 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1317 /* set crypto operation source mbuf */
1318 sym_op->m_src = ut_params->ibuf;
1320 /* Set crypto operation authentication parameters */
1321 sym_op->auth.digest.data = ut_params->digest;
1322 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1323 ut_params->ibuf, QUOTE_512_BYTES);
1324 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1326 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1327 sym_op->auth.data.length = QUOTE_512_BYTES;
1329 /* Set crypto operation cipher parameters */
1330 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1331 CIPHER_IV_LENGTH_AES_CBC);
1332 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1333 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1335 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1336 CIPHER_IV_LENGTH_AES_CBC);
1338 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1339 sym_op->cipher.data.length = QUOTE_512_BYTES;
1341 /* Process crypto operation */
1342 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1343 ut_params->op), "failed to process sym crypto op");
1345 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1346 "crypto op processing failed");
1349 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1350 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1352 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1353 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1355 "ciphertext data not as expected");
1357 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1359 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1360 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1361 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1362 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1363 DIGEST_BYTE_LENGTH_SHA1,
1364 "Generated digest data not as expected");
1366 return TEST_SUCCESS;
1369 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1371 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1373 static uint8_t hmac_sha512_key[] = {
1374 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1375 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1376 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1377 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1378 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1379 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1380 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1381 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1383 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1384 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1385 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1386 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1387 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1388 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1389 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1390 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1391 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1396 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1397 struct crypto_unittest_params *ut_params,
1398 uint8_t *cipher_key,
1402 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1403 struct crypto_unittest_params *ut_params,
1404 struct crypto_testsuite_params *ts_params,
1405 const uint8_t *cipher,
1406 const uint8_t *digest,
1411 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1412 struct crypto_unittest_params *ut_params,
1413 uint8_t *cipher_key,
1417 /* Setup Cipher Parameters */
1418 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1419 ut_params->cipher_xform.next = NULL;
1421 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1422 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1423 ut_params->cipher_xform.cipher.key.data = cipher_key;
1424 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1426 /* Setup HMAC Parameters */
1427 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1428 ut_params->auth_xform.next = &ut_params->cipher_xform;
1430 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1431 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1432 ut_params->auth_xform.auth.key.data = hmac_key;
1433 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1434 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1436 return TEST_SUCCESS;
1441 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1442 struct crypto_unittest_params *ut_params,
1443 struct crypto_testsuite_params *ts_params,
1444 const uint8_t *cipher,
1445 const uint8_t *digest,
1448 /* Generate test mbuf data and digest */
1449 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1452 QUOTE_512_BYTES, 0);
1454 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1455 DIGEST_BYTE_LENGTH_SHA512);
1456 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1458 rte_memcpy(ut_params->digest,
1460 DIGEST_BYTE_LENGTH_SHA512);
1462 /* Generate Crypto op data structure */
1463 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1464 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1465 TEST_ASSERT_NOT_NULL(ut_params->op,
1466 "Failed to allocate symmetric crypto operation struct");
1468 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1470 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1472 /* set crypto operation source mbuf */
1473 sym_op->m_src = ut_params->ibuf;
1475 sym_op->auth.digest.data = ut_params->digest;
1476 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1477 ut_params->ibuf, QUOTE_512_BYTES);
1478 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1480 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1481 sym_op->auth.data.length = QUOTE_512_BYTES;
1483 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1484 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1485 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1486 ut_params->ibuf, 0);
1487 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1489 rte_memcpy(sym_op->cipher.iv.data, iv,
1490 CIPHER_IV_LENGTH_AES_CBC);
1492 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1493 sym_op->cipher.data.length = QUOTE_512_BYTES;
1495 /* Process crypto operation */
1496 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1497 ut_params->op), "failed to process sym crypto op");
1499 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1500 "crypto op processing failed");
1502 ut_params->obuf = ut_params->op->sym->m_src;
1505 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1506 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1507 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1509 "Plaintext data not as expected");
1512 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1513 "Digest verification failed");
1515 return TEST_SUCCESS;
1519 test_AES_cipheronly_mb_all(void)
1521 struct crypto_testsuite_params *ts_params = &testsuite_params;
1524 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1525 ts_params->op_mpool, ts_params->valid_devs[0],
1526 RTE_CRYPTODEV_AESNI_MB_PMD,
1527 BLKCIPHER_AES_CIPHERONLY_TYPE);
1529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1531 return TEST_SUCCESS;
1535 test_AES_docsis_mb_all(void)
1537 struct crypto_testsuite_params *ts_params = &testsuite_params;
1540 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1541 ts_params->op_mpool, ts_params->valid_devs[0],
1542 RTE_CRYPTODEV_AESNI_MB_PMD,
1543 BLKCIPHER_AES_DOCSIS_TYPE);
1545 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1547 return TEST_SUCCESS;
1551 test_authonly_mb_all(void)
1553 struct crypto_testsuite_params *ts_params = &testsuite_params;
1556 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1557 ts_params->op_mpool, ts_params->valid_devs[0],
1558 RTE_CRYPTODEV_AESNI_MB_PMD,
1559 BLKCIPHER_AUTHONLY_TYPE);
1561 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1563 return TEST_SUCCESS;
1567 test_AES_chain_mb_all(void)
1569 struct crypto_testsuite_params *ts_params = &testsuite_params;
1572 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1573 ts_params->op_mpool, ts_params->valid_devs[0],
1574 RTE_CRYPTODEV_AESNI_MB_PMD,
1575 BLKCIPHER_AES_CHAIN_TYPE);
1577 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1579 return TEST_SUCCESS;
1582 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1585 test_AES_cipheronly_scheduler_all(void)
1587 struct crypto_testsuite_params *ts_params = &testsuite_params;
1590 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1591 ts_params->op_mpool, ts_params->valid_devs[0],
1592 RTE_CRYPTODEV_SCHEDULER_PMD,
1593 BLKCIPHER_AES_CIPHERONLY_TYPE);
1595 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1597 return TEST_SUCCESS;
1601 test_AES_chain_scheduler_all(void)
1603 struct crypto_testsuite_params *ts_params = &testsuite_params;
1606 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1607 ts_params->op_mpool, ts_params->valid_devs[0],
1608 RTE_CRYPTODEV_SCHEDULER_PMD,
1609 BLKCIPHER_AES_CHAIN_TYPE);
1611 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1613 return TEST_SUCCESS;
1617 test_authonly_scheduler_all(void)
1619 struct crypto_testsuite_params *ts_params = &testsuite_params;
1622 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1623 ts_params->op_mpool, ts_params->valid_devs[0],
1624 RTE_CRYPTODEV_SCHEDULER_PMD,
1625 BLKCIPHER_AUTHONLY_TYPE);
1627 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1629 return TEST_SUCCESS;
1632 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1635 test_AES_chain_openssl_all(void)
1637 struct crypto_testsuite_params *ts_params = &testsuite_params;
1640 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1641 ts_params->op_mpool, ts_params->valid_devs[0],
1642 RTE_CRYPTODEV_OPENSSL_PMD,
1643 BLKCIPHER_AES_CHAIN_TYPE);
1645 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1647 return TEST_SUCCESS;
1651 test_AES_cipheronly_openssl_all(void)
1653 struct crypto_testsuite_params *ts_params = &testsuite_params;
1656 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1657 ts_params->op_mpool, ts_params->valid_devs[0],
1658 RTE_CRYPTODEV_OPENSSL_PMD,
1659 BLKCIPHER_AES_CIPHERONLY_TYPE);
1661 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1663 return TEST_SUCCESS;
1667 test_AES_chain_qat_all(void)
1669 struct crypto_testsuite_params *ts_params = &testsuite_params;
1672 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1673 ts_params->op_mpool, ts_params->valid_devs[0],
1674 RTE_CRYPTODEV_QAT_SYM_PMD,
1675 BLKCIPHER_AES_CHAIN_TYPE);
1677 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1679 return TEST_SUCCESS;
1683 test_AES_cipheronly_qat_all(void)
1685 struct crypto_testsuite_params *ts_params = &testsuite_params;
1688 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1689 ts_params->op_mpool, ts_params->valid_devs[0],
1690 RTE_CRYPTODEV_QAT_SYM_PMD,
1691 BLKCIPHER_AES_CIPHERONLY_TYPE);
1693 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1695 return TEST_SUCCESS;
1699 test_authonly_openssl_all(void)
1701 struct crypto_testsuite_params *ts_params = &testsuite_params;
1704 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1705 ts_params->op_mpool, ts_params->valid_devs[0],
1706 RTE_CRYPTODEV_OPENSSL_PMD,
1707 BLKCIPHER_AUTHONLY_TYPE);
1709 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1711 return TEST_SUCCESS;
1715 test_AES_chain_armv8_all(void)
1717 struct crypto_testsuite_params *ts_params = &testsuite_params;
1720 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1721 ts_params->op_mpool, ts_params->valid_devs[0],
1722 RTE_CRYPTODEV_ARMV8_PMD,
1723 BLKCIPHER_AES_CHAIN_TYPE);
1725 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1727 return TEST_SUCCESS;
1730 /* ***** SNOW 3G Tests ***** */
1732 create_wireless_algo_hash_session(uint8_t dev_id,
1733 const uint8_t *key, const uint8_t key_len,
1734 const uint8_t aad_len, const uint8_t auth_len,
1735 enum rte_crypto_auth_operation op,
1736 enum rte_crypto_auth_algorithm algo)
1738 uint8_t hash_key[key_len];
1740 struct crypto_unittest_params *ut_params = &unittest_params;
1742 memcpy(hash_key, key, key_len);
1744 TEST_HEXDUMP(stdout, "key:", key, key_len);
1746 /* Setup Authentication Parameters */
1747 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1748 ut_params->auth_xform.next = NULL;
1750 ut_params->auth_xform.auth.op = op;
1751 ut_params->auth_xform.auth.algo = algo;
1752 ut_params->auth_xform.auth.key.length = key_len;
1753 ut_params->auth_xform.auth.key.data = hash_key;
1754 ut_params->auth_xform.auth.digest_length = auth_len;
1755 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1756 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1757 &ut_params->auth_xform);
1758 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1763 create_wireless_algo_cipher_session(uint8_t dev_id,
1764 enum rte_crypto_cipher_operation op,
1765 enum rte_crypto_cipher_algorithm algo,
1766 const uint8_t *key, const uint8_t key_len)
1768 uint8_t cipher_key[key_len];
1770 struct crypto_unittest_params *ut_params = &unittest_params;
1772 memcpy(cipher_key, key, key_len);
1774 /* Setup Cipher Parameters */
1775 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1776 ut_params->cipher_xform.next = NULL;
1778 ut_params->cipher_xform.cipher.algo = algo;
1779 ut_params->cipher_xform.cipher.op = op;
1780 ut_params->cipher_xform.cipher.key.data = cipher_key;
1781 ut_params->cipher_xform.cipher.key.length = key_len;
1783 TEST_HEXDUMP(stdout, "key:", key, key_len);
1785 /* Create Crypto session */
1786 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1789 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1794 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1795 const unsigned cipher_len,
1796 const unsigned cipher_offset,
1797 enum rte_crypto_cipher_algorithm algo)
1799 struct crypto_testsuite_params *ts_params = &testsuite_params;
1800 struct crypto_unittest_params *ut_params = &unittest_params;
1801 unsigned iv_pad_len = 0;
1803 /* Generate Crypto op data structure */
1804 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1805 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1806 TEST_ASSERT_NOT_NULL(ut_params->op,
1807 "Failed to allocate pktmbuf offload");
1809 /* Set crypto operation data parameters */
1810 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1812 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1814 /* set crypto operation source mbuf */
1815 sym_op->m_src = ut_params->ibuf;
1818 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1819 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1821 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1823 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1826 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1828 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1829 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1830 sym_op->cipher.iv.length = iv_pad_len;
1832 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1833 sym_op->cipher.data.length = cipher_len;
1834 sym_op->cipher.data.offset = cipher_offset;
1839 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1840 const unsigned cipher_len,
1841 const unsigned cipher_offset,
1842 enum rte_crypto_cipher_algorithm algo)
1844 struct crypto_testsuite_params *ts_params = &testsuite_params;
1845 struct crypto_unittest_params *ut_params = &unittest_params;
1846 unsigned iv_pad_len = 0;
1848 /* Generate Crypto op data structure */
1849 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1850 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1851 TEST_ASSERT_NOT_NULL(ut_params->op,
1852 "Failed to allocate pktmbuf offload");
1854 /* Set crypto operation data parameters */
1855 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1857 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1859 /* set crypto operation source mbuf */
1860 sym_op->m_src = ut_params->ibuf;
1861 sym_op->m_dst = ut_params->obuf;
1864 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1865 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1867 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1868 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1871 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1873 /* For OOP operation both buffers must have the same size */
1874 if (ut_params->obuf)
1875 rte_pktmbuf_prepend(ut_params->obuf, iv_pad_len);
1877 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1878 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1879 sym_op->cipher.iv.length = iv_pad_len;
1881 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1882 sym_op->cipher.data.length = cipher_len;
1883 sym_op->cipher.data.offset = cipher_offset;
1888 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1889 enum rte_crypto_cipher_operation cipher_op,
1890 enum rte_crypto_auth_operation auth_op,
1891 enum rte_crypto_auth_algorithm auth_algo,
1892 enum rte_crypto_cipher_algorithm cipher_algo,
1893 const uint8_t *key, const uint8_t key_len,
1894 const uint8_t aad_len, const uint8_t auth_len)
1897 uint8_t cipher_auth_key[key_len];
1899 struct crypto_unittest_params *ut_params = &unittest_params;
1901 memcpy(cipher_auth_key, key, key_len);
1903 /* Setup Authentication Parameters */
1904 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1905 ut_params->auth_xform.next = NULL;
1907 ut_params->auth_xform.auth.op = auth_op;
1908 ut_params->auth_xform.auth.algo = auth_algo;
1909 ut_params->auth_xform.auth.key.length = key_len;
1910 /* Hash key = cipher key */
1911 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1912 ut_params->auth_xform.auth.digest_length = auth_len;
1913 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1915 /* Setup Cipher Parameters */
1916 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1917 ut_params->cipher_xform.next = &ut_params->auth_xform;
1919 ut_params->cipher_xform.cipher.algo = cipher_algo;
1920 ut_params->cipher_xform.cipher.op = cipher_op;
1921 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1922 ut_params->cipher_xform.cipher.key.length = key_len;
1924 TEST_HEXDUMP(stdout, "key:", key, key_len);
1926 /* Create Crypto session*/
1927 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1928 &ut_params->cipher_xform);
1930 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1935 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1936 enum rte_crypto_cipher_operation cipher_op,
1937 enum rte_crypto_auth_operation auth_op,
1938 enum rte_crypto_auth_algorithm auth_algo,
1939 enum rte_crypto_cipher_algorithm cipher_algo,
1940 const uint8_t *key, const uint8_t key_len,
1941 const uint8_t aad_len, const uint8_t auth_len)
1943 uint8_t auth_cipher_key[key_len];
1945 struct crypto_unittest_params *ut_params = &unittest_params;
1947 memcpy(auth_cipher_key, key, key_len);
1949 /* Setup Authentication Parameters */
1950 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1951 ut_params->auth_xform.auth.op = auth_op;
1952 ut_params->auth_xform.next = &ut_params->cipher_xform;
1953 ut_params->auth_xform.auth.algo = auth_algo;
1954 ut_params->auth_xform.auth.key.length = key_len;
1955 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1956 ut_params->auth_xform.auth.digest_length = auth_len;
1957 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1959 /* Setup Cipher Parameters */
1960 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1961 ut_params->cipher_xform.next = NULL;
1962 ut_params->cipher_xform.cipher.algo = cipher_algo;
1963 ut_params->cipher_xform.cipher.op = cipher_op;
1964 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1965 ut_params->cipher_xform.cipher.key.length = key_len;
1967 TEST_HEXDUMP(stdout, "key:", key, key_len);
1969 /* Create Crypto session*/
1970 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1971 &ut_params->auth_xform);
1973 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1979 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1980 const unsigned auth_tag_len,
1981 const uint8_t *aad, const unsigned aad_len,
1982 unsigned data_pad_len,
1983 enum rte_crypto_auth_operation op,
1984 enum rte_crypto_auth_algorithm algo,
1985 const unsigned auth_len, const unsigned auth_offset)
1987 struct crypto_testsuite_params *ts_params = &testsuite_params;
1989 struct crypto_unittest_params *ut_params = &unittest_params;
1991 unsigned aad_buffer_len;
1993 /* Generate Crypto op data structure */
1994 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1995 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1996 TEST_ASSERT_NOT_NULL(ut_params->op,
1997 "Failed to allocate pktmbuf offload");
1999 /* Set crypto operation data parameters */
2000 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2002 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2004 /* set crypto operation source mbuf */
2005 sym_op->m_src = ut_params->ibuf;
2009 * Always allocate the aad up to the block size.
2010 * The cryptodev API calls out -
2011 * - the array must be big enough to hold the AAD, plus any
2012 * space to round this up to the nearest multiple of the
2013 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2015 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2016 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2018 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2019 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2020 ut_params->ibuf, aad_buffer_len);
2021 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2022 "no room to prepend aad");
2023 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2025 sym_op->auth.aad.length = aad_len;
2027 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2028 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2030 TEST_HEXDUMP(stdout, "aad:",
2031 sym_op->auth.aad.data, aad_len);
2034 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2035 ut_params->ibuf, auth_tag_len);
2037 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2038 "no room to append auth tag");
2039 ut_params->digest = sym_op->auth.digest.data;
2040 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2041 ut_params->ibuf, data_pad_len + aad_len);
2042 sym_op->auth.digest.length = auth_tag_len;
2043 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2044 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2046 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2048 TEST_HEXDUMP(stdout, "digest:",
2049 sym_op->auth.digest.data,
2050 sym_op->auth.digest.length);
2052 sym_op->auth.data.length = auth_len;
2053 sym_op->auth.data.offset = auth_offset;
2059 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2060 const unsigned auth_tag_len,
2061 const uint8_t *aad, const uint8_t aad_len,
2062 unsigned data_pad_len,
2063 enum rte_crypto_auth_operation op,
2064 enum rte_crypto_auth_algorithm auth_algo,
2065 enum rte_crypto_cipher_algorithm cipher_algo,
2066 const uint8_t *iv, const uint8_t iv_len,
2067 const unsigned cipher_len, const unsigned cipher_offset,
2068 const unsigned auth_len, const unsigned auth_offset)
2070 struct crypto_testsuite_params *ts_params = &testsuite_params;
2071 struct crypto_unittest_params *ut_params = &unittest_params;
2073 unsigned iv_pad_len = 0;
2074 unsigned aad_buffer_len;
2076 /* Generate Crypto op data structure */
2077 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2078 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2079 TEST_ASSERT_NOT_NULL(ut_params->op,
2080 "Failed to allocate pktmbuf offload");
2081 /* Set crypto operation data parameters */
2082 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2084 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2086 /* set crypto operation source mbuf */
2087 sym_op->m_src = ut_params->ibuf;
2090 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2091 ut_params->ibuf, auth_tag_len);
2093 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2094 "no room to append auth tag");
2095 ut_params->digest = sym_op->auth.digest.data;
2096 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2097 ut_params->ibuf, data_pad_len);
2098 sym_op->auth.digest.length = auth_tag_len;
2099 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2100 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2102 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2104 TEST_HEXDUMP(stdout, "digest:",
2105 sym_op->auth.digest.data,
2106 sym_op->auth.digest.length);
2110 * Always allocate the aad up to the block size.
2111 * The cryptodev API calls out -
2112 * - the array must be big enough to hold the AAD, plus any
2113 * space to round this up to the nearest multiple of the
2114 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2116 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2117 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2119 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2120 sym_op->auth.aad.data =
2121 (uint8_t *)rte_pktmbuf_prepend(
2122 ut_params->ibuf, aad_buffer_len);
2123 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2124 "no room to prepend aad");
2125 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2127 sym_op->auth.aad.length = aad_len;
2128 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2129 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2130 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2133 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2134 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2136 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2137 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2138 ut_params->ibuf, iv_pad_len);
2140 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2141 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2142 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2143 sym_op->cipher.iv.length = iv_pad_len;
2144 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2145 sym_op->cipher.data.length = cipher_len;
2146 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2147 sym_op->auth.data.length = auth_len;
2148 sym_op->auth.data.offset = auth_offset + cipher_offset;
2154 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2155 const uint8_t *iv, const uint8_t iv_len,
2156 const uint8_t *aad, const uint8_t aad_len,
2157 unsigned data_pad_len,
2158 const unsigned cipher_len, const unsigned cipher_offset,
2159 const unsigned auth_len, const unsigned auth_offset,
2160 enum rte_crypto_auth_algorithm auth_algo,
2161 enum rte_crypto_cipher_algorithm cipher_algo)
2163 struct crypto_testsuite_params *ts_params = &testsuite_params;
2164 struct crypto_unittest_params *ut_params = &unittest_params;
2166 unsigned iv_pad_len = 0;
2167 unsigned aad_buffer_len = 0;
2169 /* Generate Crypto op data structure */
2170 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2171 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2172 TEST_ASSERT_NOT_NULL(ut_params->op,
2173 "Failed to allocate pktmbuf offload");
2175 /* Set crypto operation data parameters */
2176 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2178 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2180 /* set crypto operation source mbuf */
2181 sym_op->m_src = ut_params->ibuf;
2184 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2185 ut_params->ibuf, auth_tag_len);
2187 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2188 "no room to append auth tag");
2190 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2191 ut_params->ibuf, data_pad_len);
2192 sym_op->auth.digest.length = auth_tag_len;
2194 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2196 TEST_HEXDUMP(stdout, "digest:",
2197 sym_op->auth.digest.data,
2198 sym_op->auth.digest.length);
2202 * Always allocate the aad up to the block size.
2203 * The cryptodev API calls out -
2204 * - the array must be big enough to hold the AAD, plus any
2205 * space to round this up to the nearest multiple of the
2206 * block size (8 bytes for KASUMI 16 bytes).
2208 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2209 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2211 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2212 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2213 ut_params->ibuf, aad_buffer_len);
2214 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2215 "no room to prepend aad");
2216 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2218 sym_op->auth.aad.length = aad_len;
2219 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2220 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2221 TEST_HEXDUMP(stdout, "aad:",
2222 sym_op->auth.aad.data, aad_len);
2225 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2226 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2228 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2230 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2231 ut_params->ibuf, iv_pad_len);
2232 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2234 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2235 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2236 sym_op->cipher.iv.length = iv_pad_len;
2238 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2240 sym_op->cipher.data.length = cipher_len;
2241 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2243 sym_op->auth.data.length = auth_len;
2244 sym_op->auth.data.offset = auth_offset + cipher_offset;
2250 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2252 struct crypto_testsuite_params *ts_params = &testsuite_params;
2253 struct crypto_unittest_params *ut_params = &unittest_params;
2256 unsigned plaintext_pad_len;
2257 unsigned plaintext_len;
2260 /* Create SNOW 3G session */
2261 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2262 tdata->key.data, tdata->key.len,
2263 tdata->aad.len, tdata->digest.len,
2264 RTE_CRYPTO_AUTH_OP_GENERATE,
2265 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2269 /* alloc mbuf and set payload */
2270 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2272 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2273 rte_pktmbuf_tailroom(ut_params->ibuf));
2275 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2276 /* Append data which is padded to a multiple of */
2277 /* the algorithms block size */
2278 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2279 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2281 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2283 /* Create SNOW 3G operation */
2284 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2285 tdata->aad.data, tdata->aad.len,
2286 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2287 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2288 tdata->validAuthLenInBits.len,
2289 tdata->validAuthOffsetLenInBits.len);
2293 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2295 ut_params->obuf = ut_params->op->sym->m_src;
2296 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2297 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2298 + plaintext_pad_len + tdata->aad.len;
2301 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2304 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2305 "SNOW 3G Generated auth tag not as expected");
2311 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2313 struct crypto_testsuite_params *ts_params = &testsuite_params;
2314 struct crypto_unittest_params *ut_params = &unittest_params;
2317 unsigned plaintext_pad_len;
2318 unsigned plaintext_len;
2321 /* Create SNOW 3G session */
2322 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2323 tdata->key.data, tdata->key.len,
2324 tdata->aad.len, tdata->digest.len,
2325 RTE_CRYPTO_AUTH_OP_VERIFY,
2326 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2329 /* alloc mbuf and set payload */
2330 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2332 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2333 rte_pktmbuf_tailroom(ut_params->ibuf));
2335 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2336 /* Append data which is padded to a multiple of */
2337 /* the algorithms block size */
2338 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2339 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2341 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2343 /* Create SNOW 3G operation */
2344 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2346 tdata->aad.data, tdata->aad.len,
2348 RTE_CRYPTO_AUTH_OP_VERIFY,
2349 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2350 tdata->validAuthLenInBits.len,
2351 tdata->validAuthOffsetLenInBits.len);
2355 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2357 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2358 ut_params->obuf = ut_params->op->sym->m_src;
2359 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2360 + plaintext_pad_len + tdata->aad.len;
2363 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2372 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2374 struct crypto_testsuite_params *ts_params = &testsuite_params;
2375 struct crypto_unittest_params *ut_params = &unittest_params;
2378 unsigned plaintext_pad_len;
2379 unsigned plaintext_len;
2382 /* Create KASUMI session */
2383 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2384 tdata->key.data, tdata->key.len,
2385 tdata->aad.len, tdata->digest.len,
2386 RTE_CRYPTO_AUTH_OP_GENERATE,
2387 RTE_CRYPTO_AUTH_KASUMI_F9);
2391 /* alloc mbuf and set payload */
2392 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2394 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2395 rte_pktmbuf_tailroom(ut_params->ibuf));
2397 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2398 /* Append data which is padded to a multiple of */
2399 /* the algorithms block size */
2400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2401 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2403 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2405 /* Create KASUMI operation */
2406 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2407 tdata->aad.data, tdata->aad.len,
2408 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2409 RTE_CRYPTO_AUTH_KASUMI_F9,
2410 tdata->validAuthLenInBits.len,
2411 tdata->validAuthOffsetLenInBits.len);
2415 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2417 ut_params->obuf = ut_params->op->sym->m_src;
2418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2419 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2420 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2423 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2426 DIGEST_BYTE_LENGTH_KASUMI_F9,
2427 "KASUMI Generated auth tag not as expected");
2433 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2435 struct crypto_testsuite_params *ts_params = &testsuite_params;
2436 struct crypto_unittest_params *ut_params = &unittest_params;
2439 unsigned plaintext_pad_len;
2440 unsigned plaintext_len;
2443 /* Create KASUMI session */
2444 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2445 tdata->key.data, tdata->key.len,
2446 tdata->aad.len, tdata->digest.len,
2447 RTE_CRYPTO_AUTH_OP_VERIFY,
2448 RTE_CRYPTO_AUTH_KASUMI_F9);
2451 /* alloc mbuf and set payload */
2452 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2454 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2455 rte_pktmbuf_tailroom(ut_params->ibuf));
2457 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2458 /* Append data which is padded to a multiple */
2459 /* of the algorithms block size */
2460 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2461 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2463 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2465 /* Create KASUMI operation */
2466 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2468 tdata->aad.data, tdata->aad.len,
2470 RTE_CRYPTO_AUTH_OP_VERIFY,
2471 RTE_CRYPTO_AUTH_KASUMI_F9,
2472 tdata->validAuthLenInBits.len,
2473 tdata->validAuthOffsetLenInBits.len);
2477 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2479 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2480 ut_params->obuf = ut_params->op->sym->m_src;
2481 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2482 + plaintext_pad_len + tdata->aad.len;
2485 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2494 test_snow3g_hash_generate_test_case_1(void)
2496 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2500 test_snow3g_hash_generate_test_case_2(void)
2502 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2506 test_snow3g_hash_generate_test_case_3(void)
2508 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2512 test_snow3g_hash_generate_test_case_4(void)
2514 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2518 test_snow3g_hash_generate_test_case_5(void)
2520 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2524 test_snow3g_hash_generate_test_case_6(void)
2526 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2530 test_snow3g_hash_verify_test_case_1(void)
2532 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2537 test_snow3g_hash_verify_test_case_2(void)
2539 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2543 test_snow3g_hash_verify_test_case_3(void)
2545 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2549 test_snow3g_hash_verify_test_case_4(void)
2551 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2555 test_snow3g_hash_verify_test_case_5(void)
2557 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2561 test_snow3g_hash_verify_test_case_6(void)
2563 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2567 test_kasumi_hash_generate_test_case_1(void)
2569 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2573 test_kasumi_hash_generate_test_case_2(void)
2575 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2579 test_kasumi_hash_generate_test_case_3(void)
2581 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2585 test_kasumi_hash_generate_test_case_4(void)
2587 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2591 test_kasumi_hash_generate_test_case_5(void)
2593 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2597 test_kasumi_hash_generate_test_case_6(void)
2599 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2603 test_kasumi_hash_verify_test_case_1(void)
2605 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2609 test_kasumi_hash_verify_test_case_2(void)
2611 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2615 test_kasumi_hash_verify_test_case_3(void)
2617 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2621 test_kasumi_hash_verify_test_case_4(void)
2623 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2627 test_kasumi_hash_verify_test_case_5(void)
2629 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2633 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2635 struct crypto_testsuite_params *ts_params = &testsuite_params;
2636 struct crypto_unittest_params *ut_params = &unittest_params;
2639 uint8_t *plaintext, *ciphertext;
2640 unsigned plaintext_pad_len;
2641 unsigned plaintext_len;
2643 /* Create KASUMI session */
2644 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2645 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2646 RTE_CRYPTO_CIPHER_KASUMI_F8,
2647 tdata->key.data, tdata->key.len);
2651 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2653 /* Clear mbuf payload */
2654 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2655 rte_pktmbuf_tailroom(ut_params->ibuf));
2657 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2658 /* Append data which is padded to a multiple */
2659 /* of the algorithms block size */
2660 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2661 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2663 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2665 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2667 /* Create KASUMI operation */
2668 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2669 tdata->plaintext.len,
2670 tdata->validCipherOffsetLenInBits.len,
2671 RTE_CRYPTO_CIPHER_KASUMI_F8);
2675 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2677 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2679 ut_params->obuf = ut_params->op->sym->m_dst;
2680 if (ut_params->obuf)
2681 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2684 ciphertext = plaintext;
2686 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2689 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2691 tdata->ciphertext.data,
2692 tdata->validCipherLenInBits.len,
2693 "KASUMI Ciphertext data not as expected");
2698 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2700 struct crypto_testsuite_params *ts_params = &testsuite_params;
2701 struct crypto_unittest_params *ut_params = &unittest_params;
2705 unsigned int plaintext_pad_len;
2706 unsigned int plaintext_len;
2708 uint8_t buffer[10000];
2709 const uint8_t *ciphertext;
2711 struct rte_cryptodev_info dev_info;
2713 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2714 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2715 printf("Device doesn't support scatter-gather. "
2720 /* Create KASUMI session */
2721 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2722 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2723 RTE_CRYPTO_CIPHER_KASUMI_F8,
2724 tdata->key.data, tdata->key.len);
2728 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2731 /* Append data which is padded to a multiple */
2732 /* of the algorithms block size */
2733 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2735 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2736 plaintext_pad_len, 10, 0);
2738 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2740 /* Create KASUMI operation */
2741 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2743 tdata->plaintext.len,
2744 tdata->validCipherOffsetLenInBits.len,
2745 RTE_CRYPTO_CIPHER_KASUMI_F8);
2749 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2751 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2753 ut_params->obuf = ut_params->op->sym->m_dst;
2755 if (ut_params->obuf)
2756 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2757 plaintext_len, buffer);
2759 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2760 plaintext_len, buffer);
2763 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2766 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2768 tdata->ciphertext.data,
2769 tdata->validCipherLenInBits.len,
2770 "KASUMI Ciphertext data not as expected");
2775 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2777 struct crypto_testsuite_params *ts_params = &testsuite_params;
2778 struct crypto_unittest_params *ut_params = &unittest_params;
2781 uint8_t *plaintext, *ciphertext;
2782 unsigned plaintext_pad_len;
2783 unsigned plaintext_len;
2785 /* Create KASUMI session */
2786 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2787 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2788 RTE_CRYPTO_CIPHER_KASUMI_F8,
2789 tdata->key.data, tdata->key.len);
2793 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2794 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2796 /* Clear mbuf payload */
2797 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2798 rte_pktmbuf_tailroom(ut_params->ibuf));
2800 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2801 /* Append data which is padded to a multiple */
2802 /* of the algorithms block size */
2803 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2804 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2806 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2807 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2809 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2811 /* Create KASUMI operation */
2812 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2814 tdata->plaintext.len,
2815 tdata->validCipherOffsetLenInBits.len,
2816 RTE_CRYPTO_CIPHER_KASUMI_F8);
2820 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2822 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2824 ut_params->obuf = ut_params->op->sym->m_dst;
2825 if (ut_params->obuf)
2826 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2829 ciphertext = plaintext;
2831 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2834 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2836 tdata->ciphertext.data,
2837 tdata->validCipherLenInBits.len,
2838 "KASUMI Ciphertext data not as expected");
2843 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2845 struct crypto_testsuite_params *ts_params = &testsuite_params;
2846 struct crypto_unittest_params *ut_params = &unittest_params;
2849 unsigned int plaintext_pad_len;
2850 unsigned int plaintext_len;
2852 const uint8_t *ciphertext;
2853 uint8_t buffer[2048];
2855 struct rte_cryptodev_info dev_info;
2857 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2858 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2859 printf("Device doesn't support scatter-gather. "
2864 /* Create KASUMI session */
2865 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2866 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2867 RTE_CRYPTO_CIPHER_KASUMI_F8,
2868 tdata->key.data, tdata->key.len);
2872 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2873 /* Append data which is padded to a multiple */
2874 /* of the algorithms block size */
2875 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2877 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2878 plaintext_pad_len, 10, 0);
2879 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2880 plaintext_pad_len, 3, 0);
2882 /* Append data which is padded to a multiple */
2883 /* of the algorithms block size */
2884 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2886 /* Create KASUMI operation */
2887 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2889 tdata->plaintext.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 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2902 plaintext_pad_len, buffer);
2904 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2905 plaintext_pad_len, buffer);
2908 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2910 tdata->ciphertext.data,
2911 tdata->validCipherLenInBits.len,
2912 "KASUMI Ciphertext data not as expected");
2918 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2920 struct crypto_testsuite_params *ts_params = &testsuite_params;
2921 struct crypto_unittest_params *ut_params = &unittest_params;
2924 uint8_t *ciphertext, *plaintext;
2925 unsigned ciphertext_pad_len;
2926 unsigned ciphertext_len;
2928 /* Create KASUMI session */
2929 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2930 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2931 RTE_CRYPTO_CIPHER_KASUMI_F8,
2932 tdata->key.data, tdata->key.len);
2936 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2937 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2939 /* Clear mbuf payload */
2940 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2941 rte_pktmbuf_tailroom(ut_params->ibuf));
2943 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2944 /* Append data which is padded to a multiple */
2945 /* of the algorithms block size */
2946 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2947 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2948 ciphertext_pad_len);
2949 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2950 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2952 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2954 /* Create KASUMI operation */
2955 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2957 tdata->ciphertext.len,
2958 tdata->validCipherOffsetLenInBits.len,
2959 RTE_CRYPTO_CIPHER_KASUMI_F8);
2963 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2965 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2967 ut_params->obuf = ut_params->op->sym->m_dst;
2968 if (ut_params->obuf)
2969 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2972 plaintext = ciphertext;
2974 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2977 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2979 tdata->plaintext.data,
2980 tdata->validCipherLenInBits.len,
2981 "KASUMI Plaintext data not as expected");
2986 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2988 struct crypto_testsuite_params *ts_params = &testsuite_params;
2989 struct crypto_unittest_params *ut_params = &unittest_params;
2992 uint8_t *ciphertext, *plaintext;
2993 unsigned ciphertext_pad_len;
2994 unsigned ciphertext_len;
2996 /* Create KASUMI session */
2997 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2998 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2999 RTE_CRYPTO_CIPHER_KASUMI_F8,
3000 tdata->key.data, tdata->key.len);
3004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3006 /* Clear mbuf payload */
3007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3008 rte_pktmbuf_tailroom(ut_params->ibuf));
3010 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3011 /* Append data which is padded to a multiple */
3012 /* of the algorithms block size */
3013 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3014 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3015 ciphertext_pad_len);
3016 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3018 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3020 /* Create KASUMI operation */
3021 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3023 tdata->ciphertext.len,
3024 tdata->validCipherOffsetLenInBits.len,
3025 RTE_CRYPTO_CIPHER_KASUMI_F8);
3029 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3031 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3033 ut_params->obuf = ut_params->op->sym->m_dst;
3034 if (ut_params->obuf)
3035 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3038 plaintext = ciphertext;
3040 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3043 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3045 tdata->plaintext.data,
3046 tdata->validCipherLenInBits.len,
3047 "KASUMI Plaintext data not as expected");
3052 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3054 struct crypto_testsuite_params *ts_params = &testsuite_params;
3055 struct crypto_unittest_params *ut_params = &unittest_params;
3058 uint8_t *plaintext, *ciphertext;
3059 unsigned plaintext_pad_len;
3060 unsigned plaintext_len;
3062 /* Create SNOW 3G session */
3063 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3064 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3065 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3066 tdata->key.data, tdata->key.len);
3070 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3072 /* Clear mbuf payload */
3073 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3074 rte_pktmbuf_tailroom(ut_params->ibuf));
3076 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3077 /* Append data which is padded to a multiple of */
3078 /* the algorithms block size */
3079 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3080 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3082 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3084 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3086 /* Create SNOW 3G operation */
3087 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3088 tdata->validCipherLenInBits.len,
3089 tdata->validCipherOffsetLenInBits.len,
3090 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3094 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3096 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3098 ut_params->obuf = ut_params->op->sym->m_dst;
3099 if (ut_params->obuf)
3100 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3103 ciphertext = plaintext;
3105 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3108 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3110 tdata->ciphertext.data,
3111 tdata->validDataLenInBits.len,
3112 "SNOW 3G Ciphertext data not as expected");
3118 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3120 struct crypto_testsuite_params *ts_params = &testsuite_params;
3121 struct crypto_unittest_params *ut_params = &unittest_params;
3122 uint8_t *plaintext, *ciphertext;
3125 unsigned plaintext_pad_len;
3126 unsigned plaintext_len;
3128 /* Create SNOW 3G session */
3129 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3130 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3131 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3132 tdata->key.data, tdata->key.len);
3136 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3137 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3139 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3140 "Failed to allocate input buffer in mempool");
3141 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3142 "Failed to allocate output buffer in mempool");
3144 /* Clear mbuf payload */
3145 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3146 rte_pktmbuf_tailroom(ut_params->ibuf));
3148 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3149 /* Append data which is padded to a multiple of */
3150 /* the algorithms block size */
3151 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3152 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3154 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3155 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3157 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3159 /* Create SNOW 3G operation */
3160 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3162 tdata->validCipherLenInBits.len,
3163 tdata->validCipherOffsetLenInBits.len,
3164 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3168 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3170 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3172 ut_params->obuf = ut_params->op->sym->m_dst;
3173 if (ut_params->obuf)
3174 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3177 ciphertext = plaintext;
3179 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3182 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3184 tdata->ciphertext.data,
3185 tdata->validDataLenInBits.len,
3186 "SNOW 3G Ciphertext data not as expected");
3191 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3193 struct crypto_testsuite_params *ts_params = &testsuite_params;
3194 struct crypto_unittest_params *ut_params = &unittest_params;
3197 unsigned int plaintext_pad_len;
3198 unsigned int plaintext_len;
3199 uint8_t buffer[10000];
3200 const uint8_t *ciphertext;
3202 struct rte_cryptodev_info dev_info;
3204 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3205 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3206 printf("Device doesn't support scatter-gather. "
3211 /* Create SNOW 3G session */
3212 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3213 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3214 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3215 tdata->key.data, tdata->key.len);
3219 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3220 /* Append data which is padded to a multiple of */
3221 /* the algorithms block size */
3222 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3224 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3225 plaintext_pad_len, 10, 0);
3226 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3227 plaintext_pad_len, 3, 0);
3229 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3230 "Failed to allocate input buffer in mempool");
3231 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3232 "Failed to allocate output buffer in mempool");
3234 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3236 /* Create SNOW 3G operation */
3237 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3239 tdata->validCipherLenInBits.len,
3240 tdata->validCipherOffsetLenInBits.len,
3241 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3245 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3247 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3249 ut_params->obuf = ut_params->op->sym->m_dst;
3250 if (ut_params->obuf)
3251 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3252 plaintext_len, buffer);
3254 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3255 plaintext_len, buffer);
3257 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3260 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3262 tdata->ciphertext.data,
3263 tdata->validDataLenInBits.len,
3264 "SNOW 3G Ciphertext data not as expected");
3269 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3271 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3273 uint8_t curr_byte, prev_byte;
3274 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3275 uint8_t lower_byte_mask = (1 << offset) - 1;
3278 prev_byte = buffer[0];
3279 buffer[0] >>= offset;
3281 for (i = 1; i < length_in_bytes; i++) {
3282 curr_byte = buffer[i];
3283 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3284 (curr_byte >> offset);
3285 prev_byte = curr_byte;
3290 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3292 struct crypto_testsuite_params *ts_params = &testsuite_params;
3293 struct crypto_unittest_params *ut_params = &unittest_params;
3294 uint8_t *plaintext, *ciphertext;
3296 uint32_t plaintext_len;
3297 uint32_t plaintext_pad_len;
3298 uint8_t extra_offset = 4;
3299 uint8_t *expected_ciphertext_shifted;
3301 /* Create SNOW 3G session */
3302 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3303 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3304 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3305 tdata->key.data, tdata->key.len);
3309 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3310 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3312 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3313 "Failed to allocate input buffer in mempool");
3314 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3315 "Failed to allocate output buffer in mempool");
3317 /* Clear mbuf payload */
3318 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3319 rte_pktmbuf_tailroom(ut_params->ibuf));
3321 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3323 * Append data which is padded to a
3324 * multiple of the algorithms block size
3326 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3328 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3331 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3333 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3334 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3336 #ifdef RTE_APP_TEST_DEBUG
3337 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3339 /* Create SNOW 3G operation */
3340 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3342 tdata->validCipherLenInBits.len,
3343 tdata->validCipherOffsetLenInBits.len +
3345 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3349 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3351 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3353 ut_params->obuf = ut_params->op->sym->m_dst;
3354 if (ut_params->obuf)
3355 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3358 ciphertext = plaintext;
3360 #ifdef RTE_APP_TEST_DEBUG
3361 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3364 expected_ciphertext_shifted = rte_malloc(NULL,
3365 ceil_byte_length(plaintext_len + extra_offset), 0);
3367 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3368 "failed to reserve memory for ciphertext shifted\n");
3370 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3371 ceil_byte_length(tdata->ciphertext.len));
3372 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3375 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3377 expected_ciphertext_shifted,
3378 tdata->validDataLenInBits.len,
3380 "SNOW 3G Ciphertext data not as expected");
3384 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3386 struct crypto_testsuite_params *ts_params = &testsuite_params;
3387 struct crypto_unittest_params *ut_params = &unittest_params;
3391 uint8_t *plaintext, *ciphertext;
3392 unsigned ciphertext_pad_len;
3393 unsigned ciphertext_len;
3395 /* Create SNOW 3G session */
3396 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3397 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3398 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3399 tdata->key.data, tdata->key.len);
3403 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3405 /* Clear mbuf payload */
3406 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3407 rte_pktmbuf_tailroom(ut_params->ibuf));
3409 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3410 /* Append data which is padded to a multiple of */
3411 /* the algorithms block size */
3412 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3413 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3414 ciphertext_pad_len);
3415 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3417 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3419 /* Create SNOW 3G operation */
3420 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3421 tdata->validCipherLenInBits.len,
3422 tdata->validCipherOffsetLenInBits.len,
3423 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3427 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3429 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3430 ut_params->obuf = ut_params->op->sym->m_dst;
3431 if (ut_params->obuf)
3432 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3435 plaintext = ciphertext;
3437 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3440 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3441 tdata->plaintext.data,
3442 tdata->validDataLenInBits.len,
3443 "SNOW 3G Plaintext data not as expected");
3447 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3449 struct crypto_testsuite_params *ts_params = &testsuite_params;
3450 struct crypto_unittest_params *ut_params = &unittest_params;
3454 uint8_t *plaintext, *ciphertext;
3455 unsigned ciphertext_pad_len;
3456 unsigned ciphertext_len;
3458 /* Create SNOW 3G session */
3459 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3460 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3461 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3462 tdata->key.data, tdata->key.len);
3466 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3467 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3469 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3470 "Failed to allocate input buffer");
3471 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3472 "Failed to allocate output buffer");
3474 /* Clear mbuf payload */
3475 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3476 rte_pktmbuf_tailroom(ut_params->ibuf));
3478 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3479 rte_pktmbuf_tailroom(ut_params->obuf));
3481 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3482 /* Append data which is padded to a multiple of */
3483 /* the algorithms block size */
3484 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3485 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3486 ciphertext_pad_len);
3487 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3488 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3490 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3492 /* Create SNOW 3G operation */
3493 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3495 tdata->validCipherLenInBits.len,
3496 tdata->validCipherOffsetLenInBits.len,
3497 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3501 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3503 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3504 ut_params->obuf = ut_params->op->sym->m_dst;
3505 if (ut_params->obuf)
3506 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3509 plaintext = ciphertext;
3511 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3514 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3515 tdata->plaintext.data,
3516 tdata->validDataLenInBits.len,
3517 "SNOW 3G Plaintext data not as expected");
3522 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3524 struct crypto_testsuite_params *ts_params = &testsuite_params;
3525 struct crypto_unittest_params *ut_params = &unittest_params;
3529 uint8_t *plaintext, *ciphertext;
3530 unsigned plaintext_pad_len;
3531 unsigned plaintext_len;
3533 /* Create SNOW 3G session */
3534 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3535 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3536 RTE_CRYPTO_AUTH_OP_GENERATE,
3537 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3538 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3539 tdata->key.data, tdata->key.len,
3540 tdata->aad.len, tdata->digest.len);
3543 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3545 /* clear mbuf payload */
3546 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3547 rte_pktmbuf_tailroom(ut_params->ibuf));
3549 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3550 /* Append data which is padded to a multiple of */
3551 /* the algorithms block size */
3552 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3553 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3555 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3557 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3559 /* Create SNOW 3G operation */
3560 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3561 tdata->digest.len, tdata->aad.data,
3562 tdata->aad.len, /*tdata->plaintext.len,*/
3563 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3564 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3565 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3566 tdata->iv.data, tdata->iv.len,
3567 tdata->validCipherLenInBits.len,
3568 tdata->validCipherOffsetLenInBits.len,
3569 tdata->validAuthLenInBits.len,
3570 tdata->validAuthOffsetLenInBits.len
3575 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3577 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3578 ut_params->obuf = ut_params->op->sym->m_src;
3579 if (ut_params->obuf)
3580 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3581 + tdata->iv.len + tdata->aad.len;
3583 ciphertext = plaintext;
3585 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3587 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3589 tdata->ciphertext.data,
3590 tdata->validDataLenInBits.len,
3591 "SNOW 3G Ciphertext data not as expected");
3593 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3594 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3597 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3600 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3601 "SNOW 3G Generated auth tag not as expected");
3605 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3607 struct crypto_testsuite_params *ts_params = &testsuite_params;
3608 struct crypto_unittest_params *ut_params = &unittest_params;
3612 uint8_t *plaintext, *ciphertext;
3613 unsigned plaintext_pad_len;
3614 unsigned plaintext_len;
3616 /* Create SNOW 3G session */
3617 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3618 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3619 RTE_CRYPTO_AUTH_OP_GENERATE,
3620 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3621 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3622 tdata->key.data, tdata->key.len,
3623 tdata->aad.len, tdata->digest.len);
3627 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3629 /* clear mbuf payload */
3630 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3631 rte_pktmbuf_tailroom(ut_params->ibuf));
3633 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3634 /* Append data which is padded to a multiple of */
3635 /* the algorithms block size */
3636 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3637 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3639 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3641 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3643 /* Create SNOW 3G operation */
3644 retval = create_wireless_algo_auth_cipher_operation(
3646 tdata->iv.data, tdata->iv.len,
3647 tdata->aad.data, tdata->aad.len,
3649 tdata->validCipherLenInBits.len,
3650 tdata->validCipherOffsetLenInBits.len,
3651 tdata->validAuthLenInBits.len,
3652 tdata->validAuthOffsetLenInBits.len,
3653 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3654 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3662 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3663 ut_params->obuf = ut_params->op->sym->m_src;
3664 if (ut_params->obuf)
3665 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3666 + tdata->aad.len + tdata->iv.len;
3668 ciphertext = plaintext;
3670 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3671 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3672 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3675 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3677 tdata->ciphertext.data,
3678 tdata->validDataLenInBits.len,
3679 "SNOW 3G Ciphertext data not as expected");
3682 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3685 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3686 "SNOW 3G Generated auth tag not as expected");
3691 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3693 struct crypto_testsuite_params *ts_params = &testsuite_params;
3694 struct crypto_unittest_params *ut_params = &unittest_params;
3698 uint8_t *plaintext, *ciphertext;
3699 unsigned plaintext_pad_len;
3700 unsigned plaintext_len;
3702 /* Create KASUMI session */
3703 retval = create_wireless_algo_auth_cipher_session(
3704 ts_params->valid_devs[0],
3705 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3706 RTE_CRYPTO_AUTH_OP_GENERATE,
3707 RTE_CRYPTO_AUTH_KASUMI_F9,
3708 RTE_CRYPTO_CIPHER_KASUMI_F8,
3709 tdata->key.data, tdata->key.len,
3710 tdata->aad.len, tdata->digest.len);
3713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3715 /* clear mbuf payload */
3716 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3717 rte_pktmbuf_tailroom(ut_params->ibuf));
3719 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3720 /* Append data which is padded to a multiple of */
3721 /* the algorithms block size */
3722 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3723 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3725 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3727 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3729 /* Create KASUMI operation */
3730 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3731 tdata->iv.data, tdata->iv.len,
3732 tdata->aad.data, tdata->aad.len,
3734 tdata->validCipherLenInBits.len,
3735 tdata->validCipherOffsetLenInBits.len,
3736 tdata->validAuthLenInBits.len,
3737 tdata->validAuthOffsetLenInBits.len,
3738 RTE_CRYPTO_AUTH_KASUMI_F9,
3739 RTE_CRYPTO_CIPHER_KASUMI_F8
3745 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3747 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3748 ut_params->obuf = ut_params->op->sym->m_src;
3749 if (ut_params->obuf)
3750 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3751 + tdata->iv.len + tdata->aad.len;
3753 ciphertext = plaintext;
3756 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3758 tdata->ciphertext.data,
3759 tdata->validCipherLenInBits.len,
3760 "KASUMI Ciphertext data not as expected");
3761 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3762 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3765 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3768 DIGEST_BYTE_LENGTH_KASUMI_F9,
3769 "KASUMI Generated auth tag not as expected");
3774 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3776 struct crypto_testsuite_params *ts_params = &testsuite_params;
3777 struct crypto_unittest_params *ut_params = &unittest_params;
3781 uint8_t *plaintext, *ciphertext;
3782 unsigned plaintext_pad_len;
3783 unsigned plaintext_len;
3785 /* Create KASUMI session */
3786 retval = create_wireless_algo_cipher_auth_session(
3787 ts_params->valid_devs[0],
3788 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3789 RTE_CRYPTO_AUTH_OP_GENERATE,
3790 RTE_CRYPTO_AUTH_KASUMI_F9,
3791 RTE_CRYPTO_CIPHER_KASUMI_F8,
3792 tdata->key.data, tdata->key.len,
3793 tdata->aad.len, tdata->digest.len);
3797 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3799 /* clear mbuf payload */
3800 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3801 rte_pktmbuf_tailroom(ut_params->ibuf));
3803 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3804 /* Append data which is padded to a multiple of */
3805 /* the algorithms block size */
3806 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3807 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3809 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3811 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3813 /* Create KASUMI operation */
3814 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3815 tdata->digest.len, tdata->aad.data,
3817 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3818 RTE_CRYPTO_AUTH_KASUMI_F9,
3819 RTE_CRYPTO_CIPHER_KASUMI_F8,
3820 tdata->iv.data, tdata->iv.len,
3821 tdata->validCipherLenInBits.len,
3822 tdata->validCipherOffsetLenInBits.len,
3823 tdata->validAuthLenInBits.len,
3824 tdata->validAuthOffsetLenInBits.len
3829 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3831 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3832 ut_params->obuf = ut_params->op->sym->m_src;
3833 if (ut_params->obuf)
3834 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3835 + tdata->aad.len + tdata->iv.len;
3837 ciphertext = plaintext;
3839 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3840 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3843 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3845 tdata->ciphertext.data,
3846 tdata->validCipherLenInBits.len,
3847 "KASUMI Ciphertext data not as expected");
3850 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3853 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3854 "KASUMI Generated auth tag not as expected");
3859 test_zuc_encryption(const struct zuc_test_data *tdata)
3861 struct crypto_testsuite_params *ts_params = &testsuite_params;
3862 struct crypto_unittest_params *ut_params = &unittest_params;
3865 uint8_t *plaintext, *ciphertext;
3866 unsigned plaintext_pad_len;
3867 unsigned plaintext_len;
3869 /* Create ZUC session */
3870 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3871 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3872 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3873 tdata->key.data, tdata->key.len);
3877 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3879 /* Clear mbuf payload */
3880 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3881 rte_pktmbuf_tailroom(ut_params->ibuf));
3883 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3884 /* Append data which is padded to a multiple */
3885 /* of the algorithms block size */
3886 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3887 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3889 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3891 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3893 /* Create ZUC operation */
3894 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3895 tdata->plaintext.len,
3896 tdata->validCipherOffsetLenInBits.len,
3897 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3901 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3903 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3905 ut_params->obuf = ut_params->op->sym->m_dst;
3906 if (ut_params->obuf)
3907 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3910 ciphertext = plaintext;
3912 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3917 tdata->ciphertext.data,
3918 tdata->validCipherLenInBits.len,
3919 "ZUC Ciphertext data not as expected");
3924 test_zuc_encryption_sgl(const struct zuc_test_data *tdata)
3926 struct crypto_testsuite_params *ts_params = &testsuite_params;
3927 struct crypto_unittest_params *ut_params = &unittest_params;
3931 unsigned int plaintext_pad_len;
3932 unsigned int plaintext_len;
3933 const uint8_t *ciphertext;
3934 uint8_t ciphertext_buffer[2048];
3935 struct rte_cryptodev_info dev_info;
3937 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3938 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3939 printf("Device doesn't support scatter-gather. "
3944 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3946 /* Append data which is padded to a multiple */
3947 /* of the algorithms block size */
3948 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3950 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3951 plaintext_pad_len, 10, 0);
3953 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
3954 tdata->plaintext.data);
3956 /* Create ZUC session */
3957 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3958 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3959 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3960 tdata->key.data, tdata->key.len);
3964 /* Clear mbuf payload */
3966 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3968 /* Create ZUC operation */
3969 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3970 tdata->iv.len, tdata->plaintext.len,
3971 tdata->validCipherOffsetLenInBits.len,
3972 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3976 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3978 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3980 ut_params->obuf = ut_params->op->sym->m_dst;
3981 if (ut_params->obuf)
3982 ciphertext = rte_pktmbuf_read(ut_params->obuf,
3983 tdata->iv.len, plaintext_len, ciphertext_buffer);
3985 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3986 tdata->iv.len, plaintext_len, ciphertext_buffer);
3989 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3992 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3994 tdata->ciphertext.data,
3995 tdata->validCipherLenInBits.len,
3996 "ZUC Ciphertext data not as expected");
4002 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
4004 struct crypto_testsuite_params *ts_params = &testsuite_params;
4005 struct crypto_unittest_params *ut_params = &unittest_params;
4008 unsigned plaintext_pad_len;
4009 unsigned plaintext_len;
4012 /* Create ZUC session */
4013 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4014 tdata->key.data, tdata->key.len,
4015 tdata->aad.len, tdata->digest.len,
4016 RTE_CRYPTO_AUTH_OP_GENERATE,
4017 RTE_CRYPTO_AUTH_ZUC_EIA3);
4021 /* alloc mbuf and set payload */
4022 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4024 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4025 rte_pktmbuf_tailroom(ut_params->ibuf));
4027 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4028 /* Append data which is padded to a multiple of */
4029 /* the algorithms block size */
4030 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4031 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4033 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4035 /* Create ZUC operation */
4036 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4037 tdata->aad.data, tdata->aad.len,
4038 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4039 RTE_CRYPTO_AUTH_ZUC_EIA3,
4040 tdata->validAuthLenInBits.len,
4041 tdata->validAuthOffsetLenInBits.len);
4045 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4047 ut_params->obuf = ut_params->op->sym->m_src;
4048 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4049 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4050 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
4053 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4056 DIGEST_BYTE_LENGTH_KASUMI_F9,
4057 "ZUC Generated auth tag not as expected");
4063 test_kasumi_encryption_test_case_1(void)
4065 return test_kasumi_encryption(&kasumi_test_case_1);
4069 test_kasumi_encryption_test_case_1_sgl(void)
4071 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4075 test_kasumi_encryption_test_case_1_oop(void)
4077 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4081 test_kasumi_encryption_test_case_1_oop_sgl(void)
4083 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4087 test_kasumi_encryption_test_case_2(void)
4089 return test_kasumi_encryption(&kasumi_test_case_2);
4093 test_kasumi_encryption_test_case_3(void)
4095 return test_kasumi_encryption(&kasumi_test_case_3);
4099 test_kasumi_encryption_test_case_4(void)
4101 return test_kasumi_encryption(&kasumi_test_case_4);
4105 test_kasumi_encryption_test_case_5(void)
4107 return test_kasumi_encryption(&kasumi_test_case_5);
4111 test_kasumi_decryption_test_case_1(void)
4113 return test_kasumi_decryption(&kasumi_test_case_1);
4117 test_kasumi_decryption_test_case_1_oop(void)
4119 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4123 test_kasumi_decryption_test_case_2(void)
4125 return test_kasumi_decryption(&kasumi_test_case_2);
4129 test_kasumi_decryption_test_case_3(void)
4131 return test_kasumi_decryption(&kasumi_test_case_3);
4135 test_kasumi_decryption_test_case_4(void)
4137 return test_kasumi_decryption(&kasumi_test_case_4);
4141 test_kasumi_decryption_test_case_5(void)
4143 return test_kasumi_decryption(&kasumi_test_case_5);
4146 test_snow3g_encryption_test_case_1(void)
4148 return test_snow3g_encryption(&snow3g_test_case_1);
4152 test_snow3g_encryption_test_case_1_oop(void)
4154 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4158 test_snow3g_encryption_test_case_1_oop_sgl(void)
4160 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4165 test_snow3g_encryption_test_case_1_offset_oop(void)
4167 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4171 test_snow3g_encryption_test_case_2(void)
4173 return test_snow3g_encryption(&snow3g_test_case_2);
4177 test_snow3g_encryption_test_case_3(void)
4179 return test_snow3g_encryption(&snow3g_test_case_3);
4183 test_snow3g_encryption_test_case_4(void)
4185 return test_snow3g_encryption(&snow3g_test_case_4);
4189 test_snow3g_encryption_test_case_5(void)
4191 return test_snow3g_encryption(&snow3g_test_case_5);
4195 test_snow3g_decryption_test_case_1(void)
4197 return test_snow3g_decryption(&snow3g_test_case_1);
4201 test_snow3g_decryption_test_case_1_oop(void)
4203 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4207 test_snow3g_decryption_test_case_2(void)
4209 return test_snow3g_decryption(&snow3g_test_case_2);
4213 test_snow3g_decryption_test_case_3(void)
4215 return test_snow3g_decryption(&snow3g_test_case_3);
4219 test_snow3g_decryption_test_case_4(void)
4221 return test_snow3g_decryption(&snow3g_test_case_4);
4225 test_snow3g_decryption_test_case_5(void)
4227 return test_snow3g_decryption(&snow3g_test_case_5);
4230 test_snow3g_cipher_auth_test_case_1(void)
4232 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4236 test_snow3g_auth_cipher_test_case_1(void)
4238 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4242 test_kasumi_auth_cipher_test_case_1(void)
4244 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4248 test_kasumi_cipher_auth_test_case_1(void)
4250 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4254 test_zuc_encryption_test_case_1(void)
4256 return test_zuc_encryption(&zuc_test_case_1);
4260 test_zuc_encryption_test_case_2(void)
4262 return test_zuc_encryption(&zuc_test_case_2);
4266 test_zuc_encryption_test_case_3(void)
4268 return test_zuc_encryption(&zuc_test_case_3);
4272 test_zuc_encryption_test_case_4(void)
4274 return test_zuc_encryption(&zuc_test_case_4);
4278 test_zuc_encryption_test_case_5(void)
4280 return test_zuc_encryption(&zuc_test_case_5);
4284 test_zuc_encryption_test_case_6_sgl(void)
4286 return test_zuc_encryption_sgl(&zuc_test_case_1);
4290 test_zuc_hash_generate_test_case_1(void)
4292 return test_zuc_authentication(&zuc_hash_test_case_1);
4296 test_zuc_hash_generate_test_case_2(void)
4298 return test_zuc_authentication(&zuc_hash_test_case_2);
4302 test_zuc_hash_generate_test_case_3(void)
4304 return test_zuc_authentication(&zuc_hash_test_case_3);
4308 test_zuc_hash_generate_test_case_4(void)
4310 return test_zuc_authentication(&zuc_hash_test_case_4);
4314 test_zuc_hash_generate_test_case_5(void)
4316 return test_zuc_authentication(&zuc_hash_test_case_5);
4320 test_3DES_chain_qat_all(void)
4322 struct crypto_testsuite_params *ts_params = &testsuite_params;
4325 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4326 ts_params->op_mpool, ts_params->valid_devs[0],
4327 RTE_CRYPTODEV_QAT_SYM_PMD,
4328 BLKCIPHER_3DES_CHAIN_TYPE);
4330 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4332 return TEST_SUCCESS;
4336 test_DES_cipheronly_qat_all(void)
4338 struct crypto_testsuite_params *ts_params = &testsuite_params;
4341 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4342 ts_params->op_mpool, ts_params->valid_devs[0],
4343 RTE_CRYPTODEV_QAT_SYM_PMD,
4344 BLKCIPHER_DES_CIPHERONLY_TYPE);
4346 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4348 return TEST_SUCCESS;
4352 test_DES_docsis_openssl_all(void)
4354 struct crypto_testsuite_params *ts_params = &testsuite_params;
4357 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4358 ts_params->op_mpool, ts_params->valid_devs[0],
4359 RTE_CRYPTODEV_OPENSSL_PMD,
4360 BLKCIPHER_DES_DOCSIS_TYPE);
4362 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4364 return TEST_SUCCESS;
4368 test_3DES_cipheronly_qat_all(void)
4370 struct crypto_testsuite_params *ts_params = &testsuite_params;
4373 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4374 ts_params->op_mpool, ts_params->valid_devs[0],
4375 RTE_CRYPTODEV_QAT_SYM_PMD,
4376 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4378 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4380 return TEST_SUCCESS;
4384 test_3DES_chain_openssl_all(void)
4386 struct crypto_testsuite_params *ts_params = &testsuite_params;
4389 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4390 ts_params->op_mpool, ts_params->valid_devs[0],
4391 RTE_CRYPTODEV_OPENSSL_PMD,
4392 BLKCIPHER_3DES_CHAIN_TYPE);
4394 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4396 return TEST_SUCCESS;
4400 test_3DES_cipheronly_openssl_all(void)
4402 struct crypto_testsuite_params *ts_params = &testsuite_params;
4405 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4406 ts_params->op_mpool, ts_params->valid_devs[0],
4407 RTE_CRYPTODEV_OPENSSL_PMD,
4408 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4410 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4412 return TEST_SUCCESS;
4415 /* ***** AES-GCM Tests ***** */
4418 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4419 const uint8_t *key, const uint8_t key_len,
4420 const uint8_t aad_len, const uint8_t auth_len,
4421 enum rte_crypto_auth_operation auth_op)
4423 uint8_t cipher_key[key_len];
4425 struct crypto_unittest_params *ut_params = &unittest_params;
4427 memcpy(cipher_key, key, key_len);
4429 /* Setup Cipher Parameters */
4430 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4431 ut_params->cipher_xform.next = NULL;
4433 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4434 ut_params->auth_xform.auth.op = auth_op;
4435 ut_params->cipher_xform.cipher.op = op;
4436 ut_params->cipher_xform.cipher.key.data = cipher_key;
4437 ut_params->cipher_xform.cipher.key.length = key_len;
4439 TEST_HEXDUMP(stdout, "key:", key, key_len);
4441 /* Setup Authentication Parameters */
4442 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4443 ut_params->auth_xform.next = NULL;
4445 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4447 ut_params->auth_xform.auth.digest_length = auth_len;
4448 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4449 ut_params->auth_xform.auth.key.length = 0;
4450 ut_params->auth_xform.auth.key.data = NULL;
4452 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4453 ut_params->cipher_xform.next = &ut_params->auth_xform;
4455 /* Create Crypto session*/
4456 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4457 &ut_params->cipher_xform);
4458 } else {/* Create Crypto session*/
4459 ut_params->auth_xform.next = &ut_params->cipher_xform;
4460 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4461 &ut_params->auth_xform);
4464 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4470 create_gcm_xforms(struct rte_crypto_op *op,
4471 enum rte_crypto_cipher_operation cipher_op,
4472 uint8_t *key, const uint8_t key_len,
4473 const uint8_t aad_len, const uint8_t auth_len,
4474 enum rte_crypto_auth_operation auth_op)
4476 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4477 "failed to allocate space for crypto transforms");
4479 struct rte_crypto_sym_op *sym_op = op->sym;
4481 /* Setup Cipher Parameters */
4482 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4483 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4484 sym_op->xform->cipher.op = cipher_op;
4485 sym_op->xform->cipher.key.data = key;
4486 sym_op->xform->cipher.key.length = key_len;
4488 TEST_HEXDUMP(stdout, "key:", key, key_len);
4490 /* Setup Authentication Parameters */
4491 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4492 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4493 sym_op->xform->next->auth.op = auth_op;
4494 sym_op->xform->next->auth.digest_length = auth_len;
4495 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4496 sym_op->xform->next->auth.key.length = 0;
4497 sym_op->xform->next->auth.key.data = NULL;
4498 sym_op->xform->next->next = NULL;
4504 create_gcm_operation(enum rte_crypto_cipher_operation op,
4505 const struct gcm_test_data *tdata)
4507 struct crypto_testsuite_params *ts_params = &testsuite_params;
4508 struct crypto_unittest_params *ut_params = &unittest_params;
4510 uint8_t *plaintext, *ciphertext;
4511 unsigned int iv_pad_len, aad_pad_len, plaintext_pad_len;
4513 /* Generate Crypto op data structure */
4514 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4515 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4516 TEST_ASSERT_NOT_NULL(ut_params->op,
4517 "Failed to allocate symmetric crypto operation struct");
4519 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4521 /* Append aad data */
4522 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4523 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4525 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4526 "no room to append aad");
4528 sym_op->auth.aad.length = tdata->aad.len;
4529 sym_op->auth.aad.phys_addr =
4530 rte_pktmbuf_mtophys(ut_params->ibuf);
4531 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4532 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4533 sym_op->auth.aad.length);
4536 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
4537 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4538 ut_params->ibuf, iv_pad_len);
4539 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4541 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4542 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4543 sym_op->cipher.iv.length = tdata->iv.len;
4545 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4546 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
4547 sym_op->cipher.iv.length);
4549 /* Append plaintext/ciphertext */
4550 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4551 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4552 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4554 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4556 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4557 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4558 tdata->plaintext.len);
4560 if (ut_params->obuf) {
4561 ciphertext = (uint8_t *)rte_pktmbuf_append(
4563 plaintext_pad_len + aad_pad_len +
4565 TEST_ASSERT_NOT_NULL(ciphertext,
4566 "no room to append ciphertext");
4568 memset(ciphertext + aad_pad_len + iv_pad_len, 0,
4569 tdata->ciphertext.len);
4572 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4573 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4575 TEST_ASSERT_NOT_NULL(ciphertext,
4576 "no room to append ciphertext");
4578 memcpy(ciphertext, tdata->ciphertext.data,
4579 tdata->ciphertext.len);
4580 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4581 tdata->ciphertext.len);
4583 if (ut_params->obuf) {
4584 plaintext = (uint8_t *)rte_pktmbuf_append(
4586 plaintext_pad_len + aad_pad_len +
4588 TEST_ASSERT_NOT_NULL(plaintext,
4589 "no room to append plaintext");
4591 memset(plaintext + aad_pad_len + iv_pad_len, 0,
4592 tdata->plaintext.len);
4596 /* Append digest data */
4597 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4598 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4599 ut_params->obuf ? ut_params->obuf :
4601 tdata->auth_tag.len);
4602 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4603 "no room to append digest");
4604 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4605 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4606 ut_params->obuf ? ut_params->obuf :
4609 aad_pad_len + iv_pad_len);
4610 sym_op->auth.digest.length = tdata->auth_tag.len;
4612 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4613 ut_params->ibuf, tdata->auth_tag.len);
4614 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4615 "no room to append digest");
4616 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4618 plaintext_pad_len + aad_pad_len + iv_pad_len);
4619 sym_op->auth.digest.length = tdata->auth_tag.len;
4621 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4622 tdata->auth_tag.len);
4623 TEST_HEXDUMP(stdout, "digest:",
4624 sym_op->auth.digest.data,
4625 sym_op->auth.digest.length);
4628 sym_op->cipher.data.length = tdata->plaintext.len;
4629 sym_op->cipher.data.offset = aad_pad_len + iv_pad_len;
4631 sym_op->auth.data.length = tdata->plaintext.len;
4632 sym_op->auth.data.offset = aad_pad_len + iv_pad_len;
4638 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4640 struct crypto_testsuite_params *ts_params = &testsuite_params;
4641 struct crypto_unittest_params *ut_params = &unittest_params;
4644 uint8_t *ciphertext, *auth_tag;
4645 uint16_t plaintext_pad_len;
4648 /* Create GCM session */
4649 retval = create_gcm_session(ts_params->valid_devs[0],
4650 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4651 tdata->key.data, tdata->key.len,
4652 tdata->aad.len, tdata->auth_tag.len,
4653 RTE_CRYPTO_AUTH_OP_GENERATE);
4657 if (tdata->aad.len > MBUF_SIZE) {
4658 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4659 /* Populate full size of add data */
4660 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4661 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4663 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4665 /* clear mbuf payload */
4666 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4667 rte_pktmbuf_tailroom(ut_params->ibuf));
4669 /* Create GCM operation */
4670 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4674 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4676 ut_params->op->sym->m_src = ut_params->ibuf;
4678 /* Process crypto operation */
4679 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4680 ut_params->op), "failed to process sym crypto op");
4682 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4683 "crypto op processing failed");
4685 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4687 if (ut_params->op->sym->m_dst) {
4688 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4690 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4691 uint8_t *, plaintext_pad_len);
4693 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4695 ut_params->op->sym->cipher.data.offset);
4696 auth_tag = ciphertext + plaintext_pad_len;
4699 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4700 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4703 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4705 tdata->ciphertext.data,
4706 tdata->ciphertext.len,
4707 "GCM Ciphertext data not as expected");
4709 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4711 tdata->auth_tag.data,
4712 tdata->auth_tag.len,
4713 "GCM Generated auth tag not as expected");
4720 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4722 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4726 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4728 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4732 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4734 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4738 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4740 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4744 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4746 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4750 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4752 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4756 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4758 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4762 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4764 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4768 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4770 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4774 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4776 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4780 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
4782 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
4786 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
4788 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
4792 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
4794 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
4798 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
4800 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
4804 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
4806 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
4810 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
4812 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
4816 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4818 struct crypto_testsuite_params *ts_params = &testsuite_params;
4819 struct crypto_unittest_params *ut_params = &unittest_params;
4825 /* Create GCM session */
4826 retval = create_gcm_session(ts_params->valid_devs[0],
4827 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4828 tdata->key.data, tdata->key.len,
4829 tdata->aad.len, tdata->auth_tag.len,
4830 RTE_CRYPTO_AUTH_OP_VERIFY);
4834 /* alloc mbuf and set payload */
4835 if (tdata->aad.len > MBUF_SIZE) {
4836 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4837 /* Populate full size of add data */
4838 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4839 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4841 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4843 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4844 rte_pktmbuf_tailroom(ut_params->ibuf));
4846 /* Create GCM operation */
4847 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
4851 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4853 ut_params->op->sym->m_src = ut_params->ibuf;
4855 /* Process crypto operation */
4856 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4857 ut_params->op), "failed to process sym crypto op");
4859 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4860 "crypto op processing failed");
4862 if (ut_params->op->sym->m_dst)
4863 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4866 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4868 ut_params->op->sym->cipher.data.offset);
4870 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4873 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4875 tdata->plaintext.data,
4876 tdata->plaintext.len,
4877 "GCM plaintext data not as expected");
4879 TEST_ASSERT_EQUAL(ut_params->op->status,
4880 RTE_CRYPTO_OP_STATUS_SUCCESS,
4881 "GCM authentication failed");
4886 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4888 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4892 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4894 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4898 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4900 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4904 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4906 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4910 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4912 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4916 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4918 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4922 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4924 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4928 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
4930 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
4934 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
4936 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
4940 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
4942 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
4946 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
4948 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
4952 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
4954 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
4958 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
4960 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
4964 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
4966 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
4970 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
4972 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
4976 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
4978 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
4982 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
4984 struct crypto_testsuite_params *ts_params = &testsuite_params;
4985 struct crypto_unittest_params *ut_params = &unittest_params;
4988 uint8_t *ciphertext, *auth_tag;
4989 uint16_t plaintext_pad_len;
4991 /* Create GCM session */
4992 retval = create_gcm_session(ts_params->valid_devs[0],
4993 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4994 tdata->key.data, tdata->key.len,
4995 tdata->aad.len, tdata->auth_tag.len,
4996 RTE_CRYPTO_AUTH_OP_GENERATE);
5000 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5001 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5003 /* clear mbuf payload */
5004 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5005 rte_pktmbuf_tailroom(ut_params->ibuf));
5006 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5007 rte_pktmbuf_tailroom(ut_params->obuf));
5009 /* Create GCM operation */
5010 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5014 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5016 ut_params->op->sym->m_src = ut_params->ibuf;
5017 ut_params->op->sym->m_dst = ut_params->obuf;
5019 /* Process crypto operation */
5020 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5021 ut_params->op), "failed to process sym crypto op");
5023 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5024 "crypto op processing failed");
5026 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5028 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5029 ut_params->op->sym->cipher.data.offset);
5030 auth_tag = ciphertext + plaintext_pad_len;
5032 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5033 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5036 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5038 tdata->ciphertext.data,
5039 tdata->ciphertext.len,
5040 "GCM Ciphertext data not as expected");
5042 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5044 tdata->auth_tag.data,
5045 tdata->auth_tag.len,
5046 "GCM Generated auth tag not as expected");
5053 test_mb_AES_GCM_authenticated_encryption_oop(void)
5055 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5059 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5061 struct crypto_testsuite_params *ts_params = &testsuite_params;
5062 struct crypto_unittest_params *ut_params = &unittest_params;
5067 /* Create GCM session */
5068 retval = create_gcm_session(ts_params->valid_devs[0],
5069 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5070 tdata->key.data, tdata->key.len,
5071 tdata->aad.len, tdata->auth_tag.len,
5072 RTE_CRYPTO_AUTH_OP_VERIFY);
5076 /* alloc mbuf and set payload */
5077 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5078 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5080 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5081 rte_pktmbuf_tailroom(ut_params->ibuf));
5082 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5083 rte_pktmbuf_tailroom(ut_params->obuf));
5085 /* Create GCM operation */
5086 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5090 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5092 ut_params->op->sym->m_src = ut_params->ibuf;
5093 ut_params->op->sym->m_dst = ut_params->obuf;
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_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5100 "crypto op processing failed");
5102 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5103 ut_params->op->sym->cipher.data.offset);
5105 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5108 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5110 tdata->plaintext.data,
5111 tdata->plaintext.len,
5112 "GCM plaintext data not as expected");
5114 TEST_ASSERT_EQUAL(ut_params->op->status,
5115 RTE_CRYPTO_OP_STATUS_SUCCESS,
5116 "GCM authentication failed");
5121 test_mb_AES_GCM_authenticated_decryption_oop(void)
5123 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5127 test_AES_GCM_authenticated_encryption_sessionless(
5128 const struct gcm_test_data *tdata)
5130 struct crypto_testsuite_params *ts_params = &testsuite_params;
5131 struct crypto_unittest_params *ut_params = &unittest_params;
5134 uint8_t *ciphertext, *auth_tag;
5135 uint16_t plaintext_pad_len;
5136 uint8_t key[tdata->key.len + 1];
5138 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5140 /* clear mbuf payload */
5141 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5142 rte_pktmbuf_tailroom(ut_params->ibuf));
5144 /* Create GCM operation */
5145 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5149 /* Create GCM xforms */
5150 memcpy(key, tdata->key.data, tdata->key.len);
5151 retval = create_gcm_xforms(ut_params->op,
5152 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5153 key, tdata->key.len,
5154 tdata->aad.len, tdata->auth_tag.len,
5155 RTE_CRYPTO_AUTH_OP_GENERATE);
5159 ut_params->op->sym->m_src = ut_params->ibuf;
5161 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5162 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5163 "crypto op session type not sessionless");
5165 /* Process crypto operation */
5166 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5167 ut_params->op), "failed to process sym crypto op");
5169 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5171 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5172 "crypto op status not success");
5174 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5176 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5177 ut_params->op->sym->cipher.data.offset);
5178 auth_tag = ciphertext + plaintext_pad_len;
5180 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5181 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5184 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5186 tdata->ciphertext.data,
5187 tdata->ciphertext.len,
5188 "GCM Ciphertext data not as expected");
5190 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5192 tdata->auth_tag.data,
5193 tdata->auth_tag.len,
5194 "GCM Generated auth tag not as expected");
5201 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5203 return test_AES_GCM_authenticated_encryption_sessionless(
5208 test_AES_GCM_authenticated_decryption_sessionless(
5209 const struct gcm_test_data *tdata)
5211 struct crypto_testsuite_params *ts_params = &testsuite_params;
5212 struct crypto_unittest_params *ut_params = &unittest_params;
5216 uint8_t key[tdata->key.len + 1];
5218 /* alloc mbuf and set payload */
5219 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5221 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5222 rte_pktmbuf_tailroom(ut_params->ibuf));
5224 /* Create GCM operation */
5225 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5229 /* Create GCM xforms */
5230 memcpy(key, tdata->key.data, tdata->key.len);
5231 retval = create_gcm_xforms(ut_params->op,
5232 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5233 key, tdata->key.len,
5234 tdata->aad.len, tdata->auth_tag.len,
5235 RTE_CRYPTO_AUTH_OP_VERIFY);
5239 ut_params->op->sym->m_src = ut_params->ibuf;
5241 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5242 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5243 "crypto op session type not sessionless");
5245 /* Process crypto operation */
5246 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5247 ut_params->op), "failed to process sym crypto op");
5249 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5251 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5252 "crypto op status not success");
5254 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5255 ut_params->op->sym->cipher.data.offset);
5257 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5260 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5262 tdata->plaintext.data,
5263 tdata->plaintext.len,
5264 "GCM plaintext data not as expected");
5266 TEST_ASSERT_EQUAL(ut_params->op->status,
5267 RTE_CRYPTO_OP_STATUS_SUCCESS,
5268 "GCM authentication failed");
5273 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5275 return test_AES_GCM_authenticated_decryption_sessionless(
5282 struct crypto_testsuite_params *ts_params = &testsuite_params;
5283 struct rte_cryptodev_stats stats;
5284 struct rte_cryptodev *dev;
5285 cryptodev_stats_get_t temp_pfn;
5287 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5288 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5289 &stats) == -ENODEV),
5290 "rte_cryptodev_stats_get invalid dev failed");
5291 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5292 "rte_cryptodev_stats_get invalid Param failed");
5293 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5294 temp_pfn = dev->dev_ops->stats_get;
5295 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5296 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5298 "rte_cryptodev_stats_get invalid Param failed");
5299 dev->dev_ops->stats_get = temp_pfn;
5301 /* Test expected values */
5303 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5305 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5307 "rte_cryptodev_stats_get failed");
5308 TEST_ASSERT((stats.enqueued_count == 1),
5309 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5310 TEST_ASSERT((stats.dequeued_count == 1),
5311 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5312 TEST_ASSERT((stats.enqueue_err_count == 0),
5313 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5314 TEST_ASSERT((stats.dequeue_err_count == 0),
5315 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5317 /* invalid device but should ignore and not reset device stats*/
5318 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5319 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5321 "rte_cryptodev_stats_get failed");
5322 TEST_ASSERT((stats.enqueued_count == 1),
5323 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5325 /* check that a valid reset clears stats */
5326 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5327 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5329 "rte_cryptodev_stats_get failed");
5330 TEST_ASSERT((stats.enqueued_count == 0),
5331 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5332 TEST_ASSERT((stats.dequeued_count == 0),
5333 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5335 return TEST_SUCCESS;
5338 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5339 struct crypto_unittest_params *ut_params,
5340 enum rte_crypto_auth_operation op,
5341 const struct HMAC_MD5_vector *test_case)
5345 memcpy(key, test_case->key.data, test_case->key.len);
5347 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5348 ut_params->auth_xform.next = NULL;
5349 ut_params->auth_xform.auth.op = op;
5351 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5353 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5354 ut_params->auth_xform.auth.add_auth_data_length = 0;
5355 ut_params->auth_xform.auth.key.length = test_case->key.len;
5356 ut_params->auth_xform.auth.key.data = key;
5358 ut_params->sess = rte_cryptodev_sym_session_create(
5359 ts_params->valid_devs[0], &ut_params->auth_xform);
5361 if (ut_params->sess == NULL)
5364 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5366 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5367 rte_pktmbuf_tailroom(ut_params->ibuf));
5372 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5373 const struct HMAC_MD5_vector *test_case,
5374 uint8_t **plaintext)
5376 uint16_t plaintext_pad_len;
5378 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5380 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5383 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5385 memcpy(*plaintext, test_case->plaintext.data,
5386 test_case->plaintext.len);
5388 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5389 ut_params->ibuf, MD5_DIGEST_LEN);
5390 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5391 "no room to append digest");
5392 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5393 ut_params->ibuf, plaintext_pad_len);
5394 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5396 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5397 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5398 test_case->auth_tag.len);
5401 sym_op->auth.data.offset = 0;
5402 sym_op->auth.data.length = test_case->plaintext.len;
5404 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5405 ut_params->op->sym->m_src = ut_params->ibuf;
5411 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5413 uint16_t plaintext_pad_len;
5414 uint8_t *plaintext, *auth_tag;
5416 struct crypto_testsuite_params *ts_params = &testsuite_params;
5417 struct crypto_unittest_params *ut_params = &unittest_params;
5419 if (MD5_HMAC_create_session(ts_params, ut_params,
5420 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5423 /* Generate Crypto op data structure */
5424 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5425 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5426 TEST_ASSERT_NOT_NULL(ut_params->op,
5427 "Failed to allocate symmetric crypto operation struct");
5429 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5432 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5435 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5436 ut_params->op), "failed to process sym crypto op");
5438 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5439 "crypto op processing failed");
5441 if (ut_params->op->sym->m_dst) {
5442 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5443 uint8_t *, plaintext_pad_len);
5445 auth_tag = plaintext + plaintext_pad_len;
5448 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5450 test_case->auth_tag.data,
5451 test_case->auth_tag.len,
5452 "HMAC_MD5 generated tag not as expected");
5454 return TEST_SUCCESS;
5458 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5462 struct crypto_testsuite_params *ts_params = &testsuite_params;
5463 struct crypto_unittest_params *ut_params = &unittest_params;
5465 if (MD5_HMAC_create_session(ts_params, ut_params,
5466 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5470 /* Generate Crypto op data structure */
5471 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5472 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5473 TEST_ASSERT_NOT_NULL(ut_params->op,
5474 "Failed to allocate symmetric crypto operation struct");
5476 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5479 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5480 ut_params->op), "failed to process sym crypto op");
5482 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5483 "HMAC_MD5 crypto op processing failed");
5485 return TEST_SUCCESS;
5489 test_MD5_HMAC_generate_case_1(void)
5491 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5495 test_MD5_HMAC_verify_case_1(void)
5497 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5501 test_MD5_HMAC_generate_case_2(void)
5503 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5507 test_MD5_HMAC_verify_case_2(void)
5509 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5513 test_multi_session(void)
5515 struct crypto_testsuite_params *ts_params = &testsuite_params;
5516 struct crypto_unittest_params *ut_params = &unittest_params;
5518 struct rte_cryptodev_info dev_info;
5519 struct rte_cryptodev_sym_session **sessions;
5523 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5524 aes_cbc_key, hmac_sha512_key);
5527 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5529 sessions = rte_malloc(NULL,
5530 (sizeof(struct rte_cryptodev_sym_session *) *
5531 dev_info.sym.max_nb_sessions) + 1, 0);
5533 /* Create multiple crypto sessions*/
5534 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5535 sessions[i] = rte_cryptodev_sym_session_create(
5536 ts_params->valid_devs[0],
5537 &ut_params->auth_xform);
5538 TEST_ASSERT_NOT_NULL(sessions[i],
5539 "Session creation failed at session number %u",
5542 /* Attempt to send a request on each session */
5543 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5547 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5548 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5550 "Failed to perform decrypt on request number %u.", i);
5551 /* free crypto operation structure */
5553 rte_crypto_op_free(ut_params->op);
5556 * free mbuf - both obuf and ibuf are usually the same,
5557 * so check if they point at the same address is necessary,
5558 * to avoid freeing the mbuf twice.
5560 if (ut_params->obuf) {
5561 rte_pktmbuf_free(ut_params->obuf);
5562 if (ut_params->ibuf == ut_params->obuf)
5563 ut_params->ibuf = 0;
5564 ut_params->obuf = 0;
5566 if (ut_params->ibuf) {
5567 rte_pktmbuf_free(ut_params->ibuf);
5568 ut_params->ibuf = 0;
5572 /* Next session create should fail */
5573 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5574 &ut_params->auth_xform);
5575 TEST_ASSERT_NULL(sessions[i],
5576 "Session creation succeeded unexpectedly!");
5578 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5579 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5584 return TEST_SUCCESS;
5587 struct multi_session_params {
5588 struct crypto_unittest_params ut_params;
5589 uint8_t *cipher_key;
5591 const uint8_t *cipher;
5592 const uint8_t *digest;
5596 #define MB_SESSION_NUMBER 3
5599 test_multi_session_random_usage(void)
5601 struct crypto_testsuite_params *ts_params = &testsuite_params;
5602 struct rte_cryptodev_info dev_info;
5603 struct rte_cryptodev_sym_session **sessions;
5605 struct multi_session_params ut_paramz[] = {
5608 .cipher_key = ms_aes_cbc_key0,
5609 .hmac_key = ms_hmac_key0,
5610 .cipher = ms_aes_cbc_cipher0,
5611 .digest = ms_hmac_digest0,
5612 .iv = ms_aes_cbc_iv0
5615 .cipher_key = ms_aes_cbc_key1,
5616 .hmac_key = ms_hmac_key1,
5617 .cipher = ms_aes_cbc_cipher1,
5618 .digest = ms_hmac_digest1,
5619 .iv = ms_aes_cbc_iv1
5622 .cipher_key = ms_aes_cbc_key2,
5623 .hmac_key = ms_hmac_key2,
5624 .cipher = ms_aes_cbc_cipher2,
5625 .digest = ms_hmac_digest2,
5626 .iv = ms_aes_cbc_iv2
5631 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5633 sessions = rte_malloc(NULL,
5634 (sizeof(struct rte_cryptodev_sym_session *)
5635 * dev_info.sym.max_nb_sessions) + 1, 0);
5637 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5638 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5639 sizeof(struct crypto_unittest_params));
5641 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5642 &ut_paramz[i].ut_params,
5643 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5645 /* Create multiple crypto sessions*/
5646 sessions[i] = rte_cryptodev_sym_session_create(
5647 ts_params->valid_devs[0],
5648 &ut_paramz[i].ut_params.auth_xform);
5650 TEST_ASSERT_NOT_NULL(sessions[i],
5651 "Session creation failed at session number %u",
5657 for (i = 0; i < 40000; i++) {
5659 j = rand() % MB_SESSION_NUMBER;
5661 TEST_ASSERT_SUCCESS(
5662 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5664 &ut_paramz[j].ut_params,
5665 ts_params, ut_paramz[j].cipher,
5666 ut_paramz[j].digest,
5668 "Failed to perform decrypt on request number %u.", i);
5670 if (ut_paramz[j].ut_params.op)
5671 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5674 * free mbuf - both obuf and ibuf are usually the same,
5675 * so check if they point at the same address is necessary,
5676 * to avoid freeing the mbuf twice.
5678 if (ut_paramz[j].ut_params.obuf) {
5679 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5680 if (ut_paramz[j].ut_params.ibuf
5681 == ut_paramz[j].ut_params.obuf)
5682 ut_paramz[j].ut_params.ibuf = 0;
5683 ut_paramz[j].ut_params.obuf = 0;
5685 if (ut_paramz[j].ut_params.ibuf) {
5686 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5687 ut_paramz[j].ut_params.ibuf = 0;
5691 for (i = 0; i < MB_SESSION_NUMBER; i++)
5692 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5697 return TEST_SUCCESS;
5701 test_null_cipher_only_operation(void)
5703 struct crypto_testsuite_params *ts_params = &testsuite_params;
5704 struct crypto_unittest_params *ut_params = &unittest_params;
5706 /* Generate test mbuf data and space for digest */
5707 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5708 catch_22_quote, QUOTE_512_BYTES, 0);
5710 /* Setup Cipher Parameters */
5711 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5712 ut_params->cipher_xform.next = NULL;
5714 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5715 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5717 /* Create Crypto session*/
5718 ut_params->sess = rte_cryptodev_sym_session_create(
5719 ts_params->valid_devs[0], &ut_params->cipher_xform);
5720 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5722 /* Generate Crypto op data structure */
5723 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5724 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5725 TEST_ASSERT_NOT_NULL(ut_params->op,
5726 "Failed to allocate symmetric crypto operation struct");
5728 /* Set crypto operation data parameters */
5729 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5731 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5733 /* set crypto operation source mbuf */
5734 sym_op->m_src = ut_params->ibuf;
5736 sym_op->cipher.data.offset = 0;
5737 sym_op->cipher.data.length = QUOTE_512_BYTES;
5739 /* Process crypto operation */
5740 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5742 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5744 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5745 "crypto operation processing failed");
5748 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5749 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5752 "Ciphertext data not as expected");
5754 return TEST_SUCCESS;
5758 test_null_auth_only_operation(void)
5760 struct crypto_testsuite_params *ts_params = &testsuite_params;
5761 struct crypto_unittest_params *ut_params = &unittest_params;
5763 /* Generate test mbuf data and space for digest */
5764 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5765 catch_22_quote, QUOTE_512_BYTES, 0);
5767 /* Setup HMAC Parameters */
5768 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5769 ut_params->auth_xform.next = NULL;
5771 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5772 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5774 /* Create Crypto session*/
5775 ut_params->sess = rte_cryptodev_sym_session_create(
5776 ts_params->valid_devs[0], &ut_params->auth_xform);
5777 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5779 /* Generate Crypto op data structure */
5780 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5781 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5782 TEST_ASSERT_NOT_NULL(ut_params->op,
5783 "Failed to allocate symmetric crypto operation struct");
5785 /* Set crypto operation data parameters */
5786 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5788 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5790 sym_op->m_src = ut_params->ibuf;
5792 sym_op->auth.data.offset = 0;
5793 sym_op->auth.data.length = QUOTE_512_BYTES;
5795 /* Process crypto operation */
5796 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5798 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5800 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5801 "crypto operation processing failed");
5803 return TEST_SUCCESS;
5807 test_null_cipher_auth_operation(void)
5809 struct crypto_testsuite_params *ts_params = &testsuite_params;
5810 struct crypto_unittest_params *ut_params = &unittest_params;
5812 /* Generate test mbuf data and space for digest */
5813 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5814 catch_22_quote, QUOTE_512_BYTES, 0);
5816 /* Setup Cipher Parameters */
5817 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5818 ut_params->cipher_xform.next = &ut_params->auth_xform;
5820 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5821 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5823 /* Setup HMAC Parameters */
5824 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5825 ut_params->auth_xform.next = NULL;
5827 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5828 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5830 /* Create Crypto session*/
5831 ut_params->sess = rte_cryptodev_sym_session_create(
5832 ts_params->valid_devs[0], &ut_params->cipher_xform);
5833 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5835 /* Generate Crypto op data structure */
5836 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5837 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5838 TEST_ASSERT_NOT_NULL(ut_params->op,
5839 "Failed to allocate symmetric crypto operation struct");
5841 /* Set crypto operation data parameters */
5842 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5844 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5846 sym_op->m_src = ut_params->ibuf;
5848 sym_op->cipher.data.offset = 0;
5849 sym_op->cipher.data.length = QUOTE_512_BYTES;
5851 sym_op->auth.data.offset = 0;
5852 sym_op->auth.data.length = QUOTE_512_BYTES;
5854 /* Process crypto operation */
5855 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5857 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5859 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5860 "crypto operation processing failed");
5863 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5864 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5867 "Ciphertext data not as expected");
5869 return TEST_SUCCESS;
5873 test_null_auth_cipher_operation(void)
5875 struct crypto_testsuite_params *ts_params = &testsuite_params;
5876 struct crypto_unittest_params *ut_params = &unittest_params;
5878 /* Generate test mbuf data and space for digest */
5879 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5880 catch_22_quote, QUOTE_512_BYTES, 0);
5882 /* Setup Cipher Parameters */
5883 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5884 ut_params->cipher_xform.next = NULL;
5886 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5887 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5889 /* Setup HMAC Parameters */
5890 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5891 ut_params->auth_xform.next = &ut_params->cipher_xform;
5893 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5894 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5896 /* Create Crypto session*/
5897 ut_params->sess = rte_cryptodev_sym_session_create(
5898 ts_params->valid_devs[0], &ut_params->cipher_xform);
5899 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5901 /* Generate Crypto op data structure */
5902 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5903 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5904 TEST_ASSERT_NOT_NULL(ut_params->op,
5905 "Failed to allocate symmetric crypto operation struct");
5907 /* Set crypto operation data parameters */
5908 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5910 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5912 sym_op->m_src = ut_params->ibuf;
5914 sym_op->cipher.data.offset = 0;
5915 sym_op->cipher.data.length = QUOTE_512_BYTES;
5917 sym_op->auth.data.offset = 0;
5918 sym_op->auth.data.length = QUOTE_512_BYTES;
5920 /* Process crypto operation */
5921 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5923 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5925 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5926 "crypto operation processing failed");
5929 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5930 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5933 "Ciphertext data not as expected");
5935 return TEST_SUCCESS;
5940 test_null_invalid_operation(void)
5942 struct crypto_testsuite_params *ts_params = &testsuite_params;
5943 struct crypto_unittest_params *ut_params = &unittest_params;
5945 /* Setup Cipher Parameters */
5946 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5947 ut_params->cipher_xform.next = NULL;
5949 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
5950 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5952 /* Create Crypto session*/
5953 ut_params->sess = rte_cryptodev_sym_session_create(
5954 ts_params->valid_devs[0], &ut_params->cipher_xform);
5955 TEST_ASSERT_NULL(ut_params->sess,
5956 "Session creation succeeded unexpectedly");
5959 /* Setup HMAC Parameters */
5960 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5961 ut_params->auth_xform.next = NULL;
5963 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
5964 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5966 /* Create Crypto session*/
5967 ut_params->sess = rte_cryptodev_sym_session_create(
5968 ts_params->valid_devs[0], &ut_params->auth_xform);
5969 TEST_ASSERT_NULL(ut_params->sess,
5970 "Session creation succeeded unexpectedly");
5972 return TEST_SUCCESS;
5976 #define NULL_BURST_LENGTH (32)
5979 test_null_burst_operation(void)
5981 struct crypto_testsuite_params *ts_params = &testsuite_params;
5982 struct crypto_unittest_params *ut_params = &unittest_params;
5984 unsigned i, burst_len = NULL_BURST_LENGTH;
5986 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
5987 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
5989 /* Setup Cipher Parameters */
5990 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5991 ut_params->cipher_xform.next = &ut_params->auth_xform;
5993 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5994 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5996 /* Setup HMAC Parameters */
5997 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5998 ut_params->auth_xform.next = NULL;
6000 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6001 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6003 /* Create Crypto session*/
6004 ut_params->sess = rte_cryptodev_sym_session_create(
6005 ts_params->valid_devs[0], &ut_params->cipher_xform);
6006 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6008 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6009 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6010 burst_len, "failed to generate burst of crypto ops");
6012 /* Generate an operation for each mbuf in burst */
6013 for (i = 0; i < burst_len; i++) {
6014 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6016 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6018 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6022 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6024 burst[i]->sym->m_src = m;
6027 /* Process crypto operation */
6028 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6029 0, burst, burst_len),
6031 "Error enqueuing burst");
6033 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6034 0, burst_dequeued, burst_len),
6036 "Error dequeuing burst");
6039 for (i = 0; i < burst_len; i++) {
6041 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6042 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6044 "data not as expected");
6046 rte_pktmbuf_free(burst[i]->sym->m_src);
6047 rte_crypto_op_free(burst[i]);
6050 return TEST_SUCCESS;
6054 generate_gmac_large_plaintext(uint8_t *data)
6058 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6059 memcpy(&data[i], &data[0], 32);
6063 create_gmac_operation(enum rte_crypto_auth_operation op,
6064 const struct gmac_test_data *tdata)
6066 struct crypto_testsuite_params *ts_params = &testsuite_params;
6067 struct crypto_unittest_params *ut_params = &unittest_params;
6068 struct rte_crypto_sym_op *sym_op;
6070 unsigned iv_pad_len;
6071 unsigned aad_pad_len;
6073 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
6074 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6077 * Runtime generate the large plain text instead of use hard code
6078 * plain text vector. It is done to avoid create huge source file
6079 * with the test vector.
6081 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6082 generate_gmac_large_plaintext(tdata->aad.data);
6084 /* Generate Crypto op data structure */
6085 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6086 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6087 TEST_ASSERT_NOT_NULL(ut_params->op,
6088 "Failed to allocate symmetric crypto operation struct");
6090 sym_op = ut_params->op->sym;
6091 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6093 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6094 "no room to append aad");
6096 sym_op->auth.aad.length = tdata->aad.len;
6097 sym_op->auth.aad.phys_addr =
6098 rte_pktmbuf_mtophys(ut_params->ibuf);
6099 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6101 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6102 ut_params->ibuf, tdata->gmac_tag.len);
6103 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6104 "no room to append digest");
6106 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6107 ut_params->ibuf, aad_pad_len);
6108 sym_op->auth.digest.length = tdata->gmac_tag.len;
6110 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6111 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6112 tdata->gmac_tag.len);
6113 TEST_HEXDUMP(stdout, "digest:",
6114 sym_op->auth.digest.data,
6115 sym_op->auth.digest.length);
6118 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6119 ut_params->ibuf, iv_pad_len);
6120 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6122 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6123 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6124 sym_op->cipher.iv.length = tdata->iv.len;
6126 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
6128 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6130 sym_op->cipher.data.length = 0;
6131 sym_op->cipher.data.offset = 0;
6133 sym_op->auth.data.offset = 0;
6134 sym_op->auth.data.length = 0;
6139 static int create_gmac_session(uint8_t dev_id,
6140 enum rte_crypto_cipher_operation op,
6141 const struct gmac_test_data *tdata,
6142 enum rte_crypto_auth_operation auth_op)
6144 uint8_t cipher_key[tdata->key.len];
6146 struct crypto_unittest_params *ut_params = &unittest_params;
6148 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6150 /* For GMAC we setup cipher parameters */
6151 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6152 ut_params->cipher_xform.next = NULL;
6153 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6154 ut_params->cipher_xform.cipher.op = op;
6155 ut_params->cipher_xform.cipher.key.data = cipher_key;
6156 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6158 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6159 ut_params->auth_xform.next = NULL;
6161 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6162 ut_params->auth_xform.auth.op = auth_op;
6163 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6164 ut_params->auth_xform.auth.add_auth_data_length = 0;
6165 ut_params->auth_xform.auth.key.length = 0;
6166 ut_params->auth_xform.auth.key.data = NULL;
6168 ut_params->cipher_xform.next = &ut_params->auth_xform;
6170 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6171 &ut_params->cipher_xform);
6173 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6179 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6181 struct crypto_testsuite_params *ts_params = &testsuite_params;
6182 struct crypto_unittest_params *ut_params = &unittest_params;
6186 uint8_t *auth_tag, *p;
6187 uint16_t aad_pad_len;
6189 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6190 "No GMAC length in the source data");
6192 retval = create_gmac_session(ts_params->valid_devs[0],
6193 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6194 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6199 if (tdata->aad.len > MBUF_SIZE)
6200 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6202 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6203 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6204 "Failed to allocate input buffer in mempool");
6206 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6207 rte_pktmbuf_tailroom(ut_params->ibuf));
6209 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6211 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6213 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6219 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6221 ut_params->op->sym->m_src = ut_params->ibuf;
6223 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6224 ut_params->op), "failed to process sym crypto op");
6226 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6227 "crypto op processing failed");
6229 if (ut_params->op->sym->m_dst) {
6230 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6231 uint8_t *, aad_pad_len);
6233 auth_tag = p + aad_pad_len;
6236 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6238 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6240 tdata->gmac_tag.data,
6241 tdata->gmac_tag.len,
6242 "GMAC Generated auth tag not as expected");
6248 test_AES_GMAC_authentication_test_case_1(void)
6250 return test_AES_GMAC_authentication(&gmac_test_case_1);
6254 test_AES_GMAC_authentication_test_case_2(void)
6256 return test_AES_GMAC_authentication(&gmac_test_case_2);
6260 test_AES_GMAC_authentication_test_case_3(void)
6262 return test_AES_GMAC_authentication(&gmac_test_case_3);
6266 test_AES_GMAC_authentication_test_case_4(void)
6268 return test_AES_GMAC_authentication(&gmac_test_case_4);
6272 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6274 struct crypto_testsuite_params *ts_params = &testsuite_params;
6275 struct crypto_unittest_params *ut_params = &unittest_params;
6278 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6279 "No GMAC length in the source data");
6281 retval = create_gmac_session(ts_params->valid_devs[0],
6282 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6283 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6288 if (tdata->aad.len > MBUF_SIZE)
6289 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6291 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6292 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6293 "Failed to allocate input buffer in mempool");
6295 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6296 rte_pktmbuf_tailroom(ut_params->ibuf));
6298 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6304 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6306 ut_params->op->sym->m_src = ut_params->ibuf;
6308 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6309 ut_params->op), "failed to process sym crypto op");
6311 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6312 "crypto op processing failed");
6319 test_AES_GMAC_authentication_verify_test_case_1(void)
6321 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6325 test_AES_GMAC_authentication_verify_test_case_2(void)
6327 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6331 test_AES_GMAC_authentication_verify_test_case_3(void)
6333 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6337 test_AES_GMAC_authentication_verify_test_case_4(void)
6339 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6342 struct test_crypto_vector {
6343 enum rte_crypto_cipher_algorithm crypto_algo;
6356 const uint8_t *data;
6361 const uint8_t *data;
6365 enum rte_crypto_auth_algorithm auth_algo;
6373 const uint8_t *data;
6383 static const struct test_crypto_vector
6384 hmac_sha1_test_crypto_vector = {
6385 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6387 .data = plaintext_hash,
6392 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6393 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6394 0xDE, 0xF4, 0xDE, 0xAD
6400 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6401 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6402 0x3F, 0x91, 0x64, 0x59
6408 static const struct test_crypto_vector
6409 aes128_gmac_test_vector = {
6410 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6411 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6413 .data = plaintext_hash,
6418 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6419 0x08, 0x09, 0x0A, 0x0B
6425 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6426 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6432 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6433 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6439 static const struct test_crypto_vector
6440 aes128cbc_hmac_sha1_test_vector = {
6441 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6444 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6445 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6451 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6452 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6457 .data = plaintext_hash,
6461 .data = ciphertext512_aes128cbc,
6464 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6467 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6468 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6469 0xDE, 0xF4, 0xDE, 0xAD
6475 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6476 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6477 0x18, 0x8C, 0x1D, 0x32
6484 data_corruption(uint8_t *data)
6490 tag_corruption(uint8_t *data, unsigned int tag_offset)
6492 data[tag_offset] += 1;
6496 create_auth_session(struct crypto_unittest_params *ut_params,
6498 const struct test_crypto_vector *reference,
6499 enum rte_crypto_auth_operation auth_op)
6501 uint8_t auth_key[reference->auth_key.len + 1];
6503 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6505 /* Setup Authentication Parameters */
6506 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6507 ut_params->auth_xform.auth.op = auth_op;
6508 ut_params->auth_xform.next = NULL;
6509 ut_params->auth_xform.auth.algo = reference->auth_algo;
6510 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6511 ut_params->auth_xform.auth.key.data = auth_key;
6512 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6513 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6515 /* Create Crypto session*/
6516 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6517 &ut_params->auth_xform);
6519 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6525 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6527 const struct test_crypto_vector *reference,
6528 enum rte_crypto_auth_operation auth_op,
6529 enum rte_crypto_cipher_operation cipher_op)
6531 uint8_t cipher_key[reference->cipher_key.len + 1];
6532 uint8_t auth_key[reference->auth_key.len + 1];
6534 memcpy(cipher_key, reference->cipher_key.data,
6535 reference->cipher_key.len);
6536 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6538 /* Setup Authentication Parameters */
6539 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6540 ut_params->auth_xform.auth.op = auth_op;
6541 ut_params->auth_xform.next = &ut_params->cipher_xform;
6542 ut_params->auth_xform.auth.algo = reference->auth_algo;
6543 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6544 ut_params->auth_xform.auth.key.data = auth_key;
6545 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6546 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6548 /* Setup Cipher Parameters */
6549 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6550 ut_params->cipher_xform.next = NULL;
6551 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6552 ut_params->cipher_xform.cipher.op = cipher_op;
6553 ut_params->cipher_xform.cipher.key.data = cipher_key;
6554 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6556 /* Create Crypto session*/
6557 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6558 &ut_params->auth_xform);
6560 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6566 create_auth_operation(struct crypto_testsuite_params *ts_params,
6567 struct crypto_unittest_params *ut_params,
6568 const struct test_crypto_vector *reference,
6569 unsigned int auth_generate)
6571 /* Generate Crypto op data structure */
6572 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6573 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6574 TEST_ASSERT_NOT_NULL(ut_params->op,
6575 "Failed to allocate pktmbuf offload");
6577 /* Set crypto operation data parameters */
6578 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6580 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6582 /* set crypto operation source mbuf */
6583 sym_op->m_src = ut_params->ibuf;
6586 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6587 ut_params->ibuf, reference->digest.len);
6589 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6590 "no room to append auth tag");
6592 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6593 ut_params->ibuf, reference->plaintext.len);
6594 sym_op->auth.digest.length = reference->digest.len;
6597 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6599 memcpy(sym_op->auth.digest.data,
6600 reference->digest.data,
6601 reference->digest.len);
6603 TEST_HEXDUMP(stdout, "digest:",
6604 sym_op->auth.digest.data,
6605 sym_op->auth.digest.length);
6607 sym_op->auth.data.length = reference->plaintext.len;
6608 sym_op->auth.data.offset = 0;
6614 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6615 struct crypto_unittest_params *ut_params,
6616 const struct test_crypto_vector *reference,
6617 unsigned int auth_generate)
6619 /* Generate Crypto op data structure */
6620 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6621 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6622 TEST_ASSERT_NOT_NULL(ut_params->op,
6623 "Failed to allocate pktmbuf offload");
6625 /* Set crypto operation data parameters */
6626 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6628 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6630 /* set crypto operation source mbuf */
6631 sym_op->m_src = ut_params->ibuf;
6634 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6635 reference->aad.len);
6636 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6637 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6639 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6641 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6642 sym_op->auth.aad.length = reference->aad.len;
6645 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6646 ut_params->ibuf, reference->digest.len);
6648 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6649 "no room to append auth tag");
6651 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6652 ut_params->ibuf, reference->ciphertext.len);
6653 sym_op->auth.digest.length = reference->digest.len;
6656 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6658 memcpy(sym_op->auth.digest.data,
6659 reference->digest.data,
6660 reference->digest.len);
6662 TEST_HEXDUMP(stdout, "digest:",
6663 sym_op->auth.digest.data,
6664 sym_op->auth.digest.length);
6666 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6667 ut_params->ibuf, reference->iv.len);
6668 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6670 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6671 sym_op->cipher.iv.length = reference->iv.len;
6673 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6675 sym_op->cipher.data.length = 0;
6676 sym_op->cipher.data.offset = 0;
6678 sym_op->auth.data.length = 0;
6679 sym_op->auth.data.offset = 0;
6685 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6686 struct crypto_unittest_params *ut_params,
6687 const struct test_crypto_vector *reference,
6688 unsigned int auth_generate)
6690 /* Generate Crypto op data structure */
6691 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6692 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6693 TEST_ASSERT_NOT_NULL(ut_params->op,
6694 "Failed to allocate pktmbuf offload");
6696 /* Set crypto operation data parameters */
6697 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6699 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6701 /* set crypto operation source mbuf */
6702 sym_op->m_src = ut_params->ibuf;
6705 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6706 ut_params->ibuf, reference->digest.len);
6708 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6709 "no room to append auth tag");
6711 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6712 ut_params->ibuf, reference->ciphertext.len);
6713 sym_op->auth.digest.length = reference->digest.len;
6716 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6718 memcpy(sym_op->auth.digest.data,
6719 reference->digest.data,
6720 reference->digest.len);
6722 TEST_HEXDUMP(stdout, "digest:",
6723 sym_op->auth.digest.data,
6724 sym_op->auth.digest.length);
6726 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6727 ut_params->ibuf, reference->iv.len);
6728 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6730 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6731 sym_op->cipher.iv.length = reference->iv.len;
6733 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6735 sym_op->cipher.data.length = reference->ciphertext.len;
6736 sym_op->cipher.data.offset = reference->iv.len;
6738 sym_op->auth.data.length = reference->ciphertext.len;
6739 sym_op->auth.data.offset = reference->iv.len;
6745 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6746 struct crypto_unittest_params *ut_params,
6747 const struct test_crypto_vector *reference)
6749 return create_auth_operation(ts_params, ut_params, reference, 0);
6753 create_auth_verify_GMAC_operation(
6754 struct crypto_testsuite_params *ts_params,
6755 struct crypto_unittest_params *ut_params,
6756 const struct test_crypto_vector *reference)
6758 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6762 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6763 struct crypto_unittest_params *ut_params,
6764 const struct test_crypto_vector *reference)
6766 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6770 test_authentication_verify_fail_when_data_corruption(
6771 struct crypto_testsuite_params *ts_params,
6772 struct crypto_unittest_params *ut_params,
6773 const struct test_crypto_vector *reference,
6774 unsigned int data_corrupted)
6780 /* Create session */
6781 retval = create_auth_session(ut_params,
6782 ts_params->valid_devs[0],
6784 RTE_CRYPTO_AUTH_OP_VERIFY);
6788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6789 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6790 "Failed to allocate input buffer in mempool");
6792 /* clear mbuf payload */
6793 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6794 rte_pktmbuf_tailroom(ut_params->ibuf));
6796 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6797 reference->plaintext.len);
6798 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6799 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6801 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6803 /* Create operation */
6804 retval = create_auth_verify_operation(ts_params, ut_params, reference);
6810 data_corruption(plaintext);
6812 tag_corruption(plaintext, reference->plaintext.len);
6814 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6816 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6817 TEST_ASSERT_EQUAL(ut_params->op->status,
6818 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6819 "authentication not failed");
6821 ut_params->obuf = ut_params->op->sym->m_src;
6822 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6828 test_authentication_verify_GMAC_fail_when_corruption(
6829 struct crypto_testsuite_params *ts_params,
6830 struct crypto_unittest_params *ut_params,
6831 const struct test_crypto_vector *reference,
6832 unsigned int data_corrupted)
6836 /* Create session */
6837 retval = create_auth_cipher_session(ut_params,
6838 ts_params->valid_devs[0],
6840 RTE_CRYPTO_AUTH_OP_VERIFY,
6841 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6845 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6846 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6847 "Failed to allocate input buffer in mempool");
6849 /* clear mbuf payload */
6850 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6851 rte_pktmbuf_tailroom(ut_params->ibuf));
6853 /* Create operation */
6854 retval = create_auth_verify_GMAC_operation(ts_params,
6862 data_corruption(ut_params->op->sym->auth.aad.data);
6864 tag_corruption(ut_params->op->sym->auth.aad.data,
6865 reference->aad.len);
6867 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6869 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6870 TEST_ASSERT_EQUAL(ut_params->op->status,
6871 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6872 "authentication not failed");
6874 ut_params->obuf = ut_params->op->sym->m_src;
6875 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6881 test_authenticated_decryption_fail_when_corruption(
6882 struct crypto_testsuite_params *ts_params,
6883 struct crypto_unittest_params *ut_params,
6884 const struct test_crypto_vector *reference,
6885 unsigned int data_corrupted)
6889 uint8_t *ciphertext;
6891 /* Create session */
6892 retval = create_auth_cipher_session(ut_params,
6893 ts_params->valid_devs[0],
6895 RTE_CRYPTO_AUTH_OP_VERIFY,
6896 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6900 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6901 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6902 "Failed to allocate input buffer in mempool");
6904 /* clear mbuf payload */
6905 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6906 rte_pktmbuf_tailroom(ut_params->ibuf));
6908 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6909 reference->ciphertext.len);
6910 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
6911 memcpy(ciphertext, reference->ciphertext.data,
6912 reference->ciphertext.len);
6914 /* Create operation */
6915 retval = create_cipher_auth_verify_operation(ts_params,
6923 data_corruption(ciphertext);
6925 tag_corruption(ciphertext, reference->ciphertext.len);
6927 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6930 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6931 TEST_ASSERT_EQUAL(ut_params->op->status,
6932 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6933 "authentication not failed");
6935 ut_params->obuf = ut_params->op->sym->m_src;
6936 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6942 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
6943 const struct gcm_test_data *tdata,
6944 void *digest_mem, uint64_t digest_phys)
6946 struct crypto_testsuite_params *ts_params = &testsuite_params;
6947 struct crypto_unittest_params *ut_params = &unittest_params;
6949 const unsigned int auth_tag_len = tdata->auth_tag.len;
6950 const unsigned int iv_len = tdata->iv.len;
6951 const unsigned int aad_len = tdata->aad.len;
6953 unsigned int iv_pad_len = 0;
6955 /* Generate Crypto op data structure */
6956 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6957 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6958 TEST_ASSERT_NOT_NULL(ut_params->op,
6959 "Failed to allocate symmetric crypto operation struct");
6961 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6963 sym_op->auth.digest.data = digest_mem;
6965 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6966 "no room to append digest");
6968 sym_op->auth.digest.phys_addr = digest_phys;
6969 sym_op->auth.digest.length = auth_tag_len;
6971 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
6972 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
6974 TEST_HEXDUMP(stdout, "digest:",
6975 sym_op->auth.digest.data,
6976 sym_op->auth.digest.length);
6979 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
6981 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6982 ut_params->ibuf, iv_pad_len);
6984 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
6985 "no room to prepend iv");
6987 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6988 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6989 sym_op->cipher.iv.length = iv_len;
6991 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
6993 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
6994 ut_params->ibuf, aad_len);
6995 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6996 "no room to prepend aad");
6997 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
6999 sym_op->auth.aad.length = aad_len;
7001 memset(sym_op->auth.aad.data, 0, aad_len);
7002 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7004 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
7005 TEST_HEXDUMP(stdout, "aad:",
7006 sym_op->auth.aad.data, aad_len);
7008 sym_op->cipher.data.length = tdata->plaintext.len;
7009 sym_op->cipher.data.offset = aad_len + iv_pad_len;
7011 sym_op->auth.data.offset = aad_len + iv_pad_len;
7012 sym_op->auth.data.length = tdata->plaintext.len;
7017 #define SGL_MAX_NO 16
7020 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7021 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7023 struct crypto_testsuite_params *ts_params = &testsuite_params;
7024 struct crypto_unittest_params *ut_params = &unittest_params;
7025 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7028 int to_trn_tbl[SGL_MAX_NO];
7030 unsigned int trn_data = 0;
7031 uint8_t *plaintext, *ciphertext, *auth_tag;
7033 if (fragsz > tdata->plaintext.len)
7034 fragsz = tdata->plaintext.len;
7036 uint16_t plaintext_len = fragsz;
7037 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7039 if (fragsz_oop > tdata->plaintext.len)
7040 frag_size_oop = tdata->plaintext.len;
7043 void *digest_mem = NULL;
7045 uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
7048 if (tdata->plaintext.len % fragsz != 0) {
7049 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7052 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7057 * For out-op-place we need to alloc another mbuf
7060 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7061 rte_pktmbuf_append(ut_params->obuf,
7062 frag_size_oop + prepend_len);
7063 buf_oop = ut_params->obuf;
7066 /* Create GCM session */
7067 retval = create_gcm_session(ts_params->valid_devs[0],
7068 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7069 tdata->key.data, tdata->key.len,
7070 tdata->aad.len, tdata->auth_tag.len,
7071 RTE_CRYPTO_AUTH_OP_GENERATE);
7075 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7077 /* clear mbuf payload */
7078 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7079 rte_pktmbuf_tailroom(ut_params->ibuf));
7081 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7084 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7086 trn_data += plaintext_len;
7088 buf = ut_params->ibuf;
7091 * Loop until no more fragments
7094 while (trn_data < tdata->plaintext.len) {
7096 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7097 (tdata->plaintext.len - trn_data) : fragsz;
7099 to_trn_tbl[ecx++] = to_trn;
7101 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7104 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7105 rte_pktmbuf_tailroom(buf));
7108 if (oop && !fragsz_oop) {
7109 buf_last_oop = buf_oop->next =
7110 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7111 buf_oop = buf_oop->next;
7112 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7113 0, rte_pktmbuf_tailroom(buf_oop));
7114 rte_pktmbuf_append(buf_oop, to_trn);
7117 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7120 memcpy(plaintext, tdata->plaintext.data + trn_data,
7123 if (trn_data == tdata->plaintext.len) {
7126 digest_mem = rte_pktmbuf_append(buf_oop,
7127 tdata->auth_tag.len);
7129 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7130 tdata->auth_tag.len);
7134 uint64_t digest_phys = 0;
7136 ut_params->ibuf->nb_segs = segs;
7139 if (fragsz_oop && oop) {
7143 if (frag_size_oop == tdata->plaintext.len) {
7144 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7145 tdata->auth_tag.len);
7147 digest_phys = rte_pktmbuf_mtophys_offset(
7149 tdata->plaintext.len + prepend_len);
7152 trn_data = frag_size_oop;
7153 while (trn_data < tdata->plaintext.len) {
7156 (tdata->plaintext.len - trn_data <
7158 (tdata->plaintext.len - trn_data) :
7161 to_trn_tbl[ecx++] = to_trn;
7163 buf_last_oop = buf_oop->next =
7164 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7165 buf_oop = buf_oop->next;
7166 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7167 0, rte_pktmbuf_tailroom(buf_oop));
7168 rte_pktmbuf_append(buf_oop, to_trn);
7172 if (trn_data == tdata->plaintext.len) {
7173 digest_mem = rte_pktmbuf_append(buf_oop,
7174 tdata->auth_tag.len);
7178 ut_params->obuf->nb_segs = segs;
7182 * Place digest at the end of the last buffer
7185 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7186 if (oop && buf_last_oop)
7187 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7189 if (!digest_mem && !oop) {
7190 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7191 + tdata->auth_tag.len);
7192 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7193 tdata->plaintext.len);
7196 /* Create GCM opertaion */
7197 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7198 tdata, digest_mem, digest_phys);
7203 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7205 ut_params->op->sym->m_src = ut_params->ibuf;
7207 ut_params->op->sym->m_dst = ut_params->obuf;
7209 /* Process crypto operation */
7210 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7211 ut_params->op), "failed to process sym crypto op");
7213 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7214 "crypto op processing failed");
7217 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7218 uint8_t *, prepend_len);
7220 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7221 uint8_t *, prepend_len);
7225 fragsz = fragsz_oop;
7227 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7229 tdata->ciphertext.data,
7231 "GCM Ciphertext data not as expected");
7233 buf = ut_params->op->sym->m_src->next;
7235 buf = ut_params->op->sym->m_dst->next;
7237 unsigned int off = fragsz;
7241 ciphertext = rte_pktmbuf_mtod(buf,
7244 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7246 tdata->ciphertext.data + off,
7248 "GCM Ciphertext data not as expected");
7250 off += to_trn_tbl[ecx++];
7254 auth_tag = digest_mem;
7255 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7257 tdata->auth_tag.data,
7258 tdata->auth_tag.len,
7259 "GCM Generated auth tag not as expected");
7265 #define OUT_OF_PLACE 1
7268 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7270 return test_AES_GCM_authenticated_encryption_SGL(
7271 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7275 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7277 return test_AES_GCM_authenticated_encryption_SGL(
7278 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7282 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7284 return test_AES_GCM_authenticated_encryption_SGL(
7285 &gcm_test_case_8, OUT_OF_PLACE, 400,
7286 gcm_test_case_8.plaintext.len);
7290 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7293 return test_AES_GCM_authenticated_encryption_SGL(
7294 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7298 test_authentication_verify_fail_when_data_corrupted(
7299 struct crypto_testsuite_params *ts_params,
7300 struct crypto_unittest_params *ut_params,
7301 const struct test_crypto_vector *reference)
7303 return test_authentication_verify_fail_when_data_corruption(
7304 ts_params, ut_params, reference, 1);
7308 test_authentication_verify_fail_when_tag_corrupted(
7309 struct crypto_testsuite_params *ts_params,
7310 struct crypto_unittest_params *ut_params,
7311 const struct test_crypto_vector *reference)
7313 return test_authentication_verify_fail_when_data_corruption(
7314 ts_params, ut_params, reference, 0);
7318 test_authentication_verify_GMAC_fail_when_data_corrupted(
7319 struct crypto_testsuite_params *ts_params,
7320 struct crypto_unittest_params *ut_params,
7321 const struct test_crypto_vector *reference)
7323 return test_authentication_verify_GMAC_fail_when_corruption(
7324 ts_params, ut_params, reference, 1);
7328 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7329 struct crypto_testsuite_params *ts_params,
7330 struct crypto_unittest_params *ut_params,
7331 const struct test_crypto_vector *reference)
7333 return test_authentication_verify_GMAC_fail_when_corruption(
7334 ts_params, ut_params, reference, 0);
7338 test_authenticated_decryption_fail_when_data_corrupted(
7339 struct crypto_testsuite_params *ts_params,
7340 struct crypto_unittest_params *ut_params,
7341 const struct test_crypto_vector *reference)
7343 return test_authenticated_decryption_fail_when_corruption(
7344 ts_params, ut_params, reference, 1);
7348 test_authenticated_decryption_fail_when_tag_corrupted(
7349 struct crypto_testsuite_params *ts_params,
7350 struct crypto_unittest_params *ut_params,
7351 const struct test_crypto_vector *reference)
7353 return test_authenticated_decryption_fail_when_corruption(
7354 ts_params, ut_params, reference, 0);
7358 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7360 return test_authentication_verify_fail_when_data_corrupted(
7361 &testsuite_params, &unittest_params,
7362 &hmac_sha1_test_crypto_vector);
7366 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7368 return test_authentication_verify_fail_when_tag_corrupted(
7369 &testsuite_params, &unittest_params,
7370 &hmac_sha1_test_crypto_vector);
7374 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7376 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7377 &testsuite_params, &unittest_params,
7378 &aes128_gmac_test_vector);
7382 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7384 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7385 &testsuite_params, &unittest_params,
7386 &aes128_gmac_test_vector);
7390 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7392 return test_authenticated_decryption_fail_when_data_corrupted(
7395 &aes128cbc_hmac_sha1_test_vector);
7399 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7401 return test_authenticated_decryption_fail_when_tag_corrupted(
7404 &aes128cbc_hmac_sha1_test_vector);
7407 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7409 /* global AESNI slave IDs for the scheduler test */
7410 uint8_t aesni_ids[2];
7413 test_scheduler_attach_slave_op(void)
7415 struct crypto_testsuite_params *ts_params = &testsuite_params;
7416 uint8_t sched_id = ts_params->valid_devs[0];
7417 uint32_t nb_devs, i, nb_devs_attached = 0;
7420 /* create 2 AESNI_MB if necessary */
7421 nb_devs = rte_cryptodev_count_devtype(
7422 RTE_CRYPTODEV_AESNI_MB_PMD);
7424 for (i = nb_devs; i < 2; i++) {
7425 ret = rte_eal_vdev_init(
7426 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
7428 TEST_ASSERT(ret == 0,
7429 "Failed to create instance %u of"
7431 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7435 /* attach 2 AESNI_MB cdevs */
7436 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7438 struct rte_cryptodev_info info;
7440 rte_cryptodev_info_get(i, &info);
7441 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7444 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7447 TEST_ASSERT(ret == 0,
7448 "Failed to attach device %u of pmd : %s", i,
7449 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7451 aesni_ids[nb_devs_attached] = (uint8_t)i;
7460 test_scheduler_detach_slave_op(void)
7462 struct crypto_testsuite_params *ts_params = &testsuite_params;
7463 uint8_t sched_id = ts_params->valid_devs[0];
7467 for (i = 0; i < 2; i++) {
7468 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7470 TEST_ASSERT(ret == 0,
7471 "Failed to detach device %u", aesni_ids[i]);
7478 test_scheduler_mode_op(void)
7480 struct crypto_testsuite_params *ts_params = &testsuite_params;
7481 uint8_t sched_id = ts_params->valid_devs[0];
7482 struct rte_cryptodev_scheduler_ops op = {0};
7483 struct rte_cryptodev_scheduler dummy_scheduler = {
7484 .description = "dummy scheduler to test mode",
7485 .name = "dummy scheduler",
7486 .mode = CDEV_SCHED_MODE_USERDEFINED,
7491 /* set user defined mode */
7492 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7494 TEST_ASSERT(ret == 0,
7495 "Failed to set cdev %u to user defined mode", sched_id);
7497 /* set round robin mode */
7498 ret = rte_crpytodev_scheduler_mode_set(sched_id,
7499 CDEV_SCHED_MODE_ROUNDROBIN);
7500 TEST_ASSERT(ret == 0,
7501 "Failed to set cdev %u to round-robin mode", sched_id);
7502 TEST_ASSERT(rte_crpytodev_scheduler_mode_get(sched_id) ==
7503 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7509 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7510 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7511 .setup = testsuite_setup,
7512 .teardown = testsuite_teardown,
7513 .unit_test_cases = {
7514 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7515 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7516 TEST_CASE_ST(ut_setup, ut_teardown,
7517 test_AES_chain_scheduler_all),
7518 TEST_CASE_ST(ut_setup, ut_teardown,
7519 test_AES_cipheronly_scheduler_all),
7520 TEST_CASE_ST(ut_setup, ut_teardown,
7521 test_authonly_scheduler_all),
7522 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7523 TEST_CASES_END() /**< NULL terminate unit test array */
7527 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7529 static struct unit_test_suite cryptodev_qat_testsuite = {
7530 .suite_name = "Crypto QAT Unit Test Suite",
7531 .setup = testsuite_setup,
7532 .teardown = testsuite_teardown,
7533 .unit_test_cases = {
7534 TEST_CASE_ST(ut_setup, ut_teardown,
7535 test_device_configure_invalid_dev_id),
7536 TEST_CASE_ST(ut_setup, ut_teardown,
7537 test_device_configure_invalid_queue_pair_ids),
7538 TEST_CASE_ST(ut_setup, ut_teardown,
7539 test_queue_pair_descriptor_setup),
7540 TEST_CASE_ST(ut_setup, ut_teardown,
7541 test_multi_session),
7543 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7544 TEST_CASE_ST(ut_setup, ut_teardown,
7545 test_AES_cipheronly_qat_all),
7546 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7547 TEST_CASE_ST(ut_setup, ut_teardown,
7548 test_3DES_cipheronly_qat_all),
7549 TEST_CASE_ST(ut_setup, ut_teardown,
7550 test_DES_cipheronly_qat_all),
7551 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7553 /** AES GCM Authenticated Encryption */
7554 TEST_CASE_ST(ut_setup, ut_teardown,
7555 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7556 TEST_CASE_ST(ut_setup, ut_teardown,
7557 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7558 TEST_CASE_ST(ut_setup, ut_teardown,
7559 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7560 TEST_CASE_ST(ut_setup, ut_teardown,
7561 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7562 TEST_CASE_ST(ut_setup, ut_teardown,
7563 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7564 TEST_CASE_ST(ut_setup, ut_teardown,
7565 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7566 TEST_CASE_ST(ut_setup, ut_teardown,
7567 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7568 TEST_CASE_ST(ut_setup, ut_teardown,
7569 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7570 TEST_CASE_ST(ut_setup, ut_teardown,
7571 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7572 TEST_CASE_ST(ut_setup, ut_teardown,
7573 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7575 /** AES GCM Authenticated Decryption */
7576 TEST_CASE_ST(ut_setup, ut_teardown,
7577 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7578 TEST_CASE_ST(ut_setup, ut_teardown,
7579 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7580 TEST_CASE_ST(ut_setup, ut_teardown,
7581 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7582 TEST_CASE_ST(ut_setup, ut_teardown,
7583 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7584 TEST_CASE_ST(ut_setup, ut_teardown,
7585 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7586 TEST_CASE_ST(ut_setup, ut_teardown,
7587 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7588 TEST_CASE_ST(ut_setup, ut_teardown,
7589 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7591 /** AES GMAC Authentication */
7592 TEST_CASE_ST(ut_setup, ut_teardown,
7593 test_AES_GMAC_authentication_test_case_1),
7594 TEST_CASE_ST(ut_setup, ut_teardown,
7595 test_AES_GMAC_authentication_verify_test_case_1),
7596 TEST_CASE_ST(ut_setup, ut_teardown,
7597 test_AES_GMAC_authentication_test_case_2),
7598 TEST_CASE_ST(ut_setup, ut_teardown,
7599 test_AES_GMAC_authentication_verify_test_case_2),
7600 TEST_CASE_ST(ut_setup, ut_teardown,
7601 test_AES_GMAC_authentication_test_case_3),
7602 TEST_CASE_ST(ut_setup, ut_teardown,
7603 test_AES_GMAC_authentication_verify_test_case_3),
7605 /** SNOW 3G encrypt only (UEA2) */
7606 TEST_CASE_ST(ut_setup, ut_teardown,
7607 test_snow3g_encryption_test_case_1),
7608 TEST_CASE_ST(ut_setup, ut_teardown,
7609 test_snow3g_encryption_test_case_2),
7610 TEST_CASE_ST(ut_setup, ut_teardown,
7611 test_snow3g_encryption_test_case_3),
7612 TEST_CASE_ST(ut_setup, ut_teardown,
7613 test_snow3g_encryption_test_case_4),
7614 TEST_CASE_ST(ut_setup, ut_teardown,
7615 test_snow3g_encryption_test_case_5),
7617 TEST_CASE_ST(ut_setup, ut_teardown,
7618 test_snow3g_encryption_test_case_1_oop),
7619 TEST_CASE_ST(ut_setup, ut_teardown,
7620 test_snow3g_decryption_test_case_1_oop),
7622 /** SNOW 3G decrypt only (UEA2) */
7623 TEST_CASE_ST(ut_setup, ut_teardown,
7624 test_snow3g_decryption_test_case_1),
7625 TEST_CASE_ST(ut_setup, ut_teardown,
7626 test_snow3g_decryption_test_case_2),
7627 TEST_CASE_ST(ut_setup, ut_teardown,
7628 test_snow3g_decryption_test_case_3),
7629 TEST_CASE_ST(ut_setup, ut_teardown,
7630 test_snow3g_decryption_test_case_4),
7631 TEST_CASE_ST(ut_setup, ut_teardown,
7632 test_snow3g_decryption_test_case_5),
7633 TEST_CASE_ST(ut_setup, ut_teardown,
7634 test_snow3g_hash_generate_test_case_1),
7635 TEST_CASE_ST(ut_setup, ut_teardown,
7636 test_snow3g_hash_generate_test_case_2),
7637 TEST_CASE_ST(ut_setup, ut_teardown,
7638 test_snow3g_hash_generate_test_case_3),
7639 TEST_CASE_ST(ut_setup, ut_teardown,
7640 test_snow3g_hash_verify_test_case_1),
7641 TEST_CASE_ST(ut_setup, ut_teardown,
7642 test_snow3g_hash_verify_test_case_2),
7643 TEST_CASE_ST(ut_setup, ut_teardown,
7644 test_snow3g_hash_verify_test_case_3),
7645 TEST_CASE_ST(ut_setup, ut_teardown,
7646 test_snow3g_cipher_auth_test_case_1),
7647 TEST_CASE_ST(ut_setup, ut_teardown,
7648 test_snow3g_auth_cipher_test_case_1),
7650 /** HMAC_MD5 Authentication */
7651 TEST_CASE_ST(ut_setup, ut_teardown,
7652 test_MD5_HMAC_generate_case_1),
7653 TEST_CASE_ST(ut_setup, ut_teardown,
7654 test_MD5_HMAC_verify_case_1),
7655 TEST_CASE_ST(ut_setup, ut_teardown,
7656 test_MD5_HMAC_generate_case_2),
7657 TEST_CASE_ST(ut_setup, ut_teardown,
7658 test_MD5_HMAC_verify_case_2),
7661 TEST_CASE_ST(ut_setup, ut_teardown,
7662 test_null_auth_only_operation),
7663 TEST_CASE_ST(ut_setup, ut_teardown,
7664 test_null_cipher_only_operation),
7665 TEST_CASE_ST(ut_setup, ut_teardown,
7666 test_null_cipher_auth_operation),
7667 TEST_CASE_ST(ut_setup, ut_teardown,
7668 test_null_auth_cipher_operation),
7670 TEST_CASE_ST(ut_setup, ut_teardown,
7671 test_kasumi_hash_generate_test_case_6),
7674 TEST_CASE_ST(ut_setup, ut_teardown,
7675 test_kasumi_encryption_test_case_1),
7676 TEST_CASE_ST(ut_setup, ut_teardown,
7677 test_kasumi_encryption_test_case_3),
7678 TEST_CASE_ST(ut_setup, ut_teardown,
7679 test_kasumi_auth_cipher_test_case_1),
7680 TEST_CASE_ST(ut_setup, ut_teardown,
7681 test_kasumi_cipher_auth_test_case_1),
7683 /** Negative tests */
7684 TEST_CASE_ST(ut_setup, ut_teardown,
7685 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7686 TEST_CASE_ST(ut_setup, ut_teardown,
7687 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7688 TEST_CASE_ST(ut_setup, ut_teardown,
7689 authentication_verify_AES128_GMAC_fail_data_corrupt),
7690 TEST_CASE_ST(ut_setup, ut_teardown,
7691 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7692 TEST_CASE_ST(ut_setup, ut_teardown,
7693 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7694 TEST_CASE_ST(ut_setup, ut_teardown,
7695 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7697 TEST_CASES_END() /**< NULL terminate unit test array */
7701 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7702 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7703 .setup = testsuite_setup,
7704 .teardown = testsuite_teardown,
7705 .unit_test_cases = {
7706 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7707 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7708 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7709 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7711 TEST_CASES_END() /**< NULL terminate unit test array */
7715 static struct unit_test_suite cryptodev_openssl_testsuite = {
7716 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7717 .setup = testsuite_setup,
7718 .teardown = testsuite_teardown,
7719 .unit_test_cases = {
7720 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7721 TEST_CASE_ST(ut_setup, ut_teardown,
7722 test_multi_session_random_usage),
7723 TEST_CASE_ST(ut_setup, ut_teardown,
7724 test_AES_chain_openssl_all),
7725 TEST_CASE_ST(ut_setup, ut_teardown,
7726 test_AES_cipheronly_openssl_all),
7727 TEST_CASE_ST(ut_setup, ut_teardown,
7728 test_3DES_chain_openssl_all),
7729 TEST_CASE_ST(ut_setup, ut_teardown,
7730 test_3DES_cipheronly_openssl_all),
7731 TEST_CASE_ST(ut_setup, ut_teardown,
7732 test_DES_docsis_openssl_all),
7733 TEST_CASE_ST(ut_setup, ut_teardown,
7734 test_authonly_openssl_all),
7736 /** AES GCM Authenticated Encryption */
7737 TEST_CASE_ST(ut_setup, ut_teardown,
7738 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7739 TEST_CASE_ST(ut_setup, ut_teardown,
7740 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7741 TEST_CASE_ST(ut_setup, ut_teardown,
7742 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7743 TEST_CASE_ST(ut_setup, ut_teardown,
7744 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7745 TEST_CASE_ST(ut_setup, ut_teardown,
7746 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7747 TEST_CASE_ST(ut_setup, ut_teardown,
7748 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7749 TEST_CASE_ST(ut_setup, ut_teardown,
7750 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7752 /** AES GCM Authenticated Decryption */
7753 TEST_CASE_ST(ut_setup, ut_teardown,
7754 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7755 TEST_CASE_ST(ut_setup, ut_teardown,
7756 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7757 TEST_CASE_ST(ut_setup, ut_teardown,
7758 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7759 TEST_CASE_ST(ut_setup, ut_teardown,
7760 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7761 TEST_CASE_ST(ut_setup, ut_teardown,
7762 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7763 TEST_CASE_ST(ut_setup, ut_teardown,
7764 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7765 TEST_CASE_ST(ut_setup, ut_teardown,
7766 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7768 /** AES GMAC Authentication */
7769 TEST_CASE_ST(ut_setup, ut_teardown,
7770 test_AES_GMAC_authentication_test_case_1),
7771 TEST_CASE_ST(ut_setup, ut_teardown,
7772 test_AES_GMAC_authentication_verify_test_case_1),
7773 TEST_CASE_ST(ut_setup, ut_teardown,
7774 test_AES_GMAC_authentication_test_case_2),
7775 TEST_CASE_ST(ut_setup, ut_teardown,
7776 test_AES_GMAC_authentication_verify_test_case_2),
7777 TEST_CASE_ST(ut_setup, ut_teardown,
7778 test_AES_GMAC_authentication_test_case_3),
7779 TEST_CASE_ST(ut_setup, ut_teardown,
7780 test_AES_GMAC_authentication_verify_test_case_3),
7781 TEST_CASE_ST(ut_setup, ut_teardown,
7782 test_AES_GMAC_authentication_test_case_4),
7783 TEST_CASE_ST(ut_setup, ut_teardown,
7784 test_AES_GMAC_authentication_verify_test_case_4),
7786 /** Scatter-Gather */
7787 TEST_CASE_ST(ut_setup, ut_teardown,
7788 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7790 /** Negative tests */
7791 TEST_CASE_ST(ut_setup, ut_teardown,
7792 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7793 TEST_CASE_ST(ut_setup, ut_teardown,
7794 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7795 TEST_CASE_ST(ut_setup, ut_teardown,
7796 authentication_verify_AES128_GMAC_fail_data_corrupt),
7797 TEST_CASE_ST(ut_setup, ut_teardown,
7798 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7799 TEST_CASE_ST(ut_setup, ut_teardown,
7800 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7801 TEST_CASE_ST(ut_setup, ut_teardown,
7802 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7804 TEST_CASES_END() /**< NULL terminate unit test array */
7808 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
7809 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
7810 .setup = testsuite_setup,
7811 .teardown = testsuite_teardown,
7812 .unit_test_cases = {
7813 /** AES GCM Authenticated Encryption */
7814 TEST_CASE_ST(ut_setup, ut_teardown,
7815 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7820 TEST_CASE_ST(ut_setup, ut_teardown,
7821 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7822 TEST_CASE_ST(ut_setup, ut_teardown,
7823 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7824 TEST_CASE_ST(ut_setup, ut_teardown,
7825 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7826 TEST_CASE_ST(ut_setup, ut_teardown,
7827 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7829 /** AES GCM Authenticated Decryption */
7830 TEST_CASE_ST(ut_setup, ut_teardown,
7831 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7832 TEST_CASE_ST(ut_setup, ut_teardown,
7833 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7834 TEST_CASE_ST(ut_setup, ut_teardown,
7835 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7836 TEST_CASE_ST(ut_setup, ut_teardown,
7837 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7838 TEST_CASE_ST(ut_setup, ut_teardown,
7839 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7840 TEST_CASE_ST(ut_setup, ut_teardown,
7841 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7842 TEST_CASE_ST(ut_setup, ut_teardown,
7843 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7845 /** AES GCM Authenticated Encryption 256 bits key */
7846 TEST_CASE_ST(ut_setup, ut_teardown,
7847 test_mb_AES_GCM_auth_encryption_test_case_256_1),
7848 TEST_CASE_ST(ut_setup, ut_teardown,
7849 test_mb_AES_GCM_auth_encryption_test_case_256_2),
7850 TEST_CASE_ST(ut_setup, ut_teardown,
7851 test_mb_AES_GCM_auth_encryption_test_case_256_3),
7852 TEST_CASE_ST(ut_setup, ut_teardown,
7853 test_mb_AES_GCM_auth_encryption_test_case_256_4),
7854 TEST_CASE_ST(ut_setup, ut_teardown,
7855 test_mb_AES_GCM_auth_encryption_test_case_256_5),
7856 TEST_CASE_ST(ut_setup, ut_teardown,
7857 test_mb_AES_GCM_auth_encryption_test_case_256_6),
7858 TEST_CASE_ST(ut_setup, ut_teardown,
7859 test_mb_AES_GCM_auth_encryption_test_case_256_7),
7861 /** AES GCM Authenticated Decryption 256 bits key */
7862 TEST_CASE_ST(ut_setup, ut_teardown,
7863 test_mb_AES_GCM_auth_decryption_test_case_256_1),
7864 TEST_CASE_ST(ut_setup, ut_teardown,
7865 test_mb_AES_GCM_auth_decryption_test_case_256_2),
7866 TEST_CASE_ST(ut_setup, ut_teardown,
7867 test_mb_AES_GCM_auth_decryption_test_case_256_3),
7868 TEST_CASE_ST(ut_setup, ut_teardown,
7869 test_mb_AES_GCM_auth_decryption_test_case_256_4),
7870 TEST_CASE_ST(ut_setup, ut_teardown,
7871 test_mb_AES_GCM_auth_decryption_test_case_256_5),
7872 TEST_CASE_ST(ut_setup, ut_teardown,
7873 test_mb_AES_GCM_auth_decryption_test_case_256_6),
7874 TEST_CASE_ST(ut_setup, ut_teardown,
7875 test_mb_AES_GCM_auth_decryption_test_case_256_7),
7877 /** AES GCM Authenticated Encryption big aad size */
7878 TEST_CASE_ST(ut_setup, ut_teardown,
7879 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
7880 TEST_CASE_ST(ut_setup, ut_teardown,
7881 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
7883 /** AES GCM Authenticated Decryption big aad size */
7884 TEST_CASE_ST(ut_setup, ut_teardown,
7885 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
7886 TEST_CASE_ST(ut_setup, ut_teardown,
7887 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
7889 /** AES GMAC Authentication */
7890 TEST_CASE_ST(ut_setup, ut_teardown,
7891 test_AES_GMAC_authentication_test_case_1),
7892 TEST_CASE_ST(ut_setup, ut_teardown,
7893 test_AES_GMAC_authentication_verify_test_case_1),
7894 TEST_CASE_ST(ut_setup, ut_teardown,
7895 test_AES_GMAC_authentication_test_case_3),
7896 TEST_CASE_ST(ut_setup, ut_teardown,
7897 test_AES_GMAC_authentication_verify_test_case_3),
7898 TEST_CASE_ST(ut_setup, ut_teardown,
7899 test_AES_GMAC_authentication_test_case_4),
7900 TEST_CASE_ST(ut_setup, ut_teardown,
7901 test_AES_GMAC_authentication_verify_test_case_4),
7903 /** Negative tests */
7904 TEST_CASE_ST(ut_setup, ut_teardown,
7905 authentication_verify_AES128_GMAC_fail_data_corrupt),
7906 TEST_CASE_ST(ut_setup, ut_teardown,
7907 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7909 /** Out of place tests */
7910 TEST_CASE_ST(ut_setup, ut_teardown,
7911 test_mb_AES_GCM_authenticated_encryption_oop),
7912 TEST_CASE_ST(ut_setup, ut_teardown,
7913 test_mb_AES_GCM_authenticated_decryption_oop),
7915 /** Session-less tests */
7916 TEST_CASE_ST(ut_setup, ut_teardown,
7917 test_mb_AES_GCM_authenticated_encryption_sessionless),
7918 TEST_CASE_ST(ut_setup, ut_teardown,
7919 test_mb_AES_GCM_authenticated_decryption_sessionless),
7921 /** Scatter-Gather */
7922 TEST_CASE_ST(ut_setup, ut_teardown,
7923 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7925 TEST_CASES_END() /**< NULL terminate unit test array */
7929 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
7930 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
7931 .setup = testsuite_setup,
7932 .teardown = testsuite_teardown,
7933 .unit_test_cases = {
7934 /** KASUMI encrypt only (UEA1) */
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_kasumi_encryption_test_case_1),
7937 TEST_CASE_ST(ut_setup, ut_teardown,
7938 test_kasumi_encryption_test_case_1_sgl),
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_kasumi_encryption_test_case_2),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_kasumi_encryption_test_case_3),
7943 TEST_CASE_ST(ut_setup, ut_teardown,
7944 test_kasumi_encryption_test_case_4),
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_kasumi_encryption_test_case_5),
7947 /** KASUMI decrypt only (UEA1) */
7948 TEST_CASE_ST(ut_setup, ut_teardown,
7949 test_kasumi_decryption_test_case_1),
7950 TEST_CASE_ST(ut_setup, ut_teardown,
7951 test_kasumi_decryption_test_case_2),
7952 TEST_CASE_ST(ut_setup, ut_teardown,
7953 test_kasumi_decryption_test_case_3),
7954 TEST_CASE_ST(ut_setup, ut_teardown,
7955 test_kasumi_decryption_test_case_4),
7956 TEST_CASE_ST(ut_setup, ut_teardown,
7957 test_kasumi_decryption_test_case_5),
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 test_kasumi_encryption_test_case_1_oop),
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 test_kasumi_encryption_test_case_1_oop_sgl),
7965 TEST_CASE_ST(ut_setup, ut_teardown,
7966 test_kasumi_decryption_test_case_1_oop),
7968 /** KASUMI hash only (UIA1) */
7969 TEST_CASE_ST(ut_setup, ut_teardown,
7970 test_kasumi_hash_generate_test_case_1),
7971 TEST_CASE_ST(ut_setup, ut_teardown,
7972 test_kasumi_hash_generate_test_case_2),
7973 TEST_CASE_ST(ut_setup, ut_teardown,
7974 test_kasumi_hash_generate_test_case_3),
7975 TEST_CASE_ST(ut_setup, ut_teardown,
7976 test_kasumi_hash_generate_test_case_4),
7977 TEST_CASE_ST(ut_setup, ut_teardown,
7978 test_kasumi_hash_generate_test_case_5),
7979 TEST_CASE_ST(ut_setup, ut_teardown,
7980 test_kasumi_hash_generate_test_case_6),
7981 TEST_CASE_ST(ut_setup, ut_teardown,
7982 test_kasumi_hash_verify_test_case_1),
7983 TEST_CASE_ST(ut_setup, ut_teardown,
7984 test_kasumi_hash_verify_test_case_2),
7985 TEST_CASE_ST(ut_setup, ut_teardown,
7986 test_kasumi_hash_verify_test_case_3),
7987 TEST_CASE_ST(ut_setup, ut_teardown,
7988 test_kasumi_hash_verify_test_case_4),
7989 TEST_CASE_ST(ut_setup, ut_teardown,
7990 test_kasumi_hash_verify_test_case_5),
7991 TEST_CASE_ST(ut_setup, ut_teardown,
7992 test_kasumi_auth_cipher_test_case_1),
7993 TEST_CASE_ST(ut_setup, ut_teardown,
7994 test_kasumi_cipher_auth_test_case_1),
7995 TEST_CASES_END() /**< NULL terminate unit test array */
7998 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
7999 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8000 .setup = testsuite_setup,
8001 .teardown = testsuite_teardown,
8002 .unit_test_cases = {
8003 /** SNOW 3G encrypt only (UEA2) */
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_snow3g_encryption_test_case_1),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_snow3g_encryption_test_case_2),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 test_snow3g_encryption_test_case_3),
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 test_snow3g_encryption_test_case_4),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 test_snow3g_encryption_test_case_5),
8015 TEST_CASE_ST(ut_setup, ut_teardown,
8016 test_snow3g_encryption_test_case_1_oop),
8017 TEST_CASE_ST(ut_setup, ut_teardown,
8018 test_snow3g_encryption_test_case_1_oop_sgl),
8019 TEST_CASE_ST(ut_setup, ut_teardown,
8020 test_snow3g_decryption_test_case_1_oop),
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 test_snow3g_encryption_test_case_1_offset_oop),
8025 /** SNOW 3G decrypt only (UEA2) */
8026 TEST_CASE_ST(ut_setup, ut_teardown,
8027 test_snow3g_decryption_test_case_1),
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 test_snow3g_decryption_test_case_2),
8030 TEST_CASE_ST(ut_setup, ut_teardown,
8031 test_snow3g_decryption_test_case_3),
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_snow3g_decryption_test_case_4),
8034 TEST_CASE_ST(ut_setup, ut_teardown,
8035 test_snow3g_decryption_test_case_5),
8036 TEST_CASE_ST(ut_setup, ut_teardown,
8037 test_snow3g_hash_generate_test_case_1),
8038 TEST_CASE_ST(ut_setup, ut_teardown,
8039 test_snow3g_hash_generate_test_case_2),
8040 TEST_CASE_ST(ut_setup, ut_teardown,
8041 test_snow3g_hash_generate_test_case_3),
8042 /* Tests with buffers which length is not byte-aligned */
8043 TEST_CASE_ST(ut_setup, ut_teardown,
8044 test_snow3g_hash_generate_test_case_4),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_snow3g_hash_generate_test_case_5),
8047 TEST_CASE_ST(ut_setup, ut_teardown,
8048 test_snow3g_hash_generate_test_case_6),
8049 TEST_CASE_ST(ut_setup, ut_teardown,
8050 test_snow3g_hash_verify_test_case_1),
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 test_snow3g_hash_verify_test_case_2),
8053 TEST_CASE_ST(ut_setup, ut_teardown,
8054 test_snow3g_hash_verify_test_case_3),
8055 /* Tests with buffers which length is not byte-aligned */
8056 TEST_CASE_ST(ut_setup, ut_teardown,
8057 test_snow3g_hash_verify_test_case_4),
8058 TEST_CASE_ST(ut_setup, ut_teardown,
8059 test_snow3g_hash_verify_test_case_5),
8060 TEST_CASE_ST(ut_setup, ut_teardown,
8061 test_snow3g_hash_verify_test_case_6),
8062 TEST_CASE_ST(ut_setup, ut_teardown,
8063 test_snow3g_cipher_auth_test_case_1),
8064 TEST_CASE_ST(ut_setup, ut_teardown,
8065 test_snow3g_auth_cipher_test_case_1),
8067 TEST_CASES_END() /**< NULL terminate unit test array */
8071 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8072 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8073 .setup = testsuite_setup,
8074 .teardown = testsuite_teardown,
8075 .unit_test_cases = {
8076 /** ZUC encrypt only (EEA3) */
8077 TEST_CASE_ST(ut_setup, ut_teardown,
8078 test_zuc_encryption_test_case_1),
8079 TEST_CASE_ST(ut_setup, ut_teardown,
8080 test_zuc_encryption_test_case_2),
8081 TEST_CASE_ST(ut_setup, ut_teardown,
8082 test_zuc_encryption_test_case_3),
8083 TEST_CASE_ST(ut_setup, ut_teardown,
8084 test_zuc_encryption_test_case_4),
8085 TEST_CASE_ST(ut_setup, ut_teardown,
8086 test_zuc_encryption_test_case_5),
8087 TEST_CASE_ST(ut_setup, ut_teardown,
8088 test_zuc_hash_generate_test_case_1),
8089 TEST_CASE_ST(ut_setup, ut_teardown,
8090 test_zuc_hash_generate_test_case_2),
8091 TEST_CASE_ST(ut_setup, ut_teardown,
8092 test_zuc_hash_generate_test_case_3),
8093 TEST_CASE_ST(ut_setup, ut_teardown,
8094 test_zuc_hash_generate_test_case_4),
8095 TEST_CASE_ST(ut_setup, ut_teardown,
8096 test_zuc_hash_generate_test_case_5),
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 test_zuc_encryption_test_case_6_sgl),
8099 TEST_CASES_END() /**< NULL terminate unit test array */
8103 static struct unit_test_suite cryptodev_null_testsuite = {
8104 .suite_name = "Crypto Device NULL Unit Test Suite",
8105 .setup = testsuite_setup,
8106 .teardown = testsuite_teardown,
8107 .unit_test_cases = {
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_null_auth_only_operation),
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_null_cipher_only_operation),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_null_cipher_auth_operation),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_null_auth_cipher_operation),
8116 TEST_CASE_ST(ut_setup, ut_teardown,
8117 test_null_invalid_operation),
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_null_burst_operation),
8121 TEST_CASES_END() /**< NULL terminate unit test array */
8125 static struct unit_test_suite cryptodev_armv8_testsuite = {
8126 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8127 .setup = testsuite_setup,
8128 .teardown = testsuite_teardown,
8129 .unit_test_cases = {
8130 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8132 /** Negative tests */
8133 TEST_CASE_ST(ut_setup, ut_teardown,
8134 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8135 TEST_CASE_ST(ut_setup, ut_teardown,
8136 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8138 TEST_CASES_END() /**< NULL terminate unit test array */
8143 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8145 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8146 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8150 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8152 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8154 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8158 test_cryptodev_openssl(void)
8160 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8162 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8166 test_cryptodev_aesni_gcm(void)
8168 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8170 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8174 test_cryptodev_null(void)
8176 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8178 return unit_test_suite_runner(&cryptodev_null_testsuite);
8182 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8184 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8186 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8190 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8192 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8194 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8198 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8200 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8202 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8206 test_cryptodev_armv8(void)
8208 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8210 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8213 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8216 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8218 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8219 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8222 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8226 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8227 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8228 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8229 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8230 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8231 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8232 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8233 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8234 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);