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 */
361 dev_id = ts_params->valid_devs[0];
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 cryptodev %u",
395 testsuite_teardown(void)
397 struct crypto_testsuite_params *ts_params = &testsuite_params;
399 if (ts_params->mbuf_pool != NULL) {
400 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
401 rte_mempool_avail_count(ts_params->mbuf_pool));
404 if (ts_params->op_mpool != NULL) {
405 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
406 rte_mempool_avail_count(ts_params->op_mpool));
414 struct crypto_testsuite_params *ts_params = &testsuite_params;
415 struct crypto_unittest_params *ut_params = &unittest_params;
419 /* Clear unit test parameters before running test */
420 memset(ut_params, 0, sizeof(*ut_params));
422 /* Reconfigure device to default parameters */
423 ts_params->conf.nb_queue_pairs = DEFAULT_NUM_QPS_PER_QAT_DEVICE;
424 ts_params->conf.socket_id = SOCKET_ID_ANY;
425 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
427 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
429 "Failed to configure cryptodev %u",
430 ts_params->valid_devs[0]);
433 * Now reconfigure queues to size we actually want to use in this
436 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
438 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
439 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
440 ts_params->valid_devs[0], qp_id,
442 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
443 "Failed to setup queue pair %u on cryptodev %u",
444 qp_id, ts_params->valid_devs[0]);
448 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
450 /* Start the device */
451 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
452 "Failed to start cryptodev %u",
453 ts_params->valid_devs[0]);
461 struct crypto_testsuite_params *ts_params = &testsuite_params;
462 struct crypto_unittest_params *ut_params = &unittest_params;
463 struct rte_cryptodev_stats stats;
465 /* free crypto session structure */
466 if (ut_params->sess) {
467 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
469 ut_params->sess = NULL;
472 /* free crypto operation structure */
474 rte_crypto_op_free(ut_params->op);
477 * free mbuf - both obuf and ibuf are usually the same,
478 * so check if they point at the same address is necessary,
479 * to avoid freeing the mbuf twice.
481 if (ut_params->obuf) {
482 rte_pktmbuf_free(ut_params->obuf);
483 if (ut_params->ibuf == ut_params->obuf)
487 if (ut_params->ibuf) {
488 rte_pktmbuf_free(ut_params->ibuf);
492 if (ts_params->mbuf_pool != NULL)
493 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
494 rte_mempool_avail_count(ts_params->mbuf_pool));
496 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
498 /* Stop the device */
499 rte_cryptodev_stop(ts_params->valid_devs[0]);
503 test_device_configure_invalid_dev_id(void)
505 struct crypto_testsuite_params *ts_params = &testsuite_params;
506 uint16_t dev_id, num_devs = 0;
508 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
509 "Need at least %d devices for test", 1);
511 /* valid dev_id values */
512 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
514 /* Stop the device in case it's started so it can be configured */
515 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
517 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
518 "Failed test for rte_cryptodev_configure: "
519 "invalid dev_num %u", dev_id);
521 /* invalid dev_id values */
524 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
525 "Failed test for rte_cryptodev_configure: "
526 "invalid dev_num %u", dev_id);
530 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
531 "Failed test for rte_cryptodev_configure:"
532 "invalid dev_num %u", dev_id);
538 test_device_configure_invalid_queue_pair_ids(void)
540 struct crypto_testsuite_params *ts_params = &testsuite_params;
542 /* Stop the device in case it's started so it can be configured */
543 rte_cryptodev_stop(ts_params->valid_devs[0]);
545 /* valid - one queue pairs */
546 ts_params->conf.nb_queue_pairs = 1;
548 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
550 "Failed to configure cryptodev: dev_id %u, qp_id %u",
551 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
554 /* valid - max value queue pairs */
555 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
557 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
559 "Failed to configure cryptodev: dev_id %u, qp_id %u",
560 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
563 /* invalid - zero queue pairs */
564 ts_params->conf.nb_queue_pairs = 0;
566 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
568 "Failed test for rte_cryptodev_configure, dev_id %u,"
570 ts_params->valid_devs[0],
571 ts_params->conf.nb_queue_pairs);
574 /* invalid - max value supported by field queue pairs */
575 ts_params->conf.nb_queue_pairs = UINT16_MAX;
577 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
579 "Failed test for rte_cryptodev_configure, dev_id %u,"
581 ts_params->valid_devs[0],
582 ts_params->conf.nb_queue_pairs);
585 /* invalid - max value + 1 queue pairs */
586 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
588 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
590 "Failed test for rte_cryptodev_configure, dev_id %u,"
592 ts_params->valid_devs[0],
593 ts_params->conf.nb_queue_pairs);
599 test_queue_pair_descriptor_setup(void)
601 struct crypto_testsuite_params *ts_params = &testsuite_params;
602 struct rte_cryptodev_info dev_info;
603 struct rte_cryptodev_qp_conf qp_conf = {
604 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
609 /* Stop the device in case it's started so it can be configured */
610 rte_cryptodev_stop(ts_params->valid_devs[0]);
613 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
615 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
617 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
618 &ts_params->conf), "Failed to configure cryptodev %u",
619 ts_params->valid_devs[0]);
623 * Test various ring sizes on this device. memzones can't be
624 * freed so are re-used if ring is released and re-created.
626 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
628 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
629 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
630 ts_params->valid_devs[0], qp_id, &qp_conf,
631 rte_cryptodev_socket_id(
632 ts_params->valid_devs[0])),
634 "rte_cryptodev_queue_pair_setup: num_inflights "
635 "%u on qp %u on cryptodev %u",
636 qp_conf.nb_descriptors, qp_id,
637 ts_params->valid_devs[0]);
640 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
642 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
643 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
644 ts_params->valid_devs[0], qp_id, &qp_conf,
645 rte_cryptodev_socket_id(
646 ts_params->valid_devs[0])),
648 " rte_cryptodev_queue_pair_setup: num_inflights"
649 " %u on qp %u on cryptodev %u",
650 qp_conf.nb_descriptors, qp_id,
651 ts_params->valid_devs[0]);
654 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
656 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
657 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
658 ts_params->valid_devs[0], qp_id, &qp_conf,
659 rte_cryptodev_socket_id(
660 ts_params->valid_devs[0])),
662 "rte_cryptodev_queue_pair_setup: num_inflights"
663 " %u on qp %u on cryptodev %u",
664 qp_conf.nb_descriptors, qp_id,
665 ts_params->valid_devs[0]);
668 /* invalid number of descriptors - max supported + 2 */
669 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
671 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
672 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
673 ts_params->valid_devs[0], qp_id, &qp_conf,
674 rte_cryptodev_socket_id(
675 ts_params->valid_devs[0])),
676 "Unexpectedly passed test for "
677 "rte_cryptodev_queue_pair_setup:"
678 "num_inflights %u on qp %u on cryptodev %u",
679 qp_conf.nb_descriptors, qp_id,
680 ts_params->valid_devs[0]);
683 /* invalid number of descriptors - max value of parameter */
684 qp_conf.nb_descriptors = UINT32_MAX-1;
686 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
687 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
688 ts_params->valid_devs[0], qp_id, &qp_conf,
689 rte_cryptodev_socket_id(
690 ts_params->valid_devs[0])),
691 "Unexpectedly passed test for "
692 "rte_cryptodev_queue_pair_setup:"
693 "num_inflights %u on qp %u on cryptodev %u",
694 qp_conf.nb_descriptors, qp_id,
695 ts_params->valid_devs[0]);
698 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
700 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
701 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
702 ts_params->valid_devs[0], qp_id, &qp_conf,
703 rte_cryptodev_socket_id(
704 ts_params->valid_devs[0])),
706 " rte_cryptodev_queue_pair_setup:"
707 "num_inflights %u on qp %u on cryptodev %u",
708 qp_conf.nb_descriptors, qp_id,
709 ts_params->valid_devs[0]);
712 /* invalid number of descriptors - max supported + 1 */
713 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
715 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
716 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
717 ts_params->valid_devs[0], qp_id, &qp_conf,
718 rte_cryptodev_socket_id(
719 ts_params->valid_devs[0])),
720 "Unexpectedly passed test for "
721 "rte_cryptodev_queue_pair_setup:"
722 "num_inflights %u on qp %u on cryptodev %u",
723 qp_conf.nb_descriptors, qp_id,
724 ts_params->valid_devs[0]);
727 /* test invalid queue pair id */
728 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
730 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
732 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
733 ts_params->valid_devs[0],
735 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
736 "Failed test for rte_cryptodev_queue_pair_setup:"
737 "invalid qp %u on cryptodev %u",
738 qp_id, ts_params->valid_devs[0]);
740 qp_id = 0xffff; /*invalid*/
742 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
743 ts_params->valid_devs[0],
745 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
746 "Failed test for rte_cryptodev_queue_pair_setup:"
747 "invalid qp %u on cryptodev %u",
748 qp_id, ts_params->valid_devs[0]);
753 /* ***** Plaintext data for tests ***** */
755 const char catch_22_quote_1[] =
756 "There was only one catch and that was Catch-22, which "
757 "specified that a concern for one's safety in the face of "
758 "dangers that were real and immediate was the process of a "
759 "rational mind. Orr was crazy and could be grounded. All he "
760 "had to do was ask; and as soon as he did, he would no longer "
761 "be crazy and would have to fly more missions. Orr would be "
762 "crazy to fly more missions and sane if he didn't, but if he "
763 "was sane he had to fly them. If he flew them he was crazy "
764 "and didn't have to; but if he didn't want to he was sane and "
765 "had to. Yossarian was moved very deeply by the absolute "
766 "simplicity of this clause of Catch-22 and let out a "
767 "respectful whistle. \"That's some catch, that Catch-22\", he "
768 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
770 const char catch_22_quote[] =
771 "What a lousy earth! He wondered how many people were "
772 "destitute that same night even in his own prosperous country, "
773 "how many homes were shanties, how many husbands were drunk "
774 "and wives socked, and how many children were bullied, abused, "
775 "or abandoned. How many families hungered for food they could "
776 "not afford to buy? How many hearts were broken? How many "
777 "suicides would take place that same night, how many people "
778 "would go insane? How many cockroaches and landlords would "
779 "triumph? How many winners were losers, successes failures, "
780 "and rich men poor men? How many wise guys were stupid? How "
781 "many happy endings were unhappy endings? How many honest men "
782 "were liars, brave men cowards, loyal men traitors, how many "
783 "sainted men were corrupt, how many people in positions of "
784 "trust had sold their souls to bodyguards, how many had never "
785 "had souls? How many straight-and-narrow paths were crooked "
786 "paths? How many best families were worst families and how "
787 "many good people were bad people? When you added them all up "
788 "and then subtracted, you might be left with only the children, "
789 "and perhaps with Albert Einstein and an old violinist or "
790 "sculptor somewhere.";
792 #define QUOTE_480_BYTES (480)
793 #define QUOTE_512_BYTES (512)
794 #define QUOTE_768_BYTES (768)
795 #define QUOTE_1024_BYTES (1024)
799 /* ***** SHA1 Hash Tests ***** */
801 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
803 static uint8_t hmac_sha1_key[] = {
804 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
805 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
806 0xDE, 0xF4, 0xDE, 0xAD };
808 /* ***** SHA224 Hash Tests ***** */
810 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
813 /* ***** AES-CBC Cipher Tests ***** */
815 #define CIPHER_KEY_LENGTH_AES_CBC (16)
816 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
818 static uint8_t aes_cbc_key[] = {
819 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
820 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
822 static uint8_t aes_cbc_iv[] = {
823 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
824 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
827 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
829 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
830 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
831 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
832 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
833 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
834 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
835 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
836 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
837 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
838 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
839 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
840 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
841 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
842 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
843 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
844 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
845 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
846 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
847 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
848 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
849 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
850 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
851 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
852 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
853 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
854 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
855 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
856 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
857 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
858 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
859 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
860 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
861 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
862 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
863 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
864 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
865 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
866 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
867 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
868 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
869 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
870 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
871 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
872 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
873 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
874 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
875 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
876 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
877 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
878 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
879 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
880 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
881 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
882 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
883 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
884 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
885 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
886 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
887 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
888 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
889 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
890 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
891 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
892 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
893 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
896 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
897 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
898 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
899 0x18, 0x8c, 0x1d, 0x32
903 /* Multisession Vector context Test */
905 static uint8_t ms_aes_cbc_key0[] = {
906 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
907 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
910 static uint8_t ms_aes_cbc_iv0[] = {
911 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
912 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
915 static const uint8_t ms_aes_cbc_cipher0[] = {
916 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
917 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
918 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
919 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
920 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
921 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
922 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
923 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
924 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
925 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
926 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
927 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
928 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
929 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
930 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
931 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
932 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
933 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
934 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
935 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
936 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
937 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
938 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
939 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
940 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
941 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
942 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
943 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
944 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
945 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
946 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
947 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
948 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
949 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
950 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
951 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
952 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
953 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
954 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
955 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
956 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
957 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
958 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
959 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
960 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
961 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
962 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
963 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
964 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
965 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
966 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
967 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
968 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
969 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
970 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
971 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
972 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
973 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
974 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
975 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
976 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
977 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
978 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
979 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
983 static uint8_t ms_hmac_key0[] = {
984 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
985 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
986 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
987 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
988 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
989 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
990 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
991 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
994 static const uint8_t ms_hmac_digest0[] = {
995 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
996 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
997 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
998 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
999 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1000 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1001 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1002 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1006 /* Begin session 1 */
1008 static uint8_t ms_aes_cbc_key1[] = {
1009 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1010 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1013 static uint8_t ms_aes_cbc_iv1[] = {
1014 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1015 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1018 static const uint8_t ms_aes_cbc_cipher1[] = {
1019 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1020 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1021 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1022 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1023 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1024 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1025 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1026 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1027 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1028 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1029 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1030 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1031 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1032 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1033 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1034 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1035 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1036 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1037 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1038 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1039 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1040 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1041 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1042 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1043 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1044 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1045 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1046 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1047 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1048 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1049 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1050 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1051 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1052 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1053 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1054 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1055 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1056 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1057 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1058 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1059 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1060 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1061 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1062 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1063 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1064 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1065 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1066 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1067 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1068 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1069 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1070 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1071 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1072 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1073 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1074 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1075 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1076 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1077 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1078 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1079 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1080 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1081 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1082 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1086 static uint8_t ms_hmac_key1[] = {
1087 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1088 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1089 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1090 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1091 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1092 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1093 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1094 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1097 static const uint8_t ms_hmac_digest1[] = {
1098 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1099 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1100 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1101 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1102 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1103 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1104 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1105 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1108 /* Begin Session 2 */
1109 static uint8_t ms_aes_cbc_key2[] = {
1110 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1111 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1114 static uint8_t ms_aes_cbc_iv2[] = {
1115 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1116 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1119 static const uint8_t ms_aes_cbc_cipher2[] = {
1120 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1121 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1122 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1123 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1124 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1125 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1126 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1127 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1128 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1129 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1130 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1131 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1132 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1133 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1134 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1135 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1136 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1137 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1138 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1139 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1140 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1141 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1142 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1143 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1144 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1145 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1146 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1147 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1148 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1149 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1150 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1151 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1152 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1153 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1154 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1155 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1156 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1157 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1158 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1159 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1160 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1161 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1162 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1163 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1164 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1165 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1166 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1167 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1168 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1169 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1170 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1171 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1172 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1173 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1174 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1175 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1176 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1177 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1178 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1179 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1180 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1181 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1182 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1183 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1186 static uint8_t ms_hmac_key2[] = {
1187 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1188 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1189 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1190 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1191 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1192 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1193 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1194 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1197 static const uint8_t ms_hmac_digest2[] = {
1198 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1199 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1200 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1201 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1202 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1203 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1204 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1205 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1212 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1214 struct crypto_testsuite_params *ts_params = &testsuite_params;
1215 struct crypto_unittest_params *ut_params = &unittest_params;
1217 /* Generate test mbuf data and space for digest */
1218 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1219 catch_22_quote, QUOTE_512_BYTES, 0);
1221 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1222 DIGEST_BYTE_LENGTH_SHA1);
1223 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1225 /* Setup Cipher Parameters */
1226 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1227 ut_params->cipher_xform.next = &ut_params->auth_xform;
1229 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1230 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1231 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1232 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1234 /* Setup HMAC Parameters */
1235 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1237 ut_params->auth_xform.next = NULL;
1239 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1240 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1241 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1242 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1243 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1245 /* Create crypto session*/
1246 ut_params->sess = rte_cryptodev_sym_session_create(
1247 ts_params->valid_devs[0],
1248 &ut_params->cipher_xform);
1249 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1251 /* Generate crypto op data structure */
1252 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1253 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1254 TEST_ASSERT_NOT_NULL(ut_params->op,
1255 "Failed to allocate symmetric crypto operation struct");
1257 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1259 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1261 /* set crypto operation source mbuf */
1262 sym_op->m_src = ut_params->ibuf;
1264 /* Set crypto operation authentication parameters */
1265 sym_op->auth.digest.data = ut_params->digest;
1266 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1267 ut_params->ibuf, QUOTE_512_BYTES);
1268 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1270 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1271 sym_op->auth.data.length = QUOTE_512_BYTES;
1273 /* Set crypto operation cipher parameters */
1274 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1275 CIPHER_IV_LENGTH_AES_CBC);
1276 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1277 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1279 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1280 CIPHER_IV_LENGTH_AES_CBC);
1282 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1283 sym_op->cipher.data.length = QUOTE_512_BYTES;
1285 /* Process crypto operation */
1286 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1287 ut_params->op), "failed to process sym crypto op");
1289 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1290 "crypto op processing failed");
1293 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1294 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1296 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1297 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1299 "ciphertext data not as expected");
1301 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1303 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1304 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1305 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1306 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1307 DIGEST_BYTE_LENGTH_SHA1,
1308 "Generated digest data not as expected");
1310 return TEST_SUCCESS;
1313 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1315 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1317 static uint8_t hmac_sha512_key[] = {
1318 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1319 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1320 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1321 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1322 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1323 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1324 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1325 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1327 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1328 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1329 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1330 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1331 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1332 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1333 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1334 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1335 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1340 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1341 struct crypto_unittest_params *ut_params,
1342 uint8_t *cipher_key,
1346 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1347 struct crypto_unittest_params *ut_params,
1348 struct crypto_testsuite_params *ts_params,
1349 const uint8_t *cipher,
1350 const uint8_t *digest,
1355 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1356 struct crypto_unittest_params *ut_params,
1357 uint8_t *cipher_key,
1361 /* Setup Cipher Parameters */
1362 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1363 ut_params->cipher_xform.next = NULL;
1365 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1366 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1367 ut_params->cipher_xform.cipher.key.data = cipher_key;
1368 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1370 /* Setup HMAC Parameters */
1371 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1372 ut_params->auth_xform.next = &ut_params->cipher_xform;
1374 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1375 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1376 ut_params->auth_xform.auth.key.data = hmac_key;
1377 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1378 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1380 return TEST_SUCCESS;
1385 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1386 struct crypto_unittest_params *ut_params,
1387 struct crypto_testsuite_params *ts_params,
1388 const uint8_t *cipher,
1389 const uint8_t *digest,
1392 /* Generate test mbuf data and digest */
1393 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1396 QUOTE_512_BYTES, 0);
1398 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1399 DIGEST_BYTE_LENGTH_SHA512);
1400 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1402 rte_memcpy(ut_params->digest,
1404 DIGEST_BYTE_LENGTH_SHA512);
1406 /* Generate Crypto op data structure */
1407 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1408 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1409 TEST_ASSERT_NOT_NULL(ut_params->op,
1410 "Failed to allocate symmetric crypto operation struct");
1412 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1414 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1416 /* set crypto operation source mbuf */
1417 sym_op->m_src = ut_params->ibuf;
1419 sym_op->auth.digest.data = ut_params->digest;
1420 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1421 ut_params->ibuf, QUOTE_512_BYTES);
1422 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1424 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1425 sym_op->auth.data.length = QUOTE_512_BYTES;
1427 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1428 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1429 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1430 ut_params->ibuf, 0);
1431 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1433 rte_memcpy(sym_op->cipher.iv.data, iv,
1434 CIPHER_IV_LENGTH_AES_CBC);
1436 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1437 sym_op->cipher.data.length = QUOTE_512_BYTES;
1439 /* Process crypto operation */
1440 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1441 ut_params->op), "failed to process sym crypto op");
1443 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1444 "crypto op processing failed");
1446 ut_params->obuf = ut_params->op->sym->m_src;
1449 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1450 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1451 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1453 "Plaintext data not as expected");
1456 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1457 "Digest verification failed");
1459 return TEST_SUCCESS;
1463 test_AES_chain_mb_all(void)
1465 struct crypto_testsuite_params *ts_params = &testsuite_params;
1468 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1469 ts_params->op_mpool, ts_params->valid_devs[0],
1470 RTE_CRYPTODEV_AESNI_MB_PMD,
1471 BLKCIPHER_AES_CHAIN_TYPE);
1473 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1475 return TEST_SUCCESS;
1479 test_AES_chain_libcrypto_all(void)
1481 struct crypto_testsuite_params *ts_params = &testsuite_params;
1484 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1485 ts_params->op_mpool, ts_params->valid_devs[0],
1486 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1487 BLKCIPHER_AES_CHAIN_TYPE);
1489 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1491 return TEST_SUCCESS;
1495 test_AES_cipheronly_libcrypto_all(void)
1497 struct crypto_testsuite_params *ts_params = &testsuite_params;
1500 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1501 ts_params->op_mpool, ts_params->valid_devs[0],
1502 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1503 BLKCIPHER_AES_CIPHERONLY_TYPE);
1505 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1507 return TEST_SUCCESS;
1511 test_AES_chain_qat_all(void)
1513 struct crypto_testsuite_params *ts_params = &testsuite_params;
1516 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1517 ts_params->op_mpool, ts_params->valid_devs[0],
1518 RTE_CRYPTODEV_QAT_SYM_PMD,
1519 BLKCIPHER_AES_CHAIN_TYPE);
1521 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1523 return TEST_SUCCESS;
1527 test_authonly_libcrypto_all(void)
1529 struct crypto_testsuite_params *ts_params = &testsuite_params;
1532 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1533 ts_params->op_mpool, ts_params->valid_devs[0],
1534 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1535 BLKCIPHER_AUTHONLY_TYPE);
1537 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1539 return TEST_SUCCESS;
1542 /* ***** SNOW 3G Tests ***** */
1544 create_wireless_algo_hash_session(uint8_t dev_id,
1545 const uint8_t *key, const uint8_t key_len,
1546 const uint8_t aad_len, const uint8_t auth_len,
1547 enum rte_crypto_auth_operation op,
1548 enum rte_crypto_auth_algorithm algo)
1550 uint8_t hash_key[key_len];
1552 struct crypto_unittest_params *ut_params = &unittest_params;
1554 memcpy(hash_key, key, key_len);
1556 TEST_HEXDUMP(stdout, "key:", key, key_len);
1558 /* Setup Authentication Parameters */
1559 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1560 ut_params->auth_xform.next = NULL;
1562 ut_params->auth_xform.auth.op = op;
1563 ut_params->auth_xform.auth.algo = algo;
1564 ut_params->auth_xform.auth.key.length = key_len;
1565 ut_params->auth_xform.auth.key.data = hash_key;
1566 ut_params->auth_xform.auth.digest_length = auth_len;
1567 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1568 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1569 &ut_params->auth_xform);
1570 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1575 create_wireless_algo_cipher_session(uint8_t dev_id,
1576 enum rte_crypto_cipher_operation op,
1577 enum rte_crypto_cipher_algorithm algo,
1578 const uint8_t *key, const uint8_t key_len)
1580 uint8_t cipher_key[key_len];
1582 struct crypto_unittest_params *ut_params = &unittest_params;
1584 memcpy(cipher_key, key, key_len);
1586 /* Setup Cipher Parameters */
1587 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1588 ut_params->cipher_xform.next = NULL;
1590 ut_params->cipher_xform.cipher.algo = algo;
1591 ut_params->cipher_xform.cipher.op = op;
1592 ut_params->cipher_xform.cipher.key.data = cipher_key;
1593 ut_params->cipher_xform.cipher.key.length = key_len;
1595 TEST_HEXDUMP(stdout, "key:", key, key_len);
1597 /* Create Crypto session */
1598 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1601 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1606 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1607 const unsigned cipher_len,
1608 const unsigned cipher_offset,
1609 enum rte_crypto_cipher_algorithm algo)
1611 struct crypto_testsuite_params *ts_params = &testsuite_params;
1612 struct crypto_unittest_params *ut_params = &unittest_params;
1613 unsigned iv_pad_len = 0;
1615 /* Generate Crypto op data structure */
1616 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1617 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1618 TEST_ASSERT_NOT_NULL(ut_params->op,
1619 "Failed to allocate pktmbuf offload");
1621 /* Set crypto operation data parameters */
1622 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1624 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1626 /* set crypto operation source mbuf */
1627 sym_op->m_src = ut_params->ibuf;
1630 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1631 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1633 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1635 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1638 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1640 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1641 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1642 sym_op->cipher.iv.length = iv_pad_len;
1644 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1645 sym_op->cipher.data.length = cipher_len;
1646 sym_op->cipher.data.offset = cipher_offset;
1651 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1652 const unsigned cipher_len,
1653 const unsigned cipher_offset,
1654 enum rte_crypto_cipher_algorithm algo)
1656 struct crypto_testsuite_params *ts_params = &testsuite_params;
1657 struct crypto_unittest_params *ut_params = &unittest_params;
1658 unsigned iv_pad_len = 0;
1660 /* Generate Crypto op data structure */
1661 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1662 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1663 TEST_ASSERT_NOT_NULL(ut_params->op,
1664 "Failed to allocate pktmbuf offload");
1666 /* Set crypto operation data parameters */
1667 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1669 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1671 /* set crypto operation source mbuf */
1672 sym_op->m_src = ut_params->ibuf;
1673 sym_op->m_dst = ut_params->obuf;
1676 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1677 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1679 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1680 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1683 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1685 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1686 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1687 sym_op->cipher.iv.length = iv_pad_len;
1689 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1690 sym_op->cipher.data.length = cipher_len;
1691 sym_op->cipher.data.offset = cipher_offset;
1696 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1697 enum rte_crypto_cipher_operation cipher_op,
1698 enum rte_crypto_auth_operation auth_op,
1699 enum rte_crypto_auth_algorithm auth_algo,
1700 enum rte_crypto_cipher_algorithm cipher_algo,
1701 const uint8_t *key, const uint8_t key_len,
1702 const uint8_t aad_len, const uint8_t auth_len)
1705 uint8_t cipher_auth_key[key_len];
1707 struct crypto_unittest_params *ut_params = &unittest_params;
1709 memcpy(cipher_auth_key, key, key_len);
1711 /* Setup Authentication Parameters */
1712 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1713 ut_params->auth_xform.next = NULL;
1715 ut_params->auth_xform.auth.op = auth_op;
1716 ut_params->auth_xform.auth.algo = auth_algo;
1717 ut_params->auth_xform.auth.key.length = key_len;
1718 /* Hash key = cipher key */
1719 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1720 ut_params->auth_xform.auth.digest_length = auth_len;
1721 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1723 /* Setup Cipher Parameters */
1724 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1725 ut_params->cipher_xform.next = &ut_params->auth_xform;
1727 ut_params->cipher_xform.cipher.algo = cipher_algo;
1728 ut_params->cipher_xform.cipher.op = cipher_op;
1729 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1730 ut_params->cipher_xform.cipher.key.length = key_len;
1732 TEST_HEXDUMP(stdout, "key:", key, key_len);
1734 /* Create Crypto session*/
1735 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1736 &ut_params->cipher_xform);
1738 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1743 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1744 enum rte_crypto_cipher_operation cipher_op,
1745 enum rte_crypto_auth_operation auth_op,
1746 enum rte_crypto_auth_algorithm auth_algo,
1747 enum rte_crypto_cipher_algorithm cipher_algo,
1748 const uint8_t *key, const uint8_t key_len,
1749 const uint8_t aad_len, const uint8_t auth_len)
1751 uint8_t auth_cipher_key[key_len];
1753 struct crypto_unittest_params *ut_params = &unittest_params;
1755 memcpy(auth_cipher_key, key, key_len);
1757 /* Setup Authentication Parameters */
1758 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1759 ut_params->auth_xform.auth.op = auth_op;
1760 ut_params->auth_xform.next = &ut_params->cipher_xform;
1761 ut_params->auth_xform.auth.algo = auth_algo;
1762 ut_params->auth_xform.auth.key.length = key_len;
1763 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1764 ut_params->auth_xform.auth.digest_length = auth_len;
1765 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1767 /* Setup Cipher Parameters */
1768 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1769 ut_params->cipher_xform.next = NULL;
1770 ut_params->cipher_xform.cipher.algo = cipher_algo;
1771 ut_params->cipher_xform.cipher.op = cipher_op;
1772 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1773 ut_params->cipher_xform.cipher.key.length = key_len;
1775 TEST_HEXDUMP(stdout, "key:", key, key_len);
1777 /* Create Crypto session*/
1778 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1779 &ut_params->auth_xform);
1781 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1787 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1788 const unsigned auth_tag_len,
1789 const uint8_t *aad, const unsigned aad_len,
1790 unsigned data_pad_len,
1791 enum rte_crypto_auth_operation op,
1792 enum rte_crypto_auth_algorithm algo,
1793 const unsigned auth_len, const unsigned auth_offset)
1795 struct crypto_testsuite_params *ts_params = &testsuite_params;
1797 struct crypto_unittest_params *ut_params = &unittest_params;
1799 unsigned aad_buffer_len;
1801 /* Generate Crypto op data structure */
1802 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1803 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1804 TEST_ASSERT_NOT_NULL(ut_params->op,
1805 "Failed to allocate pktmbuf offload");
1807 /* Set crypto operation data parameters */
1808 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1810 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1812 /* set crypto operation source mbuf */
1813 sym_op->m_src = ut_params->ibuf;
1817 * Always allocate the aad up to the block size.
1818 * The cryptodev API calls out -
1819 * - the array must be big enough to hold the AAD, plus any
1820 * space to round this up to the nearest multiple of the
1821 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1823 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1824 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1826 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1827 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1828 ut_params->ibuf, aad_buffer_len);
1829 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1830 "no room to prepend aad");
1831 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1833 sym_op->auth.aad.length = aad_len;
1835 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1836 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1838 TEST_HEXDUMP(stdout, "aad:",
1839 sym_op->auth.aad.data, aad_len);
1842 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1843 ut_params->ibuf, auth_tag_len);
1845 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1846 "no room to append auth tag");
1847 ut_params->digest = sym_op->auth.digest.data;
1848 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1849 ut_params->ibuf, data_pad_len + aad_len);
1850 sym_op->auth.digest.length = auth_tag_len;
1851 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1852 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1854 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1856 TEST_HEXDUMP(stdout, "digest:",
1857 sym_op->auth.digest.data,
1858 sym_op->auth.digest.length);
1860 sym_op->auth.data.length = auth_len;
1861 sym_op->auth.data.offset = auth_offset;
1867 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1868 const unsigned auth_tag_len,
1869 const uint8_t *aad, const uint8_t aad_len,
1870 unsigned data_pad_len,
1871 enum rte_crypto_auth_operation op,
1872 enum rte_crypto_auth_algorithm auth_algo,
1873 enum rte_crypto_cipher_algorithm cipher_algo,
1874 const uint8_t *iv, const uint8_t iv_len,
1875 const unsigned cipher_len, const unsigned cipher_offset,
1876 const unsigned auth_len, const unsigned auth_offset)
1878 struct crypto_testsuite_params *ts_params = &testsuite_params;
1879 struct crypto_unittest_params *ut_params = &unittest_params;
1881 unsigned iv_pad_len = 0;
1882 unsigned aad_buffer_len;
1884 /* Generate Crypto op data structure */
1885 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1886 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1887 TEST_ASSERT_NOT_NULL(ut_params->op,
1888 "Failed to allocate pktmbuf offload");
1889 /* Set crypto operation data parameters */
1890 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1892 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1894 /* set crypto operation source mbuf */
1895 sym_op->m_src = ut_params->ibuf;
1898 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1899 ut_params->ibuf, auth_tag_len);
1901 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1902 "no room to append auth tag");
1903 ut_params->digest = sym_op->auth.digest.data;
1904 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1905 ut_params->ibuf, data_pad_len);
1906 sym_op->auth.digest.length = auth_tag_len;
1907 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1908 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1910 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1912 TEST_HEXDUMP(stdout, "digest:",
1913 sym_op->auth.digest.data,
1914 sym_op->auth.digest.length);
1918 * Always allocate the aad up to the block size.
1919 * The cryptodev API calls out -
1920 * - the array must be big enough to hold the AAD, plus any
1921 * space to round this up to the nearest multiple of the
1922 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1924 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1925 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1927 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1928 sym_op->auth.aad.data =
1929 (uint8_t *)rte_pktmbuf_prepend(
1930 ut_params->ibuf, aad_buffer_len);
1931 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1932 "no room to prepend aad");
1933 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1935 sym_op->auth.aad.length = aad_len;
1936 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1937 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1938 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1941 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1942 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1944 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1945 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1946 ut_params->ibuf, iv_pad_len);
1948 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1949 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1950 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1951 sym_op->cipher.iv.length = iv_pad_len;
1952 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1953 sym_op->cipher.data.length = cipher_len;
1954 sym_op->cipher.data.offset = cipher_offset + auth_offset;
1955 sym_op->auth.data.length = auth_len;
1956 sym_op->auth.data.offset = auth_offset + cipher_offset;
1962 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
1963 const uint8_t *iv, const uint8_t iv_len,
1964 const uint8_t *aad, const uint8_t aad_len,
1965 unsigned data_pad_len,
1966 const unsigned cipher_len, const unsigned cipher_offset,
1967 const unsigned auth_len, const unsigned auth_offset,
1968 enum rte_crypto_auth_algorithm auth_algo,
1969 enum rte_crypto_cipher_algorithm cipher_algo)
1971 struct crypto_testsuite_params *ts_params = &testsuite_params;
1972 struct crypto_unittest_params *ut_params = &unittest_params;
1974 unsigned iv_pad_len = 0;
1975 unsigned aad_buffer_len = 0;
1977 /* Generate Crypto op data structure */
1978 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1979 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1980 TEST_ASSERT_NOT_NULL(ut_params->op,
1981 "Failed to allocate pktmbuf offload");
1983 /* Set crypto operation data parameters */
1984 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1986 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1988 /* set crypto operation source mbuf */
1989 sym_op->m_src = ut_params->ibuf;
1992 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1993 ut_params->ibuf, auth_tag_len);
1995 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1996 "no room to append auth tag");
1998 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1999 ut_params->ibuf, data_pad_len);
2000 sym_op->auth.digest.length = auth_tag_len;
2002 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2004 TEST_HEXDUMP(stdout, "digest:",
2005 sym_op->auth.digest.data,
2006 sym_op->auth.digest.length);
2010 * Always allocate the aad up to the block size.
2011 * The cryptodev API calls out -
2012 * - the array must be big enough to hold the AAD, plus any
2013 * space to round this up to the nearest multiple of the
2014 * block size (8 bytes for KASUMI 16 bytes).
2016 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2017 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2019 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2020 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2021 ut_params->ibuf, aad_buffer_len);
2022 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2023 "no room to prepend aad");
2024 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2026 sym_op->auth.aad.length = aad_len;
2027 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2028 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2029 TEST_HEXDUMP(stdout, "aad:",
2030 sym_op->auth.aad.data, aad_len);
2033 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2034 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2036 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2038 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2039 ut_params->ibuf, iv_pad_len);
2040 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2042 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2043 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2044 sym_op->cipher.iv.length = iv_pad_len;
2046 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2048 sym_op->cipher.data.length = cipher_len;
2049 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2051 sym_op->auth.data.length = auth_len;
2052 sym_op->auth.data.offset = auth_offset + cipher_offset;
2058 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2060 struct crypto_testsuite_params *ts_params = &testsuite_params;
2061 struct crypto_unittest_params *ut_params = &unittest_params;
2064 unsigned plaintext_pad_len;
2065 unsigned plaintext_len;
2068 /* Create SNOW 3G session */
2069 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2070 tdata->key.data, tdata->key.len,
2071 tdata->aad.len, tdata->digest.len,
2072 RTE_CRYPTO_AUTH_OP_GENERATE,
2073 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2077 /* alloc mbuf and set payload */
2078 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2080 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2081 rte_pktmbuf_tailroom(ut_params->ibuf));
2083 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2084 /* Append data which is padded to a multiple of */
2085 /* the algorithms block size */
2086 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2087 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2089 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2091 /* Create SNOW 3G operation */
2092 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2093 tdata->aad.data, tdata->aad.len,
2094 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2095 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2096 tdata->validAuthLenInBits.len,
2097 tdata->validAuthOffsetLenInBits.len);
2101 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2103 ut_params->obuf = ut_params->op->sym->m_src;
2104 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2105 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2106 + plaintext_pad_len + tdata->aad.len;
2109 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2112 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2113 "SNOW 3G Generated auth tag not as expected");
2119 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2121 struct crypto_testsuite_params *ts_params = &testsuite_params;
2122 struct crypto_unittest_params *ut_params = &unittest_params;
2125 unsigned plaintext_pad_len;
2126 unsigned plaintext_len;
2129 /* Create SNOW 3G session */
2130 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2131 tdata->key.data, tdata->key.len,
2132 tdata->aad.len, tdata->digest.len,
2133 RTE_CRYPTO_AUTH_OP_VERIFY,
2134 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2137 /* alloc mbuf and set payload */
2138 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2140 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2141 rte_pktmbuf_tailroom(ut_params->ibuf));
2143 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2144 /* Append data which is padded to a multiple of */
2145 /* the algorithms block size */
2146 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2147 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2149 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2151 /* Create SNOW 3G operation */
2152 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2154 tdata->aad.data, tdata->aad.len,
2156 RTE_CRYPTO_AUTH_OP_VERIFY,
2157 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2158 tdata->validAuthLenInBits.len,
2159 tdata->validAuthOffsetLenInBits.len);
2163 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2165 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2166 ut_params->obuf = ut_params->op->sym->m_src;
2167 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2168 + plaintext_pad_len + tdata->aad.len;
2171 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2180 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2182 struct crypto_testsuite_params *ts_params = &testsuite_params;
2183 struct crypto_unittest_params *ut_params = &unittest_params;
2186 unsigned plaintext_pad_len;
2187 unsigned plaintext_len;
2190 /* Create KASUMI session */
2191 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2192 tdata->key.data, tdata->key.len,
2193 tdata->aad.len, tdata->digest.len,
2194 RTE_CRYPTO_AUTH_OP_GENERATE,
2195 RTE_CRYPTO_AUTH_KASUMI_F9);
2199 /* alloc mbuf and set payload */
2200 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2202 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2203 rte_pktmbuf_tailroom(ut_params->ibuf));
2205 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2206 /* Append data which is padded to a multiple of */
2207 /* the algorithms block size */
2208 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2209 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2211 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2213 /* Create KASUMI operation */
2214 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2215 tdata->aad.data, tdata->aad.len,
2216 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2217 RTE_CRYPTO_AUTH_KASUMI_F9,
2218 tdata->validAuthLenInBits.len,
2219 tdata->validAuthOffsetLenInBits.len);
2223 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2225 ut_params->obuf = ut_params->op->sym->m_src;
2226 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2227 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2228 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2231 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2234 DIGEST_BYTE_LENGTH_KASUMI_F9,
2235 "KASUMI Generated auth tag not as expected");
2241 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2243 struct crypto_testsuite_params *ts_params = &testsuite_params;
2244 struct crypto_unittest_params *ut_params = &unittest_params;
2247 unsigned plaintext_pad_len;
2248 unsigned plaintext_len;
2251 /* Create KASUMI session */
2252 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2253 tdata->key.data, tdata->key.len,
2254 tdata->aad.len, tdata->digest.len,
2255 RTE_CRYPTO_AUTH_OP_VERIFY,
2256 RTE_CRYPTO_AUTH_KASUMI_F9);
2259 /* alloc mbuf and set payload */
2260 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2262 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2263 rte_pktmbuf_tailroom(ut_params->ibuf));
2265 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2266 /* Append data which is padded to a multiple */
2267 /* of the algorithms block size */
2268 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2269 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2271 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2273 /* Create KASUMI operation */
2274 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2276 tdata->aad.data, tdata->aad.len,
2278 RTE_CRYPTO_AUTH_OP_VERIFY,
2279 RTE_CRYPTO_AUTH_KASUMI_F9,
2280 tdata->validAuthLenInBits.len,
2281 tdata->validAuthOffsetLenInBits.len);
2285 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2287 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2288 ut_params->obuf = ut_params->op->sym->m_src;
2289 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2290 + plaintext_pad_len + tdata->aad.len;
2293 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2302 test_snow3g_hash_generate_test_case_1(void)
2304 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2308 test_snow3g_hash_generate_test_case_2(void)
2310 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2314 test_snow3g_hash_generate_test_case_3(void)
2316 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2320 test_snow3g_hash_generate_test_case_4(void)
2322 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2326 test_snow3g_hash_generate_test_case_5(void)
2328 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2332 test_snow3g_hash_generate_test_case_6(void)
2334 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2338 test_snow3g_hash_verify_test_case_1(void)
2340 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2345 test_snow3g_hash_verify_test_case_2(void)
2347 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2351 test_snow3g_hash_verify_test_case_3(void)
2353 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2357 test_snow3g_hash_verify_test_case_4(void)
2359 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2363 test_snow3g_hash_verify_test_case_5(void)
2365 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2369 test_snow3g_hash_verify_test_case_6(void)
2371 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2375 test_kasumi_hash_generate_test_case_1(void)
2377 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2381 test_kasumi_hash_generate_test_case_2(void)
2383 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2387 test_kasumi_hash_generate_test_case_3(void)
2389 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2393 test_kasumi_hash_generate_test_case_4(void)
2395 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2399 test_kasumi_hash_generate_test_case_5(void)
2401 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2405 test_kasumi_hash_generate_test_case_6(void)
2407 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2411 test_kasumi_hash_verify_test_case_1(void)
2413 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2417 test_kasumi_hash_verify_test_case_2(void)
2419 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2423 test_kasumi_hash_verify_test_case_3(void)
2425 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2429 test_kasumi_hash_verify_test_case_4(void)
2431 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2435 test_kasumi_hash_verify_test_case_5(void)
2437 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2441 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2443 struct crypto_testsuite_params *ts_params = &testsuite_params;
2444 struct crypto_unittest_params *ut_params = &unittest_params;
2447 uint8_t *plaintext, *ciphertext;
2448 unsigned plaintext_pad_len;
2449 unsigned plaintext_len;
2451 /* Create KASUMI session */
2452 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2453 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2454 RTE_CRYPTO_CIPHER_KASUMI_F8,
2455 tdata->key.data, tdata->key.len);
2459 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2461 /* Clear mbuf payload */
2462 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2463 rte_pktmbuf_tailroom(ut_params->ibuf));
2465 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2466 /* Append data which is padded to a multiple */
2467 /* of the algorithms block size */
2468 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2469 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2471 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2473 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2475 /* Create KASUMI operation */
2476 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2477 tdata->plaintext.len,
2478 tdata->validCipherOffsetLenInBits.len,
2479 RTE_CRYPTO_CIPHER_KASUMI_F8);
2483 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2485 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2487 ut_params->obuf = ut_params->op->sym->m_dst;
2488 if (ut_params->obuf)
2489 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2492 ciphertext = plaintext;
2494 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2497 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2499 tdata->ciphertext.data,
2500 tdata->validCipherLenInBits.len,
2501 "KASUMI Ciphertext data not as expected");
2506 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2508 struct crypto_testsuite_params *ts_params = &testsuite_params;
2509 struct crypto_unittest_params *ut_params = &unittest_params;
2512 uint8_t *plaintext, *ciphertext;
2513 unsigned plaintext_pad_len;
2514 unsigned plaintext_len;
2516 /* Create KASUMI session */
2517 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2518 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2519 RTE_CRYPTO_CIPHER_KASUMI_F8,
2520 tdata->key.data, tdata->key.len);
2524 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2525 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2527 /* Clear mbuf payload */
2528 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2529 rte_pktmbuf_tailroom(ut_params->ibuf));
2531 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2532 /* Append data which is padded to a multiple */
2533 /* of the algorithms block size */
2534 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2535 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2537 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2538 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2540 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2542 /* Create KASUMI operation */
2543 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2545 tdata->plaintext.len,
2546 tdata->validCipherOffsetLenInBits.len,
2547 RTE_CRYPTO_CIPHER_KASUMI_F8);
2551 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2553 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2555 ut_params->obuf = ut_params->op->sym->m_dst;
2556 if (ut_params->obuf)
2557 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2560 ciphertext = plaintext;
2562 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2565 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2567 tdata->ciphertext.data,
2568 tdata->validCipherLenInBits.len,
2569 "KASUMI Ciphertext data not as expected");
2574 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2576 struct crypto_testsuite_params *ts_params = &testsuite_params;
2577 struct crypto_unittest_params *ut_params = &unittest_params;
2580 uint8_t *ciphertext, *plaintext;
2581 unsigned ciphertext_pad_len;
2582 unsigned ciphertext_len;
2584 /* Create KASUMI session */
2585 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2586 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2587 RTE_CRYPTO_CIPHER_KASUMI_F8,
2588 tdata->key.data, tdata->key.len);
2592 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2593 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2595 /* Clear mbuf payload */
2596 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2597 rte_pktmbuf_tailroom(ut_params->ibuf));
2599 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2600 /* Append data which is padded to a multiple */
2601 /* of the algorithms block size */
2602 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2603 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2604 ciphertext_pad_len);
2605 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2606 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2608 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2610 /* Create KASUMI operation */
2611 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2613 tdata->ciphertext.len,
2614 tdata->validCipherOffsetLenInBits.len,
2615 RTE_CRYPTO_CIPHER_KASUMI_F8);
2619 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2621 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2623 ut_params->obuf = ut_params->op->sym->m_dst;
2624 if (ut_params->obuf)
2625 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2628 plaintext = ciphertext;
2630 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2633 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2635 tdata->plaintext.data,
2636 tdata->validCipherLenInBits.len,
2637 "KASUMI Plaintext data not as expected");
2642 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2644 struct crypto_testsuite_params *ts_params = &testsuite_params;
2645 struct crypto_unittest_params *ut_params = &unittest_params;
2648 uint8_t *ciphertext, *plaintext;
2649 unsigned ciphertext_pad_len;
2650 unsigned ciphertext_len;
2652 /* Create KASUMI session */
2653 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2654 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2655 RTE_CRYPTO_CIPHER_KASUMI_F8,
2656 tdata->key.data, tdata->key.len);
2660 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2662 /* Clear mbuf payload */
2663 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2664 rte_pktmbuf_tailroom(ut_params->ibuf));
2666 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2667 /* Append data which is padded to a multiple */
2668 /* of the algorithms block size */
2669 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2670 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2671 ciphertext_pad_len);
2672 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2674 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2676 /* Create KASUMI operation */
2677 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2679 tdata->ciphertext.len,
2680 tdata->validCipherOffsetLenInBits.len,
2681 RTE_CRYPTO_CIPHER_KASUMI_F8);
2685 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2687 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2689 ut_params->obuf = ut_params->op->sym->m_dst;
2690 if (ut_params->obuf)
2691 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2694 plaintext = ciphertext;
2696 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2699 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2701 tdata->plaintext.data,
2702 tdata->validCipherLenInBits.len,
2703 "KASUMI Plaintext data not as expected");
2708 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2710 struct crypto_testsuite_params *ts_params = &testsuite_params;
2711 struct crypto_unittest_params *ut_params = &unittest_params;
2714 uint8_t *plaintext, *ciphertext;
2715 unsigned plaintext_pad_len;
2716 unsigned plaintext_len;
2718 /* Create SNOW 3G session */
2719 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2720 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2721 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2722 tdata->key.data, tdata->key.len);
2726 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2728 /* Clear mbuf payload */
2729 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2730 rte_pktmbuf_tailroom(ut_params->ibuf));
2732 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2733 /* Append data which is padded to a multiple of */
2734 /* the algorithms block size */
2735 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2736 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2738 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2740 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2742 /* Create SNOW 3G operation */
2743 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2744 tdata->validCipherLenInBits.len,
2745 tdata->validCipherOffsetLenInBits.len,
2746 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2750 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2752 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2754 ut_params->obuf = ut_params->op->sym->m_dst;
2755 if (ut_params->obuf)
2756 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2759 ciphertext = plaintext;
2761 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2764 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2766 tdata->ciphertext.data,
2767 tdata->validDataLenInBits.len,
2768 "SNOW 3G Ciphertext data not as expected");
2774 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2776 struct crypto_testsuite_params *ts_params = &testsuite_params;
2777 struct crypto_unittest_params *ut_params = &unittest_params;
2778 uint8_t *plaintext, *ciphertext;
2781 unsigned plaintext_pad_len;
2782 unsigned plaintext_len;
2784 /* Create SNOW 3G session */
2785 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2786 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2787 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2788 tdata->key.data, tdata->key.len);
2792 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2793 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2795 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2796 "Failed to allocate input buffer in mempool");
2797 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2798 "Failed to allocate output buffer in mempool");
2800 /* Clear mbuf payload */
2801 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2802 rte_pktmbuf_tailroom(ut_params->ibuf));
2804 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2805 /* Append data which is padded to a multiple of */
2806 /* the algorithms block size */
2807 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2808 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2810 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2811 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2813 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2815 /* Create SNOW 3G operation */
2816 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2818 tdata->validCipherLenInBits.len,
2819 tdata->validCipherOffsetLenInBits.len,
2820 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2824 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2826 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2828 ut_params->obuf = ut_params->op->sym->m_dst;
2829 if (ut_params->obuf)
2830 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2833 ciphertext = plaintext;
2835 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2838 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2840 tdata->ciphertext.data,
2841 tdata->validDataLenInBits.len,
2842 "SNOW 3G Ciphertext data not as expected");
2846 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2848 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2850 uint8_t curr_byte, prev_byte;
2851 uint32_t length_in_bytes = ceil_byte_length(length + offset);
2852 uint8_t lower_byte_mask = (1 << offset) - 1;
2855 prev_byte = buffer[0];
2856 buffer[0] >>= offset;
2858 for (i = 1; i < length_in_bytes; i++) {
2859 curr_byte = buffer[i];
2860 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2861 (curr_byte >> offset);
2862 prev_byte = curr_byte;
2867 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2869 struct crypto_testsuite_params *ts_params = &testsuite_params;
2870 struct crypto_unittest_params *ut_params = &unittest_params;
2871 uint8_t *plaintext, *ciphertext;
2873 uint32_t plaintext_len;
2874 uint32_t plaintext_pad_len;
2875 uint8_t extra_offset = 4;
2876 uint8_t *expected_ciphertext_shifted;
2878 /* Create SNOW 3G session */
2879 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2880 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2881 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2882 tdata->key.data, tdata->key.len);
2886 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2887 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2889 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2890 "Failed to allocate input buffer in mempool");
2891 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2892 "Failed to allocate output buffer in mempool");
2894 /* Clear mbuf payload */
2895 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2896 rte_pktmbuf_tailroom(ut_params->ibuf));
2898 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2900 * Append data which is padded to a
2901 * multiple of the algorithms block size
2903 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2905 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2908 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2910 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2911 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2913 #ifdef RTE_APP_TEST_DEBUG
2914 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2916 /* Create SNOW 3G operation */
2917 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2919 tdata->validCipherLenInBits.len,
2920 tdata->validCipherOffsetLenInBits.len +
2922 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2926 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2928 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2930 ut_params->obuf = ut_params->op->sym->m_dst;
2931 if (ut_params->obuf)
2932 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2935 ciphertext = plaintext;
2937 #ifdef RTE_APP_TEST_DEBUG
2938 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2941 expected_ciphertext_shifted = rte_malloc(NULL,
2942 ceil_byte_length(plaintext_len + extra_offset), 0);
2944 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2945 "failed to reserve memory for ciphertext shifted\n");
2947 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
2948 ceil_byte_length(tdata->ciphertext.len));
2949 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
2952 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
2954 expected_ciphertext_shifted,
2955 tdata->validDataLenInBits.len,
2957 "SNOW 3G Ciphertext data not as expected");
2961 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2963 struct crypto_testsuite_params *ts_params = &testsuite_params;
2964 struct crypto_unittest_params *ut_params = &unittest_params;
2968 uint8_t *plaintext, *ciphertext;
2969 unsigned ciphertext_pad_len;
2970 unsigned ciphertext_len;
2972 /* Create SNOW 3G session */
2973 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2974 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2975 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2976 tdata->key.data, tdata->key.len);
2980 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2982 /* Clear mbuf payload */
2983 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2984 rte_pktmbuf_tailroom(ut_params->ibuf));
2986 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2987 /* Append data which is padded to a multiple of */
2988 /* the algorithms block size */
2989 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
2990 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2991 ciphertext_pad_len);
2992 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2994 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2996 /* Create SNOW 3G operation */
2997 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2998 tdata->validCipherLenInBits.len,
2999 tdata->validCipherOffsetLenInBits.len,
3000 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3004 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3006 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3007 ut_params->obuf = ut_params->op->sym->m_dst;
3008 if (ut_params->obuf)
3009 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3012 plaintext = ciphertext;
3014 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3017 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3018 tdata->plaintext.data,
3019 tdata->validDataLenInBits.len,
3020 "SNOW 3G Plaintext data not as expected");
3024 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3026 struct crypto_testsuite_params *ts_params = &testsuite_params;
3027 struct crypto_unittest_params *ut_params = &unittest_params;
3031 uint8_t *plaintext, *ciphertext;
3032 unsigned ciphertext_pad_len;
3033 unsigned ciphertext_len;
3035 /* Create SNOW 3G session */
3036 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3037 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3038 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3039 tdata->key.data, tdata->key.len);
3043 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3044 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3046 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3047 "Failed to allocate input buffer");
3048 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3049 "Failed to allocate output buffer");
3051 /* Clear mbuf payload */
3052 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3053 rte_pktmbuf_tailroom(ut_params->ibuf));
3055 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3056 rte_pktmbuf_tailroom(ut_params->obuf));
3058 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3059 /* Append data which is padded to a multiple of */
3060 /* the algorithms block size */
3061 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3062 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3063 ciphertext_pad_len);
3064 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3065 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3067 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3069 /* Create SNOW 3G operation */
3070 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3072 tdata->validCipherLenInBits.len,
3073 tdata->validCipherOffsetLenInBits.len,
3074 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3078 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3080 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3081 ut_params->obuf = ut_params->op->sym->m_dst;
3082 if (ut_params->obuf)
3083 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3086 plaintext = ciphertext;
3088 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3091 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3092 tdata->plaintext.data,
3093 tdata->validDataLenInBits.len,
3094 "SNOW 3G Plaintext data not as expected");
3099 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3101 struct crypto_testsuite_params *ts_params = &testsuite_params;
3102 struct crypto_unittest_params *ut_params = &unittest_params;
3106 uint8_t *plaintext, *ciphertext;
3107 unsigned plaintext_pad_len;
3108 unsigned plaintext_len;
3110 /* Create SNOW 3G session */
3111 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3112 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3113 RTE_CRYPTO_AUTH_OP_GENERATE,
3114 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3115 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3116 tdata->key.data, tdata->key.len,
3117 tdata->aad.len, tdata->digest.len);
3120 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3122 /* clear mbuf payload */
3123 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3124 rte_pktmbuf_tailroom(ut_params->ibuf));
3126 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3127 /* Append data which is padded to a multiple of */
3128 /* the algorithms block size */
3129 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3130 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3132 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3134 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3136 /* Create SNOW 3G operation */
3137 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3138 tdata->digest.len, tdata->aad.data,
3139 tdata->aad.len, /*tdata->plaintext.len,*/
3140 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3141 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3142 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3143 tdata->iv.data, tdata->iv.len,
3144 tdata->validCipherLenInBits.len,
3145 tdata->validCipherOffsetLenInBits.len,
3146 tdata->validAuthLenInBits.len,
3147 tdata->validAuthOffsetLenInBits.len
3152 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3154 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3155 ut_params->obuf = ut_params->op->sym->m_src;
3156 if (ut_params->obuf)
3157 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3158 + tdata->iv.len + tdata->aad.len;
3160 ciphertext = plaintext;
3162 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3164 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3166 tdata->ciphertext.data,
3167 tdata->validDataLenInBits.len,
3168 "SNOW 3G Ciphertext data not as expected");
3170 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3171 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3174 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3177 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3178 "SNOW 3G Generated auth tag not as expected");
3182 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3184 struct crypto_testsuite_params *ts_params = &testsuite_params;
3185 struct crypto_unittest_params *ut_params = &unittest_params;
3189 uint8_t *plaintext, *ciphertext;
3190 unsigned plaintext_pad_len;
3191 unsigned plaintext_len;
3193 /* Create SNOW 3G session */
3194 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3195 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3196 RTE_CRYPTO_AUTH_OP_GENERATE,
3197 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3198 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3199 tdata->key.data, tdata->key.len,
3200 tdata->aad.len, tdata->digest.len);
3204 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3206 /* clear mbuf payload */
3207 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3208 rte_pktmbuf_tailroom(ut_params->ibuf));
3210 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3211 /* Append data which is padded to a multiple of */
3212 /* the algorithms block size */
3213 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3214 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3216 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3218 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3220 /* Create SNOW 3G operation */
3221 retval = create_wireless_algo_auth_cipher_operation(
3223 tdata->iv.data, tdata->iv.len,
3224 tdata->aad.data, tdata->aad.len,
3226 tdata->validCipherLenInBits.len,
3227 tdata->validCipherOffsetLenInBits.len,
3228 tdata->validAuthLenInBits.len,
3229 tdata->validAuthOffsetLenInBits.len,
3230 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3231 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3237 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3239 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3240 ut_params->obuf = ut_params->op->sym->m_src;
3241 if (ut_params->obuf)
3242 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3243 + tdata->aad.len + tdata->iv.len;
3245 ciphertext = plaintext;
3247 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3248 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3249 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3252 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3254 tdata->ciphertext.data,
3255 tdata->validDataLenInBits.len,
3256 "SNOW 3G Ciphertext data not as expected");
3259 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3262 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3263 "SNOW 3G Generated auth tag not as expected");
3268 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3270 struct crypto_testsuite_params *ts_params = &testsuite_params;
3271 struct crypto_unittest_params *ut_params = &unittest_params;
3275 uint8_t *plaintext, *ciphertext;
3276 unsigned plaintext_pad_len;
3277 unsigned plaintext_len;
3279 /* Create KASUMI session */
3280 retval = create_wireless_algo_auth_cipher_session(
3281 ts_params->valid_devs[0],
3282 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3283 RTE_CRYPTO_AUTH_OP_GENERATE,
3284 RTE_CRYPTO_AUTH_KASUMI_F9,
3285 RTE_CRYPTO_CIPHER_KASUMI_F8,
3286 tdata->key.data, tdata->key.len,
3287 tdata->aad.len, tdata->digest.len);
3290 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3292 /* clear mbuf payload */
3293 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3294 rte_pktmbuf_tailroom(ut_params->ibuf));
3296 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3297 /* Append data which is padded to a multiple of */
3298 /* the algorithms block size */
3299 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3300 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3302 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3304 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3306 /* Create KASUMI operation */
3307 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3308 tdata->iv.data, tdata->iv.len,
3309 tdata->aad.data, tdata->aad.len,
3311 tdata->validCipherLenInBits.len,
3312 tdata->validCipherOffsetLenInBits.len,
3313 tdata->validAuthLenInBits.len,
3314 tdata->validAuthOffsetLenInBits.len,
3315 RTE_CRYPTO_AUTH_KASUMI_F9,
3316 RTE_CRYPTO_CIPHER_KASUMI_F8
3322 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3324 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3325 ut_params->obuf = ut_params->op->sym->m_src;
3326 if (ut_params->obuf)
3327 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3328 + tdata->iv.len + tdata->aad.len;
3330 ciphertext = plaintext;
3333 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3335 tdata->ciphertext.data,
3336 tdata->validCipherLenInBits.len,
3337 "KASUMI Ciphertext data not as expected");
3338 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3339 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3342 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3345 DIGEST_BYTE_LENGTH_KASUMI_F9,
3346 "KASUMI Generated auth tag not as expected");
3351 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3353 struct crypto_testsuite_params *ts_params = &testsuite_params;
3354 struct crypto_unittest_params *ut_params = &unittest_params;
3358 uint8_t *plaintext, *ciphertext;
3359 unsigned plaintext_pad_len;
3360 unsigned plaintext_len;
3362 /* Create KASUMI session */
3363 retval = create_wireless_algo_cipher_auth_session(
3364 ts_params->valid_devs[0],
3365 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3366 RTE_CRYPTO_AUTH_OP_GENERATE,
3367 RTE_CRYPTO_AUTH_KASUMI_F9,
3368 RTE_CRYPTO_CIPHER_KASUMI_F8,
3369 tdata->key.data, tdata->key.len,
3370 tdata->aad.len, tdata->digest.len);
3374 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3376 /* clear mbuf payload */
3377 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3378 rte_pktmbuf_tailroom(ut_params->ibuf));
3380 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3381 /* Append data which is padded to a multiple of */
3382 /* the algorithms block size */
3383 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3384 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3386 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3388 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3390 /* Create KASUMI operation */
3391 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3392 tdata->digest.len, tdata->aad.data,
3394 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3395 RTE_CRYPTO_AUTH_KASUMI_F9,
3396 RTE_CRYPTO_CIPHER_KASUMI_F8,
3397 tdata->iv.data, tdata->iv.len,
3398 tdata->validCipherLenInBits.len,
3399 tdata->validCipherOffsetLenInBits.len,
3400 tdata->validAuthLenInBits.len,
3401 tdata->validAuthOffsetLenInBits.len
3406 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3408 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3409 ut_params->obuf = ut_params->op->sym->m_src;
3410 if (ut_params->obuf)
3411 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3412 + tdata->aad.len + tdata->iv.len;
3414 ciphertext = plaintext;
3416 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3417 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3420 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3422 tdata->ciphertext.data,
3423 tdata->validCipherLenInBits.len,
3424 "KASUMI Ciphertext data not as expected");
3427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3430 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3431 "KASUMI Generated auth tag not as expected");
3436 test_zuc_encryption(const struct zuc_test_data *tdata)
3438 struct crypto_testsuite_params *ts_params = &testsuite_params;
3439 struct crypto_unittest_params *ut_params = &unittest_params;
3442 uint8_t *plaintext, *ciphertext;
3443 unsigned plaintext_pad_len;
3444 unsigned plaintext_len;
3446 /* Create ZUC session */
3447 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3448 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3449 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3450 tdata->key.data, tdata->key.len);
3454 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3456 /* Clear mbuf payload */
3457 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3458 rte_pktmbuf_tailroom(ut_params->ibuf));
3460 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3461 /* Append data which is padded to a multiple */
3462 /* of the algorithms block size */
3463 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3464 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3466 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3468 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3470 /* Create ZUC operation */
3471 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3472 tdata->plaintext.len,
3473 tdata->validCipherOffsetLenInBits.len,
3474 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3478 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3480 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3482 ut_params->obuf = ut_params->op->sym->m_dst;
3483 if (ut_params->obuf)
3484 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3487 ciphertext = plaintext;
3489 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3492 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3494 tdata->ciphertext.data,
3495 tdata->validCipherLenInBits.len,
3496 "ZUC Ciphertext data not as expected");
3501 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3503 struct crypto_testsuite_params *ts_params = &testsuite_params;
3504 struct crypto_unittest_params *ut_params = &unittest_params;
3507 unsigned plaintext_pad_len;
3508 unsigned plaintext_len;
3511 /* Create ZUC session */
3512 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3513 tdata->key.data, tdata->key.len,
3514 tdata->aad.len, tdata->digest.len,
3515 RTE_CRYPTO_AUTH_OP_GENERATE,
3516 RTE_CRYPTO_AUTH_ZUC_EIA3);
3520 /* alloc mbuf and set payload */
3521 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3523 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3524 rte_pktmbuf_tailroom(ut_params->ibuf));
3526 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3527 /* Append data which is padded to a multiple of */
3528 /* the algorithms block size */
3529 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3530 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3532 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3534 /* Create ZUC operation */
3535 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3536 tdata->aad.data, tdata->aad.len,
3537 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3538 RTE_CRYPTO_AUTH_ZUC_EIA3,
3539 tdata->validAuthLenInBits.len,
3540 tdata->validAuthOffsetLenInBits.len);
3544 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3546 ut_params->obuf = ut_params->op->sym->m_src;
3547 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3548 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3549 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3552 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3555 DIGEST_BYTE_LENGTH_KASUMI_F9,
3556 "ZUC Generated auth tag not as expected");
3562 test_kasumi_encryption_test_case_1(void)
3564 return test_kasumi_encryption(&kasumi_test_case_1);
3568 test_kasumi_encryption_test_case_1_oop(void)
3570 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3574 test_kasumi_encryption_test_case_2(void)
3576 return test_kasumi_encryption(&kasumi_test_case_2);
3580 test_kasumi_encryption_test_case_3(void)
3582 return test_kasumi_encryption(&kasumi_test_case_3);
3586 test_kasumi_encryption_test_case_4(void)
3588 return test_kasumi_encryption(&kasumi_test_case_4);
3592 test_kasumi_encryption_test_case_5(void)
3594 return test_kasumi_encryption(&kasumi_test_case_5);
3598 test_kasumi_decryption_test_case_1(void)
3600 return test_kasumi_decryption(&kasumi_test_case_1);
3604 test_kasumi_decryption_test_case_1_oop(void)
3606 return test_kasumi_decryption_oop(&kasumi_test_case_1);
3610 test_kasumi_decryption_test_case_2(void)
3612 return test_kasumi_decryption(&kasumi_test_case_2);
3616 test_kasumi_decryption_test_case_3(void)
3618 return test_kasumi_decryption(&kasumi_test_case_3);
3622 test_kasumi_decryption_test_case_4(void)
3624 return test_kasumi_decryption(&kasumi_test_case_4);
3628 test_kasumi_decryption_test_case_5(void)
3630 return test_kasumi_decryption(&kasumi_test_case_5);
3633 test_snow3g_encryption_test_case_1(void)
3635 return test_snow3g_encryption(&snow3g_test_case_1);
3639 test_snow3g_encryption_test_case_1_oop(void)
3641 return test_snow3g_encryption_oop(&snow3g_test_case_1);
3645 test_snow3g_encryption_test_case_1_offset_oop(void)
3647 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
3651 test_snow3g_encryption_test_case_2(void)
3653 return test_snow3g_encryption(&snow3g_test_case_2);
3657 test_snow3g_encryption_test_case_3(void)
3659 return test_snow3g_encryption(&snow3g_test_case_3);
3663 test_snow3g_encryption_test_case_4(void)
3665 return test_snow3g_encryption(&snow3g_test_case_4);
3669 test_snow3g_encryption_test_case_5(void)
3671 return test_snow3g_encryption(&snow3g_test_case_5);
3675 test_snow3g_decryption_test_case_1(void)
3677 return test_snow3g_decryption(&snow3g_test_case_1);
3681 test_snow3g_decryption_test_case_1_oop(void)
3683 return test_snow3g_decryption_oop(&snow3g_test_case_1);
3687 test_snow3g_decryption_test_case_2(void)
3689 return test_snow3g_decryption(&snow3g_test_case_2);
3693 test_snow3g_decryption_test_case_3(void)
3695 return test_snow3g_decryption(&snow3g_test_case_3);
3699 test_snow3g_decryption_test_case_4(void)
3701 return test_snow3g_decryption(&snow3g_test_case_4);
3705 test_snow3g_decryption_test_case_5(void)
3707 return test_snow3g_decryption(&snow3g_test_case_5);
3710 test_snow3g_cipher_auth_test_case_1(void)
3712 return test_snow3g_cipher_auth(&snow3g_test_case_3);
3716 test_snow3g_auth_cipher_test_case_1(void)
3718 return test_snow3g_auth_cipher(&snow3g_test_case_6);
3722 test_kasumi_auth_cipher_test_case_1(void)
3724 return test_kasumi_auth_cipher(&kasumi_test_case_3);
3728 test_kasumi_cipher_auth_test_case_1(void)
3730 return test_kasumi_cipher_auth(&kasumi_test_case_6);
3734 test_zuc_encryption_test_case_1(void)
3736 return test_zuc_encryption(&zuc_test_case_1);
3740 test_zuc_encryption_test_case_2(void)
3742 return test_zuc_encryption(&zuc_test_case_2);
3746 test_zuc_encryption_test_case_3(void)
3748 return test_zuc_encryption(&zuc_test_case_3);
3752 test_zuc_encryption_test_case_4(void)
3754 return test_zuc_encryption(&zuc_test_case_4);
3758 test_zuc_encryption_test_case_5(void)
3760 return test_zuc_encryption(&zuc_test_case_5);
3764 test_zuc_hash_generate_test_case_1(void)
3766 return test_zuc_authentication(&zuc_hash_test_case_1);
3770 test_zuc_hash_generate_test_case_2(void)
3772 return test_zuc_authentication(&zuc_hash_test_case_2);
3776 test_zuc_hash_generate_test_case_3(void)
3778 return test_zuc_authentication(&zuc_hash_test_case_3);
3782 test_zuc_hash_generate_test_case_4(void)
3784 return test_zuc_authentication(&zuc_hash_test_case_4);
3788 test_zuc_hash_generate_test_case_5(void)
3790 return test_zuc_authentication(&zuc_hash_test_case_5);
3794 test_3DES_chain_qat_all(void)
3796 struct crypto_testsuite_params *ts_params = &testsuite_params;
3799 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3800 ts_params->op_mpool, ts_params->valid_devs[0],
3801 RTE_CRYPTODEV_QAT_SYM_PMD,
3802 BLKCIPHER_3DES_CHAIN_TYPE);
3804 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3806 return TEST_SUCCESS;
3810 test_3DES_cipheronly_qat_all(void)
3812 struct crypto_testsuite_params *ts_params = &testsuite_params;
3815 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3816 ts_params->op_mpool, ts_params->valid_devs[0],
3817 RTE_CRYPTODEV_QAT_SYM_PMD,
3818 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3820 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3822 return TEST_SUCCESS;
3826 test_3DES_chain_libcrypto_all(void)
3828 struct crypto_testsuite_params *ts_params = &testsuite_params;
3831 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3832 ts_params->op_mpool, ts_params->valid_devs[0],
3833 RTE_CRYPTODEV_LIBCRYPTO_PMD,
3834 BLKCIPHER_3DES_CHAIN_TYPE);
3836 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3838 return TEST_SUCCESS;
3842 test_3DES_cipheronly_libcrypto_all(void)
3844 struct crypto_testsuite_params *ts_params = &testsuite_params;
3847 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3848 ts_params->op_mpool, ts_params->valid_devs[0],
3849 RTE_CRYPTODEV_LIBCRYPTO_PMD,
3850 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3852 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3854 return TEST_SUCCESS;
3857 /* ***** AES-GCM Tests ***** */
3860 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3861 const uint8_t *key, const uint8_t key_len,
3862 const uint8_t aad_len, const uint8_t auth_len,
3863 enum rte_crypto_auth_operation auth_op)
3865 uint8_t cipher_key[key_len];
3867 struct crypto_unittest_params *ut_params = &unittest_params;
3869 memcpy(cipher_key, key, key_len);
3871 /* Setup Cipher Parameters */
3872 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3873 ut_params->cipher_xform.next = NULL;
3875 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3876 ut_params->auth_xform.auth.op = auth_op;
3877 ut_params->cipher_xform.cipher.op = op;
3878 ut_params->cipher_xform.cipher.key.data = cipher_key;
3879 ut_params->cipher_xform.cipher.key.length = key_len;
3881 TEST_HEXDUMP(stdout, "key:", key, key_len);
3883 /* Setup Authentication Parameters */
3884 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3885 ut_params->auth_xform.next = NULL;
3887 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3889 ut_params->auth_xform.auth.digest_length = auth_len;
3890 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3891 ut_params->auth_xform.auth.key.length = 0;
3892 ut_params->auth_xform.auth.key.data = NULL;
3894 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3895 ut_params->cipher_xform.next = &ut_params->auth_xform;
3897 /* Create Crypto session*/
3898 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3899 &ut_params->cipher_xform);
3900 } else {/* Create Crypto session*/
3901 ut_params->auth_xform.next = &ut_params->cipher_xform;
3902 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3903 &ut_params->auth_xform);
3906 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3912 create_gcm_operation(enum rte_crypto_cipher_operation op,
3913 const uint8_t *auth_tag, const unsigned auth_tag_len,
3914 const uint8_t *iv, const unsigned iv_len,
3915 const uint8_t *aad, const unsigned aad_len,
3916 const unsigned data_len, unsigned data_pad_len)
3918 struct crypto_testsuite_params *ts_params = &testsuite_params;
3919 struct crypto_unittest_params *ut_params = &unittest_params;
3921 unsigned iv_pad_len = 0, aad_buffer_len;
3923 /* Generate Crypto op data structure */
3924 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3925 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3926 TEST_ASSERT_NOT_NULL(ut_params->op,
3927 "Failed to allocate symmetric crypto operation struct");
3929 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3931 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3932 ut_params->ibuf, auth_tag_len);
3933 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3934 "no room to append digest");
3935 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3936 ut_params->ibuf, data_pad_len);
3937 sym_op->auth.digest.length = auth_tag_len;
3939 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3940 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3941 TEST_HEXDUMP(stdout, "digest:",
3942 sym_op->auth.digest.data,
3943 sym_op->auth.digest.length);
3947 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3949 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3950 ut_params->ibuf, iv_pad_len);
3951 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3953 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3954 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3955 sym_op->cipher.iv.length = iv_len;
3957 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3960 * Always allocate the aad up to the block size.
3961 * The cryptodev API calls out -
3962 * - the array must be big enough to hold the AAD, plus any
3963 * space to round this up to the nearest multiple of the
3964 * block size (16 bytes).
3966 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
3968 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
3969 ut_params->ibuf, aad_buffer_len);
3970 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
3971 "no room to prepend aad");
3972 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
3974 sym_op->auth.aad.length = aad_len;
3976 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
3977 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
3979 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
3980 TEST_HEXDUMP(stdout, "aad:",
3981 sym_op->auth.aad.data, aad_len);
3983 sym_op->cipher.data.length = data_len;
3984 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
3986 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
3987 sym_op->auth.data.length = data_len;
3993 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
3995 struct crypto_testsuite_params *ts_params = &testsuite_params;
3996 struct crypto_unittest_params *ut_params = &unittest_params;
4000 uint8_t *plaintext, *ciphertext, *auth_tag;
4001 uint16_t plaintext_pad_len;
4003 /* Create GCM session */
4004 retval = create_gcm_session(ts_params->valid_devs[0],
4005 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4006 tdata->key.data, tdata->key.len,
4007 tdata->aad.len, tdata->auth_tag.len,
4008 RTE_CRYPTO_AUTH_OP_GENERATE);
4013 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4015 /* clear mbuf payload */
4016 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4017 rte_pktmbuf_tailroom(ut_params->ibuf));
4020 * Append data which is padded to a multiple
4021 * of the algorithms block size
4023 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4025 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4027 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4029 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4031 /* Create GCM opertaion */
4032 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4033 tdata->auth_tag.data, tdata->auth_tag.len,
4034 tdata->iv.data, tdata->iv.len,
4035 tdata->aad.data, tdata->aad.len,
4036 tdata->plaintext.len, plaintext_pad_len);
4040 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4042 ut_params->op->sym->m_src = ut_params->ibuf;
4044 /* Process crypto operation */
4045 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4046 ut_params->op), "failed to process sym crypto op");
4048 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4049 "crypto op processing failed");
4051 if (ut_params->op->sym->m_dst) {
4052 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4054 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4055 uint8_t *, plaintext_pad_len);
4057 ciphertext = plaintext;
4058 auth_tag = plaintext + plaintext_pad_len;
4061 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4062 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4065 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4067 tdata->ciphertext.data,
4068 tdata->ciphertext.len,
4069 "GCM Ciphertext data not as expected");
4071 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4073 tdata->auth_tag.data,
4074 tdata->auth_tag.len,
4075 "GCM Generated auth tag not as expected");
4082 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4084 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4088 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4090 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4094 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4096 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4100 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4102 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4106 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4108 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4112 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4114 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4118 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4120 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4124 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4126 struct crypto_testsuite_params *ts_params = &testsuite_params;
4127 struct crypto_unittest_params *ut_params = &unittest_params;
4131 uint8_t *plaintext, *ciphertext;
4132 uint16_t ciphertext_pad_len;
4134 /* Create GCM session */
4135 retval = create_gcm_session(ts_params->valid_devs[0],
4136 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4137 tdata->key.data, tdata->key.len,
4138 tdata->aad.len, tdata->auth_tag.len,
4139 RTE_CRYPTO_AUTH_OP_VERIFY);
4144 /* alloc mbuf and set payload */
4145 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4147 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4148 rte_pktmbuf_tailroom(ut_params->ibuf));
4150 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4152 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4153 ciphertext_pad_len);
4154 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
4156 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4158 /* Create GCM opertaion */
4159 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
4160 tdata->auth_tag.data, tdata->auth_tag.len,
4161 tdata->iv.data, tdata->iv.len,
4162 tdata->aad.data, tdata->aad.len,
4163 tdata->ciphertext.len, ciphertext_pad_len);
4168 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4170 ut_params->op->sym->m_src = ut_params->ibuf;
4172 /* Process crypto operation */
4173 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4174 ut_params->op), "failed to process sym crypto op");
4176 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4177 "crypto op processing failed");
4179 if (ut_params->op->sym->m_dst)
4180 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4183 plaintext = ciphertext;
4185 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4188 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4190 tdata->plaintext.data,
4191 tdata->plaintext.len,
4192 "GCM plaintext data not as expected");
4194 TEST_ASSERT_EQUAL(ut_params->op->status,
4195 RTE_CRYPTO_OP_STATUS_SUCCESS,
4196 "GCM authentication failed");
4201 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4203 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4207 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4209 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4213 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4215 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4219 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4221 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4225 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4227 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4231 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4233 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4237 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4239 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4245 struct crypto_testsuite_params *ts_params = &testsuite_params;
4246 struct rte_cryptodev_stats stats;
4247 struct rte_cryptodev *dev;
4248 cryptodev_stats_get_t temp_pfn;
4250 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4251 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
4252 &stats) == -ENODEV),
4253 "rte_cryptodev_stats_get invalid dev failed");
4254 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
4255 "rte_cryptodev_stats_get invalid Param failed");
4256 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
4257 temp_pfn = dev->dev_ops->stats_get;
4258 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
4259 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
4261 "rte_cryptodev_stats_get invalid Param failed");
4262 dev->dev_ops->stats_get = temp_pfn;
4264 /* Test expected values */
4266 test_AES_CBC_HMAC_SHA1_encrypt_digest();
4268 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4270 "rte_cryptodev_stats_get failed");
4271 TEST_ASSERT((stats.enqueued_count == 1),
4272 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4273 TEST_ASSERT((stats.dequeued_count == 1),
4274 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4275 TEST_ASSERT((stats.enqueue_err_count == 0),
4276 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4277 TEST_ASSERT((stats.dequeue_err_count == 0),
4278 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4280 /* invalid device but should ignore and not reset device stats*/
4281 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
4282 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4284 "rte_cryptodev_stats_get failed");
4285 TEST_ASSERT((stats.enqueued_count == 1),
4286 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4288 /* check that a valid reset clears stats */
4289 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4290 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4292 "rte_cryptodev_stats_get failed");
4293 TEST_ASSERT((stats.enqueued_count == 0),
4294 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4295 TEST_ASSERT((stats.dequeued_count == 0),
4296 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4298 return TEST_SUCCESS;
4301 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
4302 struct crypto_unittest_params *ut_params,
4303 enum rte_crypto_auth_operation op,
4304 const struct HMAC_MD5_vector *test_case)
4308 memcpy(key, test_case->key.data, test_case->key.len);
4310 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4311 ut_params->auth_xform.next = NULL;
4312 ut_params->auth_xform.auth.op = op;
4314 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
4316 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
4317 ut_params->auth_xform.auth.add_auth_data_length = 0;
4318 ut_params->auth_xform.auth.key.length = test_case->key.len;
4319 ut_params->auth_xform.auth.key.data = key;
4321 ut_params->sess = rte_cryptodev_sym_session_create(
4322 ts_params->valid_devs[0], &ut_params->auth_xform);
4324 if (ut_params->sess == NULL)
4327 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4329 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4330 rte_pktmbuf_tailroom(ut_params->ibuf));
4335 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
4336 const struct HMAC_MD5_vector *test_case,
4337 uint8_t **plaintext)
4339 uint16_t plaintext_pad_len;
4341 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4343 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4346 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4348 memcpy(*plaintext, test_case->plaintext.data,
4349 test_case->plaintext.len);
4351 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4352 ut_params->ibuf, MD5_DIGEST_LEN);
4353 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4354 "no room to append digest");
4355 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4356 ut_params->ibuf, plaintext_pad_len);
4357 sym_op->auth.digest.length = MD5_DIGEST_LEN;
4359 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
4360 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
4361 test_case->auth_tag.len);
4364 sym_op->auth.data.offset = 0;
4365 sym_op->auth.data.length = test_case->plaintext.len;
4367 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4368 ut_params->op->sym->m_src = ut_params->ibuf;
4374 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
4376 uint16_t plaintext_pad_len;
4377 uint8_t *plaintext, *auth_tag;
4379 struct crypto_testsuite_params *ts_params = &testsuite_params;
4380 struct crypto_unittest_params *ut_params = &unittest_params;
4382 if (MD5_HMAC_create_session(ts_params, ut_params,
4383 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
4386 /* Generate Crypto op data structure */
4387 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4388 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4389 TEST_ASSERT_NOT_NULL(ut_params->op,
4390 "Failed to allocate symmetric crypto operation struct");
4392 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4395 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4398 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4399 ut_params->op), "failed to process sym crypto op");
4401 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4402 "crypto op processing failed");
4404 if (ut_params->op->sym->m_dst) {
4405 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4406 uint8_t *, plaintext_pad_len);
4408 auth_tag = plaintext + plaintext_pad_len;
4411 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4413 test_case->auth_tag.data,
4414 test_case->auth_tag.len,
4415 "HMAC_MD5 generated tag not as expected");
4417 return TEST_SUCCESS;
4421 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
4425 struct crypto_testsuite_params *ts_params = &testsuite_params;
4426 struct crypto_unittest_params *ut_params = &unittest_params;
4428 if (MD5_HMAC_create_session(ts_params, ut_params,
4429 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
4433 /* Generate Crypto op data structure */
4434 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4435 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4436 TEST_ASSERT_NOT_NULL(ut_params->op,
4437 "Failed to allocate symmetric crypto operation struct");
4439 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4442 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4443 ut_params->op), "failed to process sym crypto op");
4445 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4446 "HMAC_MD5 crypto op processing failed");
4448 return TEST_SUCCESS;
4452 test_MD5_HMAC_generate_case_1(void)
4454 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
4458 test_MD5_HMAC_verify_case_1(void)
4460 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
4464 test_MD5_HMAC_generate_case_2(void)
4466 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
4470 test_MD5_HMAC_verify_case_2(void)
4472 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
4476 test_multi_session(void)
4478 struct crypto_testsuite_params *ts_params = &testsuite_params;
4479 struct crypto_unittest_params *ut_params = &unittest_params;
4481 struct rte_cryptodev_info dev_info;
4482 struct rte_cryptodev_sym_session **sessions;
4486 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
4487 aes_cbc_key, hmac_sha512_key);
4490 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4492 sessions = rte_malloc(NULL,
4493 (sizeof(struct rte_cryptodev_sym_session *) *
4494 dev_info.sym.max_nb_sessions) + 1, 0);
4496 /* Create multiple crypto sessions*/
4497 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
4498 sessions[i] = rte_cryptodev_sym_session_create(
4499 ts_params->valid_devs[0],
4500 &ut_params->auth_xform);
4501 TEST_ASSERT_NOT_NULL(sessions[i],
4502 "Session creation failed at session number %u",
4505 /* Attempt to send a request on each session */
4506 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
4510 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
4511 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
4513 "Failed to perform decrypt on request number %u.", i);
4514 /* free crypto operation structure */
4516 rte_crypto_op_free(ut_params->op);
4519 * free mbuf - both obuf and ibuf are usually the same,
4520 * so check if they point at the same address is necessary,
4521 * to avoid freeing the mbuf twice.
4523 if (ut_params->obuf) {
4524 rte_pktmbuf_free(ut_params->obuf);
4525 if (ut_params->ibuf == ut_params->obuf)
4526 ut_params->ibuf = 0;
4527 ut_params->obuf = 0;
4529 if (ut_params->ibuf) {
4530 rte_pktmbuf_free(ut_params->ibuf);
4531 ut_params->ibuf = 0;
4535 /* Next session create should fail */
4536 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
4537 &ut_params->auth_xform);
4538 TEST_ASSERT_NULL(sessions[i],
4539 "Session creation succeeded unexpectedly!");
4541 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
4542 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4547 return TEST_SUCCESS;
4550 struct multi_session_params {
4551 struct crypto_unittest_params ut_params;
4552 uint8_t *cipher_key;
4554 const uint8_t *cipher;
4555 const uint8_t *digest;
4559 #define MB_SESSION_NUMBER 3
4562 test_multi_session_random_usage(void)
4564 struct crypto_testsuite_params *ts_params = &testsuite_params;
4565 struct rte_cryptodev_info dev_info;
4566 struct rte_cryptodev_sym_session **sessions;
4568 struct multi_session_params ut_paramz[] = {
4571 .cipher_key = ms_aes_cbc_key0,
4572 .hmac_key = ms_hmac_key0,
4573 .cipher = ms_aes_cbc_cipher0,
4574 .digest = ms_hmac_digest0,
4575 .iv = ms_aes_cbc_iv0
4578 .cipher_key = ms_aes_cbc_key1,
4579 .hmac_key = ms_hmac_key1,
4580 .cipher = ms_aes_cbc_cipher1,
4581 .digest = ms_hmac_digest1,
4582 .iv = ms_aes_cbc_iv1
4585 .cipher_key = ms_aes_cbc_key2,
4586 .hmac_key = ms_hmac_key2,
4587 .cipher = ms_aes_cbc_cipher2,
4588 .digest = ms_hmac_digest2,
4589 .iv = ms_aes_cbc_iv2
4594 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4596 sessions = rte_malloc(NULL,
4597 (sizeof(struct rte_cryptodev_sym_session *)
4598 * dev_info.sym.max_nb_sessions) + 1, 0);
4600 for (i = 0; i < MB_SESSION_NUMBER; i++) {
4601 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
4602 sizeof(struct crypto_unittest_params));
4604 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
4605 &ut_paramz[i].ut_params,
4606 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
4608 /* Create multiple crypto sessions*/
4609 sessions[i] = rte_cryptodev_sym_session_create(
4610 ts_params->valid_devs[0],
4611 &ut_paramz[i].ut_params.auth_xform);
4613 TEST_ASSERT_NOT_NULL(sessions[i],
4614 "Session creation failed at session number %u",
4620 for (i = 0; i < 40000; i++) {
4622 j = rand() % MB_SESSION_NUMBER;
4624 TEST_ASSERT_SUCCESS(
4625 test_AES_CBC_HMAC_SHA512_decrypt_perform(
4627 &ut_paramz[j].ut_params,
4628 ts_params, ut_paramz[j].cipher,
4629 ut_paramz[j].digest,
4631 "Failed to perform decrypt on request number %u.", i);
4633 if (ut_paramz[j].ut_params.op)
4634 rte_crypto_op_free(ut_paramz[j].ut_params.op);
4637 * free mbuf - both obuf and ibuf are usually the same,
4638 * so check if they point at the same address is necessary,
4639 * to avoid freeing the mbuf twice.
4641 if (ut_paramz[j].ut_params.obuf) {
4642 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
4643 if (ut_paramz[j].ut_params.ibuf
4644 == ut_paramz[j].ut_params.obuf)
4645 ut_paramz[j].ut_params.ibuf = 0;
4646 ut_paramz[j].ut_params.obuf = 0;
4648 if (ut_paramz[j].ut_params.ibuf) {
4649 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
4650 ut_paramz[j].ut_params.ibuf = 0;
4654 for (i = 0; i < MB_SESSION_NUMBER; i++)
4655 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4660 return TEST_SUCCESS;
4664 test_null_cipher_only_operation(void)
4666 struct crypto_testsuite_params *ts_params = &testsuite_params;
4667 struct crypto_unittest_params *ut_params = &unittest_params;
4669 /* Generate test mbuf data and space for digest */
4670 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4671 catch_22_quote, QUOTE_512_BYTES, 0);
4673 /* Setup Cipher Parameters */
4674 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4675 ut_params->cipher_xform.next = NULL;
4677 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4678 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4680 /* Create Crypto session*/
4681 ut_params->sess = rte_cryptodev_sym_session_create(
4682 ts_params->valid_devs[0], &ut_params->cipher_xform);
4683 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4685 /* Generate Crypto op data structure */
4686 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4687 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4688 TEST_ASSERT_NOT_NULL(ut_params->op,
4689 "Failed to allocate symmetric crypto operation struct");
4691 /* Set crypto operation data parameters */
4692 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4694 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4696 /* set crypto operation source mbuf */
4697 sym_op->m_src = ut_params->ibuf;
4699 sym_op->cipher.data.offset = 0;
4700 sym_op->cipher.data.length = QUOTE_512_BYTES;
4702 /* Process crypto operation */
4703 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4705 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4707 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4708 "crypto operation processing failed");
4711 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4712 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4715 "Ciphertext data not as expected");
4717 return TEST_SUCCESS;
4721 test_null_auth_only_operation(void)
4723 struct crypto_testsuite_params *ts_params = &testsuite_params;
4724 struct crypto_unittest_params *ut_params = &unittest_params;
4726 /* Generate test mbuf data and space for digest */
4727 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4728 catch_22_quote, QUOTE_512_BYTES, 0);
4730 /* Setup HMAC Parameters */
4731 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4732 ut_params->auth_xform.next = NULL;
4734 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4735 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4737 /* Create Crypto session*/
4738 ut_params->sess = rte_cryptodev_sym_session_create(
4739 ts_params->valid_devs[0], &ut_params->auth_xform);
4740 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4742 /* Generate Crypto op data structure */
4743 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4744 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4745 TEST_ASSERT_NOT_NULL(ut_params->op,
4746 "Failed to allocate symmetric crypto operation struct");
4748 /* Set crypto operation data parameters */
4749 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4751 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4753 sym_op->m_src = ut_params->ibuf;
4755 sym_op->auth.data.offset = 0;
4756 sym_op->auth.data.length = QUOTE_512_BYTES;
4758 /* Process crypto operation */
4759 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4761 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4763 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4764 "crypto operation processing failed");
4766 return TEST_SUCCESS;
4770 test_null_cipher_auth_operation(void)
4772 struct crypto_testsuite_params *ts_params = &testsuite_params;
4773 struct crypto_unittest_params *ut_params = &unittest_params;
4775 /* Generate test mbuf data and space for digest */
4776 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4777 catch_22_quote, QUOTE_512_BYTES, 0);
4779 /* Setup Cipher Parameters */
4780 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4781 ut_params->cipher_xform.next = &ut_params->auth_xform;
4783 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4784 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4786 /* Setup HMAC Parameters */
4787 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4788 ut_params->auth_xform.next = NULL;
4790 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4791 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4793 /* Create Crypto session*/
4794 ut_params->sess = rte_cryptodev_sym_session_create(
4795 ts_params->valid_devs[0], &ut_params->cipher_xform);
4796 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4798 /* Generate Crypto op data structure */
4799 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4800 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4801 TEST_ASSERT_NOT_NULL(ut_params->op,
4802 "Failed to allocate symmetric crypto operation struct");
4804 /* Set crypto operation data parameters */
4805 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4807 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4809 sym_op->m_src = ut_params->ibuf;
4811 sym_op->cipher.data.offset = 0;
4812 sym_op->cipher.data.length = QUOTE_512_BYTES;
4814 sym_op->auth.data.offset = 0;
4815 sym_op->auth.data.length = QUOTE_512_BYTES;
4817 /* Process crypto operation */
4818 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4820 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4822 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4823 "crypto operation processing failed");
4826 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4827 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4830 "Ciphertext data not as expected");
4832 return TEST_SUCCESS;
4836 test_null_auth_cipher_operation(void)
4838 struct crypto_testsuite_params *ts_params = &testsuite_params;
4839 struct crypto_unittest_params *ut_params = &unittest_params;
4841 /* Generate test mbuf data and space for digest */
4842 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4843 catch_22_quote, QUOTE_512_BYTES, 0);
4845 /* Setup Cipher Parameters */
4846 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4847 ut_params->cipher_xform.next = NULL;
4849 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4850 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4852 /* Setup HMAC Parameters */
4853 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4854 ut_params->auth_xform.next = &ut_params->cipher_xform;
4856 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4857 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4859 /* Create Crypto session*/
4860 ut_params->sess = rte_cryptodev_sym_session_create(
4861 ts_params->valid_devs[0], &ut_params->cipher_xform);
4862 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4864 /* Generate Crypto op data structure */
4865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4867 TEST_ASSERT_NOT_NULL(ut_params->op,
4868 "Failed to allocate symmetric crypto operation struct");
4870 /* Set crypto operation data parameters */
4871 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4873 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4875 sym_op->m_src = ut_params->ibuf;
4877 sym_op->cipher.data.offset = 0;
4878 sym_op->cipher.data.length = QUOTE_512_BYTES;
4880 sym_op->auth.data.offset = 0;
4881 sym_op->auth.data.length = QUOTE_512_BYTES;
4883 /* Process crypto operation */
4884 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4886 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4888 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4889 "crypto operation processing failed");
4892 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4893 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4896 "Ciphertext data not as expected");
4898 return TEST_SUCCESS;
4903 test_null_invalid_operation(void)
4905 struct crypto_testsuite_params *ts_params = &testsuite_params;
4906 struct crypto_unittest_params *ut_params = &unittest_params;
4908 /* Setup Cipher Parameters */
4909 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4910 ut_params->cipher_xform.next = NULL;
4912 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
4913 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4915 /* Create Crypto session*/
4916 ut_params->sess = rte_cryptodev_sym_session_create(
4917 ts_params->valid_devs[0], &ut_params->cipher_xform);
4918 TEST_ASSERT_NULL(ut_params->sess,
4919 "Session creation succeeded unexpectedly");
4922 /* Setup HMAC Parameters */
4923 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4924 ut_params->auth_xform.next = NULL;
4926 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
4927 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4929 /* Create Crypto session*/
4930 ut_params->sess = rte_cryptodev_sym_session_create(
4931 ts_params->valid_devs[0], &ut_params->auth_xform);
4932 TEST_ASSERT_NULL(ut_params->sess,
4933 "Session creation succeeded unexpectedly");
4935 return TEST_SUCCESS;
4939 #define NULL_BURST_LENGTH (32)
4942 test_null_burst_operation(void)
4944 struct crypto_testsuite_params *ts_params = &testsuite_params;
4945 struct crypto_unittest_params *ut_params = &unittest_params;
4947 unsigned i, burst_len = NULL_BURST_LENGTH;
4949 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
4950 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
4952 /* Setup Cipher Parameters */
4953 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4954 ut_params->cipher_xform.next = &ut_params->auth_xform;
4956 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4957 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4959 /* Setup HMAC Parameters */
4960 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4961 ut_params->auth_xform.next = NULL;
4963 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4964 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4966 /* Create Crypto session*/
4967 ut_params->sess = rte_cryptodev_sym_session_create(
4968 ts_params->valid_devs[0], &ut_params->cipher_xform);
4969 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4971 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
4972 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
4973 burst_len, "failed to generate burst of crypto ops");
4975 /* Generate an operation for each mbuf in burst */
4976 for (i = 0; i < burst_len; i++) {
4977 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4979 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
4981 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
4985 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
4987 burst[i]->sym->m_src = m;
4990 /* Process crypto operation */
4991 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
4992 0, burst, burst_len),
4994 "Error enqueuing burst");
4996 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
4997 0, burst_dequeued, burst_len),
4999 "Error dequeuing burst");
5002 for (i = 0; i < burst_len; i++) {
5004 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
5005 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
5007 "data not as expected");
5009 rte_pktmbuf_free(burst[i]->sym->m_src);
5010 rte_crypto_op_free(burst[i]);
5013 return TEST_SUCCESS;
5017 generate_gmac_large_plaintext(uint8_t *data)
5021 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5022 memcpy(&data[i], &data[0], 32);
5026 create_gmac_operation(enum rte_crypto_auth_operation op,
5027 const struct gmac_test_data *tdata)
5029 struct crypto_testsuite_params *ts_params = &testsuite_params;
5030 struct crypto_unittest_params *ut_params = &unittest_params;
5031 struct rte_crypto_sym_op *sym_op;
5033 unsigned iv_pad_len;
5034 unsigned aad_pad_len;
5036 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5037 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5040 * Runtime generate the large plain text instead of use hard code
5041 * plain text vector. It is done to avoid create huge source file
5042 * with the test vector.
5044 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5045 generate_gmac_large_plaintext(tdata->aad.data);
5047 /* Generate Crypto op data structure */
5048 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5049 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5050 TEST_ASSERT_NOT_NULL(ut_params->op,
5051 "Failed to allocate symmetric crypto operation struct");
5053 sym_op = ut_params->op->sym;
5054 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5056 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5057 "no room to append aad");
5059 sym_op->auth.aad.length = tdata->aad.len;
5060 sym_op->auth.aad.phys_addr =
5061 rte_pktmbuf_mtophys(ut_params->ibuf);
5062 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5064 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5065 ut_params->ibuf, tdata->gmac_tag.len);
5066 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5067 "no room to append digest");
5069 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5070 ut_params->ibuf, aad_pad_len);
5071 sym_op->auth.digest.length = tdata->gmac_tag.len;
5073 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5074 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
5075 tdata->gmac_tag.len);
5076 TEST_HEXDUMP(stdout, "digest:",
5077 sym_op->auth.digest.data,
5078 sym_op->auth.digest.length);
5081 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5082 ut_params->ibuf, iv_pad_len);
5083 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5085 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5086 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5087 sym_op->cipher.iv.length = tdata->iv.len;
5089 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
5091 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
5093 sym_op->cipher.data.length = 0;
5094 sym_op->cipher.data.offset = 0;
5096 sym_op->auth.data.offset = 0;
5097 sym_op->auth.data.length = 0;
5102 static int create_gmac_session(uint8_t dev_id,
5103 enum rte_crypto_cipher_operation op,
5104 const struct gmac_test_data *tdata,
5105 enum rte_crypto_auth_operation auth_op)
5107 uint8_t cipher_key[tdata->key.len];
5109 struct crypto_unittest_params *ut_params = &unittest_params;
5111 memcpy(cipher_key, tdata->key.data, tdata->key.len);
5113 /* For GMAC we setup cipher parameters */
5114 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5115 ut_params->cipher_xform.next = NULL;
5116 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
5117 ut_params->cipher_xform.cipher.op = op;
5118 ut_params->cipher_xform.cipher.key.data = cipher_key;
5119 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
5121 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5122 ut_params->auth_xform.next = NULL;
5124 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
5125 ut_params->auth_xform.auth.op = auth_op;
5126 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
5127 ut_params->auth_xform.auth.add_auth_data_length = 0;
5128 ut_params->auth_xform.auth.key.length = 0;
5129 ut_params->auth_xform.auth.key.data = NULL;
5131 ut_params->cipher_xform.next = &ut_params->auth_xform;
5133 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5134 &ut_params->cipher_xform);
5136 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5142 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
5144 struct crypto_testsuite_params *ts_params = &testsuite_params;
5145 struct crypto_unittest_params *ut_params = &unittest_params;
5149 uint8_t *auth_tag, *p;
5150 uint16_t aad_pad_len;
5152 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5153 "No GMAC length in the source data");
5155 retval = create_gmac_session(ts_params->valid_devs[0],
5156 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5157 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
5162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5164 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5165 rte_pktmbuf_tailroom(ut_params->ibuf));
5167 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5169 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
5171 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
5177 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5179 ut_params->op->sym->m_src = ut_params->ibuf;
5181 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5182 ut_params->op), "failed to process sym crypto op");
5184 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5185 "crypto op processing failed");
5187 if (ut_params->op->sym->m_dst) {
5188 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5189 uint8_t *, aad_pad_len);
5191 auth_tag = p + aad_pad_len;
5194 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
5196 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5198 tdata->gmac_tag.data,
5199 tdata->gmac_tag.len,
5200 "GMAC Generated auth tag not as expected");
5206 test_AES_GMAC_authentication_test_case_1(void)
5208 return test_AES_GMAC_authentication(&gmac_test_case_1);
5212 test_AES_GMAC_authentication_test_case_2(void)
5214 return test_AES_GMAC_authentication(&gmac_test_case_2);
5218 test_AES_GMAC_authentication_test_case_3(void)
5220 return test_AES_GMAC_authentication(&gmac_test_case_3);
5224 test_AES_GMAC_authentication_test_case_4(void)
5226 return test_AES_GMAC_authentication(&gmac_test_case_4);
5230 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
5232 struct crypto_testsuite_params *ts_params = &testsuite_params;
5233 struct crypto_unittest_params *ut_params = &unittest_params;
5236 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5237 "No GMAC length in the source data");
5239 retval = create_gmac_session(ts_params->valid_devs[0],
5240 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5241 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
5246 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5248 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5249 rte_pktmbuf_tailroom(ut_params->ibuf));
5251 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
5257 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5259 ut_params->op->sym->m_src = ut_params->ibuf;
5261 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5262 ut_params->op), "failed to process sym crypto op");
5264 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5265 "crypto op processing failed");
5272 test_AES_GMAC_authentication_verify_test_case_1(void)
5274 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
5278 test_AES_GMAC_authentication_verify_test_case_2(void)
5280 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
5284 test_AES_GMAC_authentication_verify_test_case_3(void)
5286 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
5290 test_AES_GMAC_authentication_verify_test_case_4(void)
5292 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
5295 struct test_crypto_vector {
5296 enum rte_crypto_cipher_algorithm crypto_algo;
5309 const uint8_t *data;
5314 const uint8_t *data;
5318 enum rte_crypto_auth_algorithm auth_algo;
5326 const uint8_t *data;
5336 static const struct test_crypto_vector
5337 hmac_sha1_test_crypto_vector = {
5338 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5340 .data = plaintext_hash,
5345 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5346 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5347 0xDE, 0xF4, 0xDE, 0xAD
5353 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
5354 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
5355 0x3F, 0x91, 0x64, 0x59
5361 static const struct test_crypto_vector
5362 aes128_gmac_test_vector = {
5363 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
5364 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
5366 .data = plaintext_hash,
5371 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5372 0x08, 0x09, 0x0A, 0x0B
5378 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5379 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
5385 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
5386 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
5392 static const struct test_crypto_vector
5393 aes128cbc_hmac_sha1_test_vector = {
5394 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
5397 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
5398 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
5404 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5405 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
5410 .data = plaintext_hash,
5414 .data = ciphertext512_aes128cbc,
5417 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5420 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5421 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5422 0xDE, 0xF4, 0xDE, 0xAD
5428 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
5429 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5430 0x18, 0x8C, 0x1D, 0x32
5437 data_corruption(uint8_t *data)
5443 tag_corruption(uint8_t *data, unsigned int tag_offset)
5445 data[tag_offset] += 1;
5449 create_auth_session(struct crypto_unittest_params *ut_params,
5451 const struct test_crypto_vector *reference,
5452 enum rte_crypto_auth_operation auth_op)
5454 uint8_t auth_key[reference->auth_key.len + 1];
5456 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5458 /* Setup Authentication Parameters */
5459 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5460 ut_params->auth_xform.auth.op = auth_op;
5461 ut_params->auth_xform.next = NULL;
5462 ut_params->auth_xform.auth.algo = reference->auth_algo;
5463 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5464 ut_params->auth_xform.auth.key.data = auth_key;
5465 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5466 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5468 /* Create Crypto session*/
5469 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5470 &ut_params->auth_xform);
5472 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5478 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
5480 const struct test_crypto_vector *reference,
5481 enum rte_crypto_auth_operation auth_op,
5482 enum rte_crypto_cipher_operation cipher_op)
5484 uint8_t cipher_key[reference->cipher_key.len + 1];
5485 uint8_t auth_key[reference->auth_key.len + 1];
5487 memcpy(cipher_key, reference->cipher_key.data,
5488 reference->cipher_key.len);
5489 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5491 /* Setup Authentication Parameters */
5492 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5493 ut_params->auth_xform.auth.op = auth_op;
5494 ut_params->auth_xform.next = &ut_params->cipher_xform;
5495 ut_params->auth_xform.auth.algo = reference->auth_algo;
5496 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5497 ut_params->auth_xform.auth.key.data = auth_key;
5498 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5499 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5501 /* Setup Cipher Parameters */
5502 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5503 ut_params->cipher_xform.next = NULL;
5504 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
5505 ut_params->cipher_xform.cipher.op = cipher_op;
5506 ut_params->cipher_xform.cipher.key.data = cipher_key;
5507 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
5509 /* Create Crypto session*/
5510 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5511 &ut_params->auth_xform);
5513 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5519 create_auth_operation(struct crypto_testsuite_params *ts_params,
5520 struct crypto_unittest_params *ut_params,
5521 const struct test_crypto_vector *reference,
5522 unsigned int auth_generate)
5524 /* Generate Crypto op data structure */
5525 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5526 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5527 TEST_ASSERT_NOT_NULL(ut_params->op,
5528 "Failed to allocate pktmbuf offload");
5530 /* Set crypto operation data parameters */
5531 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5533 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5535 /* set crypto operation source mbuf */
5536 sym_op->m_src = ut_params->ibuf;
5539 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5540 ut_params->ibuf, reference->digest.len);
5542 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5543 "no room to append auth tag");
5545 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5546 ut_params->ibuf, reference->plaintext.len);
5547 sym_op->auth.digest.length = reference->digest.len;
5550 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5552 memcpy(sym_op->auth.digest.data,
5553 reference->digest.data,
5554 reference->digest.len);
5556 TEST_HEXDUMP(stdout, "digest:",
5557 sym_op->auth.digest.data,
5558 sym_op->auth.digest.length);
5560 sym_op->auth.data.length = reference->plaintext.len;
5561 sym_op->auth.data.offset = 0;
5567 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
5568 struct crypto_unittest_params *ut_params,
5569 const struct test_crypto_vector *reference,
5570 unsigned int auth_generate)
5572 /* Generate Crypto op data structure */
5573 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5574 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5575 TEST_ASSERT_NOT_NULL(ut_params->op,
5576 "Failed to allocate pktmbuf offload");
5578 /* Set crypto operation data parameters */
5579 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5581 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5583 /* set crypto operation source mbuf */
5584 sym_op->m_src = ut_params->ibuf;
5587 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5588 reference->aad.len);
5589 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
5590 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
5592 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
5594 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5595 sym_op->auth.aad.length = reference->aad.len;
5598 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5599 ut_params->ibuf, reference->digest.len);
5601 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5602 "no room to append auth tag");
5604 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5605 ut_params->ibuf, reference->ciphertext.len);
5606 sym_op->auth.digest.length = reference->digest.len;
5609 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5611 memcpy(sym_op->auth.digest.data,
5612 reference->digest.data,
5613 reference->digest.len);
5615 TEST_HEXDUMP(stdout, "digest:",
5616 sym_op->auth.digest.data,
5617 sym_op->auth.digest.length);
5619 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5620 ut_params->ibuf, reference->iv.len);
5621 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5623 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5624 sym_op->cipher.iv.length = reference->iv.len;
5626 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5628 sym_op->cipher.data.length = 0;
5629 sym_op->cipher.data.offset = 0;
5631 sym_op->auth.data.length = 0;
5632 sym_op->auth.data.offset = 0;
5638 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
5639 struct crypto_unittest_params *ut_params,
5640 const struct test_crypto_vector *reference,
5641 unsigned int auth_generate)
5643 /* Generate Crypto op data structure */
5644 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5645 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5646 TEST_ASSERT_NOT_NULL(ut_params->op,
5647 "Failed to allocate pktmbuf offload");
5649 /* Set crypto operation data parameters */
5650 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5652 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5654 /* set crypto operation source mbuf */
5655 sym_op->m_src = ut_params->ibuf;
5658 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5659 ut_params->ibuf, reference->digest.len);
5661 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5662 "no room to append auth tag");
5664 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5665 ut_params->ibuf, reference->ciphertext.len);
5666 sym_op->auth.digest.length = reference->digest.len;
5669 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5671 memcpy(sym_op->auth.digest.data,
5672 reference->digest.data,
5673 reference->digest.len);
5675 TEST_HEXDUMP(stdout, "digest:",
5676 sym_op->auth.digest.data,
5677 sym_op->auth.digest.length);
5679 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5680 ut_params->ibuf, reference->iv.len);
5681 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5683 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5684 sym_op->cipher.iv.length = reference->iv.len;
5686 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5688 sym_op->cipher.data.length = reference->ciphertext.len;
5689 sym_op->cipher.data.offset = reference->iv.len;
5691 sym_op->auth.data.length = reference->ciphertext.len;
5692 sym_op->auth.data.offset = reference->iv.len;
5698 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5699 struct crypto_unittest_params *ut_params,
5700 const struct test_crypto_vector *reference)
5702 return create_auth_operation(ts_params, ut_params, reference, 0);
5706 create_auth_verify_GMAC_operation(
5707 struct crypto_testsuite_params *ts_params,
5708 struct crypto_unittest_params *ut_params,
5709 const struct test_crypto_vector *reference)
5711 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
5715 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5716 struct crypto_unittest_params *ut_params,
5717 const struct test_crypto_vector *reference)
5719 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
5723 test_authentication_verify_fail_when_data_corruption(
5724 struct crypto_testsuite_params *ts_params,
5725 struct crypto_unittest_params *ut_params,
5726 const struct test_crypto_vector *reference,
5727 unsigned int data_corrupted)
5733 /* Create session */
5734 retval = create_auth_session(ut_params,
5735 ts_params->valid_devs[0],
5737 RTE_CRYPTO_AUTH_OP_VERIFY);
5741 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5742 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5743 "Failed to allocate input buffer in mempool");
5745 /* clear mbuf payload */
5746 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5747 rte_pktmbuf_tailroom(ut_params->ibuf));
5749 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5750 reference->plaintext.len);
5751 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5752 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
5754 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
5756 /* Create operation */
5757 retval = create_auth_verify_operation(ts_params, ut_params, reference);
5763 data_corruption(plaintext);
5765 tag_corruption(plaintext, reference->plaintext.len);
5767 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5769 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5770 TEST_ASSERT_EQUAL(ut_params->op->status,
5771 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5772 "authentication not failed");
5774 ut_params->obuf = ut_params->op->sym->m_src;
5775 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5781 test_authentication_verify_GMAC_fail_when_corruption(
5782 struct crypto_testsuite_params *ts_params,
5783 struct crypto_unittest_params *ut_params,
5784 const struct test_crypto_vector *reference,
5785 unsigned int data_corrupted)
5789 /* Create session */
5790 retval = create_auth_cipher_session(ut_params,
5791 ts_params->valid_devs[0],
5793 RTE_CRYPTO_AUTH_OP_VERIFY,
5794 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5798 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5799 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5800 "Failed to allocate input buffer in mempool");
5802 /* clear mbuf payload */
5803 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5804 rte_pktmbuf_tailroom(ut_params->ibuf));
5806 /* Create operation */
5807 retval = create_auth_verify_GMAC_operation(ts_params,
5815 data_corruption(ut_params->op->sym->auth.aad.data);
5817 tag_corruption(ut_params->op->sym->auth.aad.data,
5818 reference->aad.len);
5820 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5822 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5823 TEST_ASSERT_EQUAL(ut_params->op->status,
5824 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5825 "authentication not failed");
5827 ut_params->obuf = ut_params->op->sym->m_src;
5828 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5834 test_authenticated_decryption_fail_when_corruption(
5835 struct crypto_testsuite_params *ts_params,
5836 struct crypto_unittest_params *ut_params,
5837 const struct test_crypto_vector *reference,
5838 unsigned int data_corrupted)
5842 uint8_t *ciphertext;
5844 /* Create session */
5845 retval = create_auth_cipher_session(ut_params,
5846 ts_params->valid_devs[0],
5848 RTE_CRYPTO_AUTH_OP_VERIFY,
5849 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5853 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5854 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5855 "Failed to allocate input buffer in mempool");
5857 /* clear mbuf payload */
5858 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5859 rte_pktmbuf_tailroom(ut_params->ibuf));
5861 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5862 reference->ciphertext.len);
5863 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
5864 memcpy(ciphertext, reference->ciphertext.data,
5865 reference->ciphertext.len);
5867 /* Create operation */
5868 retval = create_cipher_auth_verify_operation(ts_params,
5876 data_corruption(ciphertext);
5878 tag_corruption(ciphertext, reference->ciphertext.len);
5880 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5883 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5884 TEST_ASSERT_EQUAL(ut_params->op->status,
5885 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5886 "authentication not failed");
5888 ut_params->obuf = ut_params->op->sym->m_src;
5889 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5895 test_authentication_verify_fail_when_data_corrupted(
5896 struct crypto_testsuite_params *ts_params,
5897 struct crypto_unittest_params *ut_params,
5898 const struct test_crypto_vector *reference)
5900 return test_authentication_verify_fail_when_data_corruption(
5901 ts_params, ut_params, reference, 1);
5905 test_authentication_verify_fail_when_tag_corrupted(
5906 struct crypto_testsuite_params *ts_params,
5907 struct crypto_unittest_params *ut_params,
5908 const struct test_crypto_vector *reference)
5910 return test_authentication_verify_fail_when_data_corruption(
5911 ts_params, ut_params, reference, 0);
5915 test_authentication_verify_GMAC_fail_when_data_corrupted(
5916 struct crypto_testsuite_params *ts_params,
5917 struct crypto_unittest_params *ut_params,
5918 const struct test_crypto_vector *reference)
5920 return test_authentication_verify_GMAC_fail_when_corruption(
5921 ts_params, ut_params, reference, 1);
5925 test_authentication_verify_GMAC_fail_when_tag_corrupted(
5926 struct crypto_testsuite_params *ts_params,
5927 struct crypto_unittest_params *ut_params,
5928 const struct test_crypto_vector *reference)
5930 return test_authentication_verify_GMAC_fail_when_corruption(
5931 ts_params, ut_params, reference, 0);
5935 test_authenticated_decryption_fail_when_data_corrupted(
5936 struct crypto_testsuite_params *ts_params,
5937 struct crypto_unittest_params *ut_params,
5938 const struct test_crypto_vector *reference)
5940 return test_authenticated_decryption_fail_when_corruption(
5941 ts_params, ut_params, reference, 1);
5945 test_authenticated_decryption_fail_when_tag_corrupted(
5946 struct crypto_testsuite_params *ts_params,
5947 struct crypto_unittest_params *ut_params,
5948 const struct test_crypto_vector *reference)
5950 return test_authenticated_decryption_fail_when_corruption(
5951 ts_params, ut_params, reference, 0);
5955 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
5957 return test_authentication_verify_fail_when_data_corrupted(
5958 &testsuite_params, &unittest_params,
5959 &hmac_sha1_test_crypto_vector);
5963 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
5965 return test_authentication_verify_fail_when_tag_corrupted(
5966 &testsuite_params, &unittest_params,
5967 &hmac_sha1_test_crypto_vector);
5971 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
5973 return test_authentication_verify_GMAC_fail_when_data_corrupted(
5974 &testsuite_params, &unittest_params,
5975 &aes128_gmac_test_vector);
5979 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
5981 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
5982 &testsuite_params, &unittest_params,
5983 &aes128_gmac_test_vector);
5987 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
5989 return test_authenticated_decryption_fail_when_data_corrupted(
5992 &aes128cbc_hmac_sha1_test_vector);
5996 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
5998 return test_authenticated_decryption_fail_when_tag_corrupted(
6001 &aes128cbc_hmac_sha1_test_vector);
6004 static struct unit_test_suite cryptodev_qat_testsuite = {
6005 .suite_name = "Crypto QAT Unit Test Suite",
6006 .setup = testsuite_setup,
6007 .teardown = testsuite_teardown,
6008 .unit_test_cases = {
6009 TEST_CASE_ST(ut_setup, ut_teardown,
6010 test_device_configure_invalid_dev_id),
6011 TEST_CASE_ST(ut_setup, ut_teardown,
6012 test_device_configure_invalid_queue_pair_ids),
6013 TEST_CASE_ST(ut_setup, ut_teardown,
6014 test_queue_pair_descriptor_setup),
6015 TEST_CASE_ST(ut_setup, ut_teardown,
6016 test_multi_session),
6018 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
6019 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
6020 TEST_CASE_ST(ut_setup, ut_teardown,
6021 test_3DES_cipheronly_qat_all),
6022 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
6024 /** AES GCM Authenticated Encryption */
6025 TEST_CASE_ST(ut_setup, ut_teardown,
6026 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6027 TEST_CASE_ST(ut_setup, ut_teardown,
6028 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6029 TEST_CASE_ST(ut_setup, ut_teardown,
6030 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6031 TEST_CASE_ST(ut_setup, ut_teardown,
6032 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6033 TEST_CASE_ST(ut_setup, ut_teardown,
6034 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6035 TEST_CASE_ST(ut_setup, ut_teardown,
6036 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6037 TEST_CASE_ST(ut_setup, ut_teardown,
6038 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6040 /** AES GCM Authenticated Decryption */
6041 TEST_CASE_ST(ut_setup, ut_teardown,
6042 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6043 TEST_CASE_ST(ut_setup, ut_teardown,
6044 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6045 TEST_CASE_ST(ut_setup, ut_teardown,
6046 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6047 TEST_CASE_ST(ut_setup, ut_teardown,
6048 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6049 TEST_CASE_ST(ut_setup, ut_teardown,
6050 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6051 TEST_CASE_ST(ut_setup, ut_teardown,
6052 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6053 TEST_CASE_ST(ut_setup, ut_teardown,
6054 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6056 /** AES GMAC Authentication */
6057 TEST_CASE_ST(ut_setup, ut_teardown,
6058 test_AES_GMAC_authentication_test_case_1),
6059 TEST_CASE_ST(ut_setup, ut_teardown,
6060 test_AES_GMAC_authentication_verify_test_case_1),
6061 TEST_CASE_ST(ut_setup, ut_teardown,
6062 test_AES_GMAC_authentication_test_case_2),
6063 TEST_CASE_ST(ut_setup, ut_teardown,
6064 test_AES_GMAC_authentication_verify_test_case_2),
6065 TEST_CASE_ST(ut_setup, ut_teardown,
6066 test_AES_GMAC_authentication_test_case_3),
6067 TEST_CASE_ST(ut_setup, ut_teardown,
6068 test_AES_GMAC_authentication_verify_test_case_3),
6070 /** SNOW 3G encrypt only (UEA2) */
6071 TEST_CASE_ST(ut_setup, ut_teardown,
6072 test_snow3g_encryption_test_case_1),
6073 TEST_CASE_ST(ut_setup, ut_teardown,
6074 test_snow3g_encryption_test_case_2),
6075 TEST_CASE_ST(ut_setup, ut_teardown,
6076 test_snow3g_encryption_test_case_3),
6077 TEST_CASE_ST(ut_setup, ut_teardown,
6078 test_snow3g_encryption_test_case_4),
6079 TEST_CASE_ST(ut_setup, ut_teardown,
6080 test_snow3g_encryption_test_case_5),
6082 TEST_CASE_ST(ut_setup, ut_teardown,
6083 test_snow3g_encryption_test_case_1_oop),
6084 TEST_CASE_ST(ut_setup, ut_teardown,
6085 test_snow3g_decryption_test_case_1_oop),
6087 /** SNOW 3G decrypt only (UEA2) */
6088 TEST_CASE_ST(ut_setup, ut_teardown,
6089 test_snow3g_decryption_test_case_1),
6090 TEST_CASE_ST(ut_setup, ut_teardown,
6091 test_snow3g_decryption_test_case_2),
6092 TEST_CASE_ST(ut_setup, ut_teardown,
6093 test_snow3g_decryption_test_case_3),
6094 TEST_CASE_ST(ut_setup, ut_teardown,
6095 test_snow3g_decryption_test_case_4),
6096 TEST_CASE_ST(ut_setup, ut_teardown,
6097 test_snow3g_decryption_test_case_5),
6098 TEST_CASE_ST(ut_setup, ut_teardown,
6099 test_snow3g_hash_generate_test_case_1),
6100 TEST_CASE_ST(ut_setup, ut_teardown,
6101 test_snow3g_hash_generate_test_case_2),
6102 TEST_CASE_ST(ut_setup, ut_teardown,
6103 test_snow3g_hash_generate_test_case_3),
6104 TEST_CASE_ST(ut_setup, ut_teardown,
6105 test_snow3g_hash_verify_test_case_1),
6106 TEST_CASE_ST(ut_setup, ut_teardown,
6107 test_snow3g_hash_verify_test_case_2),
6108 TEST_CASE_ST(ut_setup, ut_teardown,
6109 test_snow3g_hash_verify_test_case_3),
6110 TEST_CASE_ST(ut_setup, ut_teardown,
6111 test_snow3g_cipher_auth_test_case_1),
6112 TEST_CASE_ST(ut_setup, ut_teardown,
6113 test_snow3g_auth_cipher_test_case_1),
6115 /** HMAC_MD5 Authentication */
6116 TEST_CASE_ST(ut_setup, ut_teardown,
6117 test_MD5_HMAC_generate_case_1),
6118 TEST_CASE_ST(ut_setup, ut_teardown,
6119 test_MD5_HMAC_verify_case_1),
6120 TEST_CASE_ST(ut_setup, ut_teardown,
6121 test_MD5_HMAC_generate_case_2),
6122 TEST_CASE_ST(ut_setup, ut_teardown,
6123 test_MD5_HMAC_verify_case_2),
6126 TEST_CASE_ST(ut_setup, ut_teardown,
6127 test_null_auth_only_operation),
6128 TEST_CASE_ST(ut_setup, ut_teardown,
6129 test_null_cipher_only_operation),
6130 TEST_CASE_ST(ut_setup, ut_teardown,
6131 test_null_cipher_auth_operation),
6132 TEST_CASE_ST(ut_setup, ut_teardown,
6133 test_null_auth_cipher_operation),
6135 TEST_CASE_ST(ut_setup, ut_teardown,
6136 test_kasumi_hash_generate_test_case_6),
6139 TEST_CASE_ST(ut_setup, ut_teardown,
6140 test_kasumi_encryption_test_case_1),
6141 TEST_CASE_ST(ut_setup, ut_teardown,
6142 test_kasumi_encryption_test_case_3),
6143 TEST_CASE_ST(ut_setup, ut_teardown,
6144 test_kasumi_auth_cipher_test_case_1),
6145 TEST_CASE_ST(ut_setup, ut_teardown,
6146 test_kasumi_cipher_auth_test_case_1),
6148 TEST_CASES_END() /**< NULL terminate unit test array */
6152 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
6153 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
6154 .setup = testsuite_setup,
6155 .teardown = testsuite_teardown,
6156 .unit_test_cases = {
6157 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
6159 TEST_CASES_END() /**< NULL terminate unit test array */
6163 static struct unit_test_suite cryptodev_libcrypto_testsuite = {
6164 .suite_name = "Crypto Device LIBCRYPTO Unit Test Suite",
6165 .setup = testsuite_setup,
6166 .teardown = testsuite_teardown,
6167 .unit_test_cases = {
6168 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
6169 TEST_CASE_ST(ut_setup, ut_teardown,
6170 test_multi_session_random_usage),
6171 TEST_CASE_ST(ut_setup, ut_teardown,
6172 test_AES_chain_libcrypto_all),
6173 TEST_CASE_ST(ut_setup, ut_teardown,
6174 test_AES_cipheronly_libcrypto_all),
6175 TEST_CASE_ST(ut_setup, ut_teardown,
6176 test_3DES_chain_libcrypto_all),
6177 TEST_CASE_ST(ut_setup, ut_teardown,
6178 test_3DES_cipheronly_libcrypto_all),
6179 TEST_CASE_ST(ut_setup, ut_teardown,
6180 test_authonly_libcrypto_all),
6182 /** AES GCM Authenticated Encryption */
6183 TEST_CASE_ST(ut_setup, ut_teardown,
6184 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6185 TEST_CASE_ST(ut_setup, ut_teardown,
6186 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6187 TEST_CASE_ST(ut_setup, ut_teardown,
6188 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6189 TEST_CASE_ST(ut_setup, ut_teardown,
6190 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6191 TEST_CASE_ST(ut_setup, ut_teardown,
6192 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6193 TEST_CASE_ST(ut_setup, ut_teardown,
6194 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6195 TEST_CASE_ST(ut_setup, ut_teardown,
6196 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6198 /** AES GCM Authenticated Decryption */
6199 TEST_CASE_ST(ut_setup, ut_teardown,
6200 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6201 TEST_CASE_ST(ut_setup, ut_teardown,
6202 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6203 TEST_CASE_ST(ut_setup, ut_teardown,
6204 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6205 TEST_CASE_ST(ut_setup, ut_teardown,
6206 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6207 TEST_CASE_ST(ut_setup, ut_teardown,
6208 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6209 TEST_CASE_ST(ut_setup, ut_teardown,
6210 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6211 TEST_CASE_ST(ut_setup, ut_teardown,
6212 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6214 /** AES GMAC Authentication */
6215 TEST_CASE_ST(ut_setup, ut_teardown,
6216 test_AES_GMAC_authentication_test_case_1),
6217 TEST_CASE_ST(ut_setup, ut_teardown,
6218 test_AES_GMAC_authentication_verify_test_case_1),
6219 TEST_CASE_ST(ut_setup, ut_teardown,
6220 test_AES_GMAC_authentication_test_case_2),
6221 TEST_CASE_ST(ut_setup, ut_teardown,
6222 test_AES_GMAC_authentication_verify_test_case_2),
6223 TEST_CASE_ST(ut_setup, ut_teardown,
6224 test_AES_GMAC_authentication_test_case_3),
6225 TEST_CASE_ST(ut_setup, ut_teardown,
6226 test_AES_GMAC_authentication_verify_test_case_3),
6227 TEST_CASE_ST(ut_setup, ut_teardown,
6228 test_AES_GMAC_authentication_test_case_4),
6229 TEST_CASE_ST(ut_setup, ut_teardown,
6230 test_AES_GMAC_authentication_verify_test_case_4),
6232 /** Negative tests */
6233 TEST_CASE_ST(ut_setup, ut_teardown,
6234 authentication_verify_HMAC_SHA1_fail_data_corrupt),
6235 TEST_CASE_ST(ut_setup, ut_teardown,
6236 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6237 TEST_CASE_ST(ut_setup, ut_teardown,
6238 authentication_verify_AES128_GMAC_fail_data_corrupt),
6239 TEST_CASE_ST(ut_setup, ut_teardown,
6240 authentication_verify_AES128_GMAC_fail_tag_corrupt),
6241 TEST_CASE_ST(ut_setup, ut_teardown,
6242 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6243 TEST_CASE_ST(ut_setup, ut_teardown,
6244 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6246 TEST_CASES_END() /**< NULL terminate unit test array */
6250 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
6251 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
6252 .setup = testsuite_setup,
6253 .teardown = testsuite_teardown,
6254 .unit_test_cases = {
6255 /** AES GCM Authenticated Encryption */
6256 TEST_CASE_ST(ut_setup, ut_teardown,
6257 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6258 TEST_CASE_ST(ut_setup, ut_teardown,
6259 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6260 TEST_CASE_ST(ut_setup, ut_teardown,
6261 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6262 TEST_CASE_ST(ut_setup, ut_teardown,
6263 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6264 TEST_CASE_ST(ut_setup, ut_teardown,
6265 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6266 TEST_CASE_ST(ut_setup, ut_teardown,
6267 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6268 TEST_CASE_ST(ut_setup, ut_teardown,
6269 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6271 /** AES GCM Authenticated Decryption */
6272 TEST_CASE_ST(ut_setup, ut_teardown,
6273 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6274 TEST_CASE_ST(ut_setup, ut_teardown,
6275 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6276 TEST_CASE_ST(ut_setup, ut_teardown,
6277 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6278 TEST_CASE_ST(ut_setup, ut_teardown,
6279 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6280 TEST_CASE_ST(ut_setup, ut_teardown,
6281 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6282 TEST_CASE_ST(ut_setup, ut_teardown,
6283 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6284 TEST_CASE_ST(ut_setup, ut_teardown,
6285 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6287 TEST_CASES_END() /**< NULL terminate unit test array */
6291 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
6292 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
6293 .setup = testsuite_setup,
6294 .teardown = testsuite_teardown,
6295 .unit_test_cases = {
6296 /** KASUMI encrypt only (UEA1) */
6297 TEST_CASE_ST(ut_setup, ut_teardown,
6298 test_kasumi_encryption_test_case_1),
6299 TEST_CASE_ST(ut_setup, ut_teardown,
6300 test_kasumi_encryption_test_case_2),
6301 TEST_CASE_ST(ut_setup, ut_teardown,
6302 test_kasumi_encryption_test_case_3),
6303 TEST_CASE_ST(ut_setup, ut_teardown,
6304 test_kasumi_encryption_test_case_4),
6305 TEST_CASE_ST(ut_setup, ut_teardown,
6306 test_kasumi_encryption_test_case_5),
6307 /** KASUMI decrypt only (UEA1) */
6308 TEST_CASE_ST(ut_setup, ut_teardown,
6309 test_kasumi_decryption_test_case_1),
6310 TEST_CASE_ST(ut_setup, ut_teardown,
6311 test_kasumi_decryption_test_case_2),
6312 TEST_CASE_ST(ut_setup, ut_teardown,
6313 test_kasumi_decryption_test_case_3),
6314 TEST_CASE_ST(ut_setup, ut_teardown,
6315 test_kasumi_decryption_test_case_4),
6316 TEST_CASE_ST(ut_setup, ut_teardown,
6317 test_kasumi_decryption_test_case_5),
6319 TEST_CASE_ST(ut_setup, ut_teardown,
6320 test_kasumi_encryption_test_case_1_oop),
6321 TEST_CASE_ST(ut_setup, ut_teardown,
6322 test_kasumi_decryption_test_case_1_oop),
6324 /** KASUMI hash only (UIA1) */
6325 TEST_CASE_ST(ut_setup, ut_teardown,
6326 test_kasumi_hash_generate_test_case_1),
6327 TEST_CASE_ST(ut_setup, ut_teardown,
6328 test_kasumi_hash_generate_test_case_2),
6329 TEST_CASE_ST(ut_setup, ut_teardown,
6330 test_kasumi_hash_generate_test_case_3),
6331 TEST_CASE_ST(ut_setup, ut_teardown,
6332 test_kasumi_hash_generate_test_case_4),
6333 TEST_CASE_ST(ut_setup, ut_teardown,
6334 test_kasumi_hash_generate_test_case_5),
6335 TEST_CASE_ST(ut_setup, ut_teardown,
6336 test_kasumi_hash_generate_test_case_6),
6337 TEST_CASE_ST(ut_setup, ut_teardown,
6338 test_kasumi_hash_verify_test_case_1),
6339 TEST_CASE_ST(ut_setup, ut_teardown,
6340 test_kasumi_hash_verify_test_case_2),
6341 TEST_CASE_ST(ut_setup, ut_teardown,
6342 test_kasumi_hash_verify_test_case_3),
6343 TEST_CASE_ST(ut_setup, ut_teardown,
6344 test_kasumi_hash_verify_test_case_4),
6345 TEST_CASE_ST(ut_setup, ut_teardown,
6346 test_kasumi_hash_verify_test_case_5),
6347 TEST_CASE_ST(ut_setup, ut_teardown,
6348 test_kasumi_auth_cipher_test_case_1),
6349 TEST_CASE_ST(ut_setup, ut_teardown,
6350 test_kasumi_cipher_auth_test_case_1),
6351 TEST_CASES_END() /**< NULL terminate unit test array */
6354 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
6355 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
6356 .setup = testsuite_setup,
6357 .teardown = testsuite_teardown,
6358 .unit_test_cases = {
6359 /** SNOW 3G encrypt only (UEA2) */
6360 TEST_CASE_ST(ut_setup, ut_teardown,
6361 test_snow3g_encryption_test_case_1),
6362 TEST_CASE_ST(ut_setup, ut_teardown,
6363 test_snow3g_encryption_test_case_2),
6364 TEST_CASE_ST(ut_setup, ut_teardown,
6365 test_snow3g_encryption_test_case_3),
6366 TEST_CASE_ST(ut_setup, ut_teardown,
6367 test_snow3g_encryption_test_case_4),
6368 TEST_CASE_ST(ut_setup, ut_teardown,
6369 test_snow3g_encryption_test_case_5),
6371 TEST_CASE_ST(ut_setup, ut_teardown,
6372 test_snow3g_encryption_test_case_1_oop),
6373 TEST_CASE_ST(ut_setup, ut_teardown,
6374 test_snow3g_decryption_test_case_1_oop),
6376 TEST_CASE_ST(ut_setup, ut_teardown,
6377 test_snow3g_encryption_test_case_1_offset_oop),
6379 /** SNOW 3G decrypt only (UEA2) */
6380 TEST_CASE_ST(ut_setup, ut_teardown,
6381 test_snow3g_decryption_test_case_1),
6382 TEST_CASE_ST(ut_setup, ut_teardown,
6383 test_snow3g_decryption_test_case_2),
6384 TEST_CASE_ST(ut_setup, ut_teardown,
6385 test_snow3g_decryption_test_case_3),
6386 TEST_CASE_ST(ut_setup, ut_teardown,
6387 test_snow3g_decryption_test_case_4),
6388 TEST_CASE_ST(ut_setup, ut_teardown,
6389 test_snow3g_decryption_test_case_5),
6390 TEST_CASE_ST(ut_setup, ut_teardown,
6391 test_snow3g_hash_generate_test_case_1),
6392 TEST_CASE_ST(ut_setup, ut_teardown,
6393 test_snow3g_hash_generate_test_case_2),
6394 TEST_CASE_ST(ut_setup, ut_teardown,
6395 test_snow3g_hash_generate_test_case_3),
6396 /* Tests with buffers which length is not byte-aligned */
6397 TEST_CASE_ST(ut_setup, ut_teardown,
6398 test_snow3g_hash_generate_test_case_4),
6399 TEST_CASE_ST(ut_setup, ut_teardown,
6400 test_snow3g_hash_generate_test_case_5),
6401 TEST_CASE_ST(ut_setup, ut_teardown,
6402 test_snow3g_hash_generate_test_case_6),
6403 TEST_CASE_ST(ut_setup, ut_teardown,
6404 test_snow3g_hash_verify_test_case_1),
6405 TEST_CASE_ST(ut_setup, ut_teardown,
6406 test_snow3g_hash_verify_test_case_2),
6407 TEST_CASE_ST(ut_setup, ut_teardown,
6408 test_snow3g_hash_verify_test_case_3),
6409 /* Tests with buffers which length is not byte-aligned */
6410 TEST_CASE_ST(ut_setup, ut_teardown,
6411 test_snow3g_hash_verify_test_case_4),
6412 TEST_CASE_ST(ut_setup, ut_teardown,
6413 test_snow3g_hash_verify_test_case_5),
6414 TEST_CASE_ST(ut_setup, ut_teardown,
6415 test_snow3g_hash_verify_test_case_6),
6416 TEST_CASE_ST(ut_setup, ut_teardown,
6417 test_snow3g_cipher_auth_test_case_1),
6418 TEST_CASE_ST(ut_setup, ut_teardown,
6419 test_snow3g_auth_cipher_test_case_1),
6421 TEST_CASES_END() /**< NULL terminate unit test array */
6425 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
6426 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
6427 .setup = testsuite_setup,
6428 .teardown = testsuite_teardown,
6429 .unit_test_cases = {
6430 /** ZUC encrypt only (EEA3) */
6431 TEST_CASE_ST(ut_setup, ut_teardown,
6432 test_zuc_encryption_test_case_1),
6433 TEST_CASE_ST(ut_setup, ut_teardown,
6434 test_zuc_encryption_test_case_2),
6435 TEST_CASE_ST(ut_setup, ut_teardown,
6436 test_zuc_encryption_test_case_3),
6437 TEST_CASE_ST(ut_setup, ut_teardown,
6438 test_zuc_encryption_test_case_4),
6439 TEST_CASE_ST(ut_setup, ut_teardown,
6440 test_zuc_encryption_test_case_5),
6441 TEST_CASE_ST(ut_setup, ut_teardown,
6442 test_zuc_hash_generate_test_case_1),
6443 TEST_CASE_ST(ut_setup, ut_teardown,
6444 test_zuc_hash_generate_test_case_2),
6445 TEST_CASE_ST(ut_setup, ut_teardown,
6446 test_zuc_hash_generate_test_case_3),
6447 TEST_CASE_ST(ut_setup, ut_teardown,
6448 test_zuc_hash_generate_test_case_4),
6449 TEST_CASE_ST(ut_setup, ut_teardown,
6450 test_zuc_hash_generate_test_case_5),
6451 TEST_CASES_END() /**< NULL terminate unit test array */
6455 static struct unit_test_suite cryptodev_null_testsuite = {
6456 .suite_name = "Crypto Device NULL Unit Test Suite",
6457 .setup = testsuite_setup,
6458 .teardown = testsuite_teardown,
6459 .unit_test_cases = {
6460 TEST_CASE_ST(ut_setup, ut_teardown,
6461 test_null_auth_only_operation),
6462 TEST_CASE_ST(ut_setup, ut_teardown,
6463 test_null_cipher_only_operation),
6464 TEST_CASE_ST(ut_setup, ut_teardown,
6465 test_null_cipher_auth_operation),
6466 TEST_CASE_ST(ut_setup, ut_teardown,
6467 test_null_auth_cipher_operation),
6468 TEST_CASE_ST(ut_setup, ut_teardown,
6469 test_null_invalid_operation),
6470 TEST_CASE_ST(ut_setup, ut_teardown,
6471 test_null_burst_operation),
6473 TEST_CASES_END() /**< NULL terminate unit test array */
6478 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
6480 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
6481 return unit_test_suite_runner(&cryptodev_qat_testsuite);
6485 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
6487 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
6489 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
6493 test_cryptodev_libcrypto(void)
6495 gbl_cryptodev_type = RTE_CRYPTODEV_LIBCRYPTO_PMD;
6497 return unit_test_suite_runner(&cryptodev_libcrypto_testsuite);
6501 test_cryptodev_aesni_gcm(void)
6503 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
6505 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
6509 test_cryptodev_null(void)
6511 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
6513 return unit_test_suite_runner(&cryptodev_null_testsuite);
6517 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
6519 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
6521 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
6525 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
6527 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
6529 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
6533 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
6535 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
6537 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
6540 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
6541 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
6542 REGISTER_TEST_COMMAND(cryptodev_libcrypto_autotest, test_cryptodev_libcrypto);
6543 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
6544 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
6545 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
6546 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
6547 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);