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_authonly_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_AUTHONLY_TYPE);
1545 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1547 return TEST_SUCCESS;
1551 test_AES_chain_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_AES_CHAIN_TYPE);
1561 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1563 return TEST_SUCCESS;
1566 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1569 test_AES_cipheronly_scheduler_all(void)
1571 struct crypto_testsuite_params *ts_params = &testsuite_params;
1574 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1575 ts_params->op_mpool, ts_params->valid_devs[0],
1576 RTE_CRYPTODEV_SCHEDULER_PMD,
1577 BLKCIPHER_AES_CIPHERONLY_TYPE);
1579 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1581 return TEST_SUCCESS;
1585 test_AES_chain_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_CHAIN_TYPE);
1595 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1597 return TEST_SUCCESS;
1601 test_authonly_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_AUTHONLY_TYPE);
1611 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1613 return TEST_SUCCESS;
1616 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1619 test_AES_chain_openssl_all(void)
1621 struct crypto_testsuite_params *ts_params = &testsuite_params;
1624 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1625 ts_params->op_mpool, ts_params->valid_devs[0],
1626 RTE_CRYPTODEV_OPENSSL_PMD,
1627 BLKCIPHER_AES_CHAIN_TYPE);
1629 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1631 return TEST_SUCCESS;
1635 test_AES_cipheronly_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_CIPHERONLY_TYPE);
1645 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1647 return TEST_SUCCESS;
1651 test_AES_chain_qat_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_QAT_SYM_PMD,
1659 BLKCIPHER_AES_CHAIN_TYPE);
1661 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1663 return TEST_SUCCESS;
1667 test_AES_cipheronly_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_CIPHERONLY_TYPE);
1677 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1679 return TEST_SUCCESS;
1683 test_authonly_openssl_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_OPENSSL_PMD,
1691 BLKCIPHER_AUTHONLY_TYPE);
1693 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1695 return TEST_SUCCESS;
1699 test_AES_chain_armv8_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_ARMV8_PMD,
1707 BLKCIPHER_AES_CHAIN_TYPE);
1709 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1711 return TEST_SUCCESS;
1714 /* ***** SNOW 3G Tests ***** */
1716 create_wireless_algo_hash_session(uint8_t dev_id,
1717 const uint8_t *key, const uint8_t key_len,
1718 const uint8_t aad_len, const uint8_t auth_len,
1719 enum rte_crypto_auth_operation op,
1720 enum rte_crypto_auth_algorithm algo)
1722 uint8_t hash_key[key_len];
1724 struct crypto_unittest_params *ut_params = &unittest_params;
1726 memcpy(hash_key, key, key_len);
1728 TEST_HEXDUMP(stdout, "key:", key, key_len);
1730 /* Setup Authentication Parameters */
1731 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1732 ut_params->auth_xform.next = NULL;
1734 ut_params->auth_xform.auth.op = op;
1735 ut_params->auth_xform.auth.algo = algo;
1736 ut_params->auth_xform.auth.key.length = key_len;
1737 ut_params->auth_xform.auth.key.data = hash_key;
1738 ut_params->auth_xform.auth.digest_length = auth_len;
1739 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1740 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1741 &ut_params->auth_xform);
1742 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1747 create_wireless_algo_cipher_session(uint8_t dev_id,
1748 enum rte_crypto_cipher_operation op,
1749 enum rte_crypto_cipher_algorithm algo,
1750 const uint8_t *key, const uint8_t key_len)
1752 uint8_t cipher_key[key_len];
1754 struct crypto_unittest_params *ut_params = &unittest_params;
1756 memcpy(cipher_key, key, key_len);
1758 /* Setup Cipher Parameters */
1759 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1760 ut_params->cipher_xform.next = NULL;
1762 ut_params->cipher_xform.cipher.algo = algo;
1763 ut_params->cipher_xform.cipher.op = op;
1764 ut_params->cipher_xform.cipher.key.data = cipher_key;
1765 ut_params->cipher_xform.cipher.key.length = key_len;
1767 TEST_HEXDUMP(stdout, "key:", key, key_len);
1769 /* Create Crypto session */
1770 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1773 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1778 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1779 const unsigned cipher_len,
1780 const unsigned cipher_offset,
1781 enum rte_crypto_cipher_algorithm algo)
1783 struct crypto_testsuite_params *ts_params = &testsuite_params;
1784 struct crypto_unittest_params *ut_params = &unittest_params;
1785 unsigned iv_pad_len = 0;
1787 /* Generate Crypto op data structure */
1788 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1789 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1790 TEST_ASSERT_NOT_NULL(ut_params->op,
1791 "Failed to allocate pktmbuf offload");
1793 /* Set crypto operation data parameters */
1794 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1796 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1798 /* set crypto operation source mbuf */
1799 sym_op->m_src = ut_params->ibuf;
1802 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1803 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1805 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1807 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1810 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1812 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1813 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1814 sym_op->cipher.iv.length = iv_pad_len;
1816 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1817 sym_op->cipher.data.length = cipher_len;
1818 sym_op->cipher.data.offset = cipher_offset;
1823 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1824 const unsigned cipher_len,
1825 const unsigned cipher_offset,
1826 enum rte_crypto_cipher_algorithm algo)
1828 struct crypto_testsuite_params *ts_params = &testsuite_params;
1829 struct crypto_unittest_params *ut_params = &unittest_params;
1830 unsigned iv_pad_len = 0;
1832 /* Generate Crypto op data structure */
1833 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1834 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1835 TEST_ASSERT_NOT_NULL(ut_params->op,
1836 "Failed to allocate pktmbuf offload");
1838 /* Set crypto operation data parameters */
1839 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1841 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1843 /* set crypto operation source mbuf */
1844 sym_op->m_src = ut_params->ibuf;
1845 sym_op->m_dst = ut_params->obuf;
1848 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1849 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1851 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1852 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1855 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1857 /* For OOP operation both buffers must have the same size */
1858 if (ut_params->obuf)
1859 rte_pktmbuf_prepend(ut_params->obuf, iv_pad_len);
1861 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1862 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1863 sym_op->cipher.iv.length = iv_pad_len;
1865 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1866 sym_op->cipher.data.length = cipher_len;
1867 sym_op->cipher.data.offset = cipher_offset;
1872 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1873 enum rte_crypto_cipher_operation cipher_op,
1874 enum rte_crypto_auth_operation auth_op,
1875 enum rte_crypto_auth_algorithm auth_algo,
1876 enum rte_crypto_cipher_algorithm cipher_algo,
1877 const uint8_t *key, const uint8_t key_len,
1878 const uint8_t aad_len, const uint8_t auth_len)
1881 uint8_t cipher_auth_key[key_len];
1883 struct crypto_unittest_params *ut_params = &unittest_params;
1885 memcpy(cipher_auth_key, key, key_len);
1887 /* Setup Authentication Parameters */
1888 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1889 ut_params->auth_xform.next = NULL;
1891 ut_params->auth_xform.auth.op = auth_op;
1892 ut_params->auth_xform.auth.algo = auth_algo;
1893 ut_params->auth_xform.auth.key.length = key_len;
1894 /* Hash key = cipher key */
1895 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1896 ut_params->auth_xform.auth.digest_length = auth_len;
1897 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1899 /* Setup Cipher Parameters */
1900 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1901 ut_params->cipher_xform.next = &ut_params->auth_xform;
1903 ut_params->cipher_xform.cipher.algo = cipher_algo;
1904 ut_params->cipher_xform.cipher.op = cipher_op;
1905 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1906 ut_params->cipher_xform.cipher.key.length = key_len;
1908 TEST_HEXDUMP(stdout, "key:", key, key_len);
1910 /* Create Crypto session*/
1911 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1912 &ut_params->cipher_xform);
1914 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1919 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1920 enum rte_crypto_cipher_operation cipher_op,
1921 enum rte_crypto_auth_operation auth_op,
1922 enum rte_crypto_auth_algorithm auth_algo,
1923 enum rte_crypto_cipher_algorithm cipher_algo,
1924 const uint8_t *key, const uint8_t key_len,
1925 const uint8_t aad_len, const uint8_t auth_len)
1927 uint8_t auth_cipher_key[key_len];
1929 struct crypto_unittest_params *ut_params = &unittest_params;
1931 memcpy(auth_cipher_key, key, key_len);
1933 /* Setup Authentication Parameters */
1934 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1935 ut_params->auth_xform.auth.op = auth_op;
1936 ut_params->auth_xform.next = &ut_params->cipher_xform;
1937 ut_params->auth_xform.auth.algo = auth_algo;
1938 ut_params->auth_xform.auth.key.length = key_len;
1939 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1940 ut_params->auth_xform.auth.digest_length = auth_len;
1941 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1943 /* Setup Cipher Parameters */
1944 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1945 ut_params->cipher_xform.next = NULL;
1946 ut_params->cipher_xform.cipher.algo = cipher_algo;
1947 ut_params->cipher_xform.cipher.op = cipher_op;
1948 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1949 ut_params->cipher_xform.cipher.key.length = key_len;
1951 TEST_HEXDUMP(stdout, "key:", key, key_len);
1953 /* Create Crypto session*/
1954 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1955 &ut_params->auth_xform);
1957 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1963 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1964 const unsigned auth_tag_len,
1965 const uint8_t *aad, const unsigned aad_len,
1966 unsigned data_pad_len,
1967 enum rte_crypto_auth_operation op,
1968 enum rte_crypto_auth_algorithm algo,
1969 const unsigned auth_len, const unsigned auth_offset)
1971 struct crypto_testsuite_params *ts_params = &testsuite_params;
1973 struct crypto_unittest_params *ut_params = &unittest_params;
1975 unsigned aad_buffer_len;
1977 /* Generate Crypto op data structure */
1978 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1979 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1980 TEST_ASSERT_NOT_NULL(ut_params->op,
1981 "Failed to allocate pktmbuf offload");
1983 /* Set crypto operation data parameters */
1984 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1986 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1988 /* set crypto operation source mbuf */
1989 sym_op->m_src = ut_params->ibuf;
1993 * Always allocate the aad up to the block size.
1994 * The cryptodev API calls out -
1995 * - the array must be big enough to hold the AAD, plus any
1996 * space to round this up to the nearest multiple of the
1997 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1999 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2000 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2002 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2003 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2004 ut_params->ibuf, aad_buffer_len);
2005 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2006 "no room to prepend aad");
2007 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2009 sym_op->auth.aad.length = aad_len;
2011 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2012 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2014 TEST_HEXDUMP(stdout, "aad:",
2015 sym_op->auth.aad.data, aad_len);
2018 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2019 ut_params->ibuf, auth_tag_len);
2021 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2022 "no room to append auth tag");
2023 ut_params->digest = sym_op->auth.digest.data;
2024 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2025 ut_params->ibuf, data_pad_len + aad_len);
2026 sym_op->auth.digest.length = auth_tag_len;
2027 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2028 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2030 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2032 TEST_HEXDUMP(stdout, "digest:",
2033 sym_op->auth.digest.data,
2034 sym_op->auth.digest.length);
2036 sym_op->auth.data.length = auth_len;
2037 sym_op->auth.data.offset = auth_offset;
2043 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2044 const unsigned auth_tag_len,
2045 const uint8_t *aad, const uint8_t aad_len,
2046 unsigned data_pad_len,
2047 enum rte_crypto_auth_operation op,
2048 enum rte_crypto_auth_algorithm auth_algo,
2049 enum rte_crypto_cipher_algorithm cipher_algo,
2050 const uint8_t *iv, const uint8_t iv_len,
2051 const unsigned cipher_len, const unsigned cipher_offset,
2052 const unsigned auth_len, const unsigned auth_offset)
2054 struct crypto_testsuite_params *ts_params = &testsuite_params;
2055 struct crypto_unittest_params *ut_params = &unittest_params;
2057 unsigned iv_pad_len = 0;
2058 unsigned aad_buffer_len;
2060 /* Generate Crypto op data structure */
2061 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2062 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2063 TEST_ASSERT_NOT_NULL(ut_params->op,
2064 "Failed to allocate pktmbuf offload");
2065 /* Set crypto operation data parameters */
2066 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2068 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2070 /* set crypto operation source mbuf */
2071 sym_op->m_src = ut_params->ibuf;
2074 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2075 ut_params->ibuf, auth_tag_len);
2077 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2078 "no room to append auth tag");
2079 ut_params->digest = sym_op->auth.digest.data;
2080 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2081 ut_params->ibuf, data_pad_len);
2082 sym_op->auth.digest.length = auth_tag_len;
2083 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2084 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2086 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2088 TEST_HEXDUMP(stdout, "digest:",
2089 sym_op->auth.digest.data,
2090 sym_op->auth.digest.length);
2094 * Always allocate the aad up to the block size.
2095 * The cryptodev API calls out -
2096 * - the array must be big enough to hold the AAD, plus any
2097 * space to round this up to the nearest multiple of the
2098 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2100 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2101 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2103 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2104 sym_op->auth.aad.data =
2105 (uint8_t *)rte_pktmbuf_prepend(
2106 ut_params->ibuf, aad_buffer_len);
2107 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2108 "no room to prepend aad");
2109 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2111 sym_op->auth.aad.length = aad_len;
2112 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2113 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2114 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2117 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2118 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2120 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2121 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2122 ut_params->ibuf, iv_pad_len);
2124 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2125 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2126 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2127 sym_op->cipher.iv.length = iv_pad_len;
2128 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2129 sym_op->cipher.data.length = cipher_len;
2130 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2131 sym_op->auth.data.length = auth_len;
2132 sym_op->auth.data.offset = auth_offset + cipher_offset;
2138 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2139 const uint8_t *iv, const uint8_t iv_len,
2140 const uint8_t *aad, const uint8_t aad_len,
2141 unsigned data_pad_len,
2142 const unsigned cipher_len, const unsigned cipher_offset,
2143 const unsigned auth_len, const unsigned auth_offset,
2144 enum rte_crypto_auth_algorithm auth_algo,
2145 enum rte_crypto_cipher_algorithm cipher_algo)
2147 struct crypto_testsuite_params *ts_params = &testsuite_params;
2148 struct crypto_unittest_params *ut_params = &unittest_params;
2150 unsigned iv_pad_len = 0;
2151 unsigned aad_buffer_len = 0;
2153 /* Generate Crypto op data structure */
2154 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2155 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2156 TEST_ASSERT_NOT_NULL(ut_params->op,
2157 "Failed to allocate pktmbuf offload");
2159 /* Set crypto operation data parameters */
2160 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2162 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2164 /* set crypto operation source mbuf */
2165 sym_op->m_src = ut_params->ibuf;
2168 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2169 ut_params->ibuf, auth_tag_len);
2171 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2172 "no room to append auth tag");
2174 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2175 ut_params->ibuf, data_pad_len);
2176 sym_op->auth.digest.length = auth_tag_len;
2178 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2180 TEST_HEXDUMP(stdout, "digest:",
2181 sym_op->auth.digest.data,
2182 sym_op->auth.digest.length);
2186 * Always allocate the aad up to the block size.
2187 * The cryptodev API calls out -
2188 * - the array must be big enough to hold the AAD, plus any
2189 * space to round this up to the nearest multiple of the
2190 * block size (8 bytes for KASUMI 16 bytes).
2192 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2193 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2195 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2196 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2197 ut_params->ibuf, aad_buffer_len);
2198 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2199 "no room to prepend aad");
2200 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2202 sym_op->auth.aad.length = aad_len;
2203 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2204 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2205 TEST_HEXDUMP(stdout, "aad:",
2206 sym_op->auth.aad.data, aad_len);
2209 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2210 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2212 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2214 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2215 ut_params->ibuf, iv_pad_len);
2216 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2218 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2219 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2220 sym_op->cipher.iv.length = iv_pad_len;
2222 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2224 sym_op->cipher.data.length = cipher_len;
2225 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2227 sym_op->auth.data.length = auth_len;
2228 sym_op->auth.data.offset = auth_offset + cipher_offset;
2234 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2236 struct crypto_testsuite_params *ts_params = &testsuite_params;
2237 struct crypto_unittest_params *ut_params = &unittest_params;
2240 unsigned plaintext_pad_len;
2241 unsigned plaintext_len;
2244 /* Create SNOW 3G session */
2245 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2246 tdata->key.data, tdata->key.len,
2247 tdata->aad.len, tdata->digest.len,
2248 RTE_CRYPTO_AUTH_OP_GENERATE,
2249 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2253 /* alloc mbuf and set payload */
2254 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2257 rte_pktmbuf_tailroom(ut_params->ibuf));
2259 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2260 /* Append data which is padded to a multiple of */
2261 /* the algorithms block size */
2262 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2263 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2265 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2267 /* Create SNOW 3G operation */
2268 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2269 tdata->aad.data, tdata->aad.len,
2270 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2271 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2272 tdata->validAuthLenInBits.len,
2273 tdata->validAuthOffsetLenInBits.len);
2277 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2279 ut_params->obuf = ut_params->op->sym->m_src;
2280 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2281 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2282 + plaintext_pad_len + tdata->aad.len;
2285 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2288 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2289 "SNOW 3G Generated auth tag not as expected");
2295 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2297 struct crypto_testsuite_params *ts_params = &testsuite_params;
2298 struct crypto_unittest_params *ut_params = &unittest_params;
2301 unsigned plaintext_pad_len;
2302 unsigned plaintext_len;
2305 /* Create SNOW 3G session */
2306 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2307 tdata->key.data, tdata->key.len,
2308 tdata->aad.len, tdata->digest.len,
2309 RTE_CRYPTO_AUTH_OP_VERIFY,
2310 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2313 /* alloc mbuf and set payload */
2314 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2317 rte_pktmbuf_tailroom(ut_params->ibuf));
2319 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2320 /* Append data which is padded to a multiple of */
2321 /* the algorithms block size */
2322 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2323 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2325 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2327 /* Create SNOW 3G operation */
2328 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2330 tdata->aad.data, tdata->aad.len,
2332 RTE_CRYPTO_AUTH_OP_VERIFY,
2333 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2334 tdata->validAuthLenInBits.len,
2335 tdata->validAuthOffsetLenInBits.len);
2339 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2341 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2342 ut_params->obuf = ut_params->op->sym->m_src;
2343 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2344 + plaintext_pad_len + tdata->aad.len;
2347 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2356 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2358 struct crypto_testsuite_params *ts_params = &testsuite_params;
2359 struct crypto_unittest_params *ut_params = &unittest_params;
2362 unsigned plaintext_pad_len;
2363 unsigned plaintext_len;
2366 /* Create KASUMI session */
2367 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2368 tdata->key.data, tdata->key.len,
2369 tdata->aad.len, tdata->digest.len,
2370 RTE_CRYPTO_AUTH_OP_GENERATE,
2371 RTE_CRYPTO_AUTH_KASUMI_F9);
2375 /* alloc mbuf and set payload */
2376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2378 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2379 rte_pktmbuf_tailroom(ut_params->ibuf));
2381 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2382 /* Append data which is padded to a multiple of */
2383 /* the algorithms block size */
2384 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2385 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2387 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2389 /* Create KASUMI operation */
2390 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2391 tdata->aad.data, tdata->aad.len,
2392 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2393 RTE_CRYPTO_AUTH_KASUMI_F9,
2394 tdata->validAuthLenInBits.len,
2395 tdata->validAuthOffsetLenInBits.len);
2399 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2401 ut_params->obuf = ut_params->op->sym->m_src;
2402 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2403 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2404 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2407 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2410 DIGEST_BYTE_LENGTH_KASUMI_F9,
2411 "KASUMI Generated auth tag not as expected");
2417 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2419 struct crypto_testsuite_params *ts_params = &testsuite_params;
2420 struct crypto_unittest_params *ut_params = &unittest_params;
2423 unsigned plaintext_pad_len;
2424 unsigned plaintext_len;
2427 /* Create KASUMI session */
2428 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2429 tdata->key.data, tdata->key.len,
2430 tdata->aad.len, tdata->digest.len,
2431 RTE_CRYPTO_AUTH_OP_VERIFY,
2432 RTE_CRYPTO_AUTH_KASUMI_F9);
2435 /* alloc mbuf and set payload */
2436 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2438 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2439 rte_pktmbuf_tailroom(ut_params->ibuf));
2441 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2442 /* Append data which is padded to a multiple */
2443 /* of the algorithms block size */
2444 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2445 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2447 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2449 /* Create KASUMI operation */
2450 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2452 tdata->aad.data, tdata->aad.len,
2454 RTE_CRYPTO_AUTH_OP_VERIFY,
2455 RTE_CRYPTO_AUTH_KASUMI_F9,
2456 tdata->validAuthLenInBits.len,
2457 tdata->validAuthOffsetLenInBits.len);
2461 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2463 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2464 ut_params->obuf = ut_params->op->sym->m_src;
2465 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2466 + plaintext_pad_len + tdata->aad.len;
2469 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2478 test_snow3g_hash_generate_test_case_1(void)
2480 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2484 test_snow3g_hash_generate_test_case_2(void)
2486 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2490 test_snow3g_hash_generate_test_case_3(void)
2492 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2496 test_snow3g_hash_generate_test_case_4(void)
2498 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2502 test_snow3g_hash_generate_test_case_5(void)
2504 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2508 test_snow3g_hash_generate_test_case_6(void)
2510 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2514 test_snow3g_hash_verify_test_case_1(void)
2516 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2521 test_snow3g_hash_verify_test_case_2(void)
2523 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2527 test_snow3g_hash_verify_test_case_3(void)
2529 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2533 test_snow3g_hash_verify_test_case_4(void)
2535 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2539 test_snow3g_hash_verify_test_case_5(void)
2541 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2545 test_snow3g_hash_verify_test_case_6(void)
2547 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2551 test_kasumi_hash_generate_test_case_1(void)
2553 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2557 test_kasumi_hash_generate_test_case_2(void)
2559 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2563 test_kasumi_hash_generate_test_case_3(void)
2565 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2569 test_kasumi_hash_generate_test_case_4(void)
2571 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2575 test_kasumi_hash_generate_test_case_5(void)
2577 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2581 test_kasumi_hash_generate_test_case_6(void)
2583 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2587 test_kasumi_hash_verify_test_case_1(void)
2589 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2593 test_kasumi_hash_verify_test_case_2(void)
2595 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2599 test_kasumi_hash_verify_test_case_3(void)
2601 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2605 test_kasumi_hash_verify_test_case_4(void)
2607 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2611 test_kasumi_hash_verify_test_case_5(void)
2613 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2617 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2619 struct crypto_testsuite_params *ts_params = &testsuite_params;
2620 struct crypto_unittest_params *ut_params = &unittest_params;
2623 uint8_t *plaintext, *ciphertext;
2624 unsigned plaintext_pad_len;
2625 unsigned plaintext_len;
2627 /* Create KASUMI session */
2628 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2629 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2630 RTE_CRYPTO_CIPHER_KASUMI_F8,
2631 tdata->key.data, tdata->key.len);
2635 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2637 /* Clear mbuf payload */
2638 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2639 rte_pktmbuf_tailroom(ut_params->ibuf));
2641 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2642 /* Append data which is padded to a multiple */
2643 /* of the algorithms block size */
2644 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2645 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2647 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2649 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2651 /* Create KASUMI operation */
2652 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2653 tdata->plaintext.len,
2654 tdata->validCipherOffsetLenInBits.len,
2655 RTE_CRYPTO_CIPHER_KASUMI_F8);
2659 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2663 ut_params->obuf = ut_params->op->sym->m_dst;
2664 if (ut_params->obuf)
2665 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2668 ciphertext = plaintext;
2670 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2673 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2675 tdata->ciphertext.data,
2676 tdata->validCipherLenInBits.len,
2677 "KASUMI Ciphertext data not as expected");
2682 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2684 struct crypto_testsuite_params *ts_params = &testsuite_params;
2685 struct crypto_unittest_params *ut_params = &unittest_params;
2689 unsigned int plaintext_pad_len;
2690 unsigned int plaintext_len;
2692 uint8_t buffer[10000];
2693 const uint8_t *ciphertext;
2695 struct rte_cryptodev_info dev_info;
2697 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2698 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2699 printf("Device doesn't support scatter-gather. "
2704 /* Create KASUMI session */
2705 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2706 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2707 RTE_CRYPTO_CIPHER_KASUMI_F8,
2708 tdata->key.data, tdata->key.len);
2712 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2715 /* Append data which is padded to a multiple */
2716 /* of the algorithms block size */
2717 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2719 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2720 plaintext_pad_len, 10, 0);
2722 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2724 /* Create KASUMI operation */
2725 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2727 tdata->plaintext.len,
2728 tdata->validCipherOffsetLenInBits.len,
2729 RTE_CRYPTO_CIPHER_KASUMI_F8);
2733 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2735 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2737 ut_params->obuf = ut_params->op->sym->m_dst;
2739 if (ut_params->obuf)
2740 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2741 plaintext_len, buffer);
2743 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2744 plaintext_len, buffer);
2747 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2750 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2752 tdata->ciphertext.data,
2753 tdata->validCipherLenInBits.len,
2754 "KASUMI Ciphertext data not as expected");
2759 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2761 struct crypto_testsuite_params *ts_params = &testsuite_params;
2762 struct crypto_unittest_params *ut_params = &unittest_params;
2765 uint8_t *plaintext, *ciphertext;
2766 unsigned plaintext_pad_len;
2767 unsigned plaintext_len;
2769 /* Create KASUMI session */
2770 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2771 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2772 RTE_CRYPTO_CIPHER_KASUMI_F8,
2773 tdata->key.data, tdata->key.len);
2777 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2778 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2780 /* Clear mbuf payload */
2781 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2782 rte_pktmbuf_tailroom(ut_params->ibuf));
2784 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2785 /* Append data which is padded to a multiple */
2786 /* of the algorithms block size */
2787 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2788 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2790 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2791 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2793 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2795 /* Create KASUMI operation */
2796 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2798 tdata->plaintext.len,
2799 tdata->validCipherOffsetLenInBits.len,
2800 RTE_CRYPTO_CIPHER_KASUMI_F8);
2804 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2806 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2808 ut_params->obuf = ut_params->op->sym->m_dst;
2809 if (ut_params->obuf)
2810 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2813 ciphertext = plaintext;
2815 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2818 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2820 tdata->ciphertext.data,
2821 tdata->validCipherLenInBits.len,
2822 "KASUMI Ciphertext data not as expected");
2827 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2829 struct crypto_testsuite_params *ts_params = &testsuite_params;
2830 struct crypto_unittest_params *ut_params = &unittest_params;
2833 unsigned int plaintext_pad_len;
2834 unsigned int plaintext_len;
2836 const uint8_t *ciphertext;
2837 uint8_t buffer[2048];
2839 struct rte_cryptodev_info dev_info;
2841 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2842 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2843 printf("Device doesn't support scatter-gather. "
2848 /* Create KASUMI session */
2849 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2850 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2851 RTE_CRYPTO_CIPHER_KASUMI_F8,
2852 tdata->key.data, tdata->key.len);
2856 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2857 /* Append data which is padded to a multiple */
2858 /* of the algorithms block size */
2859 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2861 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2862 plaintext_pad_len, 10, 0);
2863 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2864 plaintext_pad_len, 3, 0);
2866 /* Append data which is padded to a multiple */
2867 /* of the algorithms block size */
2868 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2870 /* Create KASUMI operation */
2871 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2873 tdata->plaintext.len,
2874 tdata->validCipherOffsetLenInBits.len,
2875 RTE_CRYPTO_CIPHER_KASUMI_F8);
2879 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2881 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2883 ut_params->obuf = ut_params->op->sym->m_dst;
2884 if (ut_params->obuf)
2885 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2886 plaintext_pad_len, buffer);
2888 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2889 plaintext_pad_len, buffer);
2892 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2894 tdata->ciphertext.data,
2895 tdata->validCipherLenInBits.len,
2896 "KASUMI Ciphertext data not as expected");
2902 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2904 struct crypto_testsuite_params *ts_params = &testsuite_params;
2905 struct crypto_unittest_params *ut_params = &unittest_params;
2908 uint8_t *ciphertext, *plaintext;
2909 unsigned ciphertext_pad_len;
2910 unsigned ciphertext_len;
2912 /* Create KASUMI session */
2913 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2914 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2915 RTE_CRYPTO_CIPHER_KASUMI_F8,
2916 tdata->key.data, tdata->key.len);
2920 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2921 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2923 /* Clear mbuf payload */
2924 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2925 rte_pktmbuf_tailroom(ut_params->ibuf));
2927 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2928 /* Append data which is padded to a multiple */
2929 /* of the algorithms block size */
2930 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2931 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2932 ciphertext_pad_len);
2933 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2934 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2936 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2938 /* Create KASUMI operation */
2939 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2941 tdata->ciphertext.len,
2942 tdata->validCipherOffsetLenInBits.len,
2943 RTE_CRYPTO_CIPHER_KASUMI_F8);
2947 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2951 ut_params->obuf = ut_params->op->sym->m_dst;
2952 if (ut_params->obuf)
2953 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2956 plaintext = ciphertext;
2958 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2961 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2963 tdata->plaintext.data,
2964 tdata->validCipherLenInBits.len,
2965 "KASUMI Plaintext data not as expected");
2970 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2972 struct crypto_testsuite_params *ts_params = &testsuite_params;
2973 struct crypto_unittest_params *ut_params = &unittest_params;
2976 uint8_t *ciphertext, *plaintext;
2977 unsigned ciphertext_pad_len;
2978 unsigned ciphertext_len;
2980 /* Create KASUMI session */
2981 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2982 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2983 RTE_CRYPTO_CIPHER_KASUMI_F8,
2984 tdata->key.data, tdata->key.len);
2988 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2990 /* Clear mbuf payload */
2991 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2992 rte_pktmbuf_tailroom(ut_params->ibuf));
2994 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2995 /* Append data which is padded to a multiple */
2996 /* of the algorithms block size */
2997 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2998 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2999 ciphertext_pad_len);
3000 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3002 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3004 /* Create KASUMI operation */
3005 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3007 tdata->ciphertext.len,
3008 tdata->validCipherOffsetLenInBits.len,
3009 RTE_CRYPTO_CIPHER_KASUMI_F8);
3013 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3015 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3017 ut_params->obuf = ut_params->op->sym->m_dst;
3018 if (ut_params->obuf)
3019 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3022 plaintext = ciphertext;
3024 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3027 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3029 tdata->plaintext.data,
3030 tdata->validCipherLenInBits.len,
3031 "KASUMI Plaintext data not as expected");
3036 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3038 struct crypto_testsuite_params *ts_params = &testsuite_params;
3039 struct crypto_unittest_params *ut_params = &unittest_params;
3042 uint8_t *plaintext, *ciphertext;
3043 unsigned plaintext_pad_len;
3044 unsigned plaintext_len;
3046 /* Create SNOW 3G session */
3047 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3048 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3049 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3050 tdata->key.data, tdata->key.len);
3054 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3056 /* Clear mbuf payload */
3057 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3058 rte_pktmbuf_tailroom(ut_params->ibuf));
3060 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3061 /* Append data which is padded to a multiple of */
3062 /* the algorithms block size */
3063 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3064 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3066 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3068 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3070 /* Create SNOW 3G operation */
3071 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3072 tdata->validCipherLenInBits.len,
3073 tdata->validCipherOffsetLenInBits.len,
3074 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3078 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3080 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3082 ut_params->obuf = ut_params->op->sym->m_dst;
3083 if (ut_params->obuf)
3084 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3087 ciphertext = plaintext;
3089 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3092 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3094 tdata->ciphertext.data,
3095 tdata->validDataLenInBits.len,
3096 "SNOW 3G Ciphertext data not as expected");
3102 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3104 struct crypto_testsuite_params *ts_params = &testsuite_params;
3105 struct crypto_unittest_params *ut_params = &unittest_params;
3106 uint8_t *plaintext, *ciphertext;
3109 unsigned plaintext_pad_len;
3110 unsigned plaintext_len;
3112 /* Create SNOW 3G session */
3113 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3114 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3115 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3116 tdata->key.data, tdata->key.len);
3120 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3121 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3123 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3124 "Failed to allocate input buffer in mempool");
3125 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3126 "Failed to allocate output buffer in mempool");
3128 /* Clear mbuf payload */
3129 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3130 rte_pktmbuf_tailroom(ut_params->ibuf));
3132 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3133 /* Append data which is padded to a multiple of */
3134 /* the algorithms block size */
3135 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3136 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3138 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3139 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3141 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3143 /* Create SNOW 3G operation */
3144 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3146 tdata->validCipherLenInBits.len,
3147 tdata->validCipherOffsetLenInBits.len,
3148 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3152 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3154 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3156 ut_params->obuf = ut_params->op->sym->m_dst;
3157 if (ut_params->obuf)
3158 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3161 ciphertext = plaintext;
3163 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3166 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3168 tdata->ciphertext.data,
3169 tdata->validDataLenInBits.len,
3170 "SNOW 3G Ciphertext data not as expected");
3175 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3177 struct crypto_testsuite_params *ts_params = &testsuite_params;
3178 struct crypto_unittest_params *ut_params = &unittest_params;
3181 unsigned int plaintext_pad_len;
3182 unsigned int plaintext_len;
3183 uint8_t buffer[10000];
3184 const uint8_t *ciphertext;
3186 struct rte_cryptodev_info dev_info;
3188 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3189 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3190 printf("Device doesn't support scatter-gather. "
3195 /* Create SNOW 3G session */
3196 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3197 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3198 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3199 tdata->key.data, tdata->key.len);
3203 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3204 /* Append data which is padded to a multiple of */
3205 /* the algorithms block size */
3206 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3208 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3209 plaintext_pad_len, 10, 0);
3210 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3211 plaintext_pad_len, 3, 0);
3213 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3214 "Failed to allocate input buffer in mempool");
3215 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3216 "Failed to allocate output buffer in mempool");
3218 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3220 /* Create SNOW 3G operation */
3221 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3223 tdata->validCipherLenInBits.len,
3224 tdata->validCipherOffsetLenInBits.len,
3225 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3229 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3231 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3233 ut_params->obuf = ut_params->op->sym->m_dst;
3234 if (ut_params->obuf)
3235 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3236 plaintext_len, buffer);
3238 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3239 plaintext_len, buffer);
3241 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3244 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3246 tdata->ciphertext.data,
3247 tdata->validDataLenInBits.len,
3248 "SNOW 3G Ciphertext data not as expected");
3253 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3255 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3257 uint8_t curr_byte, prev_byte;
3258 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3259 uint8_t lower_byte_mask = (1 << offset) - 1;
3262 prev_byte = buffer[0];
3263 buffer[0] >>= offset;
3265 for (i = 1; i < length_in_bytes; i++) {
3266 curr_byte = buffer[i];
3267 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3268 (curr_byte >> offset);
3269 prev_byte = curr_byte;
3274 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3276 struct crypto_testsuite_params *ts_params = &testsuite_params;
3277 struct crypto_unittest_params *ut_params = &unittest_params;
3278 uint8_t *plaintext, *ciphertext;
3280 uint32_t plaintext_len;
3281 uint32_t plaintext_pad_len;
3282 uint8_t extra_offset = 4;
3283 uint8_t *expected_ciphertext_shifted;
3285 /* Create SNOW 3G session */
3286 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3287 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3288 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3289 tdata->key.data, tdata->key.len);
3293 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3294 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3296 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3297 "Failed to allocate input buffer in mempool");
3298 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3299 "Failed to allocate output buffer in mempool");
3301 /* Clear mbuf payload */
3302 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3303 rte_pktmbuf_tailroom(ut_params->ibuf));
3305 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3307 * Append data which is padded to a
3308 * multiple of the algorithms block size
3310 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3312 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3315 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3317 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3318 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3320 #ifdef RTE_APP_TEST_DEBUG
3321 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3323 /* Create SNOW 3G operation */
3324 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3326 tdata->validCipherLenInBits.len,
3327 tdata->validCipherOffsetLenInBits.len +
3329 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3333 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3335 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3337 ut_params->obuf = ut_params->op->sym->m_dst;
3338 if (ut_params->obuf)
3339 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3342 ciphertext = plaintext;
3344 #ifdef RTE_APP_TEST_DEBUG
3345 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3348 expected_ciphertext_shifted = rte_malloc(NULL,
3349 ceil_byte_length(plaintext_len + extra_offset), 0);
3351 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3352 "failed to reserve memory for ciphertext shifted\n");
3354 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3355 ceil_byte_length(tdata->ciphertext.len));
3356 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3359 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3361 expected_ciphertext_shifted,
3362 tdata->validDataLenInBits.len,
3364 "SNOW 3G Ciphertext data not as expected");
3368 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3370 struct crypto_testsuite_params *ts_params = &testsuite_params;
3371 struct crypto_unittest_params *ut_params = &unittest_params;
3375 uint8_t *plaintext, *ciphertext;
3376 unsigned ciphertext_pad_len;
3377 unsigned ciphertext_len;
3379 /* Create SNOW 3G session */
3380 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3381 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3382 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3383 tdata->key.data, tdata->key.len);
3387 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3389 /* Clear mbuf payload */
3390 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3391 rte_pktmbuf_tailroom(ut_params->ibuf));
3393 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3394 /* Append data which is padded to a multiple of */
3395 /* the algorithms block size */
3396 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3397 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3398 ciphertext_pad_len);
3399 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3401 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3403 /* Create SNOW 3G operation */
3404 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3405 tdata->validCipherLenInBits.len,
3406 tdata->validCipherOffsetLenInBits.len,
3407 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3411 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3413 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3414 ut_params->obuf = ut_params->op->sym->m_dst;
3415 if (ut_params->obuf)
3416 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3419 plaintext = ciphertext;
3421 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3424 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3425 tdata->plaintext.data,
3426 tdata->validDataLenInBits.len,
3427 "SNOW 3G Plaintext data not as expected");
3431 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3433 struct crypto_testsuite_params *ts_params = &testsuite_params;
3434 struct crypto_unittest_params *ut_params = &unittest_params;
3438 uint8_t *plaintext, *ciphertext;
3439 unsigned ciphertext_pad_len;
3440 unsigned ciphertext_len;
3442 /* Create SNOW 3G session */
3443 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3444 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3445 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3446 tdata->key.data, tdata->key.len);
3450 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3451 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3453 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3454 "Failed to allocate input buffer");
3455 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3456 "Failed to allocate output buffer");
3458 /* Clear mbuf payload */
3459 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3460 rte_pktmbuf_tailroom(ut_params->ibuf));
3462 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3463 rte_pktmbuf_tailroom(ut_params->obuf));
3465 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3466 /* Append data which is padded to a multiple of */
3467 /* the algorithms block size */
3468 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3469 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3470 ciphertext_pad_len);
3471 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3472 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3474 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3476 /* Create SNOW 3G operation */
3477 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3479 tdata->validCipherLenInBits.len,
3480 tdata->validCipherOffsetLenInBits.len,
3481 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3485 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3488 ut_params->obuf = ut_params->op->sym->m_dst;
3489 if (ut_params->obuf)
3490 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3493 plaintext = ciphertext;
3495 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3498 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3499 tdata->plaintext.data,
3500 tdata->validDataLenInBits.len,
3501 "SNOW 3G Plaintext data not as expected");
3506 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3508 struct crypto_testsuite_params *ts_params = &testsuite_params;
3509 struct crypto_unittest_params *ut_params = &unittest_params;
3513 uint8_t *plaintext, *ciphertext;
3514 unsigned plaintext_pad_len;
3515 unsigned plaintext_len;
3517 /* Create SNOW 3G session */
3518 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3519 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3520 RTE_CRYPTO_AUTH_OP_GENERATE,
3521 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3522 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3523 tdata->key.data, tdata->key.len,
3524 tdata->aad.len, tdata->digest.len);
3527 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3529 /* clear mbuf payload */
3530 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3531 rte_pktmbuf_tailroom(ut_params->ibuf));
3533 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3534 /* Append data which is padded to a multiple of */
3535 /* the algorithms block size */
3536 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3537 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3539 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3541 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3543 /* Create SNOW 3G operation */
3544 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3545 tdata->digest.len, tdata->aad.data,
3546 tdata->aad.len, /*tdata->plaintext.len,*/
3547 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3548 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3549 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3550 tdata->iv.data, tdata->iv.len,
3551 tdata->validCipherLenInBits.len,
3552 tdata->validCipherOffsetLenInBits.len,
3553 tdata->validAuthLenInBits.len,
3554 tdata->validAuthOffsetLenInBits.len
3559 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3561 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3562 ut_params->obuf = ut_params->op->sym->m_src;
3563 if (ut_params->obuf)
3564 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3565 + tdata->iv.len + tdata->aad.len;
3567 ciphertext = plaintext;
3569 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3571 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3573 tdata->ciphertext.data,
3574 tdata->validDataLenInBits.len,
3575 "SNOW 3G Ciphertext data not as expected");
3577 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3578 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3581 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3584 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3585 "SNOW 3G Generated auth tag not as expected");
3589 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3591 struct crypto_testsuite_params *ts_params = &testsuite_params;
3592 struct crypto_unittest_params *ut_params = &unittest_params;
3596 uint8_t *plaintext, *ciphertext;
3597 unsigned plaintext_pad_len;
3598 unsigned plaintext_len;
3600 /* Create SNOW 3G session */
3601 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3602 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3603 RTE_CRYPTO_AUTH_OP_GENERATE,
3604 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3605 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3606 tdata->key.data, tdata->key.len,
3607 tdata->aad.len, tdata->digest.len);
3611 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3613 /* clear mbuf payload */
3614 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3615 rte_pktmbuf_tailroom(ut_params->ibuf));
3617 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3618 /* Append data which is padded to a multiple of */
3619 /* the algorithms block size */
3620 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3621 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3623 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3625 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3627 /* Create SNOW 3G operation */
3628 retval = create_wireless_algo_auth_cipher_operation(
3630 tdata->iv.data, tdata->iv.len,
3631 tdata->aad.data, tdata->aad.len,
3633 tdata->validCipherLenInBits.len,
3634 tdata->validCipherOffsetLenInBits.len,
3635 tdata->validAuthLenInBits.len,
3636 tdata->validAuthOffsetLenInBits.len,
3637 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3638 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3644 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3646 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3647 ut_params->obuf = ut_params->op->sym->m_src;
3648 if (ut_params->obuf)
3649 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3650 + tdata->aad.len + tdata->iv.len;
3652 ciphertext = plaintext;
3654 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3655 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3656 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3659 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3661 tdata->ciphertext.data,
3662 tdata->validDataLenInBits.len,
3663 "SNOW 3G Ciphertext data not as expected");
3666 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3669 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3670 "SNOW 3G Generated auth tag not as expected");
3675 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3677 struct crypto_testsuite_params *ts_params = &testsuite_params;
3678 struct crypto_unittest_params *ut_params = &unittest_params;
3682 uint8_t *plaintext, *ciphertext;
3683 unsigned plaintext_pad_len;
3684 unsigned plaintext_len;
3686 /* Create KASUMI session */
3687 retval = create_wireless_algo_auth_cipher_session(
3688 ts_params->valid_devs[0],
3689 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3690 RTE_CRYPTO_AUTH_OP_GENERATE,
3691 RTE_CRYPTO_AUTH_KASUMI_F9,
3692 RTE_CRYPTO_CIPHER_KASUMI_F8,
3693 tdata->key.data, tdata->key.len,
3694 tdata->aad.len, tdata->digest.len);
3697 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3699 /* clear mbuf payload */
3700 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3701 rte_pktmbuf_tailroom(ut_params->ibuf));
3703 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3704 /* Append data which is padded to a multiple of */
3705 /* the algorithms block size */
3706 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3707 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3709 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3711 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3713 /* Create KASUMI operation */
3714 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3715 tdata->iv.data, tdata->iv.len,
3716 tdata->aad.data, tdata->aad.len,
3718 tdata->validCipherLenInBits.len,
3719 tdata->validCipherOffsetLenInBits.len,
3720 tdata->validAuthLenInBits.len,
3721 tdata->validAuthOffsetLenInBits.len,
3722 RTE_CRYPTO_AUTH_KASUMI_F9,
3723 RTE_CRYPTO_CIPHER_KASUMI_F8
3729 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3731 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3732 ut_params->obuf = ut_params->op->sym->m_src;
3733 if (ut_params->obuf)
3734 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3735 + tdata->iv.len + tdata->aad.len;
3737 ciphertext = plaintext;
3740 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3742 tdata->ciphertext.data,
3743 tdata->validCipherLenInBits.len,
3744 "KASUMI Ciphertext data not as expected");
3745 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3746 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3749 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3752 DIGEST_BYTE_LENGTH_KASUMI_F9,
3753 "KASUMI Generated auth tag not as expected");
3758 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3760 struct crypto_testsuite_params *ts_params = &testsuite_params;
3761 struct crypto_unittest_params *ut_params = &unittest_params;
3765 uint8_t *plaintext, *ciphertext;
3766 unsigned plaintext_pad_len;
3767 unsigned plaintext_len;
3769 /* Create KASUMI session */
3770 retval = create_wireless_algo_cipher_auth_session(
3771 ts_params->valid_devs[0],
3772 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3773 RTE_CRYPTO_AUTH_OP_GENERATE,
3774 RTE_CRYPTO_AUTH_KASUMI_F9,
3775 RTE_CRYPTO_CIPHER_KASUMI_F8,
3776 tdata->key.data, tdata->key.len,
3777 tdata->aad.len, tdata->digest.len);
3781 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3783 /* clear mbuf payload */
3784 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3785 rte_pktmbuf_tailroom(ut_params->ibuf));
3787 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3788 /* Append data which is padded to a multiple of */
3789 /* the algorithms block size */
3790 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3791 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3793 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3795 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3797 /* Create KASUMI operation */
3798 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3799 tdata->digest.len, tdata->aad.data,
3801 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3802 RTE_CRYPTO_AUTH_KASUMI_F9,
3803 RTE_CRYPTO_CIPHER_KASUMI_F8,
3804 tdata->iv.data, tdata->iv.len,
3805 tdata->validCipherLenInBits.len,
3806 tdata->validCipherOffsetLenInBits.len,
3807 tdata->validAuthLenInBits.len,
3808 tdata->validAuthOffsetLenInBits.len
3813 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3815 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3816 ut_params->obuf = ut_params->op->sym->m_src;
3817 if (ut_params->obuf)
3818 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3819 + tdata->aad.len + tdata->iv.len;
3821 ciphertext = plaintext;
3823 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3824 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3827 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3829 tdata->ciphertext.data,
3830 tdata->validCipherLenInBits.len,
3831 "KASUMI Ciphertext data not as expected");
3834 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3837 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3838 "KASUMI Generated auth tag not as expected");
3843 test_zuc_encryption(const struct zuc_test_data *tdata)
3845 struct crypto_testsuite_params *ts_params = &testsuite_params;
3846 struct crypto_unittest_params *ut_params = &unittest_params;
3849 uint8_t *plaintext, *ciphertext;
3850 unsigned plaintext_pad_len;
3851 unsigned plaintext_len;
3853 /* Create ZUC session */
3854 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3855 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3856 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3857 tdata->key.data, tdata->key.len);
3861 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3863 /* Clear mbuf payload */
3864 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3865 rte_pktmbuf_tailroom(ut_params->ibuf));
3867 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3868 /* Append data which is padded to a multiple */
3869 /* of the algorithms block size */
3870 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3871 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3873 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3875 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3877 /* Create ZUC operation */
3878 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3879 tdata->plaintext.len,
3880 tdata->validCipherOffsetLenInBits.len,
3881 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3885 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3887 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3889 ut_params->obuf = ut_params->op->sym->m_dst;
3890 if (ut_params->obuf)
3891 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3894 ciphertext = plaintext;
3896 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3899 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3901 tdata->ciphertext.data,
3902 tdata->validCipherLenInBits.len,
3903 "ZUC Ciphertext data not as expected");
3908 test_zuc_encryption_sgl(const struct zuc_test_data *tdata)
3910 struct crypto_testsuite_params *ts_params = &testsuite_params;
3911 struct crypto_unittest_params *ut_params = &unittest_params;
3915 unsigned int plaintext_pad_len;
3916 unsigned int plaintext_len;
3917 const uint8_t *ciphertext;
3918 uint8_t ciphertext_buffer[2048];
3919 struct rte_cryptodev_info dev_info;
3921 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3922 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3923 printf("Device doesn't support scatter-gather. "
3928 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3930 /* Append data which is padded to a multiple */
3931 /* of the algorithms block size */
3932 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3934 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3935 plaintext_pad_len, 10, 0);
3937 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
3938 tdata->plaintext.data);
3940 /* Create ZUC session */
3941 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3942 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3943 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3944 tdata->key.data, tdata->key.len);
3948 /* Clear mbuf payload */
3950 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3952 /* Create ZUC operation */
3953 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3954 tdata->iv.len, tdata->plaintext.len,
3955 tdata->validCipherOffsetLenInBits.len,
3956 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3960 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3962 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3964 ut_params->obuf = ut_params->op->sym->m_dst;
3965 if (ut_params->obuf)
3966 ciphertext = rte_pktmbuf_read(ut_params->obuf,
3967 tdata->iv.len, plaintext_len, ciphertext_buffer);
3969 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3970 tdata->iv.len, plaintext_len, ciphertext_buffer);
3973 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3976 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3978 tdata->ciphertext.data,
3979 tdata->validCipherLenInBits.len,
3980 "ZUC Ciphertext data not as expected");
3986 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3988 struct crypto_testsuite_params *ts_params = &testsuite_params;
3989 struct crypto_unittest_params *ut_params = &unittest_params;
3992 unsigned plaintext_pad_len;
3993 unsigned plaintext_len;
3996 /* Create ZUC session */
3997 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3998 tdata->key.data, tdata->key.len,
3999 tdata->aad.len, tdata->digest.len,
4000 RTE_CRYPTO_AUTH_OP_GENERATE,
4001 RTE_CRYPTO_AUTH_ZUC_EIA3);
4005 /* alloc mbuf and set payload */
4006 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4008 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4009 rte_pktmbuf_tailroom(ut_params->ibuf));
4011 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4012 /* Append data which is padded to a multiple of */
4013 /* the algorithms block size */
4014 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4015 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4017 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4019 /* Create ZUC operation */
4020 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4021 tdata->aad.data, tdata->aad.len,
4022 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4023 RTE_CRYPTO_AUTH_ZUC_EIA3,
4024 tdata->validAuthLenInBits.len,
4025 tdata->validAuthOffsetLenInBits.len);
4029 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4031 ut_params->obuf = ut_params->op->sym->m_src;
4032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4033 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4034 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
4037 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4040 DIGEST_BYTE_LENGTH_KASUMI_F9,
4041 "ZUC Generated auth tag not as expected");
4047 test_kasumi_encryption_test_case_1(void)
4049 return test_kasumi_encryption(&kasumi_test_case_1);
4053 test_kasumi_encryption_test_case_1_sgl(void)
4055 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4059 test_kasumi_encryption_test_case_1_oop(void)
4061 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4065 test_kasumi_encryption_test_case_1_oop_sgl(void)
4067 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4071 test_kasumi_encryption_test_case_2(void)
4073 return test_kasumi_encryption(&kasumi_test_case_2);
4077 test_kasumi_encryption_test_case_3(void)
4079 return test_kasumi_encryption(&kasumi_test_case_3);
4083 test_kasumi_encryption_test_case_4(void)
4085 return test_kasumi_encryption(&kasumi_test_case_4);
4089 test_kasumi_encryption_test_case_5(void)
4091 return test_kasumi_encryption(&kasumi_test_case_5);
4095 test_kasumi_decryption_test_case_1(void)
4097 return test_kasumi_decryption(&kasumi_test_case_1);
4101 test_kasumi_decryption_test_case_1_oop(void)
4103 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4107 test_kasumi_decryption_test_case_2(void)
4109 return test_kasumi_decryption(&kasumi_test_case_2);
4113 test_kasumi_decryption_test_case_3(void)
4115 return test_kasumi_decryption(&kasumi_test_case_3);
4119 test_kasumi_decryption_test_case_4(void)
4121 return test_kasumi_decryption(&kasumi_test_case_4);
4125 test_kasumi_decryption_test_case_5(void)
4127 return test_kasumi_decryption(&kasumi_test_case_5);
4130 test_snow3g_encryption_test_case_1(void)
4132 return test_snow3g_encryption(&snow3g_test_case_1);
4136 test_snow3g_encryption_test_case_1_oop(void)
4138 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4142 test_snow3g_encryption_test_case_1_oop_sgl(void)
4144 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4149 test_snow3g_encryption_test_case_1_offset_oop(void)
4151 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4155 test_snow3g_encryption_test_case_2(void)
4157 return test_snow3g_encryption(&snow3g_test_case_2);
4161 test_snow3g_encryption_test_case_3(void)
4163 return test_snow3g_encryption(&snow3g_test_case_3);
4167 test_snow3g_encryption_test_case_4(void)
4169 return test_snow3g_encryption(&snow3g_test_case_4);
4173 test_snow3g_encryption_test_case_5(void)
4175 return test_snow3g_encryption(&snow3g_test_case_5);
4179 test_snow3g_decryption_test_case_1(void)
4181 return test_snow3g_decryption(&snow3g_test_case_1);
4185 test_snow3g_decryption_test_case_1_oop(void)
4187 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4191 test_snow3g_decryption_test_case_2(void)
4193 return test_snow3g_decryption(&snow3g_test_case_2);
4197 test_snow3g_decryption_test_case_3(void)
4199 return test_snow3g_decryption(&snow3g_test_case_3);
4203 test_snow3g_decryption_test_case_4(void)
4205 return test_snow3g_decryption(&snow3g_test_case_4);
4209 test_snow3g_decryption_test_case_5(void)
4211 return test_snow3g_decryption(&snow3g_test_case_5);
4214 test_snow3g_cipher_auth_test_case_1(void)
4216 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4220 test_snow3g_auth_cipher_test_case_1(void)
4222 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4226 test_kasumi_auth_cipher_test_case_1(void)
4228 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4232 test_kasumi_cipher_auth_test_case_1(void)
4234 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4238 test_zuc_encryption_test_case_1(void)
4240 return test_zuc_encryption(&zuc_test_case_1);
4244 test_zuc_encryption_test_case_2(void)
4246 return test_zuc_encryption(&zuc_test_case_2);
4250 test_zuc_encryption_test_case_3(void)
4252 return test_zuc_encryption(&zuc_test_case_3);
4256 test_zuc_encryption_test_case_4(void)
4258 return test_zuc_encryption(&zuc_test_case_4);
4262 test_zuc_encryption_test_case_5(void)
4264 return test_zuc_encryption(&zuc_test_case_5);
4268 test_zuc_encryption_test_case_6_sgl(void)
4270 return test_zuc_encryption_sgl(&zuc_test_case_1);
4274 test_zuc_hash_generate_test_case_1(void)
4276 return test_zuc_authentication(&zuc_hash_test_case_1);
4280 test_zuc_hash_generate_test_case_2(void)
4282 return test_zuc_authentication(&zuc_hash_test_case_2);
4286 test_zuc_hash_generate_test_case_3(void)
4288 return test_zuc_authentication(&zuc_hash_test_case_3);
4292 test_zuc_hash_generate_test_case_4(void)
4294 return test_zuc_authentication(&zuc_hash_test_case_4);
4298 test_zuc_hash_generate_test_case_5(void)
4300 return test_zuc_authentication(&zuc_hash_test_case_5);
4304 test_3DES_chain_qat_all(void)
4306 struct crypto_testsuite_params *ts_params = &testsuite_params;
4309 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4310 ts_params->op_mpool, ts_params->valid_devs[0],
4311 RTE_CRYPTODEV_QAT_SYM_PMD,
4312 BLKCIPHER_3DES_CHAIN_TYPE);
4314 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4316 return TEST_SUCCESS;
4320 test_DES_cipheronly_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_DES_CIPHERONLY_TYPE);
4330 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4332 return TEST_SUCCESS;
4336 test_3DES_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_3DES_CIPHERONLY_TYPE);
4346 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4348 return TEST_SUCCESS;
4352 test_3DES_chain_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_3DES_CHAIN_TYPE);
4362 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4364 return TEST_SUCCESS;
4368 test_3DES_cipheronly_openssl_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_OPENSSL_PMD,
4376 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4378 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4380 return TEST_SUCCESS;
4383 /* ***** AES-GCM Tests ***** */
4386 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4387 const uint8_t *key, const uint8_t key_len,
4388 const uint8_t aad_len, const uint8_t auth_len,
4389 enum rte_crypto_auth_operation auth_op)
4391 uint8_t cipher_key[key_len];
4393 struct crypto_unittest_params *ut_params = &unittest_params;
4395 memcpy(cipher_key, key, key_len);
4397 /* Setup Cipher Parameters */
4398 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4399 ut_params->cipher_xform.next = NULL;
4401 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4402 ut_params->auth_xform.auth.op = auth_op;
4403 ut_params->cipher_xform.cipher.op = op;
4404 ut_params->cipher_xform.cipher.key.data = cipher_key;
4405 ut_params->cipher_xform.cipher.key.length = key_len;
4407 TEST_HEXDUMP(stdout, "key:", key, key_len);
4409 /* Setup Authentication Parameters */
4410 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4411 ut_params->auth_xform.next = NULL;
4413 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4415 ut_params->auth_xform.auth.digest_length = auth_len;
4416 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4417 ut_params->auth_xform.auth.key.length = 0;
4418 ut_params->auth_xform.auth.key.data = NULL;
4420 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4421 ut_params->cipher_xform.next = &ut_params->auth_xform;
4423 /* Create Crypto session*/
4424 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4425 &ut_params->cipher_xform);
4426 } else {/* Create Crypto session*/
4427 ut_params->auth_xform.next = &ut_params->cipher_xform;
4428 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4429 &ut_params->auth_xform);
4432 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4438 create_gcm_xforms(struct rte_crypto_op *op,
4439 enum rte_crypto_cipher_operation cipher_op,
4440 uint8_t *key, const uint8_t key_len,
4441 const uint8_t aad_len, const uint8_t auth_len,
4442 enum rte_crypto_auth_operation auth_op)
4444 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4445 "failed to allocate space for crypto transforms");
4447 struct rte_crypto_sym_op *sym_op = op->sym;
4449 /* Setup Cipher Parameters */
4450 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4451 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4452 sym_op->xform->cipher.op = cipher_op;
4453 sym_op->xform->cipher.key.data = key;
4454 sym_op->xform->cipher.key.length = key_len;
4456 TEST_HEXDUMP(stdout, "key:", key, key_len);
4458 /* Setup Authentication Parameters */
4459 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4460 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4461 sym_op->xform->next->auth.op = auth_op;
4462 sym_op->xform->next->auth.digest_length = auth_len;
4463 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4464 sym_op->xform->next->auth.key.length = 0;
4465 sym_op->xform->next->auth.key.data = NULL;
4466 sym_op->xform->next->next = NULL;
4472 create_gcm_operation(enum rte_crypto_cipher_operation op,
4473 const struct gcm_test_data *tdata)
4475 struct crypto_testsuite_params *ts_params = &testsuite_params;
4476 struct crypto_unittest_params *ut_params = &unittest_params;
4478 uint8_t *plaintext, *ciphertext;
4479 unsigned int iv_pad_len, aad_pad_len, plaintext_pad_len;
4481 /* Generate Crypto op data structure */
4482 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4483 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4484 TEST_ASSERT_NOT_NULL(ut_params->op,
4485 "Failed to allocate symmetric crypto operation struct");
4487 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4489 /* Append aad data */
4490 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4491 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4493 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4494 "no room to append aad");
4496 sym_op->auth.aad.length = tdata->aad.len;
4497 sym_op->auth.aad.phys_addr =
4498 rte_pktmbuf_mtophys(ut_params->ibuf);
4499 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4500 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4501 sym_op->auth.aad.length);
4504 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
4505 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4506 ut_params->ibuf, iv_pad_len);
4507 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4509 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4510 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4511 sym_op->cipher.iv.length = tdata->iv.len;
4513 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4514 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
4515 sym_op->cipher.iv.length);
4517 /* Append plaintext/ciphertext */
4518 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4519 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4520 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4522 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4524 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4525 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4526 tdata->plaintext.len);
4528 if (ut_params->obuf) {
4529 ciphertext = (uint8_t *)rte_pktmbuf_append(
4531 plaintext_pad_len + aad_pad_len +
4533 TEST_ASSERT_NOT_NULL(ciphertext,
4534 "no room to append ciphertext");
4536 memset(ciphertext + aad_pad_len + iv_pad_len, 0,
4537 tdata->ciphertext.len);
4540 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4541 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4543 TEST_ASSERT_NOT_NULL(ciphertext,
4544 "no room to append ciphertext");
4546 memcpy(ciphertext, tdata->ciphertext.data,
4547 tdata->ciphertext.len);
4548 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4549 tdata->ciphertext.len);
4551 if (ut_params->obuf) {
4552 plaintext = (uint8_t *)rte_pktmbuf_append(
4554 plaintext_pad_len + aad_pad_len +
4556 TEST_ASSERT_NOT_NULL(plaintext,
4557 "no room to append plaintext");
4559 memset(plaintext + aad_pad_len + iv_pad_len, 0,
4560 tdata->plaintext.len);
4564 /* Append digest data */
4565 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4566 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4567 ut_params->obuf ? ut_params->obuf :
4569 tdata->auth_tag.len);
4570 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4571 "no room to append digest");
4572 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4573 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4574 ut_params->obuf ? ut_params->obuf :
4577 aad_pad_len + iv_pad_len);
4578 sym_op->auth.digest.length = tdata->auth_tag.len;
4580 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4581 ut_params->ibuf, tdata->auth_tag.len);
4582 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4583 "no room to append digest");
4584 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4586 plaintext_pad_len + aad_pad_len + iv_pad_len);
4587 sym_op->auth.digest.length = tdata->auth_tag.len;
4589 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4590 tdata->auth_tag.len);
4591 TEST_HEXDUMP(stdout, "digest:",
4592 sym_op->auth.digest.data,
4593 sym_op->auth.digest.length);
4596 sym_op->cipher.data.length = tdata->plaintext.len;
4597 sym_op->cipher.data.offset = aad_pad_len + iv_pad_len;
4599 sym_op->auth.data.length = tdata->plaintext.len;
4600 sym_op->auth.data.offset = aad_pad_len + iv_pad_len;
4606 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4608 struct crypto_testsuite_params *ts_params = &testsuite_params;
4609 struct crypto_unittest_params *ut_params = &unittest_params;
4612 uint8_t *ciphertext, *auth_tag;
4613 uint16_t plaintext_pad_len;
4616 /* Create GCM session */
4617 retval = create_gcm_session(ts_params->valid_devs[0],
4618 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4619 tdata->key.data, tdata->key.len,
4620 tdata->aad.len, tdata->auth_tag.len,
4621 RTE_CRYPTO_AUTH_OP_GENERATE);
4625 if (tdata->aad.len > MBUF_SIZE) {
4626 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4627 /* Populate full size of add data */
4628 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4629 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4631 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4633 /* clear mbuf payload */
4634 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4635 rte_pktmbuf_tailroom(ut_params->ibuf));
4637 /* Create GCM operation */
4638 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4642 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4644 ut_params->op->sym->m_src = ut_params->ibuf;
4646 /* Process crypto operation */
4647 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4648 ut_params->op), "failed to process sym crypto op");
4650 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4651 "crypto op processing failed");
4653 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4655 if (ut_params->op->sym->m_dst) {
4656 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4658 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4659 uint8_t *, plaintext_pad_len);
4661 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4663 ut_params->op->sym->cipher.data.offset);
4664 auth_tag = ciphertext + plaintext_pad_len;
4667 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4668 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4671 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4673 tdata->ciphertext.data,
4674 tdata->ciphertext.len,
4675 "GCM Ciphertext data not as expected");
4677 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4679 tdata->auth_tag.data,
4680 tdata->auth_tag.len,
4681 "GCM Generated auth tag not as expected");
4688 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4690 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4694 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4696 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4700 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4702 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4706 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4708 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4712 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4714 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4718 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4720 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4724 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4726 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4730 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4732 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4736 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4738 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4742 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4744 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4748 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
4750 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
4754 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
4756 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
4760 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
4762 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
4766 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
4768 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
4772 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
4774 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
4778 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
4780 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
4784 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4786 struct crypto_testsuite_params *ts_params = &testsuite_params;
4787 struct crypto_unittest_params *ut_params = &unittest_params;
4793 /* Create GCM session */
4794 retval = create_gcm_session(ts_params->valid_devs[0],
4795 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4796 tdata->key.data, tdata->key.len,
4797 tdata->aad.len, tdata->auth_tag.len,
4798 RTE_CRYPTO_AUTH_OP_VERIFY);
4802 /* alloc mbuf and set payload */
4803 if (tdata->aad.len > MBUF_SIZE) {
4804 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4805 /* Populate full size of add data */
4806 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4807 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4809 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4811 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4812 rte_pktmbuf_tailroom(ut_params->ibuf));
4814 /* Create GCM operation */
4815 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
4819 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4821 ut_params->op->sym->m_src = ut_params->ibuf;
4823 /* Process crypto operation */
4824 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4825 ut_params->op), "failed to process sym crypto op");
4827 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4828 "crypto op processing failed");
4830 if (ut_params->op->sym->m_dst)
4831 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4834 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4836 ut_params->op->sym->cipher.data.offset);
4838 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4841 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4843 tdata->plaintext.data,
4844 tdata->plaintext.len,
4845 "GCM plaintext data not as expected");
4847 TEST_ASSERT_EQUAL(ut_params->op->status,
4848 RTE_CRYPTO_OP_STATUS_SUCCESS,
4849 "GCM authentication failed");
4854 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4856 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4860 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4862 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4866 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4868 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4872 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4874 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4878 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4880 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4884 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4886 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4890 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4892 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4896 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
4898 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
4902 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
4904 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
4908 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
4910 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
4914 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
4916 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
4920 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
4922 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
4926 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
4928 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
4932 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
4934 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
4938 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
4940 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
4944 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
4946 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
4950 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
4952 struct crypto_testsuite_params *ts_params = &testsuite_params;
4953 struct crypto_unittest_params *ut_params = &unittest_params;
4956 uint8_t *ciphertext, *auth_tag;
4957 uint16_t plaintext_pad_len;
4959 /* Create GCM session */
4960 retval = create_gcm_session(ts_params->valid_devs[0],
4961 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4962 tdata->key.data, tdata->key.len,
4963 tdata->aad.len, tdata->auth_tag.len,
4964 RTE_CRYPTO_AUTH_OP_GENERATE);
4968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4969 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4971 /* clear mbuf payload */
4972 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4973 rte_pktmbuf_tailroom(ut_params->ibuf));
4974 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4975 rte_pktmbuf_tailroom(ut_params->obuf));
4977 /* Create GCM operation */
4978 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4982 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4984 ut_params->op->sym->m_src = ut_params->ibuf;
4985 ut_params->op->sym->m_dst = ut_params->obuf;
4987 /* Process crypto operation */
4988 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4989 ut_params->op), "failed to process sym crypto op");
4991 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4992 "crypto op processing failed");
4994 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4996 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4997 ut_params->op->sym->cipher.data.offset);
4998 auth_tag = ciphertext + plaintext_pad_len;
5000 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5001 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5004 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5006 tdata->ciphertext.data,
5007 tdata->ciphertext.len,
5008 "GCM Ciphertext data not as expected");
5010 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5012 tdata->auth_tag.data,
5013 tdata->auth_tag.len,
5014 "GCM Generated auth tag not as expected");
5021 test_mb_AES_GCM_authenticated_encryption_oop(void)
5023 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5027 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5029 struct crypto_testsuite_params *ts_params = &testsuite_params;
5030 struct crypto_unittest_params *ut_params = &unittest_params;
5035 /* Create GCM session */
5036 retval = create_gcm_session(ts_params->valid_devs[0],
5037 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5038 tdata->key.data, tdata->key.len,
5039 tdata->aad.len, tdata->auth_tag.len,
5040 RTE_CRYPTO_AUTH_OP_VERIFY);
5044 /* alloc mbuf and set payload */
5045 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5046 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5048 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5049 rte_pktmbuf_tailroom(ut_params->ibuf));
5050 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5051 rte_pktmbuf_tailroom(ut_params->obuf));
5053 /* Create GCM operation */
5054 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5058 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5060 ut_params->op->sym->m_src = ut_params->ibuf;
5061 ut_params->op->sym->m_dst = ut_params->obuf;
5063 /* Process crypto operation */
5064 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5065 ut_params->op), "failed to process sym crypto op");
5067 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5068 "crypto op processing failed");
5070 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5071 ut_params->op->sym->cipher.data.offset);
5073 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5076 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5078 tdata->plaintext.data,
5079 tdata->plaintext.len,
5080 "GCM plaintext data not as expected");
5082 TEST_ASSERT_EQUAL(ut_params->op->status,
5083 RTE_CRYPTO_OP_STATUS_SUCCESS,
5084 "GCM authentication failed");
5089 test_mb_AES_GCM_authenticated_decryption_oop(void)
5091 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5095 test_AES_GCM_authenticated_encryption_sessionless(
5096 const struct gcm_test_data *tdata)
5098 struct crypto_testsuite_params *ts_params = &testsuite_params;
5099 struct crypto_unittest_params *ut_params = &unittest_params;
5102 uint8_t *ciphertext, *auth_tag;
5103 uint16_t plaintext_pad_len;
5104 uint8_t key[tdata->key.len + 1];
5106 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5108 /* clear mbuf payload */
5109 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5110 rte_pktmbuf_tailroom(ut_params->ibuf));
5112 /* Create GCM operation */
5113 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5117 /* Create GCM xforms */
5118 memcpy(key, tdata->key.data, tdata->key.len);
5119 retval = create_gcm_xforms(ut_params->op,
5120 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5121 key, tdata->key.len,
5122 tdata->aad.len, tdata->auth_tag.len,
5123 RTE_CRYPTO_AUTH_OP_GENERATE);
5127 ut_params->op->sym->m_src = ut_params->ibuf;
5129 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5130 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5131 "crypto op session type not sessionless");
5133 /* Process crypto operation */
5134 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5135 ut_params->op), "failed to process sym crypto op");
5137 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5139 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5140 "crypto op status not success");
5142 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5144 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5145 ut_params->op->sym->cipher.data.offset);
5146 auth_tag = ciphertext + plaintext_pad_len;
5148 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5149 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5152 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5154 tdata->ciphertext.data,
5155 tdata->ciphertext.len,
5156 "GCM Ciphertext data not as expected");
5158 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5160 tdata->auth_tag.data,
5161 tdata->auth_tag.len,
5162 "GCM Generated auth tag not as expected");
5169 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5171 return test_AES_GCM_authenticated_encryption_sessionless(
5176 test_AES_GCM_authenticated_decryption_sessionless(
5177 const struct gcm_test_data *tdata)
5179 struct crypto_testsuite_params *ts_params = &testsuite_params;
5180 struct crypto_unittest_params *ut_params = &unittest_params;
5184 uint8_t key[tdata->key.len + 1];
5186 /* alloc mbuf and set payload */
5187 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5189 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5190 rte_pktmbuf_tailroom(ut_params->ibuf));
5192 /* Create GCM operation */
5193 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5197 /* Create GCM xforms */
5198 memcpy(key, tdata->key.data, tdata->key.len);
5199 retval = create_gcm_xforms(ut_params->op,
5200 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5201 key, tdata->key.len,
5202 tdata->aad.len, tdata->auth_tag.len,
5203 RTE_CRYPTO_AUTH_OP_VERIFY);
5207 ut_params->op->sym->m_src = ut_params->ibuf;
5209 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5210 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5211 "crypto op session type not sessionless");
5213 /* Process crypto operation */
5214 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5215 ut_params->op), "failed to process sym crypto op");
5217 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5219 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5220 "crypto op status not success");
5222 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5223 ut_params->op->sym->cipher.data.offset);
5225 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5228 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5230 tdata->plaintext.data,
5231 tdata->plaintext.len,
5232 "GCM plaintext data not as expected");
5234 TEST_ASSERT_EQUAL(ut_params->op->status,
5235 RTE_CRYPTO_OP_STATUS_SUCCESS,
5236 "GCM authentication failed");
5241 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5243 return test_AES_GCM_authenticated_decryption_sessionless(
5250 struct crypto_testsuite_params *ts_params = &testsuite_params;
5251 struct rte_cryptodev_stats stats;
5252 struct rte_cryptodev *dev;
5253 cryptodev_stats_get_t temp_pfn;
5255 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5256 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5257 &stats) == -ENODEV),
5258 "rte_cryptodev_stats_get invalid dev failed");
5259 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5260 "rte_cryptodev_stats_get invalid Param failed");
5261 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5262 temp_pfn = dev->dev_ops->stats_get;
5263 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5264 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5266 "rte_cryptodev_stats_get invalid Param failed");
5267 dev->dev_ops->stats_get = temp_pfn;
5269 /* Test expected values */
5271 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5273 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5275 "rte_cryptodev_stats_get failed");
5276 TEST_ASSERT((stats.enqueued_count == 1),
5277 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5278 TEST_ASSERT((stats.dequeued_count == 1),
5279 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5280 TEST_ASSERT((stats.enqueue_err_count == 0),
5281 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5282 TEST_ASSERT((stats.dequeue_err_count == 0),
5283 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5285 /* invalid device but should ignore and not reset device stats*/
5286 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5287 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5289 "rte_cryptodev_stats_get failed");
5290 TEST_ASSERT((stats.enqueued_count == 1),
5291 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5293 /* check that a valid reset clears stats */
5294 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5295 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5297 "rte_cryptodev_stats_get failed");
5298 TEST_ASSERT((stats.enqueued_count == 0),
5299 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5300 TEST_ASSERT((stats.dequeued_count == 0),
5301 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5303 return TEST_SUCCESS;
5306 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5307 struct crypto_unittest_params *ut_params,
5308 enum rte_crypto_auth_operation op,
5309 const struct HMAC_MD5_vector *test_case)
5313 memcpy(key, test_case->key.data, test_case->key.len);
5315 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5316 ut_params->auth_xform.next = NULL;
5317 ut_params->auth_xform.auth.op = op;
5319 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5321 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5322 ut_params->auth_xform.auth.add_auth_data_length = 0;
5323 ut_params->auth_xform.auth.key.length = test_case->key.len;
5324 ut_params->auth_xform.auth.key.data = key;
5326 ut_params->sess = rte_cryptodev_sym_session_create(
5327 ts_params->valid_devs[0], &ut_params->auth_xform);
5329 if (ut_params->sess == NULL)
5332 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5334 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5335 rte_pktmbuf_tailroom(ut_params->ibuf));
5340 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5341 const struct HMAC_MD5_vector *test_case,
5342 uint8_t **plaintext)
5344 uint16_t plaintext_pad_len;
5346 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5348 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5351 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5353 memcpy(*plaintext, test_case->plaintext.data,
5354 test_case->plaintext.len);
5356 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5357 ut_params->ibuf, MD5_DIGEST_LEN);
5358 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5359 "no room to append digest");
5360 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5361 ut_params->ibuf, plaintext_pad_len);
5362 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5364 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5365 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5366 test_case->auth_tag.len);
5369 sym_op->auth.data.offset = 0;
5370 sym_op->auth.data.length = test_case->plaintext.len;
5372 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5373 ut_params->op->sym->m_src = ut_params->ibuf;
5379 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5381 uint16_t plaintext_pad_len;
5382 uint8_t *plaintext, *auth_tag;
5384 struct crypto_testsuite_params *ts_params = &testsuite_params;
5385 struct crypto_unittest_params *ut_params = &unittest_params;
5387 if (MD5_HMAC_create_session(ts_params, ut_params,
5388 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5391 /* Generate Crypto op data structure */
5392 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5393 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5394 TEST_ASSERT_NOT_NULL(ut_params->op,
5395 "Failed to allocate symmetric crypto operation struct");
5397 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5400 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5403 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5404 ut_params->op), "failed to process sym crypto op");
5406 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5407 "crypto op processing failed");
5409 if (ut_params->op->sym->m_dst) {
5410 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5411 uint8_t *, plaintext_pad_len);
5413 auth_tag = plaintext + plaintext_pad_len;
5416 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5418 test_case->auth_tag.data,
5419 test_case->auth_tag.len,
5420 "HMAC_MD5 generated tag not as expected");
5422 return TEST_SUCCESS;
5426 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5430 struct crypto_testsuite_params *ts_params = &testsuite_params;
5431 struct crypto_unittest_params *ut_params = &unittest_params;
5433 if (MD5_HMAC_create_session(ts_params, ut_params,
5434 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5438 /* Generate Crypto op data structure */
5439 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5440 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5441 TEST_ASSERT_NOT_NULL(ut_params->op,
5442 "Failed to allocate symmetric crypto operation struct");
5444 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5447 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5448 ut_params->op), "failed to process sym crypto op");
5450 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5451 "HMAC_MD5 crypto op processing failed");
5453 return TEST_SUCCESS;
5457 test_MD5_HMAC_generate_case_1(void)
5459 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5463 test_MD5_HMAC_verify_case_1(void)
5465 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5469 test_MD5_HMAC_generate_case_2(void)
5471 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5475 test_MD5_HMAC_verify_case_2(void)
5477 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5481 test_multi_session(void)
5483 struct crypto_testsuite_params *ts_params = &testsuite_params;
5484 struct crypto_unittest_params *ut_params = &unittest_params;
5486 struct rte_cryptodev_info dev_info;
5487 struct rte_cryptodev_sym_session **sessions;
5491 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5492 aes_cbc_key, hmac_sha512_key);
5495 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5497 sessions = rte_malloc(NULL,
5498 (sizeof(struct rte_cryptodev_sym_session *) *
5499 dev_info.sym.max_nb_sessions) + 1, 0);
5501 /* Create multiple crypto sessions*/
5502 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5503 sessions[i] = rte_cryptodev_sym_session_create(
5504 ts_params->valid_devs[0],
5505 &ut_params->auth_xform);
5506 TEST_ASSERT_NOT_NULL(sessions[i],
5507 "Session creation failed at session number %u",
5510 /* Attempt to send a request on each session */
5511 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5515 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5516 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5518 "Failed to perform decrypt on request number %u.", i);
5519 /* free crypto operation structure */
5521 rte_crypto_op_free(ut_params->op);
5524 * free mbuf - both obuf and ibuf are usually the same,
5525 * so check if they point at the same address is necessary,
5526 * to avoid freeing the mbuf twice.
5528 if (ut_params->obuf) {
5529 rte_pktmbuf_free(ut_params->obuf);
5530 if (ut_params->ibuf == ut_params->obuf)
5531 ut_params->ibuf = 0;
5532 ut_params->obuf = 0;
5534 if (ut_params->ibuf) {
5535 rte_pktmbuf_free(ut_params->ibuf);
5536 ut_params->ibuf = 0;
5540 /* Next session create should fail */
5541 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5542 &ut_params->auth_xform);
5543 TEST_ASSERT_NULL(sessions[i],
5544 "Session creation succeeded unexpectedly!");
5546 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5547 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5552 return TEST_SUCCESS;
5555 struct multi_session_params {
5556 struct crypto_unittest_params ut_params;
5557 uint8_t *cipher_key;
5559 const uint8_t *cipher;
5560 const uint8_t *digest;
5564 #define MB_SESSION_NUMBER 3
5567 test_multi_session_random_usage(void)
5569 struct crypto_testsuite_params *ts_params = &testsuite_params;
5570 struct rte_cryptodev_info dev_info;
5571 struct rte_cryptodev_sym_session **sessions;
5573 struct multi_session_params ut_paramz[] = {
5576 .cipher_key = ms_aes_cbc_key0,
5577 .hmac_key = ms_hmac_key0,
5578 .cipher = ms_aes_cbc_cipher0,
5579 .digest = ms_hmac_digest0,
5580 .iv = ms_aes_cbc_iv0
5583 .cipher_key = ms_aes_cbc_key1,
5584 .hmac_key = ms_hmac_key1,
5585 .cipher = ms_aes_cbc_cipher1,
5586 .digest = ms_hmac_digest1,
5587 .iv = ms_aes_cbc_iv1
5590 .cipher_key = ms_aes_cbc_key2,
5591 .hmac_key = ms_hmac_key2,
5592 .cipher = ms_aes_cbc_cipher2,
5593 .digest = ms_hmac_digest2,
5594 .iv = ms_aes_cbc_iv2
5599 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5601 sessions = rte_malloc(NULL,
5602 (sizeof(struct rte_cryptodev_sym_session *)
5603 * dev_info.sym.max_nb_sessions) + 1, 0);
5605 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5606 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5607 sizeof(struct crypto_unittest_params));
5609 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5610 &ut_paramz[i].ut_params,
5611 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5613 /* Create multiple crypto sessions*/
5614 sessions[i] = rte_cryptodev_sym_session_create(
5615 ts_params->valid_devs[0],
5616 &ut_paramz[i].ut_params.auth_xform);
5618 TEST_ASSERT_NOT_NULL(sessions[i],
5619 "Session creation failed at session number %u",
5625 for (i = 0; i < 40000; i++) {
5627 j = rand() % MB_SESSION_NUMBER;
5629 TEST_ASSERT_SUCCESS(
5630 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5632 &ut_paramz[j].ut_params,
5633 ts_params, ut_paramz[j].cipher,
5634 ut_paramz[j].digest,
5636 "Failed to perform decrypt on request number %u.", i);
5638 if (ut_paramz[j].ut_params.op)
5639 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5642 * free mbuf - both obuf and ibuf are usually the same,
5643 * so check if they point at the same address is necessary,
5644 * to avoid freeing the mbuf twice.
5646 if (ut_paramz[j].ut_params.obuf) {
5647 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5648 if (ut_paramz[j].ut_params.ibuf
5649 == ut_paramz[j].ut_params.obuf)
5650 ut_paramz[j].ut_params.ibuf = 0;
5651 ut_paramz[j].ut_params.obuf = 0;
5653 if (ut_paramz[j].ut_params.ibuf) {
5654 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5655 ut_paramz[j].ut_params.ibuf = 0;
5659 for (i = 0; i < MB_SESSION_NUMBER; i++)
5660 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5665 return TEST_SUCCESS;
5669 test_null_cipher_only_operation(void)
5671 struct crypto_testsuite_params *ts_params = &testsuite_params;
5672 struct crypto_unittest_params *ut_params = &unittest_params;
5674 /* Generate test mbuf data and space for digest */
5675 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5676 catch_22_quote, QUOTE_512_BYTES, 0);
5678 /* Setup Cipher Parameters */
5679 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5680 ut_params->cipher_xform.next = NULL;
5682 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5683 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5685 /* Create Crypto session*/
5686 ut_params->sess = rte_cryptodev_sym_session_create(
5687 ts_params->valid_devs[0], &ut_params->cipher_xform);
5688 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5690 /* Generate Crypto op data structure */
5691 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5692 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5693 TEST_ASSERT_NOT_NULL(ut_params->op,
5694 "Failed to allocate symmetric crypto operation struct");
5696 /* Set crypto operation data parameters */
5697 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5699 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5701 /* set crypto operation source mbuf */
5702 sym_op->m_src = ut_params->ibuf;
5704 sym_op->cipher.data.offset = 0;
5705 sym_op->cipher.data.length = QUOTE_512_BYTES;
5707 /* Process crypto operation */
5708 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5710 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5712 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5713 "crypto operation processing failed");
5716 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5717 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5720 "Ciphertext data not as expected");
5722 return TEST_SUCCESS;
5726 test_null_auth_only_operation(void)
5728 struct crypto_testsuite_params *ts_params = &testsuite_params;
5729 struct crypto_unittest_params *ut_params = &unittest_params;
5731 /* Generate test mbuf data and space for digest */
5732 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5733 catch_22_quote, QUOTE_512_BYTES, 0);
5735 /* Setup HMAC Parameters */
5736 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5737 ut_params->auth_xform.next = NULL;
5739 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5740 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5742 /* Create Crypto session*/
5743 ut_params->sess = rte_cryptodev_sym_session_create(
5744 ts_params->valid_devs[0], &ut_params->auth_xform);
5745 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5747 /* Generate Crypto op data structure */
5748 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5749 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5750 TEST_ASSERT_NOT_NULL(ut_params->op,
5751 "Failed to allocate symmetric crypto operation struct");
5753 /* Set crypto operation data parameters */
5754 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5756 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5758 sym_op->m_src = ut_params->ibuf;
5760 sym_op->auth.data.offset = 0;
5761 sym_op->auth.data.length = QUOTE_512_BYTES;
5763 /* Process crypto operation */
5764 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5766 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5768 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5769 "crypto operation processing failed");
5771 return TEST_SUCCESS;
5775 test_null_cipher_auth_operation(void)
5777 struct crypto_testsuite_params *ts_params = &testsuite_params;
5778 struct crypto_unittest_params *ut_params = &unittest_params;
5780 /* Generate test mbuf data and space for digest */
5781 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5782 catch_22_quote, QUOTE_512_BYTES, 0);
5784 /* Setup Cipher Parameters */
5785 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5786 ut_params->cipher_xform.next = &ut_params->auth_xform;
5788 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5789 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5791 /* Setup HMAC Parameters */
5792 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5793 ut_params->auth_xform.next = NULL;
5795 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5796 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5798 /* Create Crypto session*/
5799 ut_params->sess = rte_cryptodev_sym_session_create(
5800 ts_params->valid_devs[0], &ut_params->cipher_xform);
5801 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5803 /* Generate Crypto op data structure */
5804 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5805 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5806 TEST_ASSERT_NOT_NULL(ut_params->op,
5807 "Failed to allocate symmetric crypto operation struct");
5809 /* Set crypto operation data parameters */
5810 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5812 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5814 sym_op->m_src = ut_params->ibuf;
5816 sym_op->cipher.data.offset = 0;
5817 sym_op->cipher.data.length = QUOTE_512_BYTES;
5819 sym_op->auth.data.offset = 0;
5820 sym_op->auth.data.length = QUOTE_512_BYTES;
5822 /* Process crypto operation */
5823 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5825 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5827 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5828 "crypto operation processing failed");
5831 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5832 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5835 "Ciphertext data not as expected");
5837 return TEST_SUCCESS;
5841 test_null_auth_cipher_operation(void)
5843 struct crypto_testsuite_params *ts_params = &testsuite_params;
5844 struct crypto_unittest_params *ut_params = &unittest_params;
5846 /* Generate test mbuf data and space for digest */
5847 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5848 catch_22_quote, QUOTE_512_BYTES, 0);
5850 /* Setup Cipher Parameters */
5851 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5852 ut_params->cipher_xform.next = NULL;
5854 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5855 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5857 /* Setup HMAC Parameters */
5858 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5859 ut_params->auth_xform.next = &ut_params->cipher_xform;
5861 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5862 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5864 /* Create Crypto session*/
5865 ut_params->sess = rte_cryptodev_sym_session_create(
5866 ts_params->valid_devs[0], &ut_params->cipher_xform);
5867 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5869 /* Generate Crypto op data structure */
5870 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5871 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5872 TEST_ASSERT_NOT_NULL(ut_params->op,
5873 "Failed to allocate symmetric crypto operation struct");
5875 /* Set crypto operation data parameters */
5876 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5878 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5880 sym_op->m_src = ut_params->ibuf;
5882 sym_op->cipher.data.offset = 0;
5883 sym_op->cipher.data.length = QUOTE_512_BYTES;
5885 sym_op->auth.data.offset = 0;
5886 sym_op->auth.data.length = QUOTE_512_BYTES;
5888 /* Process crypto operation */
5889 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5891 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5893 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5894 "crypto operation processing failed");
5897 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5898 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5901 "Ciphertext data not as expected");
5903 return TEST_SUCCESS;
5908 test_null_invalid_operation(void)
5910 struct crypto_testsuite_params *ts_params = &testsuite_params;
5911 struct crypto_unittest_params *ut_params = &unittest_params;
5913 /* Setup Cipher Parameters */
5914 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5915 ut_params->cipher_xform.next = NULL;
5917 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
5918 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5920 /* Create Crypto session*/
5921 ut_params->sess = rte_cryptodev_sym_session_create(
5922 ts_params->valid_devs[0], &ut_params->cipher_xform);
5923 TEST_ASSERT_NULL(ut_params->sess,
5924 "Session creation succeeded unexpectedly");
5927 /* Setup HMAC Parameters */
5928 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5929 ut_params->auth_xform.next = NULL;
5931 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
5932 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5934 /* Create Crypto session*/
5935 ut_params->sess = rte_cryptodev_sym_session_create(
5936 ts_params->valid_devs[0], &ut_params->auth_xform);
5937 TEST_ASSERT_NULL(ut_params->sess,
5938 "Session creation succeeded unexpectedly");
5940 return TEST_SUCCESS;
5944 #define NULL_BURST_LENGTH (32)
5947 test_null_burst_operation(void)
5949 struct crypto_testsuite_params *ts_params = &testsuite_params;
5950 struct crypto_unittest_params *ut_params = &unittest_params;
5952 unsigned i, burst_len = NULL_BURST_LENGTH;
5954 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
5955 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
5957 /* Setup Cipher Parameters */
5958 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5959 ut_params->cipher_xform.next = &ut_params->auth_xform;
5961 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5962 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5964 /* Setup HMAC Parameters */
5965 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5966 ut_params->auth_xform.next = NULL;
5968 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5969 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5971 /* Create Crypto session*/
5972 ut_params->sess = rte_cryptodev_sym_session_create(
5973 ts_params->valid_devs[0], &ut_params->cipher_xform);
5974 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5976 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
5977 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
5978 burst_len, "failed to generate burst of crypto ops");
5980 /* Generate an operation for each mbuf in burst */
5981 for (i = 0; i < burst_len; i++) {
5982 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5984 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
5986 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
5990 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
5992 burst[i]->sym->m_src = m;
5995 /* Process crypto operation */
5996 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
5997 0, burst, burst_len),
5999 "Error enqueuing burst");
6001 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6002 0, burst_dequeued, burst_len),
6004 "Error dequeuing burst");
6007 for (i = 0; i < burst_len; i++) {
6009 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6010 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6012 "data not as expected");
6014 rte_pktmbuf_free(burst[i]->sym->m_src);
6015 rte_crypto_op_free(burst[i]);
6018 return TEST_SUCCESS;
6022 generate_gmac_large_plaintext(uint8_t *data)
6026 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6027 memcpy(&data[i], &data[0], 32);
6031 create_gmac_operation(enum rte_crypto_auth_operation op,
6032 const struct gmac_test_data *tdata)
6034 struct crypto_testsuite_params *ts_params = &testsuite_params;
6035 struct crypto_unittest_params *ut_params = &unittest_params;
6036 struct rte_crypto_sym_op *sym_op;
6038 unsigned iv_pad_len;
6039 unsigned aad_pad_len;
6041 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
6042 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6045 * Runtime generate the large plain text instead of use hard code
6046 * plain text vector. It is done to avoid create huge source file
6047 * with the test vector.
6049 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6050 generate_gmac_large_plaintext(tdata->aad.data);
6052 /* Generate Crypto op data structure */
6053 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6054 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6055 TEST_ASSERT_NOT_NULL(ut_params->op,
6056 "Failed to allocate symmetric crypto operation struct");
6058 sym_op = ut_params->op->sym;
6059 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6061 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6062 "no room to append aad");
6064 sym_op->auth.aad.length = tdata->aad.len;
6065 sym_op->auth.aad.phys_addr =
6066 rte_pktmbuf_mtophys(ut_params->ibuf);
6067 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6069 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6070 ut_params->ibuf, tdata->gmac_tag.len);
6071 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6072 "no room to append digest");
6074 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6075 ut_params->ibuf, aad_pad_len);
6076 sym_op->auth.digest.length = tdata->gmac_tag.len;
6078 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6079 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6080 tdata->gmac_tag.len);
6081 TEST_HEXDUMP(stdout, "digest:",
6082 sym_op->auth.digest.data,
6083 sym_op->auth.digest.length);
6086 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6087 ut_params->ibuf, iv_pad_len);
6088 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6090 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6091 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6092 sym_op->cipher.iv.length = tdata->iv.len;
6094 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
6096 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6098 sym_op->cipher.data.length = 0;
6099 sym_op->cipher.data.offset = 0;
6101 sym_op->auth.data.offset = 0;
6102 sym_op->auth.data.length = 0;
6107 static int create_gmac_session(uint8_t dev_id,
6108 enum rte_crypto_cipher_operation op,
6109 const struct gmac_test_data *tdata,
6110 enum rte_crypto_auth_operation auth_op)
6112 uint8_t cipher_key[tdata->key.len];
6114 struct crypto_unittest_params *ut_params = &unittest_params;
6116 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6118 /* For GMAC we setup cipher parameters */
6119 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6120 ut_params->cipher_xform.next = NULL;
6121 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6122 ut_params->cipher_xform.cipher.op = op;
6123 ut_params->cipher_xform.cipher.key.data = cipher_key;
6124 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6126 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6127 ut_params->auth_xform.next = NULL;
6129 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6130 ut_params->auth_xform.auth.op = auth_op;
6131 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6132 ut_params->auth_xform.auth.add_auth_data_length = 0;
6133 ut_params->auth_xform.auth.key.length = 0;
6134 ut_params->auth_xform.auth.key.data = NULL;
6136 ut_params->cipher_xform.next = &ut_params->auth_xform;
6138 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6139 &ut_params->cipher_xform);
6141 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6147 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6149 struct crypto_testsuite_params *ts_params = &testsuite_params;
6150 struct crypto_unittest_params *ut_params = &unittest_params;
6154 uint8_t *auth_tag, *p;
6155 uint16_t aad_pad_len;
6157 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6158 "No GMAC length in the source data");
6160 retval = create_gmac_session(ts_params->valid_devs[0],
6161 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6162 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6167 if (tdata->aad.len > MBUF_SIZE)
6168 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6170 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6171 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6172 "Failed to allocate input buffer in mempool");
6174 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6175 rte_pktmbuf_tailroom(ut_params->ibuf));
6177 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6179 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6181 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6187 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6189 ut_params->op->sym->m_src = ut_params->ibuf;
6191 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6192 ut_params->op), "failed to process sym crypto op");
6194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6195 "crypto op processing failed");
6197 if (ut_params->op->sym->m_dst) {
6198 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6199 uint8_t *, aad_pad_len);
6201 auth_tag = p + aad_pad_len;
6204 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6206 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6208 tdata->gmac_tag.data,
6209 tdata->gmac_tag.len,
6210 "GMAC Generated auth tag not as expected");
6216 test_AES_GMAC_authentication_test_case_1(void)
6218 return test_AES_GMAC_authentication(&gmac_test_case_1);
6222 test_AES_GMAC_authentication_test_case_2(void)
6224 return test_AES_GMAC_authentication(&gmac_test_case_2);
6228 test_AES_GMAC_authentication_test_case_3(void)
6230 return test_AES_GMAC_authentication(&gmac_test_case_3);
6234 test_AES_GMAC_authentication_test_case_4(void)
6236 return test_AES_GMAC_authentication(&gmac_test_case_4);
6240 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6242 struct crypto_testsuite_params *ts_params = &testsuite_params;
6243 struct crypto_unittest_params *ut_params = &unittest_params;
6246 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6247 "No GMAC length in the source data");
6249 retval = create_gmac_session(ts_params->valid_devs[0],
6250 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6251 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6256 if (tdata->aad.len > MBUF_SIZE)
6257 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6259 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6260 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6261 "Failed to allocate input buffer in mempool");
6263 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6264 rte_pktmbuf_tailroom(ut_params->ibuf));
6266 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6272 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6274 ut_params->op->sym->m_src = ut_params->ibuf;
6276 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6277 ut_params->op), "failed to process sym crypto op");
6279 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6280 "crypto op processing failed");
6287 test_AES_GMAC_authentication_verify_test_case_1(void)
6289 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6293 test_AES_GMAC_authentication_verify_test_case_2(void)
6295 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6299 test_AES_GMAC_authentication_verify_test_case_3(void)
6301 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6305 test_AES_GMAC_authentication_verify_test_case_4(void)
6307 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6310 struct test_crypto_vector {
6311 enum rte_crypto_cipher_algorithm crypto_algo;
6324 const uint8_t *data;
6329 const uint8_t *data;
6333 enum rte_crypto_auth_algorithm auth_algo;
6341 const uint8_t *data;
6351 static const struct test_crypto_vector
6352 hmac_sha1_test_crypto_vector = {
6353 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6355 .data = plaintext_hash,
6360 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6361 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6362 0xDE, 0xF4, 0xDE, 0xAD
6368 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6369 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6370 0x3F, 0x91, 0x64, 0x59
6376 static const struct test_crypto_vector
6377 aes128_gmac_test_vector = {
6378 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6379 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6381 .data = plaintext_hash,
6386 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6387 0x08, 0x09, 0x0A, 0x0B
6393 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6394 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6400 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6401 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6407 static const struct test_crypto_vector
6408 aes128cbc_hmac_sha1_test_vector = {
6409 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6412 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6413 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6419 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6420 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6425 .data = plaintext_hash,
6429 .data = ciphertext512_aes128cbc,
6432 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6435 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6436 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6437 0xDE, 0xF4, 0xDE, 0xAD
6443 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6444 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6445 0x18, 0x8C, 0x1D, 0x32
6452 data_corruption(uint8_t *data)
6458 tag_corruption(uint8_t *data, unsigned int tag_offset)
6460 data[tag_offset] += 1;
6464 create_auth_session(struct crypto_unittest_params *ut_params,
6466 const struct test_crypto_vector *reference,
6467 enum rte_crypto_auth_operation auth_op)
6469 uint8_t auth_key[reference->auth_key.len + 1];
6471 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6473 /* Setup Authentication Parameters */
6474 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6475 ut_params->auth_xform.auth.op = auth_op;
6476 ut_params->auth_xform.next = NULL;
6477 ut_params->auth_xform.auth.algo = reference->auth_algo;
6478 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6479 ut_params->auth_xform.auth.key.data = auth_key;
6480 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6481 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6483 /* Create Crypto session*/
6484 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6485 &ut_params->auth_xform);
6487 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6493 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6495 const struct test_crypto_vector *reference,
6496 enum rte_crypto_auth_operation auth_op,
6497 enum rte_crypto_cipher_operation cipher_op)
6499 uint8_t cipher_key[reference->cipher_key.len + 1];
6500 uint8_t auth_key[reference->auth_key.len + 1];
6502 memcpy(cipher_key, reference->cipher_key.data,
6503 reference->cipher_key.len);
6504 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6506 /* Setup Authentication Parameters */
6507 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6508 ut_params->auth_xform.auth.op = auth_op;
6509 ut_params->auth_xform.next = &ut_params->cipher_xform;
6510 ut_params->auth_xform.auth.algo = reference->auth_algo;
6511 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6512 ut_params->auth_xform.auth.key.data = auth_key;
6513 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6514 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6516 /* Setup Cipher Parameters */
6517 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6518 ut_params->cipher_xform.next = NULL;
6519 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6520 ut_params->cipher_xform.cipher.op = cipher_op;
6521 ut_params->cipher_xform.cipher.key.data = cipher_key;
6522 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6524 /* Create Crypto session*/
6525 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6526 &ut_params->auth_xform);
6528 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6534 create_auth_operation(struct crypto_testsuite_params *ts_params,
6535 struct crypto_unittest_params *ut_params,
6536 const struct test_crypto_vector *reference,
6537 unsigned int auth_generate)
6539 /* Generate Crypto op data structure */
6540 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6541 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6542 TEST_ASSERT_NOT_NULL(ut_params->op,
6543 "Failed to allocate pktmbuf offload");
6545 /* Set crypto operation data parameters */
6546 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6548 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6550 /* set crypto operation source mbuf */
6551 sym_op->m_src = ut_params->ibuf;
6554 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6555 ut_params->ibuf, reference->digest.len);
6557 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6558 "no room to append auth tag");
6560 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6561 ut_params->ibuf, reference->plaintext.len);
6562 sym_op->auth.digest.length = reference->digest.len;
6565 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6567 memcpy(sym_op->auth.digest.data,
6568 reference->digest.data,
6569 reference->digest.len);
6571 TEST_HEXDUMP(stdout, "digest:",
6572 sym_op->auth.digest.data,
6573 sym_op->auth.digest.length);
6575 sym_op->auth.data.length = reference->plaintext.len;
6576 sym_op->auth.data.offset = 0;
6582 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6583 struct crypto_unittest_params *ut_params,
6584 const struct test_crypto_vector *reference,
6585 unsigned int auth_generate)
6587 /* Generate Crypto op data structure */
6588 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6589 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6590 TEST_ASSERT_NOT_NULL(ut_params->op,
6591 "Failed to allocate pktmbuf offload");
6593 /* Set crypto operation data parameters */
6594 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6596 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6598 /* set crypto operation source mbuf */
6599 sym_op->m_src = ut_params->ibuf;
6602 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6603 reference->aad.len);
6604 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6605 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6607 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6609 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6610 sym_op->auth.aad.length = reference->aad.len;
6613 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6614 ut_params->ibuf, reference->digest.len);
6616 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6617 "no room to append auth tag");
6619 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6620 ut_params->ibuf, reference->ciphertext.len);
6621 sym_op->auth.digest.length = reference->digest.len;
6624 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6626 memcpy(sym_op->auth.digest.data,
6627 reference->digest.data,
6628 reference->digest.len);
6630 TEST_HEXDUMP(stdout, "digest:",
6631 sym_op->auth.digest.data,
6632 sym_op->auth.digest.length);
6634 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6635 ut_params->ibuf, reference->iv.len);
6636 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6638 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6639 sym_op->cipher.iv.length = reference->iv.len;
6641 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6643 sym_op->cipher.data.length = 0;
6644 sym_op->cipher.data.offset = 0;
6646 sym_op->auth.data.length = 0;
6647 sym_op->auth.data.offset = 0;
6653 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6654 struct crypto_unittest_params *ut_params,
6655 const struct test_crypto_vector *reference,
6656 unsigned int auth_generate)
6658 /* Generate Crypto op data structure */
6659 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6660 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6661 TEST_ASSERT_NOT_NULL(ut_params->op,
6662 "Failed to allocate pktmbuf offload");
6664 /* Set crypto operation data parameters */
6665 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6667 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6669 /* set crypto operation source mbuf */
6670 sym_op->m_src = ut_params->ibuf;
6673 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6674 ut_params->ibuf, reference->digest.len);
6676 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6677 "no room to append auth tag");
6679 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6680 ut_params->ibuf, reference->ciphertext.len);
6681 sym_op->auth.digest.length = reference->digest.len;
6684 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6686 memcpy(sym_op->auth.digest.data,
6687 reference->digest.data,
6688 reference->digest.len);
6690 TEST_HEXDUMP(stdout, "digest:",
6691 sym_op->auth.digest.data,
6692 sym_op->auth.digest.length);
6694 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6695 ut_params->ibuf, reference->iv.len);
6696 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6698 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6699 sym_op->cipher.iv.length = reference->iv.len;
6701 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6703 sym_op->cipher.data.length = reference->ciphertext.len;
6704 sym_op->cipher.data.offset = reference->iv.len;
6706 sym_op->auth.data.length = reference->ciphertext.len;
6707 sym_op->auth.data.offset = reference->iv.len;
6713 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6714 struct crypto_unittest_params *ut_params,
6715 const struct test_crypto_vector *reference)
6717 return create_auth_operation(ts_params, ut_params, reference, 0);
6721 create_auth_verify_GMAC_operation(
6722 struct crypto_testsuite_params *ts_params,
6723 struct crypto_unittest_params *ut_params,
6724 const struct test_crypto_vector *reference)
6726 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6730 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6731 struct crypto_unittest_params *ut_params,
6732 const struct test_crypto_vector *reference)
6734 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6738 test_authentication_verify_fail_when_data_corruption(
6739 struct crypto_testsuite_params *ts_params,
6740 struct crypto_unittest_params *ut_params,
6741 const struct test_crypto_vector *reference,
6742 unsigned int data_corrupted)
6748 /* Create session */
6749 retval = create_auth_session(ut_params,
6750 ts_params->valid_devs[0],
6752 RTE_CRYPTO_AUTH_OP_VERIFY);
6756 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6757 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6758 "Failed to allocate input buffer in mempool");
6760 /* clear mbuf payload */
6761 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6762 rte_pktmbuf_tailroom(ut_params->ibuf));
6764 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6765 reference->plaintext.len);
6766 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6767 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6769 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6771 /* Create operation */
6772 retval = create_auth_verify_operation(ts_params, ut_params, reference);
6778 data_corruption(plaintext);
6780 tag_corruption(plaintext, reference->plaintext.len);
6782 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6784 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6785 TEST_ASSERT_EQUAL(ut_params->op->status,
6786 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6787 "authentication not failed");
6789 ut_params->obuf = ut_params->op->sym->m_src;
6790 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6796 test_authentication_verify_GMAC_fail_when_corruption(
6797 struct crypto_testsuite_params *ts_params,
6798 struct crypto_unittest_params *ut_params,
6799 const struct test_crypto_vector *reference,
6800 unsigned int data_corrupted)
6804 /* Create session */
6805 retval = create_auth_cipher_session(ut_params,
6806 ts_params->valid_devs[0],
6808 RTE_CRYPTO_AUTH_OP_VERIFY,
6809 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6813 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6814 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6815 "Failed to allocate input buffer in mempool");
6817 /* clear mbuf payload */
6818 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6819 rte_pktmbuf_tailroom(ut_params->ibuf));
6821 /* Create operation */
6822 retval = create_auth_verify_GMAC_operation(ts_params,
6830 data_corruption(ut_params->op->sym->auth.aad.data);
6832 tag_corruption(ut_params->op->sym->auth.aad.data,
6833 reference->aad.len);
6835 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6837 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6838 TEST_ASSERT_EQUAL(ut_params->op->status,
6839 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6840 "authentication not failed");
6842 ut_params->obuf = ut_params->op->sym->m_src;
6843 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6849 test_authenticated_decryption_fail_when_corruption(
6850 struct crypto_testsuite_params *ts_params,
6851 struct crypto_unittest_params *ut_params,
6852 const struct test_crypto_vector *reference,
6853 unsigned int data_corrupted)
6857 uint8_t *ciphertext;
6859 /* Create session */
6860 retval = create_auth_cipher_session(ut_params,
6861 ts_params->valid_devs[0],
6863 RTE_CRYPTO_AUTH_OP_VERIFY,
6864 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6868 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6869 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6870 "Failed to allocate input buffer in mempool");
6872 /* clear mbuf payload */
6873 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6874 rte_pktmbuf_tailroom(ut_params->ibuf));
6876 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6877 reference->ciphertext.len);
6878 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
6879 memcpy(ciphertext, reference->ciphertext.data,
6880 reference->ciphertext.len);
6882 /* Create operation */
6883 retval = create_cipher_auth_verify_operation(ts_params,
6891 data_corruption(ciphertext);
6893 tag_corruption(ciphertext, reference->ciphertext.len);
6895 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6898 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6899 TEST_ASSERT_EQUAL(ut_params->op->status,
6900 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6901 "authentication not failed");
6903 ut_params->obuf = ut_params->op->sym->m_src;
6904 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6910 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
6911 const struct gcm_test_data *tdata,
6912 void *digest_mem, uint64_t digest_phys)
6914 struct crypto_testsuite_params *ts_params = &testsuite_params;
6915 struct crypto_unittest_params *ut_params = &unittest_params;
6917 const unsigned int auth_tag_len = tdata->auth_tag.len;
6918 const unsigned int iv_len = tdata->iv.len;
6919 const unsigned int aad_len = tdata->aad.len;
6921 unsigned int iv_pad_len = 0;
6923 /* Generate Crypto op data structure */
6924 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6925 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6926 TEST_ASSERT_NOT_NULL(ut_params->op,
6927 "Failed to allocate symmetric crypto operation struct");
6929 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6931 sym_op->auth.digest.data = digest_mem;
6933 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6934 "no room to append digest");
6936 sym_op->auth.digest.phys_addr = digest_phys;
6937 sym_op->auth.digest.length = auth_tag_len;
6939 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
6940 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
6942 TEST_HEXDUMP(stdout, "digest:",
6943 sym_op->auth.digest.data,
6944 sym_op->auth.digest.length);
6947 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
6949 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6950 ut_params->ibuf, iv_pad_len);
6952 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
6953 "no room to prepend iv");
6955 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6956 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6957 sym_op->cipher.iv.length = iv_len;
6959 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
6961 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
6962 ut_params->ibuf, aad_len);
6963 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6964 "no room to prepend aad");
6965 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
6967 sym_op->auth.aad.length = aad_len;
6969 memset(sym_op->auth.aad.data, 0, aad_len);
6970 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
6972 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6973 TEST_HEXDUMP(stdout, "aad:",
6974 sym_op->auth.aad.data, aad_len);
6976 sym_op->cipher.data.length = tdata->plaintext.len;
6977 sym_op->cipher.data.offset = aad_len + iv_pad_len;
6979 sym_op->auth.data.offset = aad_len + iv_pad_len;
6980 sym_op->auth.data.length = tdata->plaintext.len;
6985 #define SGL_MAX_NO 16
6988 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
6989 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
6991 struct crypto_testsuite_params *ts_params = &testsuite_params;
6992 struct crypto_unittest_params *ut_params = &unittest_params;
6993 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
6996 int to_trn_tbl[SGL_MAX_NO];
6998 unsigned int trn_data = 0;
6999 uint8_t *plaintext, *ciphertext, *auth_tag;
7001 if (fragsz > tdata->plaintext.len)
7002 fragsz = tdata->plaintext.len;
7004 uint16_t plaintext_len = fragsz;
7005 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7007 if (fragsz_oop > tdata->plaintext.len)
7008 frag_size_oop = tdata->plaintext.len;
7011 void *digest_mem = NULL;
7013 uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
7016 if (tdata->plaintext.len % fragsz != 0) {
7017 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7020 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7025 * For out-op-place we need to alloc another mbuf
7028 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7029 rte_pktmbuf_append(ut_params->obuf,
7030 frag_size_oop + prepend_len);
7031 buf_oop = ut_params->obuf;
7034 /* Create GCM session */
7035 retval = create_gcm_session(ts_params->valid_devs[0],
7036 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7037 tdata->key.data, tdata->key.len,
7038 tdata->aad.len, tdata->auth_tag.len,
7039 RTE_CRYPTO_AUTH_OP_GENERATE);
7043 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7045 /* clear mbuf payload */
7046 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7047 rte_pktmbuf_tailroom(ut_params->ibuf));
7049 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7052 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7054 trn_data += plaintext_len;
7056 buf = ut_params->ibuf;
7059 * Loop until no more fragments
7062 while (trn_data < tdata->plaintext.len) {
7064 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7065 (tdata->plaintext.len - trn_data) : fragsz;
7067 to_trn_tbl[ecx++] = to_trn;
7069 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7072 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7073 rte_pktmbuf_tailroom(buf));
7076 if (oop && !fragsz_oop) {
7077 buf_last_oop = buf_oop->next =
7078 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7079 buf_oop = buf_oop->next;
7080 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7081 0, rte_pktmbuf_tailroom(buf_oop));
7082 rte_pktmbuf_append(buf_oop, to_trn);
7085 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7088 memcpy(plaintext, tdata->plaintext.data + trn_data,
7091 if (trn_data == tdata->plaintext.len) {
7094 digest_mem = rte_pktmbuf_append(buf_oop,
7095 tdata->auth_tag.len);
7097 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7098 tdata->auth_tag.len);
7102 uint64_t digest_phys = 0;
7104 ut_params->ibuf->nb_segs = segs;
7107 if (fragsz_oop && oop) {
7111 if (frag_size_oop == tdata->plaintext.len) {
7112 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7113 tdata->auth_tag.len);
7115 digest_phys = rte_pktmbuf_mtophys_offset(
7117 tdata->plaintext.len + prepend_len);
7120 trn_data = frag_size_oop;
7121 while (trn_data < tdata->plaintext.len) {
7124 (tdata->plaintext.len - trn_data <
7126 (tdata->plaintext.len - trn_data) :
7129 to_trn_tbl[ecx++] = to_trn;
7131 buf_last_oop = buf_oop->next =
7132 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7133 buf_oop = buf_oop->next;
7134 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7135 0, rte_pktmbuf_tailroom(buf_oop));
7136 rte_pktmbuf_append(buf_oop, to_trn);
7140 if (trn_data == tdata->plaintext.len) {
7141 digest_mem = rte_pktmbuf_append(buf_oop,
7142 tdata->auth_tag.len);
7146 ut_params->obuf->nb_segs = segs;
7150 * Place digest at the end of the last buffer
7153 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7154 if (oop && buf_last_oop)
7155 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7157 if (!digest_mem && !oop) {
7158 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7159 + tdata->auth_tag.len);
7160 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7161 tdata->plaintext.len);
7164 /* Create GCM opertaion */
7165 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7166 tdata, digest_mem, digest_phys);
7171 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7173 ut_params->op->sym->m_src = ut_params->ibuf;
7175 ut_params->op->sym->m_dst = ut_params->obuf;
7177 /* Process crypto operation */
7178 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7179 ut_params->op), "failed to process sym crypto op");
7181 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7182 "crypto op processing failed");
7185 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7186 uint8_t *, prepend_len);
7188 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7189 uint8_t *, prepend_len);
7193 fragsz = fragsz_oop;
7195 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7197 tdata->ciphertext.data,
7199 "GCM Ciphertext data not as expected");
7201 buf = ut_params->op->sym->m_src->next;
7203 buf = ut_params->op->sym->m_dst->next;
7205 unsigned int off = fragsz;
7209 ciphertext = rte_pktmbuf_mtod(buf,
7212 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7214 tdata->ciphertext.data + off,
7216 "GCM Ciphertext data not as expected");
7218 off += to_trn_tbl[ecx++];
7222 auth_tag = digest_mem;
7223 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7225 tdata->auth_tag.data,
7226 tdata->auth_tag.len,
7227 "GCM Generated auth tag not as expected");
7233 #define OUT_OF_PLACE 1
7236 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7238 return test_AES_GCM_authenticated_encryption_SGL(
7239 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7243 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7245 return test_AES_GCM_authenticated_encryption_SGL(
7246 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7250 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7252 return test_AES_GCM_authenticated_encryption_SGL(
7253 &gcm_test_case_8, OUT_OF_PLACE, 400,
7254 gcm_test_case_8.plaintext.len);
7258 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7261 return test_AES_GCM_authenticated_encryption_SGL(
7262 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7266 test_authentication_verify_fail_when_data_corrupted(
7267 struct crypto_testsuite_params *ts_params,
7268 struct crypto_unittest_params *ut_params,
7269 const struct test_crypto_vector *reference)
7271 return test_authentication_verify_fail_when_data_corruption(
7272 ts_params, ut_params, reference, 1);
7276 test_authentication_verify_fail_when_tag_corrupted(
7277 struct crypto_testsuite_params *ts_params,
7278 struct crypto_unittest_params *ut_params,
7279 const struct test_crypto_vector *reference)
7281 return test_authentication_verify_fail_when_data_corruption(
7282 ts_params, ut_params, reference, 0);
7286 test_authentication_verify_GMAC_fail_when_data_corrupted(
7287 struct crypto_testsuite_params *ts_params,
7288 struct crypto_unittest_params *ut_params,
7289 const struct test_crypto_vector *reference)
7291 return test_authentication_verify_GMAC_fail_when_corruption(
7292 ts_params, ut_params, reference, 1);
7296 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7297 struct crypto_testsuite_params *ts_params,
7298 struct crypto_unittest_params *ut_params,
7299 const struct test_crypto_vector *reference)
7301 return test_authentication_verify_GMAC_fail_when_corruption(
7302 ts_params, ut_params, reference, 0);
7306 test_authenticated_decryption_fail_when_data_corrupted(
7307 struct crypto_testsuite_params *ts_params,
7308 struct crypto_unittest_params *ut_params,
7309 const struct test_crypto_vector *reference)
7311 return test_authenticated_decryption_fail_when_corruption(
7312 ts_params, ut_params, reference, 1);
7316 test_authenticated_decryption_fail_when_tag_corrupted(
7317 struct crypto_testsuite_params *ts_params,
7318 struct crypto_unittest_params *ut_params,
7319 const struct test_crypto_vector *reference)
7321 return test_authenticated_decryption_fail_when_corruption(
7322 ts_params, ut_params, reference, 0);
7326 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7328 return test_authentication_verify_fail_when_data_corrupted(
7329 &testsuite_params, &unittest_params,
7330 &hmac_sha1_test_crypto_vector);
7334 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7336 return test_authentication_verify_fail_when_tag_corrupted(
7337 &testsuite_params, &unittest_params,
7338 &hmac_sha1_test_crypto_vector);
7342 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7344 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7345 &testsuite_params, &unittest_params,
7346 &aes128_gmac_test_vector);
7350 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7352 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7353 &testsuite_params, &unittest_params,
7354 &aes128_gmac_test_vector);
7358 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7360 return test_authenticated_decryption_fail_when_data_corrupted(
7363 &aes128cbc_hmac_sha1_test_vector);
7367 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7369 return test_authenticated_decryption_fail_when_tag_corrupted(
7372 &aes128cbc_hmac_sha1_test_vector);
7375 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7377 /* global AESNI slave IDs for the scheduler test */
7378 uint8_t aesni_ids[2];
7381 test_scheduler_attach_slave_op(void)
7383 struct crypto_testsuite_params *ts_params = &testsuite_params;
7384 uint8_t sched_id = ts_params->valid_devs[0];
7385 uint32_t nb_devs, qp_id, i, nb_devs_attached = 0;
7387 struct rte_cryptodev_config config = {
7388 .nb_queue_pairs = 8,
7389 .socket_id = SOCKET_ID_ANY,
7395 struct rte_cryptodev_qp_conf qp_conf = {2048};
7397 /* create 2 AESNI_MB if necessary */
7398 nb_devs = rte_cryptodev_count_devtype(
7399 RTE_CRYPTODEV_AESNI_MB_PMD);
7401 for (i = nb_devs; i < 2; i++) {
7402 ret = rte_eal_vdev_init(
7403 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
7405 TEST_ASSERT(ret == 0,
7406 "Failed to create instance %u of"
7408 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7412 /* attach 2 AESNI_MB cdevs */
7413 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7415 struct rte_cryptodev_info info;
7417 rte_cryptodev_info_get(i, &info);
7418 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7421 ret = rte_cryptodev_configure(i, &config);
7422 TEST_ASSERT(ret == 0,
7423 "Failed to configure device %u of pmd : %s", i,
7424 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7426 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
7427 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
7429 rte_cryptodev_socket_id(i)),
7430 "Failed to setup queue pair %u on "
7431 "cryptodev %u", qp_id, i);
7434 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7437 TEST_ASSERT(ret == 0,
7438 "Failed to attach device %u of pmd : %s", i,
7439 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7441 aesni_ids[nb_devs_attached] = (uint8_t)i;
7450 test_scheduler_detach_slave_op(void)
7452 struct crypto_testsuite_params *ts_params = &testsuite_params;
7453 uint8_t sched_id = ts_params->valid_devs[0];
7457 for (i = 0; i < 2; i++) {
7458 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7460 TEST_ASSERT(ret == 0,
7461 "Failed to detach device %u", aesni_ids[i]);
7468 test_scheduler_mode_op(void)
7470 struct crypto_testsuite_params *ts_params = &testsuite_params;
7471 uint8_t sched_id = ts_params->valid_devs[0];
7472 struct rte_cryptodev_scheduler_ops op = {0};
7473 struct rte_cryptodev_scheduler dummy_scheduler = {
7474 .description = "dummy scheduler to test mode",
7475 .name = "dummy scheduler",
7476 .mode = CDEV_SCHED_MODE_USERDEFINED,
7481 /* set user defined mode */
7482 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7484 TEST_ASSERT(ret == 0,
7485 "Failed to set cdev %u to user defined mode", sched_id);
7487 /* set round robin mode */
7488 ret = rte_crpytodev_scheduler_mode_set(sched_id,
7489 CDEV_SCHED_MODE_ROUNDROBIN);
7490 TEST_ASSERT(ret == 0,
7491 "Failed to set cdev %u to round-robin mode", sched_id);
7492 TEST_ASSERT(rte_crpytodev_scheduler_mode_get(sched_id) ==
7493 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7499 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7500 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7501 .setup = testsuite_setup,
7502 .teardown = testsuite_teardown,
7503 .unit_test_cases = {
7504 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7505 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7506 TEST_CASE_ST(ut_setup, ut_teardown,
7507 test_AES_chain_scheduler_all),
7508 TEST_CASE_ST(ut_setup, ut_teardown,
7509 test_AES_cipheronly_scheduler_all),
7510 TEST_CASE_ST(ut_setup, ut_teardown,
7511 test_authonly_scheduler_all),
7512 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7513 TEST_CASES_END() /**< NULL terminate unit test array */
7517 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7519 static struct unit_test_suite cryptodev_qat_testsuite = {
7520 .suite_name = "Crypto QAT Unit Test Suite",
7521 .setup = testsuite_setup,
7522 .teardown = testsuite_teardown,
7523 .unit_test_cases = {
7524 TEST_CASE_ST(ut_setup, ut_teardown,
7525 test_device_configure_invalid_dev_id),
7526 TEST_CASE_ST(ut_setup, ut_teardown,
7527 test_device_configure_invalid_queue_pair_ids),
7528 TEST_CASE_ST(ut_setup, ut_teardown,
7529 test_queue_pair_descriptor_setup),
7530 TEST_CASE_ST(ut_setup, ut_teardown,
7531 test_multi_session),
7533 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7534 TEST_CASE_ST(ut_setup, ut_teardown,
7535 test_AES_cipheronly_qat_all),
7536 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7537 TEST_CASE_ST(ut_setup, ut_teardown,
7538 test_3DES_cipheronly_qat_all),
7539 TEST_CASE_ST(ut_setup, ut_teardown,
7540 test_DES_cipheronly_qat_all),
7541 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7543 /** AES GCM Authenticated Encryption */
7544 TEST_CASE_ST(ut_setup, ut_teardown,
7545 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7546 TEST_CASE_ST(ut_setup, ut_teardown,
7547 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7548 TEST_CASE_ST(ut_setup, ut_teardown,
7549 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7550 TEST_CASE_ST(ut_setup, ut_teardown,
7551 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7552 TEST_CASE_ST(ut_setup, ut_teardown,
7553 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7554 TEST_CASE_ST(ut_setup, ut_teardown,
7555 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7556 TEST_CASE_ST(ut_setup, ut_teardown,
7557 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7558 TEST_CASE_ST(ut_setup, ut_teardown,
7559 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7560 TEST_CASE_ST(ut_setup, ut_teardown,
7561 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7562 TEST_CASE_ST(ut_setup, ut_teardown,
7563 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7565 /** AES GCM Authenticated Decryption */
7566 TEST_CASE_ST(ut_setup, ut_teardown,
7567 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7568 TEST_CASE_ST(ut_setup, ut_teardown,
7569 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7570 TEST_CASE_ST(ut_setup, ut_teardown,
7571 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7572 TEST_CASE_ST(ut_setup, ut_teardown,
7573 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7574 TEST_CASE_ST(ut_setup, ut_teardown,
7575 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7576 TEST_CASE_ST(ut_setup, ut_teardown,
7577 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7578 TEST_CASE_ST(ut_setup, ut_teardown,
7579 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7581 /** AES GMAC Authentication */
7582 TEST_CASE_ST(ut_setup, ut_teardown,
7583 test_AES_GMAC_authentication_test_case_1),
7584 TEST_CASE_ST(ut_setup, ut_teardown,
7585 test_AES_GMAC_authentication_verify_test_case_1),
7586 TEST_CASE_ST(ut_setup, ut_teardown,
7587 test_AES_GMAC_authentication_test_case_2),
7588 TEST_CASE_ST(ut_setup, ut_teardown,
7589 test_AES_GMAC_authentication_verify_test_case_2),
7590 TEST_CASE_ST(ut_setup, ut_teardown,
7591 test_AES_GMAC_authentication_test_case_3),
7592 TEST_CASE_ST(ut_setup, ut_teardown,
7593 test_AES_GMAC_authentication_verify_test_case_3),
7595 /** SNOW 3G encrypt only (UEA2) */
7596 TEST_CASE_ST(ut_setup, ut_teardown,
7597 test_snow3g_encryption_test_case_1),
7598 TEST_CASE_ST(ut_setup, ut_teardown,
7599 test_snow3g_encryption_test_case_2),
7600 TEST_CASE_ST(ut_setup, ut_teardown,
7601 test_snow3g_encryption_test_case_3),
7602 TEST_CASE_ST(ut_setup, ut_teardown,
7603 test_snow3g_encryption_test_case_4),
7604 TEST_CASE_ST(ut_setup, ut_teardown,
7605 test_snow3g_encryption_test_case_5),
7607 TEST_CASE_ST(ut_setup, ut_teardown,
7608 test_snow3g_encryption_test_case_1_oop),
7609 TEST_CASE_ST(ut_setup, ut_teardown,
7610 test_snow3g_decryption_test_case_1_oop),
7612 /** SNOW 3G decrypt only (UEA2) */
7613 TEST_CASE_ST(ut_setup, ut_teardown,
7614 test_snow3g_decryption_test_case_1),
7615 TEST_CASE_ST(ut_setup, ut_teardown,
7616 test_snow3g_decryption_test_case_2),
7617 TEST_CASE_ST(ut_setup, ut_teardown,
7618 test_snow3g_decryption_test_case_3),
7619 TEST_CASE_ST(ut_setup, ut_teardown,
7620 test_snow3g_decryption_test_case_4),
7621 TEST_CASE_ST(ut_setup, ut_teardown,
7622 test_snow3g_decryption_test_case_5),
7623 TEST_CASE_ST(ut_setup, ut_teardown,
7624 test_snow3g_hash_generate_test_case_1),
7625 TEST_CASE_ST(ut_setup, ut_teardown,
7626 test_snow3g_hash_generate_test_case_2),
7627 TEST_CASE_ST(ut_setup, ut_teardown,
7628 test_snow3g_hash_generate_test_case_3),
7629 TEST_CASE_ST(ut_setup, ut_teardown,
7630 test_snow3g_hash_verify_test_case_1),
7631 TEST_CASE_ST(ut_setup, ut_teardown,
7632 test_snow3g_hash_verify_test_case_2),
7633 TEST_CASE_ST(ut_setup, ut_teardown,
7634 test_snow3g_hash_verify_test_case_3),
7635 TEST_CASE_ST(ut_setup, ut_teardown,
7636 test_snow3g_cipher_auth_test_case_1),
7637 TEST_CASE_ST(ut_setup, ut_teardown,
7638 test_snow3g_auth_cipher_test_case_1),
7640 /** HMAC_MD5 Authentication */
7641 TEST_CASE_ST(ut_setup, ut_teardown,
7642 test_MD5_HMAC_generate_case_1),
7643 TEST_CASE_ST(ut_setup, ut_teardown,
7644 test_MD5_HMAC_verify_case_1),
7645 TEST_CASE_ST(ut_setup, ut_teardown,
7646 test_MD5_HMAC_generate_case_2),
7647 TEST_CASE_ST(ut_setup, ut_teardown,
7648 test_MD5_HMAC_verify_case_2),
7651 TEST_CASE_ST(ut_setup, ut_teardown,
7652 test_null_auth_only_operation),
7653 TEST_CASE_ST(ut_setup, ut_teardown,
7654 test_null_cipher_only_operation),
7655 TEST_CASE_ST(ut_setup, ut_teardown,
7656 test_null_cipher_auth_operation),
7657 TEST_CASE_ST(ut_setup, ut_teardown,
7658 test_null_auth_cipher_operation),
7660 TEST_CASE_ST(ut_setup, ut_teardown,
7661 test_kasumi_hash_generate_test_case_6),
7664 TEST_CASE_ST(ut_setup, ut_teardown,
7665 test_kasumi_encryption_test_case_1),
7666 TEST_CASE_ST(ut_setup, ut_teardown,
7667 test_kasumi_encryption_test_case_3),
7668 TEST_CASE_ST(ut_setup, ut_teardown,
7669 test_kasumi_auth_cipher_test_case_1),
7670 TEST_CASE_ST(ut_setup, ut_teardown,
7671 test_kasumi_cipher_auth_test_case_1),
7673 /** Negative tests */
7674 TEST_CASE_ST(ut_setup, ut_teardown,
7675 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7676 TEST_CASE_ST(ut_setup, ut_teardown,
7677 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7678 TEST_CASE_ST(ut_setup, ut_teardown,
7679 authentication_verify_AES128_GMAC_fail_data_corrupt),
7680 TEST_CASE_ST(ut_setup, ut_teardown,
7681 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7682 TEST_CASE_ST(ut_setup, ut_teardown,
7683 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7684 TEST_CASE_ST(ut_setup, ut_teardown,
7685 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7687 TEST_CASES_END() /**< NULL terminate unit test array */
7691 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7692 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7693 .setup = testsuite_setup,
7694 .teardown = testsuite_teardown,
7695 .unit_test_cases = {
7696 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7697 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7698 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7700 TEST_CASES_END() /**< NULL terminate unit test array */
7704 static struct unit_test_suite cryptodev_openssl_testsuite = {
7705 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7706 .setup = testsuite_setup,
7707 .teardown = testsuite_teardown,
7708 .unit_test_cases = {
7709 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7710 TEST_CASE_ST(ut_setup, ut_teardown,
7711 test_multi_session_random_usage),
7712 TEST_CASE_ST(ut_setup, ut_teardown,
7713 test_AES_chain_openssl_all),
7714 TEST_CASE_ST(ut_setup, ut_teardown,
7715 test_AES_cipheronly_openssl_all),
7716 TEST_CASE_ST(ut_setup, ut_teardown,
7717 test_3DES_chain_openssl_all),
7718 TEST_CASE_ST(ut_setup, ut_teardown,
7719 test_3DES_cipheronly_openssl_all),
7720 TEST_CASE_ST(ut_setup, ut_teardown,
7721 test_authonly_openssl_all),
7723 /** AES GCM Authenticated Encryption */
7724 TEST_CASE_ST(ut_setup, ut_teardown,
7725 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7726 TEST_CASE_ST(ut_setup, ut_teardown,
7727 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7728 TEST_CASE_ST(ut_setup, ut_teardown,
7729 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7730 TEST_CASE_ST(ut_setup, ut_teardown,
7731 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7732 TEST_CASE_ST(ut_setup, ut_teardown,
7733 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7734 TEST_CASE_ST(ut_setup, ut_teardown,
7735 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7736 TEST_CASE_ST(ut_setup, ut_teardown,
7737 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7739 /** AES GCM Authenticated Decryption */
7740 TEST_CASE_ST(ut_setup, ut_teardown,
7741 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7742 TEST_CASE_ST(ut_setup, ut_teardown,
7743 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7744 TEST_CASE_ST(ut_setup, ut_teardown,
7745 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7746 TEST_CASE_ST(ut_setup, ut_teardown,
7747 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7748 TEST_CASE_ST(ut_setup, ut_teardown,
7749 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7750 TEST_CASE_ST(ut_setup, ut_teardown,
7751 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7752 TEST_CASE_ST(ut_setup, ut_teardown,
7753 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7755 /** AES GMAC Authentication */
7756 TEST_CASE_ST(ut_setup, ut_teardown,
7757 test_AES_GMAC_authentication_test_case_1),
7758 TEST_CASE_ST(ut_setup, ut_teardown,
7759 test_AES_GMAC_authentication_verify_test_case_1),
7760 TEST_CASE_ST(ut_setup, ut_teardown,
7761 test_AES_GMAC_authentication_test_case_2),
7762 TEST_CASE_ST(ut_setup, ut_teardown,
7763 test_AES_GMAC_authentication_verify_test_case_2),
7764 TEST_CASE_ST(ut_setup, ut_teardown,
7765 test_AES_GMAC_authentication_test_case_3),
7766 TEST_CASE_ST(ut_setup, ut_teardown,
7767 test_AES_GMAC_authentication_verify_test_case_3),
7768 TEST_CASE_ST(ut_setup, ut_teardown,
7769 test_AES_GMAC_authentication_test_case_4),
7770 TEST_CASE_ST(ut_setup, ut_teardown,
7771 test_AES_GMAC_authentication_verify_test_case_4),
7773 /** Scatter-Gather */
7774 TEST_CASE_ST(ut_setup, ut_teardown,
7775 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7777 /** Negative tests */
7778 TEST_CASE_ST(ut_setup, ut_teardown,
7779 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7780 TEST_CASE_ST(ut_setup, ut_teardown,
7781 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 authentication_verify_AES128_GMAC_fail_data_corrupt),
7784 TEST_CASE_ST(ut_setup, ut_teardown,
7785 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7786 TEST_CASE_ST(ut_setup, ut_teardown,
7787 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7788 TEST_CASE_ST(ut_setup, ut_teardown,
7789 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7791 TEST_CASES_END() /**< NULL terminate unit test array */
7795 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
7796 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
7797 .setup = testsuite_setup,
7798 .teardown = testsuite_teardown,
7799 .unit_test_cases = {
7800 /** AES GCM Authenticated Encryption */
7801 TEST_CASE_ST(ut_setup, ut_teardown,
7802 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7803 TEST_CASE_ST(ut_setup, ut_teardown,
7804 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7805 TEST_CASE_ST(ut_setup, ut_teardown,
7806 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7807 TEST_CASE_ST(ut_setup, ut_teardown,
7808 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7809 TEST_CASE_ST(ut_setup, ut_teardown,
7810 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7811 TEST_CASE_ST(ut_setup, ut_teardown,
7812 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7813 TEST_CASE_ST(ut_setup, ut_teardown,
7814 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7816 /** AES GCM Authenticated Decryption */
7817 TEST_CASE_ST(ut_setup, ut_teardown,
7818 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7819 TEST_CASE_ST(ut_setup, ut_teardown,
7820 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7821 TEST_CASE_ST(ut_setup, ut_teardown,
7822 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7823 TEST_CASE_ST(ut_setup, ut_teardown,
7824 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7825 TEST_CASE_ST(ut_setup, ut_teardown,
7826 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7827 TEST_CASE_ST(ut_setup, ut_teardown,
7828 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7829 TEST_CASE_ST(ut_setup, ut_teardown,
7830 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7832 /** AES GCM Authenticated Encryption 256 bits key */
7833 TEST_CASE_ST(ut_setup, ut_teardown,
7834 test_mb_AES_GCM_auth_encryption_test_case_256_1),
7835 TEST_CASE_ST(ut_setup, ut_teardown,
7836 test_mb_AES_GCM_auth_encryption_test_case_256_2),
7837 TEST_CASE_ST(ut_setup, ut_teardown,
7838 test_mb_AES_GCM_auth_encryption_test_case_256_3),
7839 TEST_CASE_ST(ut_setup, ut_teardown,
7840 test_mb_AES_GCM_auth_encryption_test_case_256_4),
7841 TEST_CASE_ST(ut_setup, ut_teardown,
7842 test_mb_AES_GCM_auth_encryption_test_case_256_5),
7843 TEST_CASE_ST(ut_setup, ut_teardown,
7844 test_mb_AES_GCM_auth_encryption_test_case_256_6),
7845 TEST_CASE_ST(ut_setup, ut_teardown,
7846 test_mb_AES_GCM_auth_encryption_test_case_256_7),
7848 /** AES GCM Authenticated Decryption 256 bits key */
7849 TEST_CASE_ST(ut_setup, ut_teardown,
7850 test_mb_AES_GCM_auth_decryption_test_case_256_1),
7851 TEST_CASE_ST(ut_setup, ut_teardown,
7852 test_mb_AES_GCM_auth_decryption_test_case_256_2),
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_mb_AES_GCM_auth_decryption_test_case_256_3),
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_mb_AES_GCM_auth_decryption_test_case_256_4),
7857 TEST_CASE_ST(ut_setup, ut_teardown,
7858 test_mb_AES_GCM_auth_decryption_test_case_256_5),
7859 TEST_CASE_ST(ut_setup, ut_teardown,
7860 test_mb_AES_GCM_auth_decryption_test_case_256_6),
7861 TEST_CASE_ST(ut_setup, ut_teardown,
7862 test_mb_AES_GCM_auth_decryption_test_case_256_7),
7864 /** AES GCM Authenticated Encryption big aad size */
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
7870 /** AES GCM Authenticated Decryption big aad size */
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
7876 /** AES GMAC Authentication */
7877 TEST_CASE_ST(ut_setup, ut_teardown,
7878 test_AES_GMAC_authentication_test_case_1),
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 test_AES_GMAC_authentication_verify_test_case_1),
7881 TEST_CASE_ST(ut_setup, ut_teardown,
7882 test_AES_GMAC_authentication_test_case_3),
7883 TEST_CASE_ST(ut_setup, ut_teardown,
7884 test_AES_GMAC_authentication_verify_test_case_3),
7885 TEST_CASE_ST(ut_setup, ut_teardown,
7886 test_AES_GMAC_authentication_test_case_4),
7887 TEST_CASE_ST(ut_setup, ut_teardown,
7888 test_AES_GMAC_authentication_verify_test_case_4),
7890 /** Negative tests */
7891 TEST_CASE_ST(ut_setup, ut_teardown,
7892 authentication_verify_AES128_GMAC_fail_data_corrupt),
7893 TEST_CASE_ST(ut_setup, ut_teardown,
7894 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7896 /** Out of place tests */
7897 TEST_CASE_ST(ut_setup, ut_teardown,
7898 test_mb_AES_GCM_authenticated_encryption_oop),
7899 TEST_CASE_ST(ut_setup, ut_teardown,
7900 test_mb_AES_GCM_authenticated_decryption_oop),
7902 /** Session-less tests */
7903 TEST_CASE_ST(ut_setup, ut_teardown,
7904 test_mb_AES_GCM_authenticated_encryption_sessionless),
7905 TEST_CASE_ST(ut_setup, ut_teardown,
7906 test_mb_AES_GCM_authenticated_decryption_sessionless),
7908 /** Scatter-Gather */
7909 TEST_CASE_ST(ut_setup, ut_teardown,
7910 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7912 TEST_CASES_END() /**< NULL terminate unit test array */
7916 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
7917 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
7918 .setup = testsuite_setup,
7919 .teardown = testsuite_teardown,
7920 .unit_test_cases = {
7921 /** KASUMI encrypt only (UEA1) */
7922 TEST_CASE_ST(ut_setup, ut_teardown,
7923 test_kasumi_encryption_test_case_1),
7924 TEST_CASE_ST(ut_setup, ut_teardown,
7925 test_kasumi_encryption_test_case_1_sgl),
7926 TEST_CASE_ST(ut_setup, ut_teardown,
7927 test_kasumi_encryption_test_case_2),
7928 TEST_CASE_ST(ut_setup, ut_teardown,
7929 test_kasumi_encryption_test_case_3),
7930 TEST_CASE_ST(ut_setup, ut_teardown,
7931 test_kasumi_encryption_test_case_4),
7932 TEST_CASE_ST(ut_setup, ut_teardown,
7933 test_kasumi_encryption_test_case_5),
7934 /** KASUMI decrypt only (UEA1) */
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_kasumi_decryption_test_case_1),
7937 TEST_CASE_ST(ut_setup, ut_teardown,
7938 test_kasumi_decryption_test_case_2),
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_kasumi_decryption_test_case_3),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_kasumi_decryption_test_case_4),
7943 TEST_CASE_ST(ut_setup, ut_teardown,
7944 test_kasumi_decryption_test_case_5),
7946 TEST_CASE_ST(ut_setup, ut_teardown,
7947 test_kasumi_encryption_test_case_1_oop),
7948 TEST_CASE_ST(ut_setup, ut_teardown,
7949 test_kasumi_encryption_test_case_1_oop_sgl),
7952 TEST_CASE_ST(ut_setup, ut_teardown,
7953 test_kasumi_decryption_test_case_1_oop),
7955 /** KASUMI hash only (UIA1) */
7956 TEST_CASE_ST(ut_setup, ut_teardown,
7957 test_kasumi_hash_generate_test_case_1),
7958 TEST_CASE_ST(ut_setup, ut_teardown,
7959 test_kasumi_hash_generate_test_case_2),
7960 TEST_CASE_ST(ut_setup, ut_teardown,
7961 test_kasumi_hash_generate_test_case_3),
7962 TEST_CASE_ST(ut_setup, ut_teardown,
7963 test_kasumi_hash_generate_test_case_4),
7964 TEST_CASE_ST(ut_setup, ut_teardown,
7965 test_kasumi_hash_generate_test_case_5),
7966 TEST_CASE_ST(ut_setup, ut_teardown,
7967 test_kasumi_hash_generate_test_case_6),
7968 TEST_CASE_ST(ut_setup, ut_teardown,
7969 test_kasumi_hash_verify_test_case_1),
7970 TEST_CASE_ST(ut_setup, ut_teardown,
7971 test_kasumi_hash_verify_test_case_2),
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_kasumi_hash_verify_test_case_3),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_kasumi_hash_verify_test_case_4),
7976 TEST_CASE_ST(ut_setup, ut_teardown,
7977 test_kasumi_hash_verify_test_case_5),
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_kasumi_auth_cipher_test_case_1),
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 test_kasumi_cipher_auth_test_case_1),
7982 TEST_CASES_END() /**< NULL terminate unit test array */
7985 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
7986 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
7987 .setup = testsuite_setup,
7988 .teardown = testsuite_teardown,
7989 .unit_test_cases = {
7990 /** SNOW 3G encrypt only (UEA2) */
7991 TEST_CASE_ST(ut_setup, ut_teardown,
7992 test_snow3g_encryption_test_case_1),
7993 TEST_CASE_ST(ut_setup, ut_teardown,
7994 test_snow3g_encryption_test_case_2),
7995 TEST_CASE_ST(ut_setup, ut_teardown,
7996 test_snow3g_encryption_test_case_3),
7997 TEST_CASE_ST(ut_setup, ut_teardown,
7998 test_snow3g_encryption_test_case_4),
7999 TEST_CASE_ST(ut_setup, ut_teardown,
8000 test_snow3g_encryption_test_case_5),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_snow3g_encryption_test_case_1_oop),
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_snow3g_encryption_test_case_1_oop_sgl),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_snow3g_decryption_test_case_1_oop),
8009 TEST_CASE_ST(ut_setup, ut_teardown,
8010 test_snow3g_encryption_test_case_1_offset_oop),
8012 /** SNOW 3G decrypt only (UEA2) */
8013 TEST_CASE_ST(ut_setup, ut_teardown,
8014 test_snow3g_decryption_test_case_1),
8015 TEST_CASE_ST(ut_setup, ut_teardown,
8016 test_snow3g_decryption_test_case_2),
8017 TEST_CASE_ST(ut_setup, ut_teardown,
8018 test_snow3g_decryption_test_case_3),
8019 TEST_CASE_ST(ut_setup, ut_teardown,
8020 test_snow3g_decryption_test_case_4),
8021 TEST_CASE_ST(ut_setup, ut_teardown,
8022 test_snow3g_decryption_test_case_5),
8023 TEST_CASE_ST(ut_setup, ut_teardown,
8024 test_snow3g_hash_generate_test_case_1),
8025 TEST_CASE_ST(ut_setup, ut_teardown,
8026 test_snow3g_hash_generate_test_case_2),
8027 TEST_CASE_ST(ut_setup, ut_teardown,
8028 test_snow3g_hash_generate_test_case_3),
8029 /* Tests with buffers which length is not byte-aligned */
8030 TEST_CASE_ST(ut_setup, ut_teardown,
8031 test_snow3g_hash_generate_test_case_4),
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_snow3g_hash_generate_test_case_5),
8034 TEST_CASE_ST(ut_setup, ut_teardown,
8035 test_snow3g_hash_generate_test_case_6),
8036 TEST_CASE_ST(ut_setup, ut_teardown,
8037 test_snow3g_hash_verify_test_case_1),
8038 TEST_CASE_ST(ut_setup, ut_teardown,
8039 test_snow3g_hash_verify_test_case_2),
8040 TEST_CASE_ST(ut_setup, ut_teardown,
8041 test_snow3g_hash_verify_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_verify_test_case_4),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_snow3g_hash_verify_test_case_5),
8047 TEST_CASE_ST(ut_setup, ut_teardown,
8048 test_snow3g_hash_verify_test_case_6),
8049 TEST_CASE_ST(ut_setup, ut_teardown,
8050 test_snow3g_cipher_auth_test_case_1),
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 test_snow3g_auth_cipher_test_case_1),
8054 TEST_CASES_END() /**< NULL terminate unit test array */
8058 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8059 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8060 .setup = testsuite_setup,
8061 .teardown = testsuite_teardown,
8062 .unit_test_cases = {
8063 /** ZUC encrypt only (EEA3) */
8064 TEST_CASE_ST(ut_setup, ut_teardown,
8065 test_zuc_encryption_test_case_1),
8066 TEST_CASE_ST(ut_setup, ut_teardown,
8067 test_zuc_encryption_test_case_2),
8068 TEST_CASE_ST(ut_setup, ut_teardown,
8069 test_zuc_encryption_test_case_3),
8070 TEST_CASE_ST(ut_setup, ut_teardown,
8071 test_zuc_encryption_test_case_4),
8072 TEST_CASE_ST(ut_setup, ut_teardown,
8073 test_zuc_encryption_test_case_5),
8074 TEST_CASE_ST(ut_setup, ut_teardown,
8075 test_zuc_hash_generate_test_case_1),
8076 TEST_CASE_ST(ut_setup, ut_teardown,
8077 test_zuc_hash_generate_test_case_2),
8078 TEST_CASE_ST(ut_setup, ut_teardown,
8079 test_zuc_hash_generate_test_case_3),
8080 TEST_CASE_ST(ut_setup, ut_teardown,
8081 test_zuc_hash_generate_test_case_4),
8082 TEST_CASE_ST(ut_setup, ut_teardown,
8083 test_zuc_hash_generate_test_case_5),
8084 TEST_CASE_ST(ut_setup, ut_teardown,
8085 test_zuc_encryption_test_case_6_sgl),
8086 TEST_CASES_END() /**< NULL terminate unit test array */
8090 static struct unit_test_suite cryptodev_null_testsuite = {
8091 .suite_name = "Crypto Device NULL Unit Test Suite",
8092 .setup = testsuite_setup,
8093 .teardown = testsuite_teardown,
8094 .unit_test_cases = {
8095 TEST_CASE_ST(ut_setup, ut_teardown,
8096 test_null_auth_only_operation),
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 test_null_cipher_only_operation),
8099 TEST_CASE_ST(ut_setup, ut_teardown,
8100 test_null_cipher_auth_operation),
8101 TEST_CASE_ST(ut_setup, ut_teardown,
8102 test_null_auth_cipher_operation),
8103 TEST_CASE_ST(ut_setup, ut_teardown,
8104 test_null_invalid_operation),
8105 TEST_CASE_ST(ut_setup, ut_teardown,
8106 test_null_burst_operation),
8108 TEST_CASES_END() /**< NULL terminate unit test array */
8112 static struct unit_test_suite cryptodev_armv8_testsuite = {
8113 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8114 .setup = testsuite_setup,
8115 .teardown = testsuite_teardown,
8116 .unit_test_cases = {
8117 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8119 /** Negative tests */
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8125 TEST_CASES_END() /**< NULL terminate unit test array */
8130 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8132 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8133 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8137 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8139 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8141 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8145 test_cryptodev_openssl(void)
8147 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8149 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8153 test_cryptodev_aesni_gcm(void)
8155 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8157 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8161 test_cryptodev_null(void)
8163 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8165 return unit_test_suite_runner(&cryptodev_null_testsuite);
8169 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8171 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8173 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8177 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8179 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8181 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8185 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8187 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8189 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8193 test_cryptodev_armv8(void)
8195 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8197 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8200 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8203 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8205 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8206 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8209 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8213 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8214 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8215 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8216 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8217 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8218 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8219 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8220 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8221 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);