4 * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
39 #include <rte_crypto.h>
40 #include <rte_cryptodev.h>
41 #include <rte_cryptodev_pmd.h>
44 #include "test_cryptodev.h"
46 #include "test_cryptodev_blockcipher.h"
47 #include "test_cryptodev_aes_test_vectors.h"
48 #include "test_cryptodev_des_test_vectors.h"
49 #include "test_cryptodev_hash_test_vectors.h"
50 #include "test_cryptodev_kasumi_test_vectors.h"
51 #include "test_cryptodev_kasumi_hash_test_vectors.h"
52 #include "test_cryptodev_snow3g_test_vectors.h"
53 #include "test_cryptodev_snow3g_hash_test_vectors.h"
54 #include "test_cryptodev_zuc_test_vectors.h"
55 #include "test_cryptodev_zuc_hash_test_vectors.h"
56 #include "test_cryptodev_gcm_test_vectors.h"
57 #include "test_cryptodev_hmac_test_vectors.h"
59 static enum rte_cryptodev_type gbl_cryptodev_type;
61 struct crypto_testsuite_params {
62 struct rte_mempool *mbuf_pool;
63 struct rte_mempool *op_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
75 struct rte_cryptodev_sym_session *sess;
77 struct rte_crypto_op *op;
79 struct rte_mbuf *obuf, *ibuf;
84 #define ALIGN_POW2_ROUNDUP(num, align) \
85 (((num) + (align) - 1) & ~((align) - 1))
88 * Forward declarations.
91 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
92 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
96 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
97 struct crypto_unittest_params *ut_params,
98 struct crypto_testsuite_params *ts_param,
99 const uint8_t *cipher,
100 const uint8_t *digest,
103 static struct rte_mbuf *
104 setup_test_string(struct rte_mempool *mpool,
105 const char *string, size_t len, uint8_t blocksize)
107 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
108 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
110 memset(m->buf_addr, 0, m->buf_len);
112 char *dst = rte_pktmbuf_append(m, t_len);
119 rte_memcpy(dst, string, t_len);
121 memset(dst, 0, t_len);
127 /* Get number of bytes in X bits (rounding up) */
129 ceil_byte_length(uint32_t num_bits)
132 return ((num_bits >> 3) + 1);
134 return (num_bits >> 3);
137 static struct rte_crypto_op *
138 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
140 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
141 printf("Error sending packet for encryption");
147 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
153 static struct crypto_testsuite_params testsuite_params = { NULL };
154 static struct crypto_unittest_params unittest_params;
157 testsuite_setup(void)
159 struct crypto_testsuite_params *ts_params = &testsuite_params;
160 struct rte_cryptodev_info info;
161 unsigned i, nb_devs, dev_id;
165 memset(ts_params, 0, sizeof(*ts_params));
167 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
168 if (ts_params->mbuf_pool == NULL) {
169 /* Not already created so create */
170 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
172 NUM_MBUFS, MBUF_CACHE_SIZE, 0, UINT16_MAX,
174 if (ts_params->mbuf_pool == NULL) {
175 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
180 ts_params->op_mpool = rte_crypto_op_pool_create(
181 "MBUF_CRYPTO_SYM_OP_POOL",
182 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
183 NUM_MBUFS, MBUF_CACHE_SIZE,
185 sizeof(struct rte_crypto_sym_xform),
187 if (ts_params->op_mpool == NULL) {
188 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
192 /* Create 2 AESNI MB devices if required */
193 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
194 #ifndef RTE_LIBRTE_PMD_AESNI_MB
195 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
196 " enabled in config file to run this testsuite.\n");
199 nb_devs = rte_cryptodev_count_devtype(
200 RTE_CRYPTODEV_AESNI_MB_PMD);
202 for (i = nb_devs; i < 2; i++) {
203 ret = rte_eal_vdev_init(
204 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
206 TEST_ASSERT(ret == 0,
207 "Failed to create instance %u of"
209 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
214 /* Create 2 AESNI GCM devices if required */
215 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
216 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
217 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
218 " enabled in config file to run this testsuite.\n");
221 nb_devs = rte_cryptodev_count_devtype(
222 RTE_CRYPTODEV_AESNI_GCM_PMD);
224 for (i = nb_devs; i < 2; i++) {
225 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
226 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
227 "Failed to create instance %u of"
229 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
234 /* Create 2 SNOW 3G devices if required */
235 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
236 #ifndef RTE_LIBRTE_PMD_SNOW3G
237 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
238 " enabled in config file to run this testsuite.\n");
241 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
243 for (i = nb_devs; i < 2; i++) {
244 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
245 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
246 "Failed to create instance %u of"
248 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
253 /* Create 2 KASUMI devices if required */
254 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
255 #ifndef RTE_LIBRTE_PMD_KASUMI
256 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
257 " enabled in config file to run this testsuite.\n");
260 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
262 for (i = nb_devs; i < 2; i++) {
263 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
264 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
265 "Failed to create instance %u of"
267 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
272 /* Create 2 ZUC devices if required */
273 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
274 #ifndef RTE_LIBRTE_PMD_ZUC
275 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
276 " enabled in config file to run this testsuite.\n");
279 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
281 for (i = nb_devs; i < 2; i++) {
282 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
283 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
284 "Failed to create instance %u of"
286 i, RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
291 /* Create 2 NULL devices if required */
292 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
293 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
294 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
295 " enabled in config file to run this testsuite.\n");
298 nb_devs = rte_cryptodev_count_devtype(
299 RTE_CRYPTODEV_NULL_PMD);
301 for (i = nb_devs; i < 2; i++) {
302 int dev_id = rte_eal_vdev_init(
303 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
305 TEST_ASSERT(dev_id >= 0,
306 "Failed to create instance %u of"
308 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
313 /* Create 2 LIBCRYPTO devices if required */
314 if (gbl_cryptodev_type == RTE_CRYPTODEV_LIBCRYPTO_PMD) {
315 #ifndef RTE_LIBRTE_PMD_LIBCRYPTO
316 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_LIBCRYPTO must be"
317 " enabled in config file to run this testsuite.\n");
320 nb_devs = rte_cryptodev_count_devtype(
321 RTE_CRYPTODEV_LIBCRYPTO_PMD);
323 for (i = nb_devs; i < 2; i++) {
324 ret = rte_eal_vdev_init(
325 RTE_STR(CRYPTODEV_NAME_LIBCRYPTO_PMD),
328 TEST_ASSERT(ret == 0, "Failed to create "
329 "instance %u of pmd : %s", i,
330 RTE_STR(CRYPTODEV_NAME_LIBCRYPTO_PMD));
335 #ifndef RTE_LIBRTE_PMD_QAT
336 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
337 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
338 "in config file to run this testsuite.\n");
343 nb_devs = rte_cryptodev_count();
345 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
349 /* Create list of valid crypto devs */
350 for (i = 0; i < nb_devs; i++) {
351 rte_cryptodev_info_get(i, &info);
352 if (info.dev_type == gbl_cryptodev_type)
353 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
356 if (ts_params->valid_dev_count < 1)
359 /* Set up all the qps on the first of the valid devices found */
360 for (i = 0; i < 1; i++) {
361 dev_id = ts_params->valid_devs[i];
363 rte_cryptodev_info_get(dev_id, &info);
366 * Since we can't free and re-allocate queue memory always set
367 * the queues on this device up to max size first so enough
368 * memory is allocated for any later re-configures needed by
372 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
373 ts_params->conf.socket_id = SOCKET_ID_ANY;
374 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
376 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
378 "Failed to configure cryptodev %u with %u qps",
379 dev_id, ts_params->conf.nb_queue_pairs);
381 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
383 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
384 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
385 dev_id, qp_id, &ts_params->qp_conf,
386 rte_cryptodev_socket_id(dev_id)),
387 "Failed to setup queue pair %u on "
397 testsuite_teardown(void)
399 struct crypto_testsuite_params *ts_params = &testsuite_params;
401 if (ts_params->mbuf_pool != NULL) {
402 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
403 rte_mempool_avail_count(ts_params->mbuf_pool));
406 if (ts_params->op_mpool != NULL) {
407 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
408 rte_mempool_avail_count(ts_params->op_mpool));
416 struct crypto_testsuite_params *ts_params = &testsuite_params;
417 struct crypto_unittest_params *ut_params = &unittest_params;
421 /* Clear unit test parameters before running test */
422 memset(ut_params, 0, sizeof(*ut_params));
424 /* Reconfigure device to default parameters */
425 ts_params->conf.nb_queue_pairs = DEFAULT_NUM_QPS_PER_QAT_DEVICE;
426 ts_params->conf.socket_id = SOCKET_ID_ANY;
427 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
429 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
431 "Failed to configure cryptodev %u",
432 ts_params->valid_devs[0]);
435 * Now reconfigure queues to size we actually want to use in this
438 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
440 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
441 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
442 ts_params->valid_devs[0], qp_id,
444 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
445 "Failed to setup queue pair %u on cryptodev %u",
446 qp_id, ts_params->valid_devs[0]);
450 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
452 /* Start the device */
453 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
454 "Failed to start cryptodev %u",
455 ts_params->valid_devs[0]);
463 struct crypto_testsuite_params *ts_params = &testsuite_params;
464 struct crypto_unittest_params *ut_params = &unittest_params;
465 struct rte_cryptodev_stats stats;
467 /* free crypto session structure */
468 if (ut_params->sess) {
469 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
471 ut_params->sess = NULL;
474 /* free crypto operation structure */
476 rte_crypto_op_free(ut_params->op);
479 * free mbuf - both obuf and ibuf are usually the same,
480 * so check if they point at the same address is necessary,
481 * to avoid freeing the mbuf twice.
483 if (ut_params->obuf) {
484 rte_pktmbuf_free(ut_params->obuf);
485 if (ut_params->ibuf == ut_params->obuf)
489 if (ut_params->ibuf) {
490 rte_pktmbuf_free(ut_params->ibuf);
494 if (ts_params->mbuf_pool != NULL)
495 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
496 rte_mempool_avail_count(ts_params->mbuf_pool));
498 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
500 /* Stop the device */
501 rte_cryptodev_stop(ts_params->valid_devs[0]);
505 test_device_configure_invalid_dev_id(void)
507 struct crypto_testsuite_params *ts_params = &testsuite_params;
508 uint16_t dev_id, num_devs = 0;
510 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
511 "Need at least %d devices for test", 1);
513 /* valid dev_id values */
514 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
516 /* Stop the device in case it's started so it can be configured */
517 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
519 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
520 "Failed test for rte_cryptodev_configure: "
521 "invalid dev_num %u", dev_id);
523 /* invalid dev_id values */
526 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
527 "Failed test for rte_cryptodev_configure: "
528 "invalid dev_num %u", dev_id);
532 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
533 "Failed test for rte_cryptodev_configure:"
534 "invalid dev_num %u", dev_id);
540 test_device_configure_invalid_queue_pair_ids(void)
542 struct crypto_testsuite_params *ts_params = &testsuite_params;
544 /* Stop the device in case it's started so it can be configured */
545 rte_cryptodev_stop(ts_params->valid_devs[0]);
547 /* valid - one queue pairs */
548 ts_params->conf.nb_queue_pairs = 1;
550 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
552 "Failed to configure cryptodev: dev_id %u, qp_id %u",
553 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
556 /* valid - max value queue pairs */
557 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
559 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
561 "Failed to configure cryptodev: dev_id %u, qp_id %u",
562 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
565 /* invalid - zero queue pairs */
566 ts_params->conf.nb_queue_pairs = 0;
568 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
570 "Failed test for rte_cryptodev_configure, dev_id %u,"
572 ts_params->valid_devs[0],
573 ts_params->conf.nb_queue_pairs);
576 /* invalid - max value supported by field queue pairs */
577 ts_params->conf.nb_queue_pairs = UINT16_MAX;
579 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
581 "Failed test for rte_cryptodev_configure, dev_id %u,"
583 ts_params->valid_devs[0],
584 ts_params->conf.nb_queue_pairs);
587 /* invalid - max value + 1 queue pairs */
588 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
590 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
592 "Failed test for rte_cryptodev_configure, dev_id %u,"
594 ts_params->valid_devs[0],
595 ts_params->conf.nb_queue_pairs);
601 test_queue_pair_descriptor_setup(void)
603 struct crypto_testsuite_params *ts_params = &testsuite_params;
604 struct rte_cryptodev_info dev_info;
605 struct rte_cryptodev_qp_conf qp_conf = {
606 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
611 /* Stop the device in case it's started so it can be configured */
612 rte_cryptodev_stop(ts_params->valid_devs[0]);
615 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
617 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
619 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
620 &ts_params->conf), "Failed to configure cryptodev %u",
621 ts_params->valid_devs[0]);
625 * Test various ring sizes on this device. memzones can't be
626 * freed so are re-used if ring is released and re-created.
628 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
630 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
631 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
632 ts_params->valid_devs[0], qp_id, &qp_conf,
633 rte_cryptodev_socket_id(
634 ts_params->valid_devs[0])),
636 "rte_cryptodev_queue_pair_setup: num_inflights "
637 "%u on qp %u on cryptodev %u",
638 qp_conf.nb_descriptors, qp_id,
639 ts_params->valid_devs[0]);
642 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
644 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
645 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
646 ts_params->valid_devs[0], qp_id, &qp_conf,
647 rte_cryptodev_socket_id(
648 ts_params->valid_devs[0])),
650 " rte_cryptodev_queue_pair_setup: num_inflights"
651 " %u on qp %u on cryptodev %u",
652 qp_conf.nb_descriptors, qp_id,
653 ts_params->valid_devs[0]);
656 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
658 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
659 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
660 ts_params->valid_devs[0], qp_id, &qp_conf,
661 rte_cryptodev_socket_id(
662 ts_params->valid_devs[0])),
664 "rte_cryptodev_queue_pair_setup: num_inflights"
665 " %u on qp %u on cryptodev %u",
666 qp_conf.nb_descriptors, qp_id,
667 ts_params->valid_devs[0]);
670 /* invalid number of descriptors - max supported + 2 */
671 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
673 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
674 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
675 ts_params->valid_devs[0], qp_id, &qp_conf,
676 rte_cryptodev_socket_id(
677 ts_params->valid_devs[0])),
678 "Unexpectedly passed test for "
679 "rte_cryptodev_queue_pair_setup:"
680 "num_inflights %u on qp %u on cryptodev %u",
681 qp_conf.nb_descriptors, qp_id,
682 ts_params->valid_devs[0]);
685 /* invalid number of descriptors - max value of parameter */
686 qp_conf.nb_descriptors = UINT32_MAX-1;
688 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
689 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
690 ts_params->valid_devs[0], qp_id, &qp_conf,
691 rte_cryptodev_socket_id(
692 ts_params->valid_devs[0])),
693 "Unexpectedly passed test for "
694 "rte_cryptodev_queue_pair_setup:"
695 "num_inflights %u on qp %u on cryptodev %u",
696 qp_conf.nb_descriptors, qp_id,
697 ts_params->valid_devs[0]);
700 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
702 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
703 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
704 ts_params->valid_devs[0], qp_id, &qp_conf,
705 rte_cryptodev_socket_id(
706 ts_params->valid_devs[0])),
708 " rte_cryptodev_queue_pair_setup:"
709 "num_inflights %u on qp %u on cryptodev %u",
710 qp_conf.nb_descriptors, qp_id,
711 ts_params->valid_devs[0]);
714 /* invalid number of descriptors - max supported + 1 */
715 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
717 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
718 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
719 ts_params->valid_devs[0], qp_id, &qp_conf,
720 rte_cryptodev_socket_id(
721 ts_params->valid_devs[0])),
722 "Unexpectedly passed test for "
723 "rte_cryptodev_queue_pair_setup:"
724 "num_inflights %u on qp %u on cryptodev %u",
725 qp_conf.nb_descriptors, qp_id,
726 ts_params->valid_devs[0]);
729 /* test invalid queue pair id */
730 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
732 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
734 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
735 ts_params->valid_devs[0],
737 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
738 "Failed test for rte_cryptodev_queue_pair_setup:"
739 "invalid qp %u on cryptodev %u",
740 qp_id, ts_params->valid_devs[0]);
742 qp_id = 0xffff; /*invalid*/
744 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
745 ts_params->valid_devs[0],
747 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
748 "Failed test for rte_cryptodev_queue_pair_setup:"
749 "invalid qp %u on cryptodev %u",
750 qp_id, ts_params->valid_devs[0]);
755 /* ***** Plaintext data for tests ***** */
757 const char catch_22_quote_1[] =
758 "There was only one catch and that was Catch-22, which "
759 "specified that a concern for one's safety in the face of "
760 "dangers that were real and immediate was the process of a "
761 "rational mind. Orr was crazy and could be grounded. All he "
762 "had to do was ask; and as soon as he did, he would no longer "
763 "be crazy and would have to fly more missions. Orr would be "
764 "crazy to fly more missions and sane if he didn't, but if he "
765 "was sane he had to fly them. If he flew them he was crazy "
766 "and didn't have to; but if he didn't want to he was sane and "
767 "had to. Yossarian was moved very deeply by the absolute "
768 "simplicity of this clause of Catch-22 and let out a "
769 "respectful whistle. \"That's some catch, that Catch-22\", he "
770 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
772 const char catch_22_quote[] =
773 "What a lousy earth! He wondered how many people were "
774 "destitute that same night even in his own prosperous country, "
775 "how many homes were shanties, how many husbands were drunk "
776 "and wives socked, and how many children were bullied, abused, "
777 "or abandoned. How many families hungered for food they could "
778 "not afford to buy? How many hearts were broken? How many "
779 "suicides would take place that same night, how many people "
780 "would go insane? How many cockroaches and landlords would "
781 "triumph? How many winners were losers, successes failures, "
782 "and rich men poor men? How many wise guys were stupid? How "
783 "many happy endings were unhappy endings? How many honest men "
784 "were liars, brave men cowards, loyal men traitors, how many "
785 "sainted men were corrupt, how many people in positions of "
786 "trust had sold their souls to bodyguards, how many had never "
787 "had souls? How many straight-and-narrow paths were crooked "
788 "paths? How many best families were worst families and how "
789 "many good people were bad people? When you added them all up "
790 "and then subtracted, you might be left with only the children, "
791 "and perhaps with Albert Einstein and an old violinist or "
792 "sculptor somewhere.";
794 #define QUOTE_480_BYTES (480)
795 #define QUOTE_512_BYTES (512)
796 #define QUOTE_768_BYTES (768)
797 #define QUOTE_1024_BYTES (1024)
801 /* ***** SHA1 Hash Tests ***** */
803 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
805 static uint8_t hmac_sha1_key[] = {
806 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
807 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
808 0xDE, 0xF4, 0xDE, 0xAD };
810 /* ***** SHA224 Hash Tests ***** */
812 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
815 /* ***** AES-CBC Cipher Tests ***** */
817 #define CIPHER_KEY_LENGTH_AES_CBC (16)
818 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
820 static uint8_t aes_cbc_key[] = {
821 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
822 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
824 static uint8_t aes_cbc_iv[] = {
825 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
826 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
829 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
831 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
832 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
833 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
834 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
835 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
836 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
837 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
838 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
839 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
840 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
841 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
842 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
843 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
844 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
845 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
846 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
847 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
848 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
849 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
850 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
851 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
852 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
853 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
854 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
855 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
856 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
857 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
858 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
859 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
860 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
861 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
862 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
863 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
864 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
865 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
866 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
867 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
868 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
869 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
870 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
871 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
872 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
873 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
874 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
875 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
876 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
877 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
878 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
879 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
880 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
881 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
882 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
883 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
884 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
885 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
886 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
887 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
888 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
889 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
890 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
891 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
892 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
893 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
894 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
895 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
898 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
899 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
900 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
901 0x18, 0x8c, 0x1d, 0x32
905 /* Multisession Vector context Test */
907 static uint8_t ms_aes_cbc_key0[] = {
908 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
909 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
912 static uint8_t ms_aes_cbc_iv0[] = {
913 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
914 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
917 static const uint8_t ms_aes_cbc_cipher0[] = {
918 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
919 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
920 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
921 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
922 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
923 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
924 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
925 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
926 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
927 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
928 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
929 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
930 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
931 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
932 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
933 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
934 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
935 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
936 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
937 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
938 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
939 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
940 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
941 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
942 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
943 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
944 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
945 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
946 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
947 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
948 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
949 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
950 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
951 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
952 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
953 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
954 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
955 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
956 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
957 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
958 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
959 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
960 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
961 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
962 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
963 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
964 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
965 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
966 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
967 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
968 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
969 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
970 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
971 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
972 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
973 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
974 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
975 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
976 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
977 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
978 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
979 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
980 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
981 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
985 static uint8_t ms_hmac_key0[] = {
986 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
987 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
988 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
989 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
990 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
991 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
992 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
993 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
996 static const uint8_t ms_hmac_digest0[] = {
997 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
998 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
999 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1000 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1001 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1002 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1003 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1004 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1008 /* Begin session 1 */
1010 static uint8_t ms_aes_cbc_key1[] = {
1011 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1012 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1015 static uint8_t ms_aes_cbc_iv1[] = {
1016 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1017 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1020 static const uint8_t ms_aes_cbc_cipher1[] = {
1021 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1022 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1023 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1024 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1025 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1026 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1027 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1028 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1029 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1030 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1031 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1032 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1033 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1034 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1035 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1036 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1037 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1038 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1039 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1040 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1041 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1042 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1043 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1044 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1045 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1046 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1047 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1048 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1049 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1050 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1051 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1052 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1053 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1054 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1055 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1056 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1057 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1058 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1059 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1060 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1061 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1062 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1063 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1064 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1065 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1066 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1067 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1068 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1069 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1070 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1071 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1072 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1073 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1074 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1075 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1076 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1077 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1078 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1079 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1080 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1081 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1082 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1083 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1084 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1088 static uint8_t ms_hmac_key1[] = {
1089 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1090 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1091 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1092 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1093 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1094 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1095 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1096 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1099 static const uint8_t ms_hmac_digest1[] = {
1100 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1101 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1102 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1103 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1104 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1105 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1106 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1107 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1110 /* Begin Session 2 */
1111 static uint8_t ms_aes_cbc_key2[] = {
1112 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1113 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1116 static uint8_t ms_aes_cbc_iv2[] = {
1117 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1118 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1121 static const uint8_t ms_aes_cbc_cipher2[] = {
1122 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1123 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1124 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1125 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1126 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1127 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1128 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1129 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1130 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1131 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1132 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1133 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1134 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1135 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1136 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1137 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1138 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1139 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1140 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1141 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1142 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1143 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1144 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1145 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1146 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1147 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1148 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1149 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1150 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1151 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1152 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1153 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1154 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1155 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1156 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1157 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1158 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1159 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1160 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1161 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1162 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1163 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1164 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1165 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1166 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1167 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1168 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1169 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1170 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1171 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1172 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1173 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1174 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1175 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1176 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1177 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1178 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1179 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1180 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1181 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1182 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1183 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1184 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1185 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1188 static uint8_t ms_hmac_key2[] = {
1189 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1190 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1191 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1192 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1193 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1194 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1195 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1196 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1199 static const uint8_t ms_hmac_digest2[] = {
1200 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1201 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1202 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1203 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1204 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1205 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1206 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1207 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1214 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1216 struct crypto_testsuite_params *ts_params = &testsuite_params;
1217 struct crypto_unittest_params *ut_params = &unittest_params;
1219 /* Generate test mbuf data and space for digest */
1220 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1221 catch_22_quote, QUOTE_512_BYTES, 0);
1223 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1224 DIGEST_BYTE_LENGTH_SHA1);
1225 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1227 /* Setup Cipher Parameters */
1228 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1229 ut_params->cipher_xform.next = &ut_params->auth_xform;
1231 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1232 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1233 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1234 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1236 /* Setup HMAC Parameters */
1237 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1239 ut_params->auth_xform.next = NULL;
1241 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1242 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1243 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1244 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1245 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1247 /* Create crypto session*/
1248 ut_params->sess = rte_cryptodev_sym_session_create(
1249 ts_params->valid_devs[0],
1250 &ut_params->cipher_xform);
1251 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1253 /* Generate crypto op data structure */
1254 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1255 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1256 TEST_ASSERT_NOT_NULL(ut_params->op,
1257 "Failed to allocate symmetric crypto operation struct");
1259 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1261 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1263 /* set crypto operation source mbuf */
1264 sym_op->m_src = ut_params->ibuf;
1266 /* Set crypto operation authentication parameters */
1267 sym_op->auth.digest.data = ut_params->digest;
1268 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1269 ut_params->ibuf, QUOTE_512_BYTES);
1270 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1272 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1273 sym_op->auth.data.length = QUOTE_512_BYTES;
1275 /* Set crypto operation cipher parameters */
1276 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1277 CIPHER_IV_LENGTH_AES_CBC);
1278 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1279 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1281 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1282 CIPHER_IV_LENGTH_AES_CBC);
1284 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1285 sym_op->cipher.data.length = QUOTE_512_BYTES;
1287 /* Process crypto operation */
1288 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1289 ut_params->op), "failed to process sym crypto op");
1291 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1292 "crypto op processing failed");
1295 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1296 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1298 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1299 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1301 "ciphertext data not as expected");
1303 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1305 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1306 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1307 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1308 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1309 DIGEST_BYTE_LENGTH_SHA1,
1310 "Generated digest data not as expected");
1312 return TEST_SUCCESS;
1315 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1317 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1319 static uint8_t hmac_sha512_key[] = {
1320 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1321 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1322 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1323 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1324 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1325 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1326 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1327 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1329 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1330 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1331 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1332 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1333 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1334 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1335 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1336 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1337 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1342 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1343 struct crypto_unittest_params *ut_params,
1344 uint8_t *cipher_key,
1348 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1349 struct crypto_unittest_params *ut_params,
1350 struct crypto_testsuite_params *ts_params,
1351 const uint8_t *cipher,
1352 const uint8_t *digest,
1357 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1358 struct crypto_unittest_params *ut_params,
1359 uint8_t *cipher_key,
1363 /* Setup Cipher Parameters */
1364 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1365 ut_params->cipher_xform.next = NULL;
1367 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1368 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1369 ut_params->cipher_xform.cipher.key.data = cipher_key;
1370 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1372 /* Setup HMAC Parameters */
1373 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1374 ut_params->auth_xform.next = &ut_params->cipher_xform;
1376 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1377 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1378 ut_params->auth_xform.auth.key.data = hmac_key;
1379 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1380 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1382 return TEST_SUCCESS;
1387 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1388 struct crypto_unittest_params *ut_params,
1389 struct crypto_testsuite_params *ts_params,
1390 const uint8_t *cipher,
1391 const uint8_t *digest,
1394 /* Generate test mbuf data and digest */
1395 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1398 QUOTE_512_BYTES, 0);
1400 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1401 DIGEST_BYTE_LENGTH_SHA512);
1402 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1404 rte_memcpy(ut_params->digest,
1406 DIGEST_BYTE_LENGTH_SHA512);
1408 /* Generate Crypto op data structure */
1409 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1410 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1411 TEST_ASSERT_NOT_NULL(ut_params->op,
1412 "Failed to allocate symmetric crypto operation struct");
1414 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1416 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1418 /* set crypto operation source mbuf */
1419 sym_op->m_src = ut_params->ibuf;
1421 sym_op->auth.digest.data = ut_params->digest;
1422 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1423 ut_params->ibuf, QUOTE_512_BYTES);
1424 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1426 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1427 sym_op->auth.data.length = QUOTE_512_BYTES;
1429 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1430 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1431 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1432 ut_params->ibuf, 0);
1433 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1435 rte_memcpy(sym_op->cipher.iv.data, iv,
1436 CIPHER_IV_LENGTH_AES_CBC);
1438 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1439 sym_op->cipher.data.length = QUOTE_512_BYTES;
1441 /* Process crypto operation */
1442 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1443 ut_params->op), "failed to process sym crypto op");
1445 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1446 "crypto op processing failed");
1448 ut_params->obuf = ut_params->op->sym->m_src;
1451 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1452 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1453 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1455 "Plaintext data not as expected");
1458 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1459 "Digest verification failed");
1461 return TEST_SUCCESS;
1465 test_AES_chain_mb_all(void)
1467 struct crypto_testsuite_params *ts_params = &testsuite_params;
1470 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1471 ts_params->op_mpool, ts_params->valid_devs[0],
1472 RTE_CRYPTODEV_AESNI_MB_PMD,
1473 BLKCIPHER_AES_CHAIN_TYPE);
1475 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1477 return TEST_SUCCESS;
1481 test_AES_chain_libcrypto_all(void)
1483 struct crypto_testsuite_params *ts_params = &testsuite_params;
1486 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1487 ts_params->op_mpool, ts_params->valid_devs[0],
1488 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1489 BLKCIPHER_AES_CHAIN_TYPE);
1491 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1493 return TEST_SUCCESS;
1497 test_AES_cipheronly_libcrypto_all(void)
1499 struct crypto_testsuite_params *ts_params = &testsuite_params;
1502 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1503 ts_params->op_mpool, ts_params->valid_devs[0],
1504 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1505 BLKCIPHER_AES_CIPHERONLY_TYPE);
1507 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1509 return TEST_SUCCESS;
1513 test_AES_chain_qat_all(void)
1515 struct crypto_testsuite_params *ts_params = &testsuite_params;
1518 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1519 ts_params->op_mpool, ts_params->valid_devs[0],
1520 RTE_CRYPTODEV_QAT_SYM_PMD,
1521 BLKCIPHER_AES_CHAIN_TYPE);
1523 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1525 return TEST_SUCCESS;
1529 test_authonly_libcrypto_all(void)
1531 struct crypto_testsuite_params *ts_params = &testsuite_params;
1534 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1535 ts_params->op_mpool, ts_params->valid_devs[0],
1536 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1537 BLKCIPHER_AUTHONLY_TYPE);
1539 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1541 return TEST_SUCCESS;
1544 /* ***** SNOW 3G Tests ***** */
1546 create_wireless_algo_hash_session(uint8_t dev_id,
1547 const uint8_t *key, const uint8_t key_len,
1548 const uint8_t aad_len, const uint8_t auth_len,
1549 enum rte_crypto_auth_operation op,
1550 enum rte_crypto_auth_algorithm algo)
1552 uint8_t hash_key[key_len];
1554 struct crypto_unittest_params *ut_params = &unittest_params;
1556 memcpy(hash_key, key, key_len);
1558 TEST_HEXDUMP(stdout, "key:", key, key_len);
1560 /* Setup Authentication Parameters */
1561 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1562 ut_params->auth_xform.next = NULL;
1564 ut_params->auth_xform.auth.op = op;
1565 ut_params->auth_xform.auth.algo = algo;
1566 ut_params->auth_xform.auth.key.length = key_len;
1567 ut_params->auth_xform.auth.key.data = hash_key;
1568 ut_params->auth_xform.auth.digest_length = auth_len;
1569 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1570 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1571 &ut_params->auth_xform);
1572 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1577 create_wireless_algo_cipher_session(uint8_t dev_id,
1578 enum rte_crypto_cipher_operation op,
1579 enum rte_crypto_cipher_algorithm algo,
1580 const uint8_t *key, const uint8_t key_len)
1582 uint8_t cipher_key[key_len];
1584 struct crypto_unittest_params *ut_params = &unittest_params;
1586 memcpy(cipher_key, key, key_len);
1588 /* Setup Cipher Parameters */
1589 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1590 ut_params->cipher_xform.next = NULL;
1592 ut_params->cipher_xform.cipher.algo = algo;
1593 ut_params->cipher_xform.cipher.op = op;
1594 ut_params->cipher_xform.cipher.key.data = cipher_key;
1595 ut_params->cipher_xform.cipher.key.length = key_len;
1597 TEST_HEXDUMP(stdout, "key:", key, key_len);
1599 /* Create Crypto session */
1600 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1603 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1608 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1609 const unsigned cipher_len,
1610 const unsigned cipher_offset,
1611 enum rte_crypto_cipher_algorithm algo)
1613 struct crypto_testsuite_params *ts_params = &testsuite_params;
1614 struct crypto_unittest_params *ut_params = &unittest_params;
1615 unsigned iv_pad_len = 0;
1617 /* Generate Crypto op data structure */
1618 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1619 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1620 TEST_ASSERT_NOT_NULL(ut_params->op,
1621 "Failed to allocate pktmbuf offload");
1623 /* Set crypto operation data parameters */
1624 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1626 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1628 /* set crypto operation source mbuf */
1629 sym_op->m_src = ut_params->ibuf;
1632 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1633 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1635 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1637 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1640 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1642 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1643 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1644 sym_op->cipher.iv.length = iv_pad_len;
1646 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1647 sym_op->cipher.data.length = cipher_len;
1648 sym_op->cipher.data.offset = cipher_offset;
1653 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1654 const unsigned cipher_len,
1655 const unsigned cipher_offset,
1656 enum rte_crypto_cipher_algorithm algo)
1658 struct crypto_testsuite_params *ts_params = &testsuite_params;
1659 struct crypto_unittest_params *ut_params = &unittest_params;
1660 unsigned iv_pad_len = 0;
1662 /* Generate Crypto op data structure */
1663 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1664 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1665 TEST_ASSERT_NOT_NULL(ut_params->op,
1666 "Failed to allocate pktmbuf offload");
1668 /* Set crypto operation data parameters */
1669 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1671 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1673 /* set crypto operation source mbuf */
1674 sym_op->m_src = ut_params->ibuf;
1675 sym_op->m_dst = ut_params->obuf;
1678 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1679 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1681 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1682 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1685 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1687 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1688 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1689 sym_op->cipher.iv.length = iv_pad_len;
1691 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1692 sym_op->cipher.data.length = cipher_len;
1693 sym_op->cipher.data.offset = cipher_offset;
1698 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1699 enum rte_crypto_cipher_operation cipher_op,
1700 enum rte_crypto_auth_operation auth_op,
1701 enum rte_crypto_auth_algorithm auth_algo,
1702 enum rte_crypto_cipher_algorithm cipher_algo,
1703 const uint8_t *key, const uint8_t key_len,
1704 const uint8_t aad_len, const uint8_t auth_len)
1707 uint8_t cipher_auth_key[key_len];
1709 struct crypto_unittest_params *ut_params = &unittest_params;
1711 memcpy(cipher_auth_key, key, key_len);
1713 /* Setup Authentication Parameters */
1714 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1715 ut_params->auth_xform.next = NULL;
1717 ut_params->auth_xform.auth.op = auth_op;
1718 ut_params->auth_xform.auth.algo = auth_algo;
1719 ut_params->auth_xform.auth.key.length = key_len;
1720 /* Hash key = cipher key */
1721 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1722 ut_params->auth_xform.auth.digest_length = auth_len;
1723 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1725 /* Setup Cipher Parameters */
1726 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1727 ut_params->cipher_xform.next = &ut_params->auth_xform;
1729 ut_params->cipher_xform.cipher.algo = cipher_algo;
1730 ut_params->cipher_xform.cipher.op = cipher_op;
1731 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1732 ut_params->cipher_xform.cipher.key.length = key_len;
1734 TEST_HEXDUMP(stdout, "key:", key, key_len);
1736 /* Create Crypto session*/
1737 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1738 &ut_params->cipher_xform);
1740 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1745 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1746 enum rte_crypto_cipher_operation cipher_op,
1747 enum rte_crypto_auth_operation auth_op,
1748 enum rte_crypto_auth_algorithm auth_algo,
1749 enum rte_crypto_cipher_algorithm cipher_algo,
1750 const uint8_t *key, const uint8_t key_len,
1751 const uint8_t aad_len, const uint8_t auth_len)
1753 uint8_t auth_cipher_key[key_len];
1755 struct crypto_unittest_params *ut_params = &unittest_params;
1757 memcpy(auth_cipher_key, key, key_len);
1759 /* Setup Authentication Parameters */
1760 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1761 ut_params->auth_xform.auth.op = auth_op;
1762 ut_params->auth_xform.next = &ut_params->cipher_xform;
1763 ut_params->auth_xform.auth.algo = auth_algo;
1764 ut_params->auth_xform.auth.key.length = key_len;
1765 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1766 ut_params->auth_xform.auth.digest_length = auth_len;
1767 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1769 /* Setup Cipher Parameters */
1770 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1771 ut_params->cipher_xform.next = NULL;
1772 ut_params->cipher_xform.cipher.algo = cipher_algo;
1773 ut_params->cipher_xform.cipher.op = cipher_op;
1774 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1775 ut_params->cipher_xform.cipher.key.length = key_len;
1777 TEST_HEXDUMP(stdout, "key:", key, key_len);
1779 /* Create Crypto session*/
1780 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1781 &ut_params->auth_xform);
1783 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1789 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1790 const unsigned auth_tag_len,
1791 const uint8_t *aad, const unsigned aad_len,
1792 unsigned data_pad_len,
1793 enum rte_crypto_auth_operation op,
1794 enum rte_crypto_auth_algorithm algo,
1795 const unsigned auth_len, const unsigned auth_offset)
1797 struct crypto_testsuite_params *ts_params = &testsuite_params;
1799 struct crypto_unittest_params *ut_params = &unittest_params;
1801 unsigned aad_buffer_len;
1803 /* Generate Crypto op data structure */
1804 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1805 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1806 TEST_ASSERT_NOT_NULL(ut_params->op,
1807 "Failed to allocate pktmbuf offload");
1809 /* Set crypto operation data parameters */
1810 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1812 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1814 /* set crypto operation source mbuf */
1815 sym_op->m_src = ut_params->ibuf;
1819 * Always allocate the aad up to the block size.
1820 * The cryptodev API calls out -
1821 * - the array must be big enough to hold the AAD, plus any
1822 * space to round this up to the nearest multiple of the
1823 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1825 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1826 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1828 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1829 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1830 ut_params->ibuf, aad_buffer_len);
1831 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1832 "no room to prepend aad");
1833 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1835 sym_op->auth.aad.length = aad_len;
1837 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1838 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1840 TEST_HEXDUMP(stdout, "aad:",
1841 sym_op->auth.aad.data, aad_len);
1844 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1845 ut_params->ibuf, auth_tag_len);
1847 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1848 "no room to append auth tag");
1849 ut_params->digest = sym_op->auth.digest.data;
1850 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1851 ut_params->ibuf, data_pad_len + aad_len);
1852 sym_op->auth.digest.length = auth_tag_len;
1853 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1854 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1856 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1858 TEST_HEXDUMP(stdout, "digest:",
1859 sym_op->auth.digest.data,
1860 sym_op->auth.digest.length);
1862 sym_op->auth.data.length = auth_len;
1863 sym_op->auth.data.offset = auth_offset;
1869 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1870 const unsigned auth_tag_len,
1871 const uint8_t *aad, const uint8_t aad_len,
1872 unsigned data_pad_len,
1873 enum rte_crypto_auth_operation op,
1874 enum rte_crypto_auth_algorithm auth_algo,
1875 enum rte_crypto_cipher_algorithm cipher_algo,
1876 const uint8_t *iv, const uint8_t iv_len,
1877 const unsigned cipher_len, const unsigned cipher_offset,
1878 const unsigned auth_len, const unsigned auth_offset)
1880 struct crypto_testsuite_params *ts_params = &testsuite_params;
1881 struct crypto_unittest_params *ut_params = &unittest_params;
1883 unsigned iv_pad_len = 0;
1884 unsigned aad_buffer_len;
1886 /* Generate Crypto op data structure */
1887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1889 TEST_ASSERT_NOT_NULL(ut_params->op,
1890 "Failed to allocate pktmbuf offload");
1891 /* Set crypto operation data parameters */
1892 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1894 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1896 /* set crypto operation source mbuf */
1897 sym_op->m_src = ut_params->ibuf;
1900 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1901 ut_params->ibuf, auth_tag_len);
1903 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1904 "no room to append auth tag");
1905 ut_params->digest = sym_op->auth.digest.data;
1906 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1907 ut_params->ibuf, data_pad_len);
1908 sym_op->auth.digest.length = auth_tag_len;
1909 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1910 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1912 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1914 TEST_HEXDUMP(stdout, "digest:",
1915 sym_op->auth.digest.data,
1916 sym_op->auth.digest.length);
1920 * Always allocate the aad up to the block size.
1921 * The cryptodev API calls out -
1922 * - the array must be big enough to hold the AAD, plus any
1923 * space to round this up to the nearest multiple of the
1924 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1926 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1927 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1929 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1930 sym_op->auth.aad.data =
1931 (uint8_t *)rte_pktmbuf_prepend(
1932 ut_params->ibuf, aad_buffer_len);
1933 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1934 "no room to prepend aad");
1935 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1937 sym_op->auth.aad.length = aad_len;
1938 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1939 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1940 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1943 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1944 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1946 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1947 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1948 ut_params->ibuf, iv_pad_len);
1950 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1951 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1952 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1953 sym_op->cipher.iv.length = iv_pad_len;
1954 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1955 sym_op->cipher.data.length = cipher_len;
1956 sym_op->cipher.data.offset = cipher_offset + auth_offset;
1957 sym_op->auth.data.length = auth_len;
1958 sym_op->auth.data.offset = auth_offset + cipher_offset;
1964 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
1965 const uint8_t *iv, const uint8_t iv_len,
1966 const uint8_t *aad, const uint8_t aad_len,
1967 unsigned data_pad_len,
1968 const unsigned cipher_len, const unsigned cipher_offset,
1969 const unsigned auth_len, const unsigned auth_offset,
1970 enum rte_crypto_auth_algorithm auth_algo,
1971 enum rte_crypto_cipher_algorithm cipher_algo)
1973 struct crypto_testsuite_params *ts_params = &testsuite_params;
1974 struct crypto_unittest_params *ut_params = &unittest_params;
1976 unsigned iv_pad_len = 0;
1977 unsigned aad_buffer_len = 0;
1979 /* Generate Crypto op data structure */
1980 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1981 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1982 TEST_ASSERT_NOT_NULL(ut_params->op,
1983 "Failed to allocate pktmbuf offload");
1985 /* Set crypto operation data parameters */
1986 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1988 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1990 /* set crypto operation source mbuf */
1991 sym_op->m_src = ut_params->ibuf;
1994 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1995 ut_params->ibuf, auth_tag_len);
1997 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1998 "no room to append auth tag");
2000 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2001 ut_params->ibuf, data_pad_len);
2002 sym_op->auth.digest.length = auth_tag_len;
2004 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2006 TEST_HEXDUMP(stdout, "digest:",
2007 sym_op->auth.digest.data,
2008 sym_op->auth.digest.length);
2012 * Always allocate the aad up to the block size.
2013 * The cryptodev API calls out -
2014 * - the array must be big enough to hold the AAD, plus any
2015 * space to round this up to the nearest multiple of the
2016 * block size (8 bytes for KASUMI 16 bytes).
2018 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2019 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2021 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2022 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2023 ut_params->ibuf, aad_buffer_len);
2024 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2025 "no room to prepend aad");
2026 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2028 sym_op->auth.aad.length = aad_len;
2029 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2030 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2031 TEST_HEXDUMP(stdout, "aad:",
2032 sym_op->auth.aad.data, aad_len);
2035 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2036 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2038 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2040 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2041 ut_params->ibuf, iv_pad_len);
2042 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2044 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2045 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2046 sym_op->cipher.iv.length = iv_pad_len;
2048 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2050 sym_op->cipher.data.length = cipher_len;
2051 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2053 sym_op->auth.data.length = auth_len;
2054 sym_op->auth.data.offset = auth_offset + cipher_offset;
2060 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2062 struct crypto_testsuite_params *ts_params = &testsuite_params;
2063 struct crypto_unittest_params *ut_params = &unittest_params;
2066 unsigned plaintext_pad_len;
2067 unsigned plaintext_len;
2070 /* Create SNOW 3G session */
2071 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2072 tdata->key.data, tdata->key.len,
2073 tdata->aad.len, tdata->digest.len,
2074 RTE_CRYPTO_AUTH_OP_GENERATE,
2075 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2079 /* alloc mbuf and set payload */
2080 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2082 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2083 rte_pktmbuf_tailroom(ut_params->ibuf));
2085 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2086 /* Append data which is padded to a multiple of */
2087 /* the algorithms block size */
2088 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2089 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2091 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2093 /* Create SNOW 3G operation */
2094 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2095 tdata->aad.data, tdata->aad.len,
2096 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2097 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2098 tdata->validAuthLenInBits.len,
2099 tdata->validAuthOffsetLenInBits.len);
2103 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2105 ut_params->obuf = ut_params->op->sym->m_src;
2106 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2107 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2108 + plaintext_pad_len + tdata->aad.len;
2111 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2114 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2115 "SNOW 3G Generated auth tag not as expected");
2121 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2123 struct crypto_testsuite_params *ts_params = &testsuite_params;
2124 struct crypto_unittest_params *ut_params = &unittest_params;
2127 unsigned plaintext_pad_len;
2128 unsigned plaintext_len;
2131 /* Create SNOW 3G session */
2132 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2133 tdata->key.data, tdata->key.len,
2134 tdata->aad.len, tdata->digest.len,
2135 RTE_CRYPTO_AUTH_OP_VERIFY,
2136 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2139 /* alloc mbuf and set payload */
2140 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2142 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2143 rte_pktmbuf_tailroom(ut_params->ibuf));
2145 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2146 /* Append data which is padded to a multiple of */
2147 /* the algorithms block size */
2148 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2149 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2151 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2153 /* Create SNOW 3G operation */
2154 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2156 tdata->aad.data, tdata->aad.len,
2158 RTE_CRYPTO_AUTH_OP_VERIFY,
2159 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2160 tdata->validAuthLenInBits.len,
2161 tdata->validAuthOffsetLenInBits.len);
2165 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2167 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2168 ut_params->obuf = ut_params->op->sym->m_src;
2169 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2170 + plaintext_pad_len + tdata->aad.len;
2173 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2182 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2184 struct crypto_testsuite_params *ts_params = &testsuite_params;
2185 struct crypto_unittest_params *ut_params = &unittest_params;
2188 unsigned plaintext_pad_len;
2189 unsigned plaintext_len;
2192 /* Create KASUMI session */
2193 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2194 tdata->key.data, tdata->key.len,
2195 tdata->aad.len, tdata->digest.len,
2196 RTE_CRYPTO_AUTH_OP_GENERATE,
2197 RTE_CRYPTO_AUTH_KASUMI_F9);
2201 /* alloc mbuf and set payload */
2202 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2204 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2205 rte_pktmbuf_tailroom(ut_params->ibuf));
2207 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2208 /* Append data which is padded to a multiple of */
2209 /* the algorithms block size */
2210 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2211 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2213 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2215 /* Create KASUMI operation */
2216 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2217 tdata->aad.data, tdata->aad.len,
2218 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2219 RTE_CRYPTO_AUTH_KASUMI_F9,
2220 tdata->validAuthLenInBits.len,
2221 tdata->validAuthOffsetLenInBits.len);
2225 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2227 ut_params->obuf = ut_params->op->sym->m_src;
2228 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2229 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2230 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2233 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2236 DIGEST_BYTE_LENGTH_KASUMI_F9,
2237 "KASUMI Generated auth tag not as expected");
2243 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2245 struct crypto_testsuite_params *ts_params = &testsuite_params;
2246 struct crypto_unittest_params *ut_params = &unittest_params;
2249 unsigned plaintext_pad_len;
2250 unsigned plaintext_len;
2253 /* Create KASUMI session */
2254 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2255 tdata->key.data, tdata->key.len,
2256 tdata->aad.len, tdata->digest.len,
2257 RTE_CRYPTO_AUTH_OP_VERIFY,
2258 RTE_CRYPTO_AUTH_KASUMI_F9);
2261 /* alloc mbuf and set payload */
2262 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2264 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2265 rte_pktmbuf_tailroom(ut_params->ibuf));
2267 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2268 /* Append data which is padded to a multiple */
2269 /* of the algorithms block size */
2270 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2271 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2273 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2275 /* Create KASUMI operation */
2276 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2278 tdata->aad.data, tdata->aad.len,
2280 RTE_CRYPTO_AUTH_OP_VERIFY,
2281 RTE_CRYPTO_AUTH_KASUMI_F9,
2282 tdata->validAuthLenInBits.len,
2283 tdata->validAuthOffsetLenInBits.len);
2287 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2289 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2290 ut_params->obuf = ut_params->op->sym->m_src;
2291 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2292 + plaintext_pad_len + tdata->aad.len;
2295 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2304 test_snow3g_hash_generate_test_case_1(void)
2306 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2310 test_snow3g_hash_generate_test_case_2(void)
2312 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2316 test_snow3g_hash_generate_test_case_3(void)
2318 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2322 test_snow3g_hash_generate_test_case_4(void)
2324 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2328 test_snow3g_hash_generate_test_case_5(void)
2330 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2334 test_snow3g_hash_generate_test_case_6(void)
2336 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2340 test_snow3g_hash_verify_test_case_1(void)
2342 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2347 test_snow3g_hash_verify_test_case_2(void)
2349 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2353 test_snow3g_hash_verify_test_case_3(void)
2355 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2359 test_snow3g_hash_verify_test_case_4(void)
2361 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2365 test_snow3g_hash_verify_test_case_5(void)
2367 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2371 test_snow3g_hash_verify_test_case_6(void)
2373 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2377 test_kasumi_hash_generate_test_case_1(void)
2379 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2383 test_kasumi_hash_generate_test_case_2(void)
2385 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2389 test_kasumi_hash_generate_test_case_3(void)
2391 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2395 test_kasumi_hash_generate_test_case_4(void)
2397 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2401 test_kasumi_hash_generate_test_case_5(void)
2403 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2407 test_kasumi_hash_generate_test_case_6(void)
2409 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2413 test_kasumi_hash_verify_test_case_1(void)
2415 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2419 test_kasumi_hash_verify_test_case_2(void)
2421 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2425 test_kasumi_hash_verify_test_case_3(void)
2427 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2431 test_kasumi_hash_verify_test_case_4(void)
2433 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2437 test_kasumi_hash_verify_test_case_5(void)
2439 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2443 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2445 struct crypto_testsuite_params *ts_params = &testsuite_params;
2446 struct crypto_unittest_params *ut_params = &unittest_params;
2449 uint8_t *plaintext, *ciphertext;
2450 unsigned plaintext_pad_len;
2451 unsigned plaintext_len;
2453 /* Create KASUMI session */
2454 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2455 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2456 RTE_CRYPTO_CIPHER_KASUMI_F8,
2457 tdata->key.data, tdata->key.len);
2461 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2463 /* Clear mbuf payload */
2464 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2465 rte_pktmbuf_tailroom(ut_params->ibuf));
2467 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2468 /* Append data which is padded to a multiple */
2469 /* of the algorithms block size */
2470 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2471 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2473 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2475 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2477 /* Create KASUMI operation */
2478 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2479 tdata->plaintext.len,
2480 tdata->validCipherOffsetLenInBits.len,
2481 RTE_CRYPTO_CIPHER_KASUMI_F8);
2485 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2489 ut_params->obuf = ut_params->op->sym->m_dst;
2490 if (ut_params->obuf)
2491 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2494 ciphertext = plaintext;
2496 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2499 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2501 tdata->ciphertext.data,
2502 tdata->validCipherLenInBits.len,
2503 "KASUMI Ciphertext data not as expected");
2508 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2510 struct crypto_testsuite_params *ts_params = &testsuite_params;
2511 struct crypto_unittest_params *ut_params = &unittest_params;
2514 uint8_t *plaintext, *ciphertext;
2515 unsigned plaintext_pad_len;
2516 unsigned plaintext_len;
2518 /* Create KASUMI session */
2519 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2520 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2521 RTE_CRYPTO_CIPHER_KASUMI_F8,
2522 tdata->key.data, tdata->key.len);
2526 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2527 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2529 /* Clear mbuf payload */
2530 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2531 rte_pktmbuf_tailroom(ut_params->ibuf));
2533 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2534 /* Append data which is padded to a multiple */
2535 /* of the algorithms block size */
2536 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2537 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2539 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2540 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2542 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2544 /* Create KASUMI operation */
2545 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2547 tdata->plaintext.len,
2548 tdata->validCipherOffsetLenInBits.len,
2549 RTE_CRYPTO_CIPHER_KASUMI_F8);
2553 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2555 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2557 ut_params->obuf = ut_params->op->sym->m_dst;
2558 if (ut_params->obuf)
2559 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2562 ciphertext = plaintext;
2564 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2567 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2569 tdata->ciphertext.data,
2570 tdata->validCipherLenInBits.len,
2571 "KASUMI Ciphertext data not as expected");
2576 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2578 struct crypto_testsuite_params *ts_params = &testsuite_params;
2579 struct crypto_unittest_params *ut_params = &unittest_params;
2582 uint8_t *ciphertext, *plaintext;
2583 unsigned ciphertext_pad_len;
2584 unsigned ciphertext_len;
2586 /* Create KASUMI session */
2587 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2588 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2589 RTE_CRYPTO_CIPHER_KASUMI_F8,
2590 tdata->key.data, tdata->key.len);
2594 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2595 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2597 /* Clear mbuf payload */
2598 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2599 rte_pktmbuf_tailroom(ut_params->ibuf));
2601 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2602 /* Append data which is padded to a multiple */
2603 /* of the algorithms block size */
2604 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2605 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2606 ciphertext_pad_len);
2607 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2608 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2610 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2612 /* Create KASUMI operation */
2613 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2615 tdata->ciphertext.len,
2616 tdata->validCipherOffsetLenInBits.len,
2617 RTE_CRYPTO_CIPHER_KASUMI_F8);
2621 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2623 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2625 ut_params->obuf = ut_params->op->sym->m_dst;
2626 if (ut_params->obuf)
2627 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2630 plaintext = ciphertext;
2632 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2635 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2637 tdata->plaintext.data,
2638 tdata->validCipherLenInBits.len,
2639 "KASUMI Plaintext data not as expected");
2644 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2646 struct crypto_testsuite_params *ts_params = &testsuite_params;
2647 struct crypto_unittest_params *ut_params = &unittest_params;
2650 uint8_t *ciphertext, *plaintext;
2651 unsigned ciphertext_pad_len;
2652 unsigned ciphertext_len;
2654 /* Create KASUMI session */
2655 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2656 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2657 RTE_CRYPTO_CIPHER_KASUMI_F8,
2658 tdata->key.data, tdata->key.len);
2662 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2664 /* Clear mbuf payload */
2665 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2666 rte_pktmbuf_tailroom(ut_params->ibuf));
2668 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2669 /* Append data which is padded to a multiple */
2670 /* of the algorithms block size */
2671 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2672 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2673 ciphertext_pad_len);
2674 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2676 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2678 /* Create KASUMI operation */
2679 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2681 tdata->ciphertext.len,
2682 tdata->validCipherOffsetLenInBits.len,
2683 RTE_CRYPTO_CIPHER_KASUMI_F8);
2687 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2689 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2691 ut_params->obuf = ut_params->op->sym->m_dst;
2692 if (ut_params->obuf)
2693 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2696 plaintext = ciphertext;
2698 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2701 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2703 tdata->plaintext.data,
2704 tdata->validCipherLenInBits.len,
2705 "KASUMI Plaintext data not as expected");
2710 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2712 struct crypto_testsuite_params *ts_params = &testsuite_params;
2713 struct crypto_unittest_params *ut_params = &unittest_params;
2716 uint8_t *plaintext, *ciphertext;
2717 unsigned plaintext_pad_len;
2718 unsigned plaintext_len;
2720 /* Create SNOW 3G session */
2721 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2722 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2723 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2724 tdata->key.data, tdata->key.len);
2728 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2730 /* Clear mbuf payload */
2731 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2732 rte_pktmbuf_tailroom(ut_params->ibuf));
2734 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2735 /* Append data which is padded to a multiple of */
2736 /* the algorithms block size */
2737 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2738 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2740 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2742 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2744 /* Create SNOW 3G operation */
2745 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2746 tdata->validCipherLenInBits.len,
2747 tdata->validCipherOffsetLenInBits.len,
2748 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2752 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2754 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2756 ut_params->obuf = ut_params->op->sym->m_dst;
2757 if (ut_params->obuf)
2758 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2761 ciphertext = plaintext;
2763 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2766 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2768 tdata->ciphertext.data,
2769 tdata->validDataLenInBits.len,
2770 "SNOW 3G Ciphertext data not as expected");
2776 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2778 struct crypto_testsuite_params *ts_params = &testsuite_params;
2779 struct crypto_unittest_params *ut_params = &unittest_params;
2780 uint8_t *plaintext, *ciphertext;
2783 unsigned plaintext_pad_len;
2784 unsigned plaintext_len;
2786 /* Create SNOW 3G session */
2787 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2788 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2789 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2790 tdata->key.data, tdata->key.len);
2794 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2795 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2797 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2798 "Failed to allocate input buffer in mempool");
2799 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2800 "Failed to allocate output buffer in mempool");
2802 /* Clear mbuf payload */
2803 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2804 rte_pktmbuf_tailroom(ut_params->ibuf));
2806 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2807 /* Append data which is padded to a multiple of */
2808 /* the algorithms block size */
2809 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2810 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2812 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2813 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2815 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2817 /* Create SNOW 3G operation */
2818 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2820 tdata->validCipherLenInBits.len,
2821 tdata->validCipherOffsetLenInBits.len,
2822 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2826 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2828 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2830 ut_params->obuf = ut_params->op->sym->m_dst;
2831 if (ut_params->obuf)
2832 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2835 ciphertext = plaintext;
2837 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2840 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2842 tdata->ciphertext.data,
2843 tdata->validDataLenInBits.len,
2844 "SNOW 3G Ciphertext data not as expected");
2848 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2850 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2852 uint8_t curr_byte, prev_byte;
2853 uint32_t length_in_bytes = ceil_byte_length(length + offset);
2854 uint8_t lower_byte_mask = (1 << offset) - 1;
2857 prev_byte = buffer[0];
2858 buffer[0] >>= offset;
2860 for (i = 1; i < length_in_bytes; i++) {
2861 curr_byte = buffer[i];
2862 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2863 (curr_byte >> offset);
2864 prev_byte = curr_byte;
2869 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2871 struct crypto_testsuite_params *ts_params = &testsuite_params;
2872 struct crypto_unittest_params *ut_params = &unittest_params;
2873 uint8_t *plaintext, *ciphertext;
2875 uint32_t plaintext_len;
2876 uint32_t plaintext_pad_len;
2877 uint8_t extra_offset = 4;
2878 uint8_t *expected_ciphertext_shifted;
2880 /* Create SNOW 3G session */
2881 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2882 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2883 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2884 tdata->key.data, tdata->key.len);
2888 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2889 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2891 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2892 "Failed to allocate input buffer in mempool");
2893 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2894 "Failed to allocate output buffer in mempool");
2896 /* Clear mbuf payload */
2897 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2898 rte_pktmbuf_tailroom(ut_params->ibuf));
2900 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2902 * Append data which is padded to a
2903 * multiple of the algorithms block size
2905 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2907 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2910 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2912 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2913 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2915 #ifdef RTE_APP_TEST_DEBUG
2916 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2918 /* Create SNOW 3G operation */
2919 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2921 tdata->validCipherLenInBits.len,
2922 tdata->validCipherOffsetLenInBits.len +
2924 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2928 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2930 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2932 ut_params->obuf = ut_params->op->sym->m_dst;
2933 if (ut_params->obuf)
2934 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2937 ciphertext = plaintext;
2939 #ifdef RTE_APP_TEST_DEBUG
2940 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2943 expected_ciphertext_shifted = rte_malloc(NULL,
2944 ceil_byte_length(plaintext_len + extra_offset), 0);
2946 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2947 "failed to reserve memory for ciphertext shifted\n");
2949 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
2950 ceil_byte_length(tdata->ciphertext.len));
2951 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
2954 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
2956 expected_ciphertext_shifted,
2957 tdata->validDataLenInBits.len,
2959 "SNOW 3G Ciphertext data not as expected");
2963 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2965 struct crypto_testsuite_params *ts_params = &testsuite_params;
2966 struct crypto_unittest_params *ut_params = &unittest_params;
2970 uint8_t *plaintext, *ciphertext;
2971 unsigned ciphertext_pad_len;
2972 unsigned ciphertext_len;
2974 /* Create SNOW 3G session */
2975 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2976 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2977 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2978 tdata->key.data, tdata->key.len);
2982 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2984 /* Clear mbuf payload */
2985 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2986 rte_pktmbuf_tailroom(ut_params->ibuf));
2988 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2989 /* Append data which is padded to a multiple of */
2990 /* the algorithms block size */
2991 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
2992 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2993 ciphertext_pad_len);
2994 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2996 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2998 /* Create SNOW 3G operation */
2999 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3000 tdata->validCipherLenInBits.len,
3001 tdata->validCipherOffsetLenInBits.len,
3002 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3006 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3008 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3009 ut_params->obuf = ut_params->op->sym->m_dst;
3010 if (ut_params->obuf)
3011 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3014 plaintext = ciphertext;
3016 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3019 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3020 tdata->plaintext.data,
3021 tdata->validDataLenInBits.len,
3022 "SNOW 3G Plaintext data not as expected");
3026 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3028 struct crypto_testsuite_params *ts_params = &testsuite_params;
3029 struct crypto_unittest_params *ut_params = &unittest_params;
3033 uint8_t *plaintext, *ciphertext;
3034 unsigned ciphertext_pad_len;
3035 unsigned ciphertext_len;
3037 /* Create SNOW 3G session */
3038 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3039 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3040 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3041 tdata->key.data, tdata->key.len);
3045 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3046 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3048 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3049 "Failed to allocate input buffer");
3050 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3051 "Failed to allocate output buffer");
3053 /* Clear mbuf payload */
3054 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3055 rte_pktmbuf_tailroom(ut_params->ibuf));
3057 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3058 rte_pktmbuf_tailroom(ut_params->obuf));
3060 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3061 /* Append data which is padded to a multiple of */
3062 /* the algorithms block size */
3063 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3064 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3065 ciphertext_pad_len);
3066 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3067 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3069 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3071 /* Create SNOW 3G operation */
3072 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3074 tdata->validCipherLenInBits.len,
3075 tdata->validCipherOffsetLenInBits.len,
3076 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3080 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3082 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3083 ut_params->obuf = ut_params->op->sym->m_dst;
3084 if (ut_params->obuf)
3085 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3088 plaintext = ciphertext;
3090 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3093 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3094 tdata->plaintext.data,
3095 tdata->validDataLenInBits.len,
3096 "SNOW 3G Plaintext data not as expected");
3101 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3103 struct crypto_testsuite_params *ts_params = &testsuite_params;
3104 struct crypto_unittest_params *ut_params = &unittest_params;
3108 uint8_t *plaintext, *ciphertext;
3109 unsigned plaintext_pad_len;
3110 unsigned plaintext_len;
3112 /* Create SNOW 3G session */
3113 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3114 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3115 RTE_CRYPTO_AUTH_OP_GENERATE,
3116 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3117 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3118 tdata->key.data, tdata->key.len,
3119 tdata->aad.len, tdata->digest.len);
3122 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3124 /* clear mbuf payload */
3125 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3126 rte_pktmbuf_tailroom(ut_params->ibuf));
3128 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3129 /* Append data which is padded to a multiple of */
3130 /* the algorithms block size */
3131 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3132 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3134 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3136 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3138 /* Create SNOW 3G operation */
3139 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3140 tdata->digest.len, tdata->aad.data,
3141 tdata->aad.len, /*tdata->plaintext.len,*/
3142 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3143 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3144 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3145 tdata->iv.data, tdata->iv.len,
3146 tdata->validCipherLenInBits.len,
3147 tdata->validCipherOffsetLenInBits.len,
3148 tdata->validAuthLenInBits.len,
3149 tdata->validAuthOffsetLenInBits.len
3154 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3156 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3157 ut_params->obuf = ut_params->op->sym->m_src;
3158 if (ut_params->obuf)
3159 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3160 + tdata->iv.len + tdata->aad.len;
3162 ciphertext = plaintext;
3164 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");
3172 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3173 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3176 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3179 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3180 "SNOW 3G Generated auth tag not as expected");
3184 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3186 struct crypto_testsuite_params *ts_params = &testsuite_params;
3187 struct crypto_unittest_params *ut_params = &unittest_params;
3191 uint8_t *plaintext, *ciphertext;
3192 unsigned plaintext_pad_len;
3193 unsigned plaintext_len;
3195 /* Create SNOW 3G session */
3196 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3197 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3198 RTE_CRYPTO_AUTH_OP_GENERATE,
3199 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3200 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3201 tdata->key.data, tdata->key.len,
3202 tdata->aad.len, tdata->digest.len);
3206 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3208 /* clear mbuf payload */
3209 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3210 rte_pktmbuf_tailroom(ut_params->ibuf));
3212 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3213 /* Append data which is padded to a multiple of */
3214 /* the algorithms block size */
3215 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3216 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3218 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3220 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3222 /* Create SNOW 3G operation */
3223 retval = create_wireless_algo_auth_cipher_operation(
3225 tdata->iv.data, tdata->iv.len,
3226 tdata->aad.data, tdata->aad.len,
3228 tdata->validCipherLenInBits.len,
3229 tdata->validCipherOffsetLenInBits.len,
3230 tdata->validAuthLenInBits.len,
3231 tdata->validAuthOffsetLenInBits.len,
3232 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3233 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3239 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3241 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3242 ut_params->obuf = ut_params->op->sym->m_src;
3243 if (ut_params->obuf)
3244 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3245 + tdata->aad.len + tdata->iv.len;
3247 ciphertext = plaintext;
3249 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3250 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3251 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3254 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3256 tdata->ciphertext.data,
3257 tdata->validDataLenInBits.len,
3258 "SNOW 3G Ciphertext data not as expected");
3261 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3264 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3265 "SNOW 3G Generated auth tag not as expected");
3270 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3272 struct crypto_testsuite_params *ts_params = &testsuite_params;
3273 struct crypto_unittest_params *ut_params = &unittest_params;
3277 uint8_t *plaintext, *ciphertext;
3278 unsigned plaintext_pad_len;
3279 unsigned plaintext_len;
3281 /* Create KASUMI session */
3282 retval = create_wireless_algo_auth_cipher_session(
3283 ts_params->valid_devs[0],
3284 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3285 RTE_CRYPTO_AUTH_OP_GENERATE,
3286 RTE_CRYPTO_AUTH_KASUMI_F9,
3287 RTE_CRYPTO_CIPHER_KASUMI_F8,
3288 tdata->key.data, tdata->key.len,
3289 tdata->aad.len, tdata->digest.len);
3292 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3294 /* clear mbuf payload */
3295 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3296 rte_pktmbuf_tailroom(ut_params->ibuf));
3298 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3299 /* Append data which is padded to a multiple of */
3300 /* the algorithms block size */
3301 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3302 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3304 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3306 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3308 /* Create KASUMI operation */
3309 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3310 tdata->iv.data, tdata->iv.len,
3311 tdata->aad.data, tdata->aad.len,
3313 tdata->validCipherLenInBits.len,
3314 tdata->validCipherOffsetLenInBits.len,
3315 tdata->validAuthLenInBits.len,
3316 tdata->validAuthOffsetLenInBits.len,
3317 RTE_CRYPTO_AUTH_KASUMI_F9,
3318 RTE_CRYPTO_CIPHER_KASUMI_F8
3324 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3326 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3327 ut_params->obuf = ut_params->op->sym->m_src;
3328 if (ut_params->obuf)
3329 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3330 + tdata->iv.len + tdata->aad.len;
3332 ciphertext = plaintext;
3335 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3337 tdata->ciphertext.data,
3338 tdata->validCipherLenInBits.len,
3339 "KASUMI Ciphertext data not as expected");
3340 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3341 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3344 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3347 DIGEST_BYTE_LENGTH_KASUMI_F9,
3348 "KASUMI Generated auth tag not as expected");
3353 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3355 struct crypto_testsuite_params *ts_params = &testsuite_params;
3356 struct crypto_unittest_params *ut_params = &unittest_params;
3360 uint8_t *plaintext, *ciphertext;
3361 unsigned plaintext_pad_len;
3362 unsigned plaintext_len;
3364 /* Create KASUMI session */
3365 retval = create_wireless_algo_cipher_auth_session(
3366 ts_params->valid_devs[0],
3367 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3368 RTE_CRYPTO_AUTH_OP_GENERATE,
3369 RTE_CRYPTO_AUTH_KASUMI_F9,
3370 RTE_CRYPTO_CIPHER_KASUMI_F8,
3371 tdata->key.data, tdata->key.len,
3372 tdata->aad.len, tdata->digest.len);
3376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3378 /* clear mbuf payload */
3379 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3380 rte_pktmbuf_tailroom(ut_params->ibuf));
3382 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3383 /* Append data which is padded to a multiple of */
3384 /* the algorithms block size */
3385 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3386 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3388 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3390 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3392 /* Create KASUMI operation */
3393 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3394 tdata->digest.len, tdata->aad.data,
3396 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3397 RTE_CRYPTO_AUTH_KASUMI_F9,
3398 RTE_CRYPTO_CIPHER_KASUMI_F8,
3399 tdata->iv.data, tdata->iv.len,
3400 tdata->validCipherLenInBits.len,
3401 tdata->validCipherOffsetLenInBits.len,
3402 tdata->validAuthLenInBits.len,
3403 tdata->validAuthOffsetLenInBits.len
3408 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3410 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3411 ut_params->obuf = ut_params->op->sym->m_src;
3412 if (ut_params->obuf)
3413 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3414 + tdata->aad.len + tdata->iv.len;
3416 ciphertext = plaintext;
3418 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3419 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3422 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3424 tdata->ciphertext.data,
3425 tdata->validCipherLenInBits.len,
3426 "KASUMI Ciphertext data not as expected");
3429 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3432 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3433 "KASUMI Generated auth tag not as expected");
3438 test_zuc_encryption(const struct zuc_test_data *tdata)
3440 struct crypto_testsuite_params *ts_params = &testsuite_params;
3441 struct crypto_unittest_params *ut_params = &unittest_params;
3444 uint8_t *plaintext, *ciphertext;
3445 unsigned plaintext_pad_len;
3446 unsigned plaintext_len;
3448 /* Create ZUC session */
3449 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3450 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3451 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3452 tdata->key.data, tdata->key.len);
3456 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3458 /* Clear mbuf payload */
3459 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3460 rte_pktmbuf_tailroom(ut_params->ibuf));
3462 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3463 /* Append data which is padded to a multiple */
3464 /* of the algorithms block size */
3465 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3466 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3468 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3470 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3472 /* Create ZUC operation */
3473 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3474 tdata->plaintext.len,
3475 tdata->validCipherOffsetLenInBits.len,
3476 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3480 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3482 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3484 ut_params->obuf = ut_params->op->sym->m_dst;
3485 if (ut_params->obuf)
3486 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3489 ciphertext = plaintext;
3491 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3496 tdata->ciphertext.data,
3497 tdata->validCipherLenInBits.len,
3498 "ZUC Ciphertext data not as expected");
3503 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3505 struct crypto_testsuite_params *ts_params = &testsuite_params;
3506 struct crypto_unittest_params *ut_params = &unittest_params;
3509 unsigned plaintext_pad_len;
3510 unsigned plaintext_len;
3513 /* Create ZUC session */
3514 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3515 tdata->key.data, tdata->key.len,
3516 tdata->aad.len, tdata->digest.len,
3517 RTE_CRYPTO_AUTH_OP_GENERATE,
3518 RTE_CRYPTO_AUTH_ZUC_EIA3);
3522 /* alloc mbuf and set payload */
3523 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3525 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3526 rte_pktmbuf_tailroom(ut_params->ibuf));
3528 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3529 /* Append data which is padded to a multiple of */
3530 /* the algorithms block size */
3531 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3532 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3534 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3536 /* Create ZUC operation */
3537 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3538 tdata->aad.data, tdata->aad.len,
3539 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3540 RTE_CRYPTO_AUTH_ZUC_EIA3,
3541 tdata->validAuthLenInBits.len,
3542 tdata->validAuthOffsetLenInBits.len);
3546 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3548 ut_params->obuf = ut_params->op->sym->m_src;
3549 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3550 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3551 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3554 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3557 DIGEST_BYTE_LENGTH_KASUMI_F9,
3558 "ZUC Generated auth tag not as expected");
3564 test_kasumi_encryption_test_case_1(void)
3566 return test_kasumi_encryption(&kasumi_test_case_1);
3570 test_kasumi_encryption_test_case_1_oop(void)
3572 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3576 test_kasumi_encryption_test_case_2(void)
3578 return test_kasumi_encryption(&kasumi_test_case_2);
3582 test_kasumi_encryption_test_case_3(void)
3584 return test_kasumi_encryption(&kasumi_test_case_3);
3588 test_kasumi_encryption_test_case_4(void)
3590 return test_kasumi_encryption(&kasumi_test_case_4);
3594 test_kasumi_encryption_test_case_5(void)
3596 return test_kasumi_encryption(&kasumi_test_case_5);
3600 test_kasumi_decryption_test_case_1(void)
3602 return test_kasumi_decryption(&kasumi_test_case_1);
3606 test_kasumi_decryption_test_case_1_oop(void)
3608 return test_kasumi_decryption_oop(&kasumi_test_case_1);
3612 test_kasumi_decryption_test_case_2(void)
3614 return test_kasumi_decryption(&kasumi_test_case_2);
3618 test_kasumi_decryption_test_case_3(void)
3620 return test_kasumi_decryption(&kasumi_test_case_3);
3624 test_kasumi_decryption_test_case_4(void)
3626 return test_kasumi_decryption(&kasumi_test_case_4);
3630 test_kasumi_decryption_test_case_5(void)
3632 return test_kasumi_decryption(&kasumi_test_case_5);
3635 test_snow3g_encryption_test_case_1(void)
3637 return test_snow3g_encryption(&snow3g_test_case_1);
3641 test_snow3g_encryption_test_case_1_oop(void)
3643 return test_snow3g_encryption_oop(&snow3g_test_case_1);
3647 test_snow3g_encryption_test_case_1_offset_oop(void)
3649 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
3653 test_snow3g_encryption_test_case_2(void)
3655 return test_snow3g_encryption(&snow3g_test_case_2);
3659 test_snow3g_encryption_test_case_3(void)
3661 return test_snow3g_encryption(&snow3g_test_case_3);
3665 test_snow3g_encryption_test_case_4(void)
3667 return test_snow3g_encryption(&snow3g_test_case_4);
3671 test_snow3g_encryption_test_case_5(void)
3673 return test_snow3g_encryption(&snow3g_test_case_5);
3677 test_snow3g_decryption_test_case_1(void)
3679 return test_snow3g_decryption(&snow3g_test_case_1);
3683 test_snow3g_decryption_test_case_1_oop(void)
3685 return test_snow3g_decryption_oop(&snow3g_test_case_1);
3689 test_snow3g_decryption_test_case_2(void)
3691 return test_snow3g_decryption(&snow3g_test_case_2);
3695 test_snow3g_decryption_test_case_3(void)
3697 return test_snow3g_decryption(&snow3g_test_case_3);
3701 test_snow3g_decryption_test_case_4(void)
3703 return test_snow3g_decryption(&snow3g_test_case_4);
3707 test_snow3g_decryption_test_case_5(void)
3709 return test_snow3g_decryption(&snow3g_test_case_5);
3712 test_snow3g_cipher_auth_test_case_1(void)
3714 return test_snow3g_cipher_auth(&snow3g_test_case_3);
3718 test_snow3g_auth_cipher_test_case_1(void)
3720 return test_snow3g_auth_cipher(&snow3g_test_case_6);
3724 test_kasumi_auth_cipher_test_case_1(void)
3726 return test_kasumi_auth_cipher(&kasumi_test_case_3);
3730 test_kasumi_cipher_auth_test_case_1(void)
3732 return test_kasumi_cipher_auth(&kasumi_test_case_6);
3736 test_zuc_encryption_test_case_1(void)
3738 return test_zuc_encryption(&zuc_test_case_1);
3742 test_zuc_encryption_test_case_2(void)
3744 return test_zuc_encryption(&zuc_test_case_2);
3748 test_zuc_encryption_test_case_3(void)
3750 return test_zuc_encryption(&zuc_test_case_3);
3754 test_zuc_encryption_test_case_4(void)
3756 return test_zuc_encryption(&zuc_test_case_4);
3760 test_zuc_encryption_test_case_5(void)
3762 return test_zuc_encryption(&zuc_test_case_5);
3766 test_zuc_hash_generate_test_case_1(void)
3768 return test_zuc_authentication(&zuc_hash_test_case_1);
3772 test_zuc_hash_generate_test_case_2(void)
3774 return test_zuc_authentication(&zuc_hash_test_case_2);
3778 test_zuc_hash_generate_test_case_3(void)
3780 return test_zuc_authentication(&zuc_hash_test_case_3);
3784 test_zuc_hash_generate_test_case_4(void)
3786 return test_zuc_authentication(&zuc_hash_test_case_4);
3790 test_zuc_hash_generate_test_case_5(void)
3792 return test_zuc_authentication(&zuc_hash_test_case_5);
3796 test_3DES_chain_qat_all(void)
3798 struct crypto_testsuite_params *ts_params = &testsuite_params;
3801 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3802 ts_params->op_mpool, ts_params->valid_devs[0],
3803 RTE_CRYPTODEV_QAT_SYM_PMD,
3804 BLKCIPHER_3DES_CHAIN_TYPE);
3806 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3808 return TEST_SUCCESS;
3812 test_3DES_cipheronly_qat_all(void)
3814 struct crypto_testsuite_params *ts_params = &testsuite_params;
3817 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3818 ts_params->op_mpool, ts_params->valid_devs[0],
3819 RTE_CRYPTODEV_QAT_SYM_PMD,
3820 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3822 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3824 return TEST_SUCCESS;
3828 test_3DES_chain_libcrypto_all(void)
3830 struct crypto_testsuite_params *ts_params = &testsuite_params;
3833 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3834 ts_params->op_mpool, ts_params->valid_devs[0],
3835 RTE_CRYPTODEV_LIBCRYPTO_PMD,
3836 BLKCIPHER_3DES_CHAIN_TYPE);
3838 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3840 return TEST_SUCCESS;
3844 test_3DES_cipheronly_libcrypto_all(void)
3846 struct crypto_testsuite_params *ts_params = &testsuite_params;
3849 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3850 ts_params->op_mpool, ts_params->valid_devs[0],
3851 RTE_CRYPTODEV_LIBCRYPTO_PMD,
3852 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3854 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3856 return TEST_SUCCESS;
3859 /* ***** AES-GCM Tests ***** */
3862 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3863 const uint8_t *key, const uint8_t key_len,
3864 const uint8_t aad_len, const uint8_t auth_len,
3865 enum rte_crypto_auth_operation auth_op)
3867 uint8_t cipher_key[key_len];
3869 struct crypto_unittest_params *ut_params = &unittest_params;
3871 memcpy(cipher_key, key, key_len);
3873 /* Setup Cipher Parameters */
3874 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3875 ut_params->cipher_xform.next = NULL;
3877 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3878 ut_params->auth_xform.auth.op = auth_op;
3879 ut_params->cipher_xform.cipher.op = op;
3880 ut_params->cipher_xform.cipher.key.data = cipher_key;
3881 ut_params->cipher_xform.cipher.key.length = key_len;
3883 TEST_HEXDUMP(stdout, "key:", key, key_len);
3885 /* Setup Authentication Parameters */
3886 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3887 ut_params->auth_xform.next = NULL;
3889 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3891 ut_params->auth_xform.auth.digest_length = auth_len;
3892 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3893 ut_params->auth_xform.auth.key.length = 0;
3894 ut_params->auth_xform.auth.key.data = NULL;
3896 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3897 ut_params->cipher_xform.next = &ut_params->auth_xform;
3899 /* Create Crypto session*/
3900 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3901 &ut_params->cipher_xform);
3902 } else {/* Create Crypto session*/
3903 ut_params->auth_xform.next = &ut_params->cipher_xform;
3904 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3905 &ut_params->auth_xform);
3908 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3914 create_gcm_operation(enum rte_crypto_cipher_operation op,
3915 const uint8_t *auth_tag, const unsigned auth_tag_len,
3916 const uint8_t *iv, const unsigned iv_len,
3917 const uint8_t *aad, const unsigned aad_len,
3918 const unsigned data_len, unsigned data_pad_len)
3920 struct crypto_testsuite_params *ts_params = &testsuite_params;
3921 struct crypto_unittest_params *ut_params = &unittest_params;
3923 unsigned iv_pad_len = 0, aad_buffer_len;
3925 /* Generate Crypto op data structure */
3926 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3927 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3928 TEST_ASSERT_NOT_NULL(ut_params->op,
3929 "Failed to allocate symmetric crypto operation struct");
3931 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3933 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3934 ut_params->ibuf, auth_tag_len);
3935 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3936 "no room to append digest");
3937 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3938 ut_params->ibuf, data_pad_len);
3939 sym_op->auth.digest.length = auth_tag_len;
3941 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3942 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3943 TEST_HEXDUMP(stdout, "digest:",
3944 sym_op->auth.digest.data,
3945 sym_op->auth.digest.length);
3949 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3951 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3952 ut_params->ibuf, iv_pad_len);
3953 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3955 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3956 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3957 sym_op->cipher.iv.length = iv_len;
3959 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3962 * Always allocate the aad up to the block size.
3963 * The cryptodev API calls out -
3964 * - the array must be big enough to hold the AAD, plus any
3965 * space to round this up to the nearest multiple of the
3966 * block size (16 bytes).
3968 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
3970 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
3971 ut_params->ibuf, aad_buffer_len);
3972 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
3973 "no room to prepend aad");
3974 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
3976 sym_op->auth.aad.length = aad_len;
3978 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
3979 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
3981 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
3982 TEST_HEXDUMP(stdout, "aad:",
3983 sym_op->auth.aad.data, aad_len);
3985 sym_op->cipher.data.length = data_len;
3986 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
3988 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
3989 sym_op->auth.data.length = data_len;
3995 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
3997 struct crypto_testsuite_params *ts_params = &testsuite_params;
3998 struct crypto_unittest_params *ut_params = &unittest_params;
4002 uint8_t *plaintext, *ciphertext, *auth_tag;
4003 uint16_t plaintext_pad_len;
4005 /* Create GCM session */
4006 retval = create_gcm_session(ts_params->valid_devs[0],
4007 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4008 tdata->key.data, tdata->key.len,
4009 tdata->aad.len, tdata->auth_tag.len,
4010 RTE_CRYPTO_AUTH_OP_GENERATE);
4015 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4017 /* clear mbuf payload */
4018 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4019 rte_pktmbuf_tailroom(ut_params->ibuf));
4022 * Append data which is padded to a multiple
4023 * of the algorithms block size
4025 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4027 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4029 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4031 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4033 /* Create GCM opertaion */
4034 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4035 tdata->auth_tag.data, tdata->auth_tag.len,
4036 tdata->iv.data, tdata->iv.len,
4037 tdata->aad.data, tdata->aad.len,
4038 tdata->plaintext.len, plaintext_pad_len);
4042 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4044 ut_params->op->sym->m_src = ut_params->ibuf;
4046 /* Process crypto operation */
4047 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4048 ut_params->op), "failed to process sym crypto op");
4050 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4051 "crypto op processing failed");
4053 if (ut_params->op->sym->m_dst) {
4054 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4056 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4057 uint8_t *, plaintext_pad_len);
4059 ciphertext = plaintext;
4060 auth_tag = plaintext + plaintext_pad_len;
4063 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4064 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4067 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4069 tdata->ciphertext.data,
4070 tdata->ciphertext.len,
4071 "GCM Ciphertext data not as expected");
4073 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4075 tdata->auth_tag.data,
4076 tdata->auth_tag.len,
4077 "GCM Generated auth tag not as expected");
4084 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4086 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4090 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4092 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4096 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4098 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4102 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4104 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4108 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4110 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4114 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4116 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4120 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4122 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4126 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4128 struct crypto_testsuite_params *ts_params = &testsuite_params;
4129 struct crypto_unittest_params *ut_params = &unittest_params;
4133 uint8_t *plaintext, *ciphertext;
4134 uint16_t ciphertext_pad_len;
4136 /* Create GCM session */
4137 retval = create_gcm_session(ts_params->valid_devs[0],
4138 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4139 tdata->key.data, tdata->key.len,
4140 tdata->aad.len, tdata->auth_tag.len,
4141 RTE_CRYPTO_AUTH_OP_VERIFY);
4146 /* alloc mbuf and set payload */
4147 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4149 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4150 rte_pktmbuf_tailroom(ut_params->ibuf));
4152 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4154 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4155 ciphertext_pad_len);
4156 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
4158 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4160 /* Create GCM opertaion */
4161 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
4162 tdata->auth_tag.data, tdata->auth_tag.len,
4163 tdata->iv.data, tdata->iv.len,
4164 tdata->aad.data, tdata->aad.len,
4165 tdata->ciphertext.len, ciphertext_pad_len);
4170 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4172 ut_params->op->sym->m_src = ut_params->ibuf;
4174 /* Process crypto operation */
4175 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4176 ut_params->op), "failed to process sym crypto op");
4178 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4179 "crypto op processing failed");
4181 if (ut_params->op->sym->m_dst)
4182 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4185 plaintext = ciphertext;
4187 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4190 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4192 tdata->plaintext.data,
4193 tdata->plaintext.len,
4194 "GCM plaintext data not as expected");
4196 TEST_ASSERT_EQUAL(ut_params->op->status,
4197 RTE_CRYPTO_OP_STATUS_SUCCESS,
4198 "GCM authentication failed");
4203 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4205 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4209 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4211 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4215 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4217 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4221 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4223 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4227 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4229 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4233 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4235 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4239 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4241 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4247 struct crypto_testsuite_params *ts_params = &testsuite_params;
4248 struct rte_cryptodev_stats stats;
4249 struct rte_cryptodev *dev;
4250 cryptodev_stats_get_t temp_pfn;
4252 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4253 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
4254 &stats) == -ENODEV),
4255 "rte_cryptodev_stats_get invalid dev failed");
4256 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
4257 "rte_cryptodev_stats_get invalid Param failed");
4258 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
4259 temp_pfn = dev->dev_ops->stats_get;
4260 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
4261 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
4263 "rte_cryptodev_stats_get invalid Param failed");
4264 dev->dev_ops->stats_get = temp_pfn;
4266 /* Test expected values */
4268 test_AES_CBC_HMAC_SHA1_encrypt_digest();
4270 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4272 "rte_cryptodev_stats_get failed");
4273 TEST_ASSERT((stats.enqueued_count == 1),
4274 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4275 TEST_ASSERT((stats.dequeued_count == 1),
4276 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4277 TEST_ASSERT((stats.enqueue_err_count == 0),
4278 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4279 TEST_ASSERT((stats.dequeue_err_count == 0),
4280 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4282 /* invalid device but should ignore and not reset device stats*/
4283 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
4284 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4286 "rte_cryptodev_stats_get failed");
4287 TEST_ASSERT((stats.enqueued_count == 1),
4288 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4290 /* check that a valid reset clears stats */
4291 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4292 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4294 "rte_cryptodev_stats_get failed");
4295 TEST_ASSERT((stats.enqueued_count == 0),
4296 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4297 TEST_ASSERT((stats.dequeued_count == 0),
4298 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4300 return TEST_SUCCESS;
4303 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
4304 struct crypto_unittest_params *ut_params,
4305 enum rte_crypto_auth_operation op,
4306 const struct HMAC_MD5_vector *test_case)
4310 memcpy(key, test_case->key.data, test_case->key.len);
4312 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4313 ut_params->auth_xform.next = NULL;
4314 ut_params->auth_xform.auth.op = op;
4316 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
4318 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
4319 ut_params->auth_xform.auth.add_auth_data_length = 0;
4320 ut_params->auth_xform.auth.key.length = test_case->key.len;
4321 ut_params->auth_xform.auth.key.data = key;
4323 ut_params->sess = rte_cryptodev_sym_session_create(
4324 ts_params->valid_devs[0], &ut_params->auth_xform);
4326 if (ut_params->sess == NULL)
4329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4331 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4332 rte_pktmbuf_tailroom(ut_params->ibuf));
4337 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
4338 const struct HMAC_MD5_vector *test_case,
4339 uint8_t **plaintext)
4341 uint16_t plaintext_pad_len;
4343 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4345 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4348 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4350 memcpy(*plaintext, test_case->plaintext.data,
4351 test_case->plaintext.len);
4353 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4354 ut_params->ibuf, MD5_DIGEST_LEN);
4355 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4356 "no room to append digest");
4357 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4358 ut_params->ibuf, plaintext_pad_len);
4359 sym_op->auth.digest.length = MD5_DIGEST_LEN;
4361 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
4362 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
4363 test_case->auth_tag.len);
4366 sym_op->auth.data.offset = 0;
4367 sym_op->auth.data.length = test_case->plaintext.len;
4369 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4370 ut_params->op->sym->m_src = ut_params->ibuf;
4376 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
4378 uint16_t plaintext_pad_len;
4379 uint8_t *plaintext, *auth_tag;
4381 struct crypto_testsuite_params *ts_params = &testsuite_params;
4382 struct crypto_unittest_params *ut_params = &unittest_params;
4384 if (MD5_HMAC_create_session(ts_params, ut_params,
4385 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
4388 /* Generate Crypto op data structure */
4389 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4390 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4391 TEST_ASSERT_NOT_NULL(ut_params->op,
4392 "Failed to allocate symmetric crypto operation struct");
4394 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4397 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4400 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4401 ut_params->op), "failed to process sym crypto op");
4403 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4404 "crypto op processing failed");
4406 if (ut_params->op->sym->m_dst) {
4407 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4408 uint8_t *, plaintext_pad_len);
4410 auth_tag = plaintext + plaintext_pad_len;
4413 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4415 test_case->auth_tag.data,
4416 test_case->auth_tag.len,
4417 "HMAC_MD5 generated tag not as expected");
4419 return TEST_SUCCESS;
4423 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
4427 struct crypto_testsuite_params *ts_params = &testsuite_params;
4428 struct crypto_unittest_params *ut_params = &unittest_params;
4430 if (MD5_HMAC_create_session(ts_params, ut_params,
4431 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
4435 /* Generate Crypto op data structure */
4436 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4437 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4438 TEST_ASSERT_NOT_NULL(ut_params->op,
4439 "Failed to allocate symmetric crypto operation struct");
4441 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4444 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4445 ut_params->op), "failed to process sym crypto op");
4447 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4448 "HMAC_MD5 crypto op processing failed");
4450 return TEST_SUCCESS;
4454 test_MD5_HMAC_generate_case_1(void)
4456 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
4460 test_MD5_HMAC_verify_case_1(void)
4462 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
4466 test_MD5_HMAC_generate_case_2(void)
4468 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
4472 test_MD5_HMAC_verify_case_2(void)
4474 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
4478 test_multi_session(void)
4480 struct crypto_testsuite_params *ts_params = &testsuite_params;
4481 struct crypto_unittest_params *ut_params = &unittest_params;
4483 struct rte_cryptodev_info dev_info;
4484 struct rte_cryptodev_sym_session **sessions;
4488 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
4489 aes_cbc_key, hmac_sha512_key);
4492 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4494 sessions = rte_malloc(NULL,
4495 (sizeof(struct rte_cryptodev_sym_session *) *
4496 dev_info.sym.max_nb_sessions) + 1, 0);
4498 /* Create multiple crypto sessions*/
4499 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
4500 sessions[i] = rte_cryptodev_sym_session_create(
4501 ts_params->valid_devs[0],
4502 &ut_params->auth_xform);
4503 TEST_ASSERT_NOT_NULL(sessions[i],
4504 "Session creation failed at session number %u",
4507 /* Attempt to send a request on each session */
4508 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
4512 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
4513 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
4515 "Failed to perform decrypt on request number %u.", i);
4516 /* free crypto operation structure */
4518 rte_crypto_op_free(ut_params->op);
4521 * free mbuf - both obuf and ibuf are usually the same,
4522 * so check if they point at the same address is necessary,
4523 * to avoid freeing the mbuf twice.
4525 if (ut_params->obuf) {
4526 rte_pktmbuf_free(ut_params->obuf);
4527 if (ut_params->ibuf == ut_params->obuf)
4528 ut_params->ibuf = 0;
4529 ut_params->obuf = 0;
4531 if (ut_params->ibuf) {
4532 rte_pktmbuf_free(ut_params->ibuf);
4533 ut_params->ibuf = 0;
4537 /* Next session create should fail */
4538 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
4539 &ut_params->auth_xform);
4540 TEST_ASSERT_NULL(sessions[i],
4541 "Session creation succeeded unexpectedly!");
4543 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
4544 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4549 return TEST_SUCCESS;
4552 struct multi_session_params {
4553 struct crypto_unittest_params ut_params;
4554 uint8_t *cipher_key;
4556 const uint8_t *cipher;
4557 const uint8_t *digest;
4561 #define MB_SESSION_NUMBER 3
4564 test_multi_session_random_usage(void)
4566 struct crypto_testsuite_params *ts_params = &testsuite_params;
4567 struct rte_cryptodev_info dev_info;
4568 struct rte_cryptodev_sym_session **sessions;
4570 struct multi_session_params ut_paramz[] = {
4573 .cipher_key = ms_aes_cbc_key0,
4574 .hmac_key = ms_hmac_key0,
4575 .cipher = ms_aes_cbc_cipher0,
4576 .digest = ms_hmac_digest0,
4577 .iv = ms_aes_cbc_iv0
4580 .cipher_key = ms_aes_cbc_key1,
4581 .hmac_key = ms_hmac_key1,
4582 .cipher = ms_aes_cbc_cipher1,
4583 .digest = ms_hmac_digest1,
4584 .iv = ms_aes_cbc_iv1
4587 .cipher_key = ms_aes_cbc_key2,
4588 .hmac_key = ms_hmac_key2,
4589 .cipher = ms_aes_cbc_cipher2,
4590 .digest = ms_hmac_digest2,
4591 .iv = ms_aes_cbc_iv2
4596 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4598 sessions = rte_malloc(NULL,
4599 (sizeof(struct rte_cryptodev_sym_session *)
4600 * dev_info.sym.max_nb_sessions) + 1, 0);
4602 for (i = 0; i < MB_SESSION_NUMBER; i++) {
4603 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
4604 sizeof(struct crypto_unittest_params));
4606 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
4607 &ut_paramz[i].ut_params,
4608 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
4610 /* Create multiple crypto sessions*/
4611 sessions[i] = rte_cryptodev_sym_session_create(
4612 ts_params->valid_devs[0],
4613 &ut_paramz[i].ut_params.auth_xform);
4615 TEST_ASSERT_NOT_NULL(sessions[i],
4616 "Session creation failed at session number %u",
4622 for (i = 0; i < 40000; i++) {
4624 j = rand() % MB_SESSION_NUMBER;
4626 TEST_ASSERT_SUCCESS(
4627 test_AES_CBC_HMAC_SHA512_decrypt_perform(
4629 &ut_paramz[j].ut_params,
4630 ts_params, ut_paramz[j].cipher,
4631 ut_paramz[j].digest,
4633 "Failed to perform decrypt on request number %u.", i);
4635 if (ut_paramz[j].ut_params.op)
4636 rte_crypto_op_free(ut_paramz[j].ut_params.op);
4639 * free mbuf - both obuf and ibuf are usually the same,
4640 * so check if they point at the same address is necessary,
4641 * to avoid freeing the mbuf twice.
4643 if (ut_paramz[j].ut_params.obuf) {
4644 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
4645 if (ut_paramz[j].ut_params.ibuf
4646 == ut_paramz[j].ut_params.obuf)
4647 ut_paramz[j].ut_params.ibuf = 0;
4648 ut_paramz[j].ut_params.obuf = 0;
4650 if (ut_paramz[j].ut_params.ibuf) {
4651 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
4652 ut_paramz[j].ut_params.ibuf = 0;
4656 for (i = 0; i < MB_SESSION_NUMBER; i++)
4657 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4662 return TEST_SUCCESS;
4666 test_null_cipher_only_operation(void)
4668 struct crypto_testsuite_params *ts_params = &testsuite_params;
4669 struct crypto_unittest_params *ut_params = &unittest_params;
4671 /* Generate test mbuf data and space for digest */
4672 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4673 catch_22_quote, QUOTE_512_BYTES, 0);
4675 /* Setup Cipher Parameters */
4676 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4677 ut_params->cipher_xform.next = NULL;
4679 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4680 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4682 /* Create Crypto session*/
4683 ut_params->sess = rte_cryptodev_sym_session_create(
4684 ts_params->valid_devs[0], &ut_params->cipher_xform);
4685 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4687 /* Generate Crypto op data structure */
4688 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4689 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4690 TEST_ASSERT_NOT_NULL(ut_params->op,
4691 "Failed to allocate symmetric crypto operation struct");
4693 /* Set crypto operation data parameters */
4694 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4696 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4698 /* set crypto operation source mbuf */
4699 sym_op->m_src = ut_params->ibuf;
4701 sym_op->cipher.data.offset = 0;
4702 sym_op->cipher.data.length = QUOTE_512_BYTES;
4704 /* Process crypto operation */
4705 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4707 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4709 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4710 "crypto operation processing failed");
4713 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4714 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4717 "Ciphertext data not as expected");
4719 return TEST_SUCCESS;
4723 test_null_auth_only_operation(void)
4725 struct crypto_testsuite_params *ts_params = &testsuite_params;
4726 struct crypto_unittest_params *ut_params = &unittest_params;
4728 /* Generate test mbuf data and space for digest */
4729 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4730 catch_22_quote, QUOTE_512_BYTES, 0);
4732 /* Setup HMAC Parameters */
4733 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4734 ut_params->auth_xform.next = NULL;
4736 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4737 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4739 /* Create Crypto session*/
4740 ut_params->sess = rte_cryptodev_sym_session_create(
4741 ts_params->valid_devs[0], &ut_params->auth_xform);
4742 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4744 /* Generate Crypto op data structure */
4745 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4746 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4747 TEST_ASSERT_NOT_NULL(ut_params->op,
4748 "Failed to allocate symmetric crypto operation struct");
4750 /* Set crypto operation data parameters */
4751 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4753 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4755 sym_op->m_src = ut_params->ibuf;
4757 sym_op->auth.data.offset = 0;
4758 sym_op->auth.data.length = QUOTE_512_BYTES;
4760 /* Process crypto operation */
4761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4763 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4765 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4766 "crypto operation processing failed");
4768 return TEST_SUCCESS;
4772 test_null_cipher_auth_operation(void)
4774 struct crypto_testsuite_params *ts_params = &testsuite_params;
4775 struct crypto_unittest_params *ut_params = &unittest_params;
4777 /* Generate test mbuf data and space for digest */
4778 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4779 catch_22_quote, QUOTE_512_BYTES, 0);
4781 /* Setup Cipher Parameters */
4782 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4783 ut_params->cipher_xform.next = &ut_params->auth_xform;
4785 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4786 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4788 /* Setup HMAC Parameters */
4789 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4790 ut_params->auth_xform.next = NULL;
4792 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4793 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4795 /* Create Crypto session*/
4796 ut_params->sess = rte_cryptodev_sym_session_create(
4797 ts_params->valid_devs[0], &ut_params->cipher_xform);
4798 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4800 /* Generate Crypto op data structure */
4801 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4802 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4803 TEST_ASSERT_NOT_NULL(ut_params->op,
4804 "Failed to allocate symmetric crypto operation struct");
4806 /* Set crypto operation data parameters */
4807 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4809 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4811 sym_op->m_src = ut_params->ibuf;
4813 sym_op->cipher.data.offset = 0;
4814 sym_op->cipher.data.length = QUOTE_512_BYTES;
4816 sym_op->auth.data.offset = 0;
4817 sym_op->auth.data.length = QUOTE_512_BYTES;
4819 /* Process crypto operation */
4820 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4822 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4824 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4825 "crypto operation processing failed");
4828 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4829 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4832 "Ciphertext data not as expected");
4834 return TEST_SUCCESS;
4838 test_null_auth_cipher_operation(void)
4840 struct crypto_testsuite_params *ts_params = &testsuite_params;
4841 struct crypto_unittest_params *ut_params = &unittest_params;
4843 /* Generate test mbuf data and space for digest */
4844 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4845 catch_22_quote, QUOTE_512_BYTES, 0);
4847 /* Setup Cipher Parameters */
4848 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4849 ut_params->cipher_xform.next = NULL;
4851 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4852 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4854 /* Setup HMAC Parameters */
4855 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4856 ut_params->auth_xform.next = &ut_params->cipher_xform;
4858 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4859 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4861 /* Create Crypto session*/
4862 ut_params->sess = rte_cryptodev_sym_session_create(
4863 ts_params->valid_devs[0], &ut_params->cipher_xform);
4864 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4866 /* Generate Crypto op data structure */
4867 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4868 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4869 TEST_ASSERT_NOT_NULL(ut_params->op,
4870 "Failed to allocate symmetric crypto operation struct");
4872 /* Set crypto operation data parameters */
4873 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4875 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4877 sym_op->m_src = ut_params->ibuf;
4879 sym_op->cipher.data.offset = 0;
4880 sym_op->cipher.data.length = QUOTE_512_BYTES;
4882 sym_op->auth.data.offset = 0;
4883 sym_op->auth.data.length = QUOTE_512_BYTES;
4885 /* Process crypto operation */
4886 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4888 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4890 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4891 "crypto operation processing failed");
4894 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4895 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4898 "Ciphertext data not as expected");
4900 return TEST_SUCCESS;
4905 test_null_invalid_operation(void)
4907 struct crypto_testsuite_params *ts_params = &testsuite_params;
4908 struct crypto_unittest_params *ut_params = &unittest_params;
4910 /* Setup Cipher Parameters */
4911 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4912 ut_params->cipher_xform.next = NULL;
4914 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
4915 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4917 /* Create Crypto session*/
4918 ut_params->sess = rte_cryptodev_sym_session_create(
4919 ts_params->valid_devs[0], &ut_params->cipher_xform);
4920 TEST_ASSERT_NULL(ut_params->sess,
4921 "Session creation succeeded unexpectedly");
4924 /* Setup HMAC Parameters */
4925 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4926 ut_params->auth_xform.next = NULL;
4928 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
4929 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4931 /* Create Crypto session*/
4932 ut_params->sess = rte_cryptodev_sym_session_create(
4933 ts_params->valid_devs[0], &ut_params->auth_xform);
4934 TEST_ASSERT_NULL(ut_params->sess,
4935 "Session creation succeeded unexpectedly");
4937 return TEST_SUCCESS;
4941 #define NULL_BURST_LENGTH (32)
4944 test_null_burst_operation(void)
4946 struct crypto_testsuite_params *ts_params = &testsuite_params;
4947 struct crypto_unittest_params *ut_params = &unittest_params;
4949 unsigned i, burst_len = NULL_BURST_LENGTH;
4951 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
4952 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
4954 /* Setup Cipher Parameters */
4955 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4956 ut_params->cipher_xform.next = &ut_params->auth_xform;
4958 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4959 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4961 /* Setup HMAC Parameters */
4962 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4963 ut_params->auth_xform.next = NULL;
4965 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4966 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4968 /* Create Crypto session*/
4969 ut_params->sess = rte_cryptodev_sym_session_create(
4970 ts_params->valid_devs[0], &ut_params->cipher_xform);
4971 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4973 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
4974 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
4975 burst_len, "failed to generate burst of crypto ops");
4977 /* Generate an operation for each mbuf in burst */
4978 for (i = 0; i < burst_len; i++) {
4979 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4981 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
4983 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
4987 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
4989 burst[i]->sym->m_src = m;
4992 /* Process crypto operation */
4993 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
4994 0, burst, burst_len),
4996 "Error enqueuing burst");
4998 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
4999 0, burst_dequeued, burst_len),
5001 "Error dequeuing burst");
5004 for (i = 0; i < burst_len; i++) {
5006 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
5007 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
5009 "data not as expected");
5011 rte_pktmbuf_free(burst[i]->sym->m_src);
5012 rte_crypto_op_free(burst[i]);
5015 return TEST_SUCCESS;
5019 generate_gmac_large_plaintext(uint8_t *data)
5023 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5024 memcpy(&data[i], &data[0], 32);
5028 create_gmac_operation(enum rte_crypto_auth_operation op,
5029 const struct gmac_test_data *tdata)
5031 struct crypto_testsuite_params *ts_params = &testsuite_params;
5032 struct crypto_unittest_params *ut_params = &unittest_params;
5033 struct rte_crypto_sym_op *sym_op;
5035 unsigned iv_pad_len;
5036 unsigned aad_pad_len;
5038 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5039 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5042 * Runtime generate the large plain text instead of use hard code
5043 * plain text vector. It is done to avoid create huge source file
5044 * with the test vector.
5046 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5047 generate_gmac_large_plaintext(tdata->aad.data);
5049 /* Generate Crypto op data structure */
5050 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5051 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5052 TEST_ASSERT_NOT_NULL(ut_params->op,
5053 "Failed to allocate symmetric crypto operation struct");
5055 sym_op = ut_params->op->sym;
5056 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5058 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5059 "no room to append aad");
5061 sym_op->auth.aad.length = tdata->aad.len;
5062 sym_op->auth.aad.phys_addr =
5063 rte_pktmbuf_mtophys(ut_params->ibuf);
5064 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5066 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5067 ut_params->ibuf, tdata->gmac_tag.len);
5068 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5069 "no room to append digest");
5071 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5072 ut_params->ibuf, aad_pad_len);
5073 sym_op->auth.digest.length = tdata->gmac_tag.len;
5075 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5076 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
5077 tdata->gmac_tag.len);
5078 TEST_HEXDUMP(stdout, "digest:",
5079 sym_op->auth.digest.data,
5080 sym_op->auth.digest.length);
5083 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5084 ut_params->ibuf, iv_pad_len);
5085 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5087 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5088 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5089 sym_op->cipher.iv.length = tdata->iv.len;
5091 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
5093 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
5095 sym_op->cipher.data.length = 0;
5096 sym_op->cipher.data.offset = 0;
5098 sym_op->auth.data.offset = 0;
5099 sym_op->auth.data.length = 0;
5104 static int create_gmac_session(uint8_t dev_id,
5105 enum rte_crypto_cipher_operation op,
5106 const struct gmac_test_data *tdata,
5107 enum rte_crypto_auth_operation auth_op)
5109 uint8_t cipher_key[tdata->key.len];
5111 struct crypto_unittest_params *ut_params = &unittest_params;
5113 memcpy(cipher_key, tdata->key.data, tdata->key.len);
5115 /* For GMAC we setup cipher parameters */
5116 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5117 ut_params->cipher_xform.next = NULL;
5118 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
5119 ut_params->cipher_xform.cipher.op = op;
5120 ut_params->cipher_xform.cipher.key.data = cipher_key;
5121 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
5123 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5124 ut_params->auth_xform.next = NULL;
5126 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
5127 ut_params->auth_xform.auth.op = auth_op;
5128 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
5129 ut_params->auth_xform.auth.add_auth_data_length = 0;
5130 ut_params->auth_xform.auth.key.length = 0;
5131 ut_params->auth_xform.auth.key.data = NULL;
5133 ut_params->cipher_xform.next = &ut_params->auth_xform;
5135 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5136 &ut_params->cipher_xform);
5138 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5144 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
5146 struct crypto_testsuite_params *ts_params = &testsuite_params;
5147 struct crypto_unittest_params *ut_params = &unittest_params;
5151 uint8_t *auth_tag, *p;
5152 uint16_t aad_pad_len;
5154 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5155 "No GMAC length in the source data");
5157 retval = create_gmac_session(ts_params->valid_devs[0],
5158 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5159 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
5164 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5166 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5167 rte_pktmbuf_tailroom(ut_params->ibuf));
5169 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5171 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
5173 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
5179 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5181 ut_params->op->sym->m_src = ut_params->ibuf;
5183 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5184 ut_params->op), "failed to process sym crypto op");
5186 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5187 "crypto op processing failed");
5189 if (ut_params->op->sym->m_dst) {
5190 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5191 uint8_t *, aad_pad_len);
5193 auth_tag = p + aad_pad_len;
5196 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
5198 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5200 tdata->gmac_tag.data,
5201 tdata->gmac_tag.len,
5202 "GMAC Generated auth tag not as expected");
5208 test_AES_GMAC_authentication_test_case_1(void)
5210 return test_AES_GMAC_authentication(&gmac_test_case_1);
5214 test_AES_GMAC_authentication_test_case_2(void)
5216 return test_AES_GMAC_authentication(&gmac_test_case_2);
5220 test_AES_GMAC_authentication_test_case_3(void)
5222 return test_AES_GMAC_authentication(&gmac_test_case_3);
5226 test_AES_GMAC_authentication_test_case_4(void)
5228 return test_AES_GMAC_authentication(&gmac_test_case_4);
5232 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
5234 struct crypto_testsuite_params *ts_params = &testsuite_params;
5235 struct crypto_unittest_params *ut_params = &unittest_params;
5238 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5239 "No GMAC length in the source data");
5241 retval = create_gmac_session(ts_params->valid_devs[0],
5242 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5243 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
5248 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5250 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5251 rte_pktmbuf_tailroom(ut_params->ibuf));
5253 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
5259 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5261 ut_params->op->sym->m_src = ut_params->ibuf;
5263 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5264 ut_params->op), "failed to process sym crypto op");
5266 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5267 "crypto op processing failed");
5274 test_AES_GMAC_authentication_verify_test_case_1(void)
5276 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
5280 test_AES_GMAC_authentication_verify_test_case_2(void)
5282 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
5286 test_AES_GMAC_authentication_verify_test_case_3(void)
5288 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
5292 test_AES_GMAC_authentication_verify_test_case_4(void)
5294 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
5297 struct test_crypto_vector {
5298 enum rte_crypto_cipher_algorithm crypto_algo;
5311 const uint8_t *data;
5316 const uint8_t *data;
5320 enum rte_crypto_auth_algorithm auth_algo;
5328 const uint8_t *data;
5338 static const struct test_crypto_vector
5339 hmac_sha1_test_crypto_vector = {
5340 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5342 .data = plaintext_hash,
5347 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5348 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5349 0xDE, 0xF4, 0xDE, 0xAD
5355 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
5356 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
5357 0x3F, 0x91, 0x64, 0x59
5363 static const struct test_crypto_vector
5364 aes128_gmac_test_vector = {
5365 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
5366 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
5368 .data = plaintext_hash,
5373 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5374 0x08, 0x09, 0x0A, 0x0B
5380 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5381 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
5387 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
5388 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
5394 static const struct test_crypto_vector
5395 aes128cbc_hmac_sha1_test_vector = {
5396 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
5399 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
5400 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
5406 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5407 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
5412 .data = plaintext_hash,
5416 .data = ciphertext512_aes128cbc,
5419 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5422 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5423 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5424 0xDE, 0xF4, 0xDE, 0xAD
5430 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
5431 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5432 0x18, 0x8C, 0x1D, 0x32
5439 data_corruption(uint8_t *data)
5445 tag_corruption(uint8_t *data, unsigned int tag_offset)
5447 data[tag_offset] += 1;
5451 create_auth_session(struct crypto_unittest_params *ut_params,
5453 const struct test_crypto_vector *reference,
5454 enum rte_crypto_auth_operation auth_op)
5456 uint8_t auth_key[reference->auth_key.len + 1];
5458 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5460 /* Setup Authentication Parameters */
5461 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5462 ut_params->auth_xform.auth.op = auth_op;
5463 ut_params->auth_xform.next = NULL;
5464 ut_params->auth_xform.auth.algo = reference->auth_algo;
5465 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5466 ut_params->auth_xform.auth.key.data = auth_key;
5467 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5468 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5470 /* Create Crypto session*/
5471 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5472 &ut_params->auth_xform);
5474 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5480 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
5482 const struct test_crypto_vector *reference,
5483 enum rte_crypto_auth_operation auth_op,
5484 enum rte_crypto_cipher_operation cipher_op)
5486 uint8_t cipher_key[reference->cipher_key.len + 1];
5487 uint8_t auth_key[reference->auth_key.len + 1];
5489 memcpy(cipher_key, reference->cipher_key.data,
5490 reference->cipher_key.len);
5491 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5493 /* Setup Authentication Parameters */
5494 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5495 ut_params->auth_xform.auth.op = auth_op;
5496 ut_params->auth_xform.next = &ut_params->cipher_xform;
5497 ut_params->auth_xform.auth.algo = reference->auth_algo;
5498 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5499 ut_params->auth_xform.auth.key.data = auth_key;
5500 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5501 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5503 /* Setup Cipher Parameters */
5504 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5505 ut_params->cipher_xform.next = NULL;
5506 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
5507 ut_params->cipher_xform.cipher.op = cipher_op;
5508 ut_params->cipher_xform.cipher.key.data = cipher_key;
5509 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
5511 /* Create Crypto session*/
5512 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5513 &ut_params->auth_xform);
5515 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5521 create_auth_operation(struct crypto_testsuite_params *ts_params,
5522 struct crypto_unittest_params *ut_params,
5523 const struct test_crypto_vector *reference,
5524 unsigned int auth_generate)
5526 /* Generate Crypto op data structure */
5527 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5528 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5529 TEST_ASSERT_NOT_NULL(ut_params->op,
5530 "Failed to allocate pktmbuf offload");
5532 /* Set crypto operation data parameters */
5533 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5535 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5537 /* set crypto operation source mbuf */
5538 sym_op->m_src = ut_params->ibuf;
5541 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5542 ut_params->ibuf, reference->digest.len);
5544 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5545 "no room to append auth tag");
5547 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5548 ut_params->ibuf, reference->plaintext.len);
5549 sym_op->auth.digest.length = reference->digest.len;
5552 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5554 memcpy(sym_op->auth.digest.data,
5555 reference->digest.data,
5556 reference->digest.len);
5558 TEST_HEXDUMP(stdout, "digest:",
5559 sym_op->auth.digest.data,
5560 sym_op->auth.digest.length);
5562 sym_op->auth.data.length = reference->plaintext.len;
5563 sym_op->auth.data.offset = 0;
5569 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
5570 struct crypto_unittest_params *ut_params,
5571 const struct test_crypto_vector *reference,
5572 unsigned int auth_generate)
5574 /* Generate Crypto op data structure */
5575 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5576 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5577 TEST_ASSERT_NOT_NULL(ut_params->op,
5578 "Failed to allocate pktmbuf offload");
5580 /* Set crypto operation data parameters */
5581 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5583 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5585 /* set crypto operation source mbuf */
5586 sym_op->m_src = ut_params->ibuf;
5589 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5590 reference->aad.len);
5591 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
5592 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
5594 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
5596 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5597 sym_op->auth.aad.length = reference->aad.len;
5600 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5601 ut_params->ibuf, reference->digest.len);
5603 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5604 "no room to append auth tag");
5606 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5607 ut_params->ibuf, reference->ciphertext.len);
5608 sym_op->auth.digest.length = reference->digest.len;
5611 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5613 memcpy(sym_op->auth.digest.data,
5614 reference->digest.data,
5615 reference->digest.len);
5617 TEST_HEXDUMP(stdout, "digest:",
5618 sym_op->auth.digest.data,
5619 sym_op->auth.digest.length);
5621 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5622 ut_params->ibuf, reference->iv.len);
5623 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5625 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5626 sym_op->cipher.iv.length = reference->iv.len;
5628 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5630 sym_op->cipher.data.length = 0;
5631 sym_op->cipher.data.offset = 0;
5633 sym_op->auth.data.length = 0;
5634 sym_op->auth.data.offset = 0;
5640 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
5641 struct crypto_unittest_params *ut_params,
5642 const struct test_crypto_vector *reference,
5643 unsigned int auth_generate)
5645 /* Generate Crypto op data structure */
5646 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5647 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5648 TEST_ASSERT_NOT_NULL(ut_params->op,
5649 "Failed to allocate pktmbuf offload");
5651 /* Set crypto operation data parameters */
5652 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5654 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5656 /* set crypto operation source mbuf */
5657 sym_op->m_src = ut_params->ibuf;
5660 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5661 ut_params->ibuf, reference->digest.len);
5663 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5664 "no room to append auth tag");
5666 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5667 ut_params->ibuf, reference->ciphertext.len);
5668 sym_op->auth.digest.length = reference->digest.len;
5671 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5673 memcpy(sym_op->auth.digest.data,
5674 reference->digest.data,
5675 reference->digest.len);
5677 TEST_HEXDUMP(stdout, "digest:",
5678 sym_op->auth.digest.data,
5679 sym_op->auth.digest.length);
5681 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5682 ut_params->ibuf, reference->iv.len);
5683 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5685 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5686 sym_op->cipher.iv.length = reference->iv.len;
5688 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5690 sym_op->cipher.data.length = reference->ciphertext.len;
5691 sym_op->cipher.data.offset = reference->iv.len;
5693 sym_op->auth.data.length = reference->ciphertext.len;
5694 sym_op->auth.data.offset = reference->iv.len;
5700 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5701 struct crypto_unittest_params *ut_params,
5702 const struct test_crypto_vector *reference)
5704 return create_auth_operation(ts_params, ut_params, reference, 0);
5708 create_auth_verify_GMAC_operation(
5709 struct crypto_testsuite_params *ts_params,
5710 struct crypto_unittest_params *ut_params,
5711 const struct test_crypto_vector *reference)
5713 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
5717 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5718 struct crypto_unittest_params *ut_params,
5719 const struct test_crypto_vector *reference)
5721 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
5725 test_authentication_verify_fail_when_data_corruption(
5726 struct crypto_testsuite_params *ts_params,
5727 struct crypto_unittest_params *ut_params,
5728 const struct test_crypto_vector *reference,
5729 unsigned int data_corrupted)
5735 /* Create session */
5736 retval = create_auth_session(ut_params,
5737 ts_params->valid_devs[0],
5739 RTE_CRYPTO_AUTH_OP_VERIFY);
5743 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5744 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5745 "Failed to allocate input buffer in mempool");
5747 /* clear mbuf payload */
5748 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5749 rte_pktmbuf_tailroom(ut_params->ibuf));
5751 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5752 reference->plaintext.len);
5753 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5754 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
5756 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
5758 /* Create operation */
5759 retval = create_auth_verify_operation(ts_params, ut_params, reference);
5765 data_corruption(plaintext);
5767 tag_corruption(plaintext, reference->plaintext.len);
5769 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5771 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5772 TEST_ASSERT_EQUAL(ut_params->op->status,
5773 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5774 "authentication not failed");
5776 ut_params->obuf = ut_params->op->sym->m_src;
5777 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5783 test_authentication_verify_GMAC_fail_when_corruption(
5784 struct crypto_testsuite_params *ts_params,
5785 struct crypto_unittest_params *ut_params,
5786 const struct test_crypto_vector *reference,
5787 unsigned int data_corrupted)
5791 /* Create session */
5792 retval = create_auth_cipher_session(ut_params,
5793 ts_params->valid_devs[0],
5795 RTE_CRYPTO_AUTH_OP_VERIFY,
5796 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5800 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5801 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5802 "Failed to allocate input buffer in mempool");
5804 /* clear mbuf payload */
5805 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5806 rte_pktmbuf_tailroom(ut_params->ibuf));
5808 /* Create operation */
5809 retval = create_auth_verify_GMAC_operation(ts_params,
5817 data_corruption(ut_params->op->sym->auth.aad.data);
5819 tag_corruption(ut_params->op->sym->auth.aad.data,
5820 reference->aad.len);
5822 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5824 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5825 TEST_ASSERT_EQUAL(ut_params->op->status,
5826 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5827 "authentication not failed");
5829 ut_params->obuf = ut_params->op->sym->m_src;
5830 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5836 test_authenticated_decryption_fail_when_corruption(
5837 struct crypto_testsuite_params *ts_params,
5838 struct crypto_unittest_params *ut_params,
5839 const struct test_crypto_vector *reference,
5840 unsigned int data_corrupted)
5844 uint8_t *ciphertext;
5846 /* Create session */
5847 retval = create_auth_cipher_session(ut_params,
5848 ts_params->valid_devs[0],
5850 RTE_CRYPTO_AUTH_OP_VERIFY,
5851 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5855 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5856 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5857 "Failed to allocate input buffer in mempool");
5859 /* clear mbuf payload */
5860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5861 rte_pktmbuf_tailroom(ut_params->ibuf));
5863 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5864 reference->ciphertext.len);
5865 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
5866 memcpy(ciphertext, reference->ciphertext.data,
5867 reference->ciphertext.len);
5869 /* Create operation */
5870 retval = create_cipher_auth_verify_operation(ts_params,
5878 data_corruption(ciphertext);
5880 tag_corruption(ciphertext, reference->ciphertext.len);
5882 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5885 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5886 TEST_ASSERT_EQUAL(ut_params->op->status,
5887 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5888 "authentication not failed");
5890 ut_params->obuf = ut_params->op->sym->m_src;
5891 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5897 test_authentication_verify_fail_when_data_corrupted(
5898 struct crypto_testsuite_params *ts_params,
5899 struct crypto_unittest_params *ut_params,
5900 const struct test_crypto_vector *reference)
5902 return test_authentication_verify_fail_when_data_corruption(
5903 ts_params, ut_params, reference, 1);
5907 test_authentication_verify_fail_when_tag_corrupted(
5908 struct crypto_testsuite_params *ts_params,
5909 struct crypto_unittest_params *ut_params,
5910 const struct test_crypto_vector *reference)
5912 return test_authentication_verify_fail_when_data_corruption(
5913 ts_params, ut_params, reference, 0);
5917 test_authentication_verify_GMAC_fail_when_data_corrupted(
5918 struct crypto_testsuite_params *ts_params,
5919 struct crypto_unittest_params *ut_params,
5920 const struct test_crypto_vector *reference)
5922 return test_authentication_verify_GMAC_fail_when_corruption(
5923 ts_params, ut_params, reference, 1);
5927 test_authentication_verify_GMAC_fail_when_tag_corrupted(
5928 struct crypto_testsuite_params *ts_params,
5929 struct crypto_unittest_params *ut_params,
5930 const struct test_crypto_vector *reference)
5932 return test_authentication_verify_GMAC_fail_when_corruption(
5933 ts_params, ut_params, reference, 0);
5937 test_authenticated_decryption_fail_when_data_corrupted(
5938 struct crypto_testsuite_params *ts_params,
5939 struct crypto_unittest_params *ut_params,
5940 const struct test_crypto_vector *reference)
5942 return test_authenticated_decryption_fail_when_corruption(
5943 ts_params, ut_params, reference, 1);
5947 test_authenticated_decryption_fail_when_tag_corrupted(
5948 struct crypto_testsuite_params *ts_params,
5949 struct crypto_unittest_params *ut_params,
5950 const struct test_crypto_vector *reference)
5952 return test_authenticated_decryption_fail_when_corruption(
5953 ts_params, ut_params, reference, 0);
5957 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
5959 return test_authentication_verify_fail_when_data_corrupted(
5960 &testsuite_params, &unittest_params,
5961 &hmac_sha1_test_crypto_vector);
5965 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
5967 return test_authentication_verify_fail_when_tag_corrupted(
5968 &testsuite_params, &unittest_params,
5969 &hmac_sha1_test_crypto_vector);
5973 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
5975 return test_authentication_verify_GMAC_fail_when_data_corrupted(
5976 &testsuite_params, &unittest_params,
5977 &aes128_gmac_test_vector);
5981 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
5983 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
5984 &testsuite_params, &unittest_params,
5985 &aes128_gmac_test_vector);
5989 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
5991 return test_authenticated_decryption_fail_when_data_corrupted(
5994 &aes128cbc_hmac_sha1_test_vector);
5998 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
6000 return test_authenticated_decryption_fail_when_tag_corrupted(
6003 &aes128cbc_hmac_sha1_test_vector);
6006 static struct unit_test_suite cryptodev_qat_testsuite = {
6007 .suite_name = "Crypto QAT Unit Test Suite",
6008 .setup = testsuite_setup,
6009 .teardown = testsuite_teardown,
6010 .unit_test_cases = {
6011 TEST_CASE_ST(ut_setup, ut_teardown,
6012 test_device_configure_invalid_dev_id),
6013 TEST_CASE_ST(ut_setup, ut_teardown,
6014 test_device_configure_invalid_queue_pair_ids),
6015 TEST_CASE_ST(ut_setup, ut_teardown,
6016 test_queue_pair_descriptor_setup),
6017 TEST_CASE_ST(ut_setup, ut_teardown,
6018 test_multi_session),
6020 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
6021 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
6022 TEST_CASE_ST(ut_setup, ut_teardown,
6023 test_3DES_cipheronly_qat_all),
6024 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
6026 /** AES GCM Authenticated Encryption */
6027 TEST_CASE_ST(ut_setup, ut_teardown,
6028 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6029 TEST_CASE_ST(ut_setup, ut_teardown,
6030 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6031 TEST_CASE_ST(ut_setup, ut_teardown,
6032 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6033 TEST_CASE_ST(ut_setup, ut_teardown,
6034 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6035 TEST_CASE_ST(ut_setup, ut_teardown,
6036 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6037 TEST_CASE_ST(ut_setup, ut_teardown,
6038 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6039 TEST_CASE_ST(ut_setup, ut_teardown,
6040 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6042 /** AES GCM Authenticated Decryption */
6043 TEST_CASE_ST(ut_setup, ut_teardown,
6044 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6045 TEST_CASE_ST(ut_setup, ut_teardown,
6046 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6047 TEST_CASE_ST(ut_setup, ut_teardown,
6048 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6049 TEST_CASE_ST(ut_setup, ut_teardown,
6050 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6051 TEST_CASE_ST(ut_setup, ut_teardown,
6052 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6053 TEST_CASE_ST(ut_setup, ut_teardown,
6054 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6055 TEST_CASE_ST(ut_setup, ut_teardown,
6056 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6058 /** AES GMAC Authentication */
6059 TEST_CASE_ST(ut_setup, ut_teardown,
6060 test_AES_GMAC_authentication_test_case_1),
6061 TEST_CASE_ST(ut_setup, ut_teardown,
6062 test_AES_GMAC_authentication_verify_test_case_1),
6063 TEST_CASE_ST(ut_setup, ut_teardown,
6064 test_AES_GMAC_authentication_test_case_2),
6065 TEST_CASE_ST(ut_setup, ut_teardown,
6066 test_AES_GMAC_authentication_verify_test_case_2),
6067 TEST_CASE_ST(ut_setup, ut_teardown,
6068 test_AES_GMAC_authentication_test_case_3),
6069 TEST_CASE_ST(ut_setup, ut_teardown,
6070 test_AES_GMAC_authentication_verify_test_case_3),
6072 /** SNOW 3G encrypt only (UEA2) */
6073 TEST_CASE_ST(ut_setup, ut_teardown,
6074 test_snow3g_encryption_test_case_1),
6075 TEST_CASE_ST(ut_setup, ut_teardown,
6076 test_snow3g_encryption_test_case_2),
6077 TEST_CASE_ST(ut_setup, ut_teardown,
6078 test_snow3g_encryption_test_case_3),
6079 TEST_CASE_ST(ut_setup, ut_teardown,
6080 test_snow3g_encryption_test_case_4),
6081 TEST_CASE_ST(ut_setup, ut_teardown,
6082 test_snow3g_encryption_test_case_5),
6084 TEST_CASE_ST(ut_setup, ut_teardown,
6085 test_snow3g_encryption_test_case_1_oop),
6086 TEST_CASE_ST(ut_setup, ut_teardown,
6087 test_snow3g_decryption_test_case_1_oop),
6089 /** SNOW 3G decrypt only (UEA2) */
6090 TEST_CASE_ST(ut_setup, ut_teardown,
6091 test_snow3g_decryption_test_case_1),
6092 TEST_CASE_ST(ut_setup, ut_teardown,
6093 test_snow3g_decryption_test_case_2),
6094 TEST_CASE_ST(ut_setup, ut_teardown,
6095 test_snow3g_decryption_test_case_3),
6096 TEST_CASE_ST(ut_setup, ut_teardown,
6097 test_snow3g_decryption_test_case_4),
6098 TEST_CASE_ST(ut_setup, ut_teardown,
6099 test_snow3g_decryption_test_case_5),
6100 TEST_CASE_ST(ut_setup, ut_teardown,
6101 test_snow3g_hash_generate_test_case_1),
6102 TEST_CASE_ST(ut_setup, ut_teardown,
6103 test_snow3g_hash_generate_test_case_2),
6104 TEST_CASE_ST(ut_setup, ut_teardown,
6105 test_snow3g_hash_generate_test_case_3),
6106 TEST_CASE_ST(ut_setup, ut_teardown,
6107 test_snow3g_hash_verify_test_case_1),
6108 TEST_CASE_ST(ut_setup, ut_teardown,
6109 test_snow3g_hash_verify_test_case_2),
6110 TEST_CASE_ST(ut_setup, ut_teardown,
6111 test_snow3g_hash_verify_test_case_3),
6112 TEST_CASE_ST(ut_setup, ut_teardown,
6113 test_snow3g_cipher_auth_test_case_1),
6114 TEST_CASE_ST(ut_setup, ut_teardown,
6115 test_snow3g_auth_cipher_test_case_1),
6117 /** HMAC_MD5 Authentication */
6118 TEST_CASE_ST(ut_setup, ut_teardown,
6119 test_MD5_HMAC_generate_case_1),
6120 TEST_CASE_ST(ut_setup, ut_teardown,
6121 test_MD5_HMAC_verify_case_1),
6122 TEST_CASE_ST(ut_setup, ut_teardown,
6123 test_MD5_HMAC_generate_case_2),
6124 TEST_CASE_ST(ut_setup, ut_teardown,
6125 test_MD5_HMAC_verify_case_2),
6128 TEST_CASE_ST(ut_setup, ut_teardown,
6129 test_null_auth_only_operation),
6130 TEST_CASE_ST(ut_setup, ut_teardown,
6131 test_null_cipher_only_operation),
6132 TEST_CASE_ST(ut_setup, ut_teardown,
6133 test_null_cipher_auth_operation),
6134 TEST_CASE_ST(ut_setup, ut_teardown,
6135 test_null_auth_cipher_operation),
6137 TEST_CASE_ST(ut_setup, ut_teardown,
6138 test_kasumi_hash_generate_test_case_6),
6141 TEST_CASE_ST(ut_setup, ut_teardown,
6142 test_kasumi_encryption_test_case_1),
6143 TEST_CASE_ST(ut_setup, ut_teardown,
6144 test_kasumi_encryption_test_case_3),
6145 TEST_CASE_ST(ut_setup, ut_teardown,
6146 test_kasumi_auth_cipher_test_case_1),
6147 TEST_CASE_ST(ut_setup, ut_teardown,
6148 test_kasumi_cipher_auth_test_case_1),
6150 TEST_CASES_END() /**< NULL terminate unit test array */
6154 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
6155 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
6156 .setup = testsuite_setup,
6157 .teardown = testsuite_teardown,
6158 .unit_test_cases = {
6159 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
6161 TEST_CASES_END() /**< NULL terminate unit test array */
6165 static struct unit_test_suite cryptodev_libcrypto_testsuite = {
6166 .suite_name = "Crypto Device LIBCRYPTO Unit Test Suite",
6167 .setup = testsuite_setup,
6168 .teardown = testsuite_teardown,
6169 .unit_test_cases = {
6170 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
6171 TEST_CASE_ST(ut_setup, ut_teardown,
6172 test_multi_session_random_usage),
6173 TEST_CASE_ST(ut_setup, ut_teardown,
6174 test_AES_chain_libcrypto_all),
6175 TEST_CASE_ST(ut_setup, ut_teardown,
6176 test_AES_cipheronly_libcrypto_all),
6177 TEST_CASE_ST(ut_setup, ut_teardown,
6178 test_3DES_chain_libcrypto_all),
6179 TEST_CASE_ST(ut_setup, ut_teardown,
6180 test_3DES_cipheronly_libcrypto_all),
6181 TEST_CASE_ST(ut_setup, ut_teardown,
6182 test_authonly_libcrypto_all),
6184 /** AES GCM Authenticated Encryption */
6185 TEST_CASE_ST(ut_setup, ut_teardown,
6186 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6187 TEST_CASE_ST(ut_setup, ut_teardown,
6188 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6189 TEST_CASE_ST(ut_setup, ut_teardown,
6190 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6191 TEST_CASE_ST(ut_setup, ut_teardown,
6192 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6193 TEST_CASE_ST(ut_setup, ut_teardown,
6194 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6195 TEST_CASE_ST(ut_setup, ut_teardown,
6196 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6197 TEST_CASE_ST(ut_setup, ut_teardown,
6198 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6200 /** AES GCM Authenticated Decryption */
6201 TEST_CASE_ST(ut_setup, ut_teardown,
6202 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6203 TEST_CASE_ST(ut_setup, ut_teardown,
6204 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6205 TEST_CASE_ST(ut_setup, ut_teardown,
6206 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6207 TEST_CASE_ST(ut_setup, ut_teardown,
6208 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6209 TEST_CASE_ST(ut_setup, ut_teardown,
6210 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6211 TEST_CASE_ST(ut_setup, ut_teardown,
6212 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6213 TEST_CASE_ST(ut_setup, ut_teardown,
6214 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6216 /** AES GMAC Authentication */
6217 TEST_CASE_ST(ut_setup, ut_teardown,
6218 test_AES_GMAC_authentication_test_case_1),
6219 TEST_CASE_ST(ut_setup, ut_teardown,
6220 test_AES_GMAC_authentication_verify_test_case_1),
6221 TEST_CASE_ST(ut_setup, ut_teardown,
6222 test_AES_GMAC_authentication_test_case_2),
6223 TEST_CASE_ST(ut_setup, ut_teardown,
6224 test_AES_GMAC_authentication_verify_test_case_2),
6225 TEST_CASE_ST(ut_setup, ut_teardown,
6226 test_AES_GMAC_authentication_test_case_3),
6227 TEST_CASE_ST(ut_setup, ut_teardown,
6228 test_AES_GMAC_authentication_verify_test_case_3),
6229 TEST_CASE_ST(ut_setup, ut_teardown,
6230 test_AES_GMAC_authentication_test_case_4),
6231 TEST_CASE_ST(ut_setup, ut_teardown,
6232 test_AES_GMAC_authentication_verify_test_case_4),
6234 /** Negative tests */
6235 TEST_CASE_ST(ut_setup, ut_teardown,
6236 authentication_verify_HMAC_SHA1_fail_data_corrupt),
6237 TEST_CASE_ST(ut_setup, ut_teardown,
6238 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6239 TEST_CASE_ST(ut_setup, ut_teardown,
6240 authentication_verify_AES128_GMAC_fail_data_corrupt),
6241 TEST_CASE_ST(ut_setup, ut_teardown,
6242 authentication_verify_AES128_GMAC_fail_tag_corrupt),
6243 TEST_CASE_ST(ut_setup, ut_teardown,
6244 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6245 TEST_CASE_ST(ut_setup, ut_teardown,
6246 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6248 TEST_CASES_END() /**< NULL terminate unit test array */
6252 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
6253 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
6254 .setup = testsuite_setup,
6255 .teardown = testsuite_teardown,
6256 .unit_test_cases = {
6257 /** AES GCM Authenticated Encryption */
6258 TEST_CASE_ST(ut_setup, ut_teardown,
6259 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6260 TEST_CASE_ST(ut_setup, ut_teardown,
6261 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6262 TEST_CASE_ST(ut_setup, ut_teardown,
6263 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6264 TEST_CASE_ST(ut_setup, ut_teardown,
6265 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6266 TEST_CASE_ST(ut_setup, ut_teardown,
6267 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6268 TEST_CASE_ST(ut_setup, ut_teardown,
6269 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6270 TEST_CASE_ST(ut_setup, ut_teardown,
6271 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6273 /** AES GCM Authenticated Decryption */
6274 TEST_CASE_ST(ut_setup, ut_teardown,
6275 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6276 TEST_CASE_ST(ut_setup, ut_teardown,
6277 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6278 TEST_CASE_ST(ut_setup, ut_teardown,
6279 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6280 TEST_CASE_ST(ut_setup, ut_teardown,
6281 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6282 TEST_CASE_ST(ut_setup, ut_teardown,
6283 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6284 TEST_CASE_ST(ut_setup, ut_teardown,
6285 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6286 TEST_CASE_ST(ut_setup, ut_teardown,
6287 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6289 TEST_CASES_END() /**< NULL terminate unit test array */
6293 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
6294 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
6295 .setup = testsuite_setup,
6296 .teardown = testsuite_teardown,
6297 .unit_test_cases = {
6298 /** KASUMI encrypt only (UEA1) */
6299 TEST_CASE_ST(ut_setup, ut_teardown,
6300 test_kasumi_encryption_test_case_1),
6301 TEST_CASE_ST(ut_setup, ut_teardown,
6302 test_kasumi_encryption_test_case_2),
6303 TEST_CASE_ST(ut_setup, ut_teardown,
6304 test_kasumi_encryption_test_case_3),
6305 TEST_CASE_ST(ut_setup, ut_teardown,
6306 test_kasumi_encryption_test_case_4),
6307 TEST_CASE_ST(ut_setup, ut_teardown,
6308 test_kasumi_encryption_test_case_5),
6309 /** KASUMI decrypt only (UEA1) */
6310 TEST_CASE_ST(ut_setup, ut_teardown,
6311 test_kasumi_decryption_test_case_1),
6312 TEST_CASE_ST(ut_setup, ut_teardown,
6313 test_kasumi_decryption_test_case_2),
6314 TEST_CASE_ST(ut_setup, ut_teardown,
6315 test_kasumi_decryption_test_case_3),
6316 TEST_CASE_ST(ut_setup, ut_teardown,
6317 test_kasumi_decryption_test_case_4),
6318 TEST_CASE_ST(ut_setup, ut_teardown,
6319 test_kasumi_decryption_test_case_5),
6321 TEST_CASE_ST(ut_setup, ut_teardown,
6322 test_kasumi_encryption_test_case_1_oop),
6323 TEST_CASE_ST(ut_setup, ut_teardown,
6324 test_kasumi_decryption_test_case_1_oop),
6326 /** KASUMI hash only (UIA1) */
6327 TEST_CASE_ST(ut_setup, ut_teardown,
6328 test_kasumi_hash_generate_test_case_1),
6329 TEST_CASE_ST(ut_setup, ut_teardown,
6330 test_kasumi_hash_generate_test_case_2),
6331 TEST_CASE_ST(ut_setup, ut_teardown,
6332 test_kasumi_hash_generate_test_case_3),
6333 TEST_CASE_ST(ut_setup, ut_teardown,
6334 test_kasumi_hash_generate_test_case_4),
6335 TEST_CASE_ST(ut_setup, ut_teardown,
6336 test_kasumi_hash_generate_test_case_5),
6337 TEST_CASE_ST(ut_setup, ut_teardown,
6338 test_kasumi_hash_generate_test_case_6),
6339 TEST_CASE_ST(ut_setup, ut_teardown,
6340 test_kasumi_hash_verify_test_case_1),
6341 TEST_CASE_ST(ut_setup, ut_teardown,
6342 test_kasumi_hash_verify_test_case_2),
6343 TEST_CASE_ST(ut_setup, ut_teardown,
6344 test_kasumi_hash_verify_test_case_3),
6345 TEST_CASE_ST(ut_setup, ut_teardown,
6346 test_kasumi_hash_verify_test_case_4),
6347 TEST_CASE_ST(ut_setup, ut_teardown,
6348 test_kasumi_hash_verify_test_case_5),
6349 TEST_CASE_ST(ut_setup, ut_teardown,
6350 test_kasumi_auth_cipher_test_case_1),
6351 TEST_CASE_ST(ut_setup, ut_teardown,
6352 test_kasumi_cipher_auth_test_case_1),
6353 TEST_CASES_END() /**< NULL terminate unit test array */
6356 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
6357 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
6358 .setup = testsuite_setup,
6359 .teardown = testsuite_teardown,
6360 .unit_test_cases = {
6361 /** SNOW 3G encrypt only (UEA2) */
6362 TEST_CASE_ST(ut_setup, ut_teardown,
6363 test_snow3g_encryption_test_case_1),
6364 TEST_CASE_ST(ut_setup, ut_teardown,
6365 test_snow3g_encryption_test_case_2),
6366 TEST_CASE_ST(ut_setup, ut_teardown,
6367 test_snow3g_encryption_test_case_3),
6368 TEST_CASE_ST(ut_setup, ut_teardown,
6369 test_snow3g_encryption_test_case_4),
6370 TEST_CASE_ST(ut_setup, ut_teardown,
6371 test_snow3g_encryption_test_case_5),
6373 TEST_CASE_ST(ut_setup, ut_teardown,
6374 test_snow3g_encryption_test_case_1_oop),
6375 TEST_CASE_ST(ut_setup, ut_teardown,
6376 test_snow3g_decryption_test_case_1_oop),
6378 TEST_CASE_ST(ut_setup, ut_teardown,
6379 test_snow3g_encryption_test_case_1_offset_oop),
6381 /** SNOW 3G decrypt only (UEA2) */
6382 TEST_CASE_ST(ut_setup, ut_teardown,
6383 test_snow3g_decryption_test_case_1),
6384 TEST_CASE_ST(ut_setup, ut_teardown,
6385 test_snow3g_decryption_test_case_2),
6386 TEST_CASE_ST(ut_setup, ut_teardown,
6387 test_snow3g_decryption_test_case_3),
6388 TEST_CASE_ST(ut_setup, ut_teardown,
6389 test_snow3g_decryption_test_case_4),
6390 TEST_CASE_ST(ut_setup, ut_teardown,
6391 test_snow3g_decryption_test_case_5),
6392 TEST_CASE_ST(ut_setup, ut_teardown,
6393 test_snow3g_hash_generate_test_case_1),
6394 TEST_CASE_ST(ut_setup, ut_teardown,
6395 test_snow3g_hash_generate_test_case_2),
6396 TEST_CASE_ST(ut_setup, ut_teardown,
6397 test_snow3g_hash_generate_test_case_3),
6398 /* Tests with buffers which length is not byte-aligned */
6399 TEST_CASE_ST(ut_setup, ut_teardown,
6400 test_snow3g_hash_generate_test_case_4),
6401 TEST_CASE_ST(ut_setup, ut_teardown,
6402 test_snow3g_hash_generate_test_case_5),
6403 TEST_CASE_ST(ut_setup, ut_teardown,
6404 test_snow3g_hash_generate_test_case_6),
6405 TEST_CASE_ST(ut_setup, ut_teardown,
6406 test_snow3g_hash_verify_test_case_1),
6407 TEST_CASE_ST(ut_setup, ut_teardown,
6408 test_snow3g_hash_verify_test_case_2),
6409 TEST_CASE_ST(ut_setup, ut_teardown,
6410 test_snow3g_hash_verify_test_case_3),
6411 /* Tests with buffers which length is not byte-aligned */
6412 TEST_CASE_ST(ut_setup, ut_teardown,
6413 test_snow3g_hash_verify_test_case_4),
6414 TEST_CASE_ST(ut_setup, ut_teardown,
6415 test_snow3g_hash_verify_test_case_5),
6416 TEST_CASE_ST(ut_setup, ut_teardown,
6417 test_snow3g_hash_verify_test_case_6),
6418 TEST_CASE_ST(ut_setup, ut_teardown,
6419 test_snow3g_cipher_auth_test_case_1),
6420 TEST_CASE_ST(ut_setup, ut_teardown,
6421 test_snow3g_auth_cipher_test_case_1),
6423 TEST_CASES_END() /**< NULL terminate unit test array */
6427 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
6428 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
6429 .setup = testsuite_setup,
6430 .teardown = testsuite_teardown,
6431 .unit_test_cases = {
6432 /** ZUC encrypt only (EEA3) */
6433 TEST_CASE_ST(ut_setup, ut_teardown,
6434 test_zuc_encryption_test_case_1),
6435 TEST_CASE_ST(ut_setup, ut_teardown,
6436 test_zuc_encryption_test_case_2),
6437 TEST_CASE_ST(ut_setup, ut_teardown,
6438 test_zuc_encryption_test_case_3),
6439 TEST_CASE_ST(ut_setup, ut_teardown,
6440 test_zuc_encryption_test_case_4),
6441 TEST_CASE_ST(ut_setup, ut_teardown,
6442 test_zuc_encryption_test_case_5),
6443 TEST_CASE_ST(ut_setup, ut_teardown,
6444 test_zuc_hash_generate_test_case_1),
6445 TEST_CASE_ST(ut_setup, ut_teardown,
6446 test_zuc_hash_generate_test_case_2),
6447 TEST_CASE_ST(ut_setup, ut_teardown,
6448 test_zuc_hash_generate_test_case_3),
6449 TEST_CASE_ST(ut_setup, ut_teardown,
6450 test_zuc_hash_generate_test_case_4),
6451 TEST_CASE_ST(ut_setup, ut_teardown,
6452 test_zuc_hash_generate_test_case_5),
6453 TEST_CASES_END() /**< NULL terminate unit test array */
6457 static struct unit_test_suite cryptodev_null_testsuite = {
6458 .suite_name = "Crypto Device NULL Unit Test Suite",
6459 .setup = testsuite_setup,
6460 .teardown = testsuite_teardown,
6461 .unit_test_cases = {
6462 TEST_CASE_ST(ut_setup, ut_teardown,
6463 test_null_auth_only_operation),
6464 TEST_CASE_ST(ut_setup, ut_teardown,
6465 test_null_cipher_only_operation),
6466 TEST_CASE_ST(ut_setup, ut_teardown,
6467 test_null_cipher_auth_operation),
6468 TEST_CASE_ST(ut_setup, ut_teardown,
6469 test_null_auth_cipher_operation),
6470 TEST_CASE_ST(ut_setup, ut_teardown,
6471 test_null_invalid_operation),
6472 TEST_CASE_ST(ut_setup, ut_teardown,
6473 test_null_burst_operation),
6475 TEST_CASES_END() /**< NULL terminate unit test array */
6480 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
6482 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
6483 return unit_test_suite_runner(&cryptodev_qat_testsuite);
6487 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
6489 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
6491 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
6495 test_cryptodev_libcrypto(void)
6497 gbl_cryptodev_type = RTE_CRYPTODEV_LIBCRYPTO_PMD;
6499 return unit_test_suite_runner(&cryptodev_libcrypto_testsuite);
6503 test_cryptodev_aesni_gcm(void)
6505 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
6507 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
6511 test_cryptodev_null(void)
6513 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
6515 return unit_test_suite_runner(&cryptodev_null_testsuite);
6519 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
6521 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
6523 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
6527 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
6529 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
6531 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
6535 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
6537 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
6539 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
6542 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
6543 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
6544 REGISTER_TEST_COMMAND(cryptodev_libcrypto_autotest, test_cryptodev_libcrypto);
6545 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
6546 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
6547 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
6548 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
6549 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);