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.
35 #include <rte_common.h>
36 #include <rte_hexdump.h>
38 #include <rte_malloc.h>
39 #include <rte_memcpy.h>
41 #include <rte_crypto.h>
42 #include <rte_cryptodev.h>
43 #include <rte_cryptodev_pmd.h>
46 #include "test_cryptodev.h"
48 #include "test_cryptodev_blockcipher.h"
49 #include "test_cryptodev_aes_test_vectors.h"
50 #include "test_cryptodev_des_test_vectors.h"
51 #include "test_cryptodev_hash_test_vectors.h"
52 #include "test_cryptodev_kasumi_test_vectors.h"
53 #include "test_cryptodev_kasumi_hash_test_vectors.h"
54 #include "test_cryptodev_snow3g_test_vectors.h"
55 #include "test_cryptodev_snow3g_hash_test_vectors.h"
56 #include "test_cryptodev_zuc_test_vectors.h"
57 #include "test_cryptodev_zuc_hash_test_vectors.h"
58 #include "test_cryptodev_gcm_test_vectors.h"
59 #include "test_cryptodev_hmac_test_vectors.h"
61 static enum rte_cryptodev_type gbl_cryptodev_type;
63 struct crypto_testsuite_params {
64 struct rte_mempool *mbuf_pool;
65 struct rte_mempool *large_mbuf_pool;
66 struct rte_mempool *op_mpool;
67 struct rte_cryptodev_config conf;
68 struct rte_cryptodev_qp_conf qp_conf;
70 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
71 uint8_t valid_dev_count;
74 struct crypto_unittest_params {
75 struct rte_crypto_sym_xform cipher_xform;
76 struct rte_crypto_sym_xform auth_xform;
78 struct rte_cryptodev_sym_session *sess;
80 struct rte_crypto_op *op;
82 struct rte_mbuf *obuf, *ibuf;
87 #define ALIGN_POW2_ROUNDUP(num, align) \
88 (((num) + (align) - 1) & ~((align) - 1))
91 * Forward declarations.
94 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
95 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
99 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
100 struct crypto_unittest_params *ut_params,
101 struct crypto_testsuite_params *ts_param,
102 const uint8_t *cipher,
103 const uint8_t *digest,
106 static struct rte_mbuf *
107 setup_test_string(struct rte_mempool *mpool,
108 const char *string, size_t len, uint8_t blocksize)
110 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
111 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
113 memset(m->buf_addr, 0, m->buf_len);
115 char *dst = rte_pktmbuf_append(m, t_len);
122 rte_memcpy(dst, string, t_len);
124 memset(dst, 0, t_len);
130 /* Get number of bytes in X bits (rounding up) */
132 ceil_byte_length(uint32_t num_bits)
135 return ((num_bits >> 3) + 1);
137 return (num_bits >> 3);
140 static struct rte_crypto_op *
141 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
143 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
144 printf("Error sending packet for encryption");
150 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
156 static struct crypto_testsuite_params testsuite_params = { NULL };
157 static struct crypto_unittest_params unittest_params;
160 testsuite_setup(void)
162 struct crypto_testsuite_params *ts_params = &testsuite_params;
163 struct rte_cryptodev_info info;
164 unsigned i, nb_devs, dev_id;
168 memset(ts_params, 0, sizeof(*ts_params));
170 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
171 if (ts_params->mbuf_pool == NULL) {
172 /* Not already created so create */
173 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
175 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
177 if (ts_params->mbuf_pool == NULL) {
178 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
183 ts_params->large_mbuf_pool = rte_mempool_lookup(
184 "CRYPTO_LARGE_MBUFPOOL");
185 if (ts_params->large_mbuf_pool == NULL) {
186 /* Not already created so create */
187 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
188 "CRYPTO_LARGE_MBUFPOOL",
191 if (ts_params->large_mbuf_pool == NULL) {
193 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
198 ts_params->op_mpool = rte_crypto_op_pool_create(
199 "MBUF_CRYPTO_SYM_OP_POOL",
200 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
201 NUM_MBUFS, MBUF_CACHE_SIZE,
203 sizeof(struct rte_crypto_sym_xform),
205 if (ts_params->op_mpool == NULL) {
206 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
210 /* Create 2 AESNI MB devices if required */
211 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
212 #ifndef RTE_LIBRTE_PMD_AESNI_MB
213 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
214 " enabled in config file to run this testsuite.\n");
217 nb_devs = rte_cryptodev_count_devtype(
218 RTE_CRYPTODEV_AESNI_MB_PMD);
220 for (i = nb_devs; i < 2; i++) {
221 ret = rte_eal_vdev_init(
222 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
224 TEST_ASSERT(ret == 0,
225 "Failed to create instance %u of"
227 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
232 /* Create 2 AESNI GCM devices if required */
233 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
234 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
235 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
236 " enabled in config file to run this testsuite.\n");
239 nb_devs = rte_cryptodev_count_devtype(
240 RTE_CRYPTODEV_AESNI_GCM_PMD);
242 for (i = nb_devs; i < 2; i++) {
243 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
244 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
245 "Failed to create instance %u of"
247 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
252 /* Create 2 SNOW 3G devices if required */
253 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
254 #ifndef RTE_LIBRTE_PMD_SNOW3G
255 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
256 " enabled in config file to run this testsuite.\n");
259 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
261 for (i = nb_devs; i < 2; i++) {
262 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
263 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
264 "Failed to create instance %u of"
266 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
271 /* Create 2 KASUMI devices if required */
272 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
273 #ifndef RTE_LIBRTE_PMD_KASUMI
274 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
275 " enabled in config file to run this testsuite.\n");
278 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
280 for (i = nb_devs; i < 2; i++) {
281 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
282 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
283 "Failed to create instance %u of"
285 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
290 /* Create 2 ZUC devices if required */
291 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
292 #ifndef RTE_LIBRTE_PMD_ZUC
293 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
294 " enabled in config file to run this testsuite.\n");
297 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
299 for (i = nb_devs; i < 2; i++) {
300 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
301 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
302 "Failed to create instance %u of"
304 i, RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
309 /* Create 2 NULL devices if required */
310 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
311 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
312 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
313 " enabled in config file to run this testsuite.\n");
316 nb_devs = rte_cryptodev_count_devtype(
317 RTE_CRYPTODEV_NULL_PMD);
319 for (i = nb_devs; i < 2; i++) {
320 int dev_id = rte_eal_vdev_init(
321 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
323 TEST_ASSERT(dev_id >= 0,
324 "Failed to create instance %u of"
326 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
331 /* Create 2 OPENSSL devices if required */
332 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
333 #ifndef RTE_LIBRTE_PMD_OPENSSL
334 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
335 " enabled in config file to run this testsuite.\n");
338 nb_devs = rte_cryptodev_count_devtype(
339 RTE_CRYPTODEV_OPENSSL_PMD);
341 for (i = nb_devs; i < 2; i++) {
342 ret = rte_eal_vdev_init(
343 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
346 TEST_ASSERT(ret == 0, "Failed to create "
347 "instance %u of pmd : %s", i,
348 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
353 #ifndef RTE_LIBRTE_PMD_QAT
354 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
355 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
356 "in config file to run this testsuite.\n");
361 nb_devs = rte_cryptodev_count();
363 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
367 /* Create list of valid crypto devs */
368 for (i = 0; i < nb_devs; i++) {
369 rte_cryptodev_info_get(i, &info);
370 if (info.dev_type == gbl_cryptodev_type)
371 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
374 if (ts_params->valid_dev_count < 1)
377 /* Set up all the qps on the first of the valid devices found */
379 dev_id = ts_params->valid_devs[0];
381 rte_cryptodev_info_get(dev_id, &info);
383 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
384 ts_params->conf.socket_id = SOCKET_ID_ANY;
385 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
387 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
389 "Failed to configure cryptodev %u with %u qps",
390 dev_id, ts_params->conf.nb_queue_pairs);
392 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
394 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
395 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
396 dev_id, qp_id, &ts_params->qp_conf,
397 rte_cryptodev_socket_id(dev_id)),
398 "Failed to setup queue pair %u on cryptodev %u",
406 testsuite_teardown(void)
408 struct crypto_testsuite_params *ts_params = &testsuite_params;
410 if (ts_params->mbuf_pool != NULL) {
411 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
412 rte_mempool_avail_count(ts_params->mbuf_pool));
415 if (ts_params->op_mpool != NULL) {
416 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
417 rte_mempool_avail_count(ts_params->op_mpool));
425 struct crypto_testsuite_params *ts_params = &testsuite_params;
426 struct crypto_unittest_params *ut_params = &unittest_params;
430 /* Clear unit test parameters before running test */
431 memset(ut_params, 0, sizeof(*ut_params));
433 /* Reconfigure device to default parameters */
434 ts_params->conf.socket_id = SOCKET_ID_ANY;
435 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
437 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
439 "Failed to configure cryptodev %u",
440 ts_params->valid_devs[0]);
442 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
443 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
444 ts_params->valid_devs[0], qp_id,
446 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
447 "Failed to setup queue pair %u on cryptodev %u",
448 qp_id, ts_params->valid_devs[0]);
452 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
454 /* Start the device */
455 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
456 "Failed to start cryptodev %u",
457 ts_params->valid_devs[0]);
465 struct crypto_testsuite_params *ts_params = &testsuite_params;
466 struct crypto_unittest_params *ut_params = &unittest_params;
467 struct rte_cryptodev_stats stats;
469 /* free crypto session structure */
470 if (ut_params->sess) {
471 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
473 ut_params->sess = NULL;
476 /* free crypto operation structure */
478 rte_crypto_op_free(ut_params->op);
481 * free mbuf - both obuf and ibuf are usually the same,
482 * so check if they point at the same address is necessary,
483 * to avoid freeing the mbuf twice.
485 if (ut_params->obuf) {
486 rte_pktmbuf_free(ut_params->obuf);
487 if (ut_params->ibuf == ut_params->obuf)
491 if (ut_params->ibuf) {
492 rte_pktmbuf_free(ut_params->ibuf);
496 if (ts_params->mbuf_pool != NULL)
497 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
498 rte_mempool_avail_count(ts_params->mbuf_pool));
500 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
502 /* Stop the device */
503 rte_cryptodev_stop(ts_params->valid_devs[0]);
507 test_device_configure_invalid_dev_id(void)
509 struct crypto_testsuite_params *ts_params = &testsuite_params;
510 uint16_t dev_id, num_devs = 0;
512 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
513 "Need at least %d devices for test", 1);
515 /* valid dev_id values */
516 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
518 /* Stop the device in case it's started so it can be configured */
519 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
521 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
522 "Failed test for rte_cryptodev_configure: "
523 "invalid dev_num %u", dev_id);
525 /* invalid dev_id values */
528 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
529 "Failed test for rte_cryptodev_configure: "
530 "invalid dev_num %u", dev_id);
534 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
535 "Failed test for rte_cryptodev_configure:"
536 "invalid dev_num %u", dev_id);
542 test_device_configure_invalid_queue_pair_ids(void)
544 struct crypto_testsuite_params *ts_params = &testsuite_params;
545 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
547 /* Stop the device in case it's started so it can be configured */
548 rte_cryptodev_stop(ts_params->valid_devs[0]);
550 /* valid - one queue pairs */
551 ts_params->conf.nb_queue_pairs = 1;
553 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
555 "Failed to configure cryptodev: dev_id %u, qp_id %u",
556 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
559 /* valid - max value queue pairs */
560 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
562 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
564 "Failed to configure cryptodev: dev_id %u, qp_id %u",
565 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
568 /* invalid - zero queue pairs */
569 ts_params->conf.nb_queue_pairs = 0;
571 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
573 "Failed test for rte_cryptodev_configure, dev_id %u,"
575 ts_params->valid_devs[0],
576 ts_params->conf.nb_queue_pairs);
579 /* invalid - max value supported by field queue pairs */
580 ts_params->conf.nb_queue_pairs = UINT16_MAX;
582 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
584 "Failed test for rte_cryptodev_configure, dev_id %u,"
586 ts_params->valid_devs[0],
587 ts_params->conf.nb_queue_pairs);
590 /* invalid - max value + 1 queue pairs */
591 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
593 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
595 "Failed test for rte_cryptodev_configure, dev_id %u,"
597 ts_params->valid_devs[0],
598 ts_params->conf.nb_queue_pairs);
600 /* revert to original testsuite value */
601 ts_params->conf.nb_queue_pairs = orig_nb_qps;
607 test_queue_pair_descriptor_setup(void)
609 struct crypto_testsuite_params *ts_params = &testsuite_params;
610 struct rte_cryptodev_info dev_info;
611 struct rte_cryptodev_qp_conf qp_conf = {
612 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
617 /* Stop the device in case it's started so it can be configured */
618 rte_cryptodev_stop(ts_params->valid_devs[0]);
621 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
623 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
625 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
626 &ts_params->conf), "Failed to configure cryptodev %u",
627 ts_params->valid_devs[0]);
631 * Test various ring sizes on this device. memzones can't be
632 * freed so are re-used if ring is released and re-created.
634 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
636 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
637 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
638 ts_params->valid_devs[0], qp_id, &qp_conf,
639 rte_cryptodev_socket_id(
640 ts_params->valid_devs[0])),
642 "rte_cryptodev_queue_pair_setup: num_inflights "
643 "%u on qp %u on cryptodev %u",
644 qp_conf.nb_descriptors, qp_id,
645 ts_params->valid_devs[0]);
648 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
650 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
651 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
652 ts_params->valid_devs[0], qp_id, &qp_conf,
653 rte_cryptodev_socket_id(
654 ts_params->valid_devs[0])),
656 " rte_cryptodev_queue_pair_setup: num_inflights"
657 " %u on qp %u on cryptodev %u",
658 qp_conf.nb_descriptors, qp_id,
659 ts_params->valid_devs[0]);
662 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
664 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
665 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
666 ts_params->valid_devs[0], qp_id, &qp_conf,
667 rte_cryptodev_socket_id(
668 ts_params->valid_devs[0])),
670 "rte_cryptodev_queue_pair_setup: num_inflights"
671 " %u on qp %u on cryptodev %u",
672 qp_conf.nb_descriptors, qp_id,
673 ts_params->valid_devs[0]);
676 /* invalid number of descriptors - max supported + 2 */
677 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
679 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
680 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
681 ts_params->valid_devs[0], qp_id, &qp_conf,
682 rte_cryptodev_socket_id(
683 ts_params->valid_devs[0])),
684 "Unexpectedly passed test for "
685 "rte_cryptodev_queue_pair_setup:"
686 "num_inflights %u on qp %u on cryptodev %u",
687 qp_conf.nb_descriptors, qp_id,
688 ts_params->valid_devs[0]);
691 /* invalid number of descriptors - max value of parameter */
692 qp_conf.nb_descriptors = UINT32_MAX-1;
694 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
695 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
696 ts_params->valid_devs[0], qp_id, &qp_conf,
697 rte_cryptodev_socket_id(
698 ts_params->valid_devs[0])),
699 "Unexpectedly passed test for "
700 "rte_cryptodev_queue_pair_setup:"
701 "num_inflights %u on qp %u on cryptodev %u",
702 qp_conf.nb_descriptors, qp_id,
703 ts_params->valid_devs[0]);
706 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
708 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
709 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
710 ts_params->valid_devs[0], qp_id, &qp_conf,
711 rte_cryptodev_socket_id(
712 ts_params->valid_devs[0])),
714 " rte_cryptodev_queue_pair_setup:"
715 "num_inflights %u on qp %u on cryptodev %u",
716 qp_conf.nb_descriptors, qp_id,
717 ts_params->valid_devs[0]);
720 /* invalid number of descriptors - max supported + 1 */
721 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
723 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
724 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
725 ts_params->valid_devs[0], qp_id, &qp_conf,
726 rte_cryptodev_socket_id(
727 ts_params->valid_devs[0])),
728 "Unexpectedly passed test for "
729 "rte_cryptodev_queue_pair_setup:"
730 "num_inflights %u on qp %u on cryptodev %u",
731 qp_conf.nb_descriptors, qp_id,
732 ts_params->valid_devs[0]);
735 /* test invalid queue pair id */
736 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
738 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
740 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
741 ts_params->valid_devs[0],
743 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
744 "Failed test for rte_cryptodev_queue_pair_setup:"
745 "invalid qp %u on cryptodev %u",
746 qp_id, ts_params->valid_devs[0]);
748 qp_id = 0xffff; /*invalid*/
750 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
751 ts_params->valid_devs[0],
753 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
754 "Failed test for rte_cryptodev_queue_pair_setup:"
755 "invalid qp %u on cryptodev %u",
756 qp_id, ts_params->valid_devs[0]);
761 /* ***** Plaintext data for tests ***** */
763 const char catch_22_quote_1[] =
764 "There was only one catch and that was Catch-22, which "
765 "specified that a concern for one's safety in the face of "
766 "dangers that were real and immediate was the process of a "
767 "rational mind. Orr was crazy and could be grounded. All he "
768 "had to do was ask; and as soon as he did, he would no longer "
769 "be crazy and would have to fly more missions. Orr would be "
770 "crazy to fly more missions and sane if he didn't, but if he "
771 "was sane he had to fly them. If he flew them he was crazy "
772 "and didn't have to; but if he didn't want to he was sane and "
773 "had to. Yossarian was moved very deeply by the absolute "
774 "simplicity of this clause of Catch-22 and let out a "
775 "respectful whistle. \"That's some catch, that Catch-22\", he "
776 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
778 const char catch_22_quote[] =
779 "What a lousy earth! He wondered how many people were "
780 "destitute that same night even in his own prosperous country, "
781 "how many homes were shanties, how many husbands were drunk "
782 "and wives socked, and how many children were bullied, abused, "
783 "or abandoned. How many families hungered for food they could "
784 "not afford to buy? How many hearts were broken? How many "
785 "suicides would take place that same night, how many people "
786 "would go insane? How many cockroaches and landlords would "
787 "triumph? How many winners were losers, successes failures, "
788 "and rich men poor men? How many wise guys were stupid? How "
789 "many happy endings were unhappy endings? How many honest men "
790 "were liars, brave men cowards, loyal men traitors, how many "
791 "sainted men were corrupt, how many people in positions of "
792 "trust had sold their souls to bodyguards, how many had never "
793 "had souls? How many straight-and-narrow paths were crooked "
794 "paths? How many best families were worst families and how "
795 "many good people were bad people? When you added them all up "
796 "and then subtracted, you might be left with only the children, "
797 "and perhaps with Albert Einstein and an old violinist or "
798 "sculptor somewhere.";
800 #define QUOTE_480_BYTES (480)
801 #define QUOTE_512_BYTES (512)
802 #define QUOTE_768_BYTES (768)
803 #define QUOTE_1024_BYTES (1024)
807 /* ***** SHA1 Hash Tests ***** */
809 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
811 static uint8_t hmac_sha1_key[] = {
812 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
813 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
814 0xDE, 0xF4, 0xDE, 0xAD };
816 /* ***** SHA224 Hash Tests ***** */
818 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
821 /* ***** AES-CBC Cipher Tests ***** */
823 #define CIPHER_KEY_LENGTH_AES_CBC (16)
824 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
826 static uint8_t aes_cbc_key[] = {
827 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
828 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
830 static uint8_t aes_cbc_iv[] = {
831 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
832 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
835 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
837 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
838 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
839 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
840 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
841 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
842 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
843 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
844 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
845 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
846 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
847 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
848 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
849 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
850 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
851 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
852 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
853 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
854 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
855 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
856 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
857 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
858 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
859 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
860 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
861 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
862 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
863 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
864 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
865 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
866 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
867 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
868 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
869 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
870 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
871 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
872 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
873 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
874 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
875 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
876 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
877 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
878 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
879 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
880 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
881 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
882 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
883 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
884 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
885 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
886 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
887 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
888 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
889 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
890 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
891 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
892 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
893 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
894 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
895 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
896 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
897 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
898 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
899 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
900 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
901 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
904 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
905 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
906 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
907 0x18, 0x8c, 0x1d, 0x32
911 /* Multisession Vector context Test */
913 static uint8_t ms_aes_cbc_key0[] = {
914 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
915 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
918 static uint8_t ms_aes_cbc_iv0[] = {
919 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
920 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
923 static const uint8_t ms_aes_cbc_cipher0[] = {
924 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
925 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
926 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
927 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
928 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
929 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
930 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
931 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
932 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
933 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
934 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
935 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
936 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
937 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
938 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
939 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
940 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
941 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
942 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
943 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
944 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
945 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
946 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
947 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
948 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
949 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
950 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
951 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
952 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
953 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
954 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
955 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
956 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
957 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
958 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
959 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
960 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
961 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
962 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
963 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
964 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
965 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
966 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
967 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
968 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
969 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
970 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
971 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
972 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
973 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
974 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
975 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
976 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
977 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
978 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
979 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
980 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
981 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
982 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
983 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
984 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
985 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
986 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
987 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
991 static uint8_t ms_hmac_key0[] = {
992 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
993 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
994 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
995 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
996 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
997 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
998 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
999 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1002 static const uint8_t ms_hmac_digest0[] = {
1003 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1004 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1005 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1006 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1007 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1008 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1009 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1010 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1014 /* Begin session 1 */
1016 static uint8_t ms_aes_cbc_key1[] = {
1017 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1018 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1021 static uint8_t ms_aes_cbc_iv1[] = {
1022 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1023 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1026 static const uint8_t ms_aes_cbc_cipher1[] = {
1027 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1028 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1029 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1030 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1031 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1032 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1033 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1034 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1035 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1036 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1037 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1038 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1039 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1040 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1041 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1042 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1043 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1044 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1045 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1046 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1047 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1048 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1049 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1050 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1051 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1052 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1053 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1054 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1055 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1056 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1057 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1058 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1059 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1060 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1061 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1062 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1063 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1064 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1065 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1066 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1067 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1068 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1069 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1070 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1071 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1072 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1073 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1074 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1075 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1076 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1077 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1078 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1079 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1080 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1081 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1082 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1083 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1084 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1085 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1086 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1087 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1088 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1089 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1090 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1094 static uint8_t ms_hmac_key1[] = {
1095 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1096 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1097 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1098 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1099 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1100 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1101 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1102 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1105 static const uint8_t ms_hmac_digest1[] = {
1106 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1107 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1108 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1109 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1110 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1111 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1112 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1113 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1116 /* Begin Session 2 */
1117 static uint8_t ms_aes_cbc_key2[] = {
1118 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1119 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1122 static uint8_t ms_aes_cbc_iv2[] = {
1123 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1124 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1127 static const uint8_t ms_aes_cbc_cipher2[] = {
1128 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1129 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1130 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1131 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1132 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1133 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1134 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1135 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1136 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1137 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1138 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1139 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1140 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1141 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1142 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1143 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1144 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1145 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1146 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1147 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1148 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1149 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1150 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1151 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1152 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1153 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1154 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1155 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1156 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1157 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1158 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1159 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1160 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1161 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1162 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1163 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1164 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1165 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1166 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1167 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1168 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1169 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1170 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1171 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1172 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1173 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1174 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1175 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1176 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1177 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1178 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1179 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1180 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1181 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1182 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1183 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1184 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1185 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1186 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1187 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1188 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1189 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1190 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1191 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1194 static uint8_t ms_hmac_key2[] = {
1195 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1196 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1197 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1198 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1199 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1200 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1201 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1202 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1205 static const uint8_t ms_hmac_digest2[] = {
1206 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1207 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1208 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1209 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1210 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1211 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1212 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1213 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1220 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1222 struct crypto_testsuite_params *ts_params = &testsuite_params;
1223 struct crypto_unittest_params *ut_params = &unittest_params;
1225 /* Generate test mbuf data and space for digest */
1226 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1227 catch_22_quote, QUOTE_512_BYTES, 0);
1229 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1230 DIGEST_BYTE_LENGTH_SHA1);
1231 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1233 /* Setup Cipher Parameters */
1234 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1235 ut_params->cipher_xform.next = &ut_params->auth_xform;
1237 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1238 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1239 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1240 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1242 /* Setup HMAC Parameters */
1243 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1245 ut_params->auth_xform.next = NULL;
1247 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1248 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1249 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1250 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1251 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1253 /* Create crypto session*/
1254 ut_params->sess = rte_cryptodev_sym_session_create(
1255 ts_params->valid_devs[0],
1256 &ut_params->cipher_xform);
1257 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1259 /* Generate crypto op data structure */
1260 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1261 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1262 TEST_ASSERT_NOT_NULL(ut_params->op,
1263 "Failed to allocate symmetric crypto operation struct");
1265 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1267 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1269 /* set crypto operation source mbuf */
1270 sym_op->m_src = ut_params->ibuf;
1272 /* Set crypto operation authentication parameters */
1273 sym_op->auth.digest.data = ut_params->digest;
1274 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1275 ut_params->ibuf, QUOTE_512_BYTES);
1276 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1278 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1279 sym_op->auth.data.length = QUOTE_512_BYTES;
1281 /* Set crypto operation cipher parameters */
1282 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1283 CIPHER_IV_LENGTH_AES_CBC);
1284 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1285 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1287 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1288 CIPHER_IV_LENGTH_AES_CBC);
1290 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1291 sym_op->cipher.data.length = QUOTE_512_BYTES;
1293 /* Process crypto operation */
1294 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1295 ut_params->op), "failed to process sym crypto op");
1297 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1298 "crypto op processing failed");
1301 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1302 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1304 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1305 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1307 "ciphertext data not as expected");
1309 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1311 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1312 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1313 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1314 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1315 DIGEST_BYTE_LENGTH_SHA1,
1316 "Generated digest data not as expected");
1318 return TEST_SUCCESS;
1321 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1323 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1325 static uint8_t hmac_sha512_key[] = {
1326 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1327 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1328 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1329 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1330 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1331 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1332 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1333 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1335 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1336 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1337 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1338 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1339 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1340 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1341 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1342 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1343 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1348 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1349 struct crypto_unittest_params *ut_params,
1350 uint8_t *cipher_key,
1354 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1355 struct crypto_unittest_params *ut_params,
1356 struct crypto_testsuite_params *ts_params,
1357 const uint8_t *cipher,
1358 const uint8_t *digest,
1363 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1364 struct crypto_unittest_params *ut_params,
1365 uint8_t *cipher_key,
1369 /* Setup Cipher Parameters */
1370 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1371 ut_params->cipher_xform.next = NULL;
1373 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1374 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1375 ut_params->cipher_xform.cipher.key.data = cipher_key;
1376 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1378 /* Setup HMAC Parameters */
1379 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1380 ut_params->auth_xform.next = &ut_params->cipher_xform;
1382 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1383 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1384 ut_params->auth_xform.auth.key.data = hmac_key;
1385 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1386 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1388 return TEST_SUCCESS;
1393 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1394 struct crypto_unittest_params *ut_params,
1395 struct crypto_testsuite_params *ts_params,
1396 const uint8_t *cipher,
1397 const uint8_t *digest,
1400 /* Generate test mbuf data and digest */
1401 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1404 QUOTE_512_BYTES, 0);
1406 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1407 DIGEST_BYTE_LENGTH_SHA512);
1408 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1410 rte_memcpy(ut_params->digest,
1412 DIGEST_BYTE_LENGTH_SHA512);
1414 /* Generate Crypto op data structure */
1415 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1416 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1417 TEST_ASSERT_NOT_NULL(ut_params->op,
1418 "Failed to allocate symmetric crypto operation struct");
1420 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1422 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1424 /* set crypto operation source mbuf */
1425 sym_op->m_src = ut_params->ibuf;
1427 sym_op->auth.digest.data = ut_params->digest;
1428 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1429 ut_params->ibuf, QUOTE_512_BYTES);
1430 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1432 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1433 sym_op->auth.data.length = QUOTE_512_BYTES;
1435 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1436 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1437 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1438 ut_params->ibuf, 0);
1439 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1441 rte_memcpy(sym_op->cipher.iv.data, iv,
1442 CIPHER_IV_LENGTH_AES_CBC);
1444 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1445 sym_op->cipher.data.length = QUOTE_512_BYTES;
1447 /* Process crypto operation */
1448 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1449 ut_params->op), "failed to process sym crypto op");
1451 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1452 "crypto op processing failed");
1454 ut_params->obuf = ut_params->op->sym->m_src;
1457 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1458 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1459 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1461 "Plaintext data not as expected");
1464 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1465 "Digest verification failed");
1467 return TEST_SUCCESS;
1471 test_AES_chain_mb_all(void)
1473 struct crypto_testsuite_params *ts_params = &testsuite_params;
1476 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1477 ts_params->op_mpool, ts_params->valid_devs[0],
1478 RTE_CRYPTODEV_AESNI_MB_PMD,
1479 BLKCIPHER_AES_CHAIN_TYPE);
1481 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1483 return TEST_SUCCESS;
1487 test_AES_chain_openssl_all(void)
1489 struct crypto_testsuite_params *ts_params = &testsuite_params;
1492 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1493 ts_params->op_mpool, ts_params->valid_devs[0],
1494 RTE_CRYPTODEV_OPENSSL_PMD,
1495 BLKCIPHER_AES_CHAIN_TYPE);
1497 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1499 return TEST_SUCCESS;
1503 test_AES_cipheronly_openssl_all(void)
1505 struct crypto_testsuite_params *ts_params = &testsuite_params;
1508 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1509 ts_params->op_mpool, ts_params->valid_devs[0],
1510 RTE_CRYPTODEV_OPENSSL_PMD,
1511 BLKCIPHER_AES_CIPHERONLY_TYPE);
1513 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1515 return TEST_SUCCESS;
1519 test_AES_chain_qat_all(void)
1521 struct crypto_testsuite_params *ts_params = &testsuite_params;
1524 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1525 ts_params->op_mpool, ts_params->valid_devs[0],
1526 RTE_CRYPTODEV_QAT_SYM_PMD,
1527 BLKCIPHER_AES_CHAIN_TYPE);
1529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1531 return TEST_SUCCESS;
1535 test_authonly_openssl_all(void)
1537 struct crypto_testsuite_params *ts_params = &testsuite_params;
1540 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1541 ts_params->op_mpool, ts_params->valid_devs[0],
1542 RTE_CRYPTODEV_OPENSSL_PMD,
1543 BLKCIPHER_AUTHONLY_TYPE);
1545 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1547 return TEST_SUCCESS;
1551 test_authonly_qat_all(void)
1553 struct crypto_testsuite_params *ts_params = &testsuite_params;
1556 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1557 ts_params->op_mpool, ts_params->valid_devs[0],
1558 RTE_CRYPTODEV_QAT_SYM_PMD,
1559 BLKCIPHER_AUTHONLY_TYPE);
1561 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1563 return TEST_SUCCESS;
1566 /* ***** SNOW 3G Tests ***** */
1568 create_wireless_algo_hash_session(uint8_t dev_id,
1569 const uint8_t *key, const uint8_t key_len,
1570 const uint8_t aad_len, const uint8_t auth_len,
1571 enum rte_crypto_auth_operation op,
1572 enum rte_crypto_auth_algorithm algo)
1574 uint8_t hash_key[key_len];
1576 struct crypto_unittest_params *ut_params = &unittest_params;
1578 memcpy(hash_key, key, key_len);
1580 TEST_HEXDUMP(stdout, "key:", key, key_len);
1582 /* Setup Authentication Parameters */
1583 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1584 ut_params->auth_xform.next = NULL;
1586 ut_params->auth_xform.auth.op = op;
1587 ut_params->auth_xform.auth.algo = algo;
1588 ut_params->auth_xform.auth.key.length = key_len;
1589 ut_params->auth_xform.auth.key.data = hash_key;
1590 ut_params->auth_xform.auth.digest_length = auth_len;
1591 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1592 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1593 &ut_params->auth_xform);
1594 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1599 create_wireless_algo_cipher_session(uint8_t dev_id,
1600 enum rte_crypto_cipher_operation op,
1601 enum rte_crypto_cipher_algorithm algo,
1602 const uint8_t *key, const uint8_t key_len)
1604 uint8_t cipher_key[key_len];
1606 struct crypto_unittest_params *ut_params = &unittest_params;
1608 memcpy(cipher_key, key, key_len);
1610 /* Setup Cipher Parameters */
1611 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1612 ut_params->cipher_xform.next = NULL;
1614 ut_params->cipher_xform.cipher.algo = algo;
1615 ut_params->cipher_xform.cipher.op = op;
1616 ut_params->cipher_xform.cipher.key.data = cipher_key;
1617 ut_params->cipher_xform.cipher.key.length = key_len;
1619 TEST_HEXDUMP(stdout, "key:", key, key_len);
1621 /* Create Crypto session */
1622 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1625 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1630 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1631 const unsigned cipher_len,
1632 const unsigned cipher_offset,
1633 enum rte_crypto_cipher_algorithm algo)
1635 struct crypto_testsuite_params *ts_params = &testsuite_params;
1636 struct crypto_unittest_params *ut_params = &unittest_params;
1637 unsigned iv_pad_len = 0;
1639 /* Generate Crypto op data structure */
1640 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1641 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1642 TEST_ASSERT_NOT_NULL(ut_params->op,
1643 "Failed to allocate pktmbuf offload");
1645 /* Set crypto operation data parameters */
1646 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1648 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1650 /* set crypto operation source mbuf */
1651 sym_op->m_src = ut_params->ibuf;
1654 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1655 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1657 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1659 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1662 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1664 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1665 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1666 sym_op->cipher.iv.length = iv_pad_len;
1668 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1669 sym_op->cipher.data.length = cipher_len;
1670 sym_op->cipher.data.offset = cipher_offset;
1675 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1676 const unsigned cipher_len,
1677 const unsigned cipher_offset,
1678 enum rte_crypto_cipher_algorithm algo)
1680 struct crypto_testsuite_params *ts_params = &testsuite_params;
1681 struct crypto_unittest_params *ut_params = &unittest_params;
1682 unsigned iv_pad_len = 0;
1684 /* Generate Crypto op data structure */
1685 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1686 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1687 TEST_ASSERT_NOT_NULL(ut_params->op,
1688 "Failed to allocate pktmbuf offload");
1690 /* Set crypto operation data parameters */
1691 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1693 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1695 /* set crypto operation source mbuf */
1696 sym_op->m_src = ut_params->ibuf;
1697 sym_op->m_dst = ut_params->obuf;
1700 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1701 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1703 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1704 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1707 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1709 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1710 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1711 sym_op->cipher.iv.length = iv_pad_len;
1713 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1714 sym_op->cipher.data.length = cipher_len;
1715 sym_op->cipher.data.offset = cipher_offset;
1720 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1721 enum rte_crypto_cipher_operation cipher_op,
1722 enum rte_crypto_auth_operation auth_op,
1723 enum rte_crypto_auth_algorithm auth_algo,
1724 enum rte_crypto_cipher_algorithm cipher_algo,
1725 const uint8_t *key, const uint8_t key_len,
1726 const uint8_t aad_len, const uint8_t auth_len)
1729 uint8_t cipher_auth_key[key_len];
1731 struct crypto_unittest_params *ut_params = &unittest_params;
1733 memcpy(cipher_auth_key, key, key_len);
1735 /* Setup Authentication Parameters */
1736 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1737 ut_params->auth_xform.next = NULL;
1739 ut_params->auth_xform.auth.op = auth_op;
1740 ut_params->auth_xform.auth.algo = auth_algo;
1741 ut_params->auth_xform.auth.key.length = key_len;
1742 /* Hash key = cipher key */
1743 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1744 ut_params->auth_xform.auth.digest_length = auth_len;
1745 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1747 /* Setup Cipher Parameters */
1748 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1749 ut_params->cipher_xform.next = &ut_params->auth_xform;
1751 ut_params->cipher_xform.cipher.algo = cipher_algo;
1752 ut_params->cipher_xform.cipher.op = cipher_op;
1753 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1754 ut_params->cipher_xform.cipher.key.length = key_len;
1756 TEST_HEXDUMP(stdout, "key:", key, key_len);
1758 /* Create Crypto session*/
1759 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1760 &ut_params->cipher_xform);
1762 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1767 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1768 enum rte_crypto_cipher_operation cipher_op,
1769 enum rte_crypto_auth_operation auth_op,
1770 enum rte_crypto_auth_algorithm auth_algo,
1771 enum rte_crypto_cipher_algorithm cipher_algo,
1772 const uint8_t *key, const uint8_t key_len,
1773 const uint8_t aad_len, const uint8_t auth_len)
1775 uint8_t auth_cipher_key[key_len];
1777 struct crypto_unittest_params *ut_params = &unittest_params;
1779 memcpy(auth_cipher_key, key, key_len);
1781 /* Setup Authentication Parameters */
1782 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1783 ut_params->auth_xform.auth.op = auth_op;
1784 ut_params->auth_xform.next = &ut_params->cipher_xform;
1785 ut_params->auth_xform.auth.algo = auth_algo;
1786 ut_params->auth_xform.auth.key.length = key_len;
1787 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1788 ut_params->auth_xform.auth.digest_length = auth_len;
1789 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1791 /* Setup Cipher Parameters */
1792 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1793 ut_params->cipher_xform.next = NULL;
1794 ut_params->cipher_xform.cipher.algo = cipher_algo;
1795 ut_params->cipher_xform.cipher.op = cipher_op;
1796 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1797 ut_params->cipher_xform.cipher.key.length = key_len;
1799 TEST_HEXDUMP(stdout, "key:", key, key_len);
1801 /* Create Crypto session*/
1802 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1803 &ut_params->auth_xform);
1805 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1811 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1812 const unsigned auth_tag_len,
1813 const uint8_t *aad, const unsigned aad_len,
1814 unsigned data_pad_len,
1815 enum rte_crypto_auth_operation op,
1816 enum rte_crypto_auth_algorithm algo,
1817 const unsigned auth_len, const unsigned auth_offset)
1819 struct crypto_testsuite_params *ts_params = &testsuite_params;
1821 struct crypto_unittest_params *ut_params = &unittest_params;
1823 unsigned aad_buffer_len;
1825 /* Generate Crypto op data structure */
1826 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1827 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1828 TEST_ASSERT_NOT_NULL(ut_params->op,
1829 "Failed to allocate pktmbuf offload");
1831 /* Set crypto operation data parameters */
1832 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1834 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1836 /* set crypto operation source mbuf */
1837 sym_op->m_src = ut_params->ibuf;
1841 * Always allocate the aad up to the block size.
1842 * The cryptodev API calls out -
1843 * - the array must be big enough to hold the AAD, plus any
1844 * space to round this up to the nearest multiple of the
1845 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1847 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1848 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1850 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1851 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1852 ut_params->ibuf, aad_buffer_len);
1853 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1854 "no room to prepend aad");
1855 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1857 sym_op->auth.aad.length = aad_len;
1859 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1860 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1862 TEST_HEXDUMP(stdout, "aad:",
1863 sym_op->auth.aad.data, aad_len);
1866 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1867 ut_params->ibuf, auth_tag_len);
1869 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1870 "no room to append auth tag");
1871 ut_params->digest = sym_op->auth.digest.data;
1872 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1873 ut_params->ibuf, data_pad_len + aad_len);
1874 sym_op->auth.digest.length = auth_tag_len;
1875 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1876 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1878 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1880 TEST_HEXDUMP(stdout, "digest:",
1881 sym_op->auth.digest.data,
1882 sym_op->auth.digest.length);
1884 sym_op->auth.data.length = auth_len;
1885 sym_op->auth.data.offset = auth_offset;
1891 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1892 const unsigned auth_tag_len,
1893 const uint8_t *aad, const uint8_t aad_len,
1894 unsigned data_pad_len,
1895 enum rte_crypto_auth_operation op,
1896 enum rte_crypto_auth_algorithm auth_algo,
1897 enum rte_crypto_cipher_algorithm cipher_algo,
1898 const uint8_t *iv, const uint8_t iv_len,
1899 const unsigned cipher_len, const unsigned cipher_offset,
1900 const unsigned auth_len, const unsigned auth_offset)
1902 struct crypto_testsuite_params *ts_params = &testsuite_params;
1903 struct crypto_unittest_params *ut_params = &unittest_params;
1905 unsigned iv_pad_len = 0;
1906 unsigned aad_buffer_len;
1908 /* Generate Crypto op data structure */
1909 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1910 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1911 TEST_ASSERT_NOT_NULL(ut_params->op,
1912 "Failed to allocate pktmbuf offload");
1913 /* Set crypto operation data parameters */
1914 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1916 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1918 /* set crypto operation source mbuf */
1919 sym_op->m_src = ut_params->ibuf;
1922 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1923 ut_params->ibuf, auth_tag_len);
1925 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1926 "no room to append auth tag");
1927 ut_params->digest = sym_op->auth.digest.data;
1928 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1929 ut_params->ibuf, data_pad_len);
1930 sym_op->auth.digest.length = auth_tag_len;
1931 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1932 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1934 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1936 TEST_HEXDUMP(stdout, "digest:",
1937 sym_op->auth.digest.data,
1938 sym_op->auth.digest.length);
1942 * Always allocate the aad up to the block size.
1943 * The cryptodev API calls out -
1944 * - the array must be big enough to hold the AAD, plus any
1945 * space to round this up to the nearest multiple of the
1946 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1948 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1949 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1951 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1952 sym_op->auth.aad.data =
1953 (uint8_t *)rte_pktmbuf_prepend(
1954 ut_params->ibuf, aad_buffer_len);
1955 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1956 "no room to prepend aad");
1957 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1959 sym_op->auth.aad.length = aad_len;
1960 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1961 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1962 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1965 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1966 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1968 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1969 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1970 ut_params->ibuf, iv_pad_len);
1972 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1973 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1974 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1975 sym_op->cipher.iv.length = iv_pad_len;
1976 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1977 sym_op->cipher.data.length = cipher_len;
1978 sym_op->cipher.data.offset = cipher_offset + auth_offset;
1979 sym_op->auth.data.length = auth_len;
1980 sym_op->auth.data.offset = auth_offset + cipher_offset;
1986 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
1987 const uint8_t *iv, const uint8_t iv_len,
1988 const uint8_t *aad, const uint8_t aad_len,
1989 unsigned data_pad_len,
1990 const unsigned cipher_len, const unsigned cipher_offset,
1991 const unsigned auth_len, const unsigned auth_offset,
1992 enum rte_crypto_auth_algorithm auth_algo,
1993 enum rte_crypto_cipher_algorithm cipher_algo)
1995 struct crypto_testsuite_params *ts_params = &testsuite_params;
1996 struct crypto_unittest_params *ut_params = &unittest_params;
1998 unsigned iv_pad_len = 0;
1999 unsigned aad_buffer_len = 0;
2001 /* Generate Crypto op data structure */
2002 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2003 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2004 TEST_ASSERT_NOT_NULL(ut_params->op,
2005 "Failed to allocate pktmbuf offload");
2007 /* Set crypto operation data parameters */
2008 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2010 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2012 /* set crypto operation source mbuf */
2013 sym_op->m_src = ut_params->ibuf;
2016 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2017 ut_params->ibuf, auth_tag_len);
2019 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2020 "no room to append auth tag");
2022 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2023 ut_params->ibuf, data_pad_len);
2024 sym_op->auth.digest.length = auth_tag_len;
2026 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2028 TEST_HEXDUMP(stdout, "digest:",
2029 sym_op->auth.digest.data,
2030 sym_op->auth.digest.length);
2034 * Always allocate the aad up to the block size.
2035 * The cryptodev API calls out -
2036 * - the array must be big enough to hold the AAD, plus any
2037 * space to round this up to the nearest multiple of the
2038 * block size (8 bytes for KASUMI 16 bytes).
2040 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2041 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2043 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2044 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2045 ut_params->ibuf, aad_buffer_len);
2046 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2047 "no room to prepend aad");
2048 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2050 sym_op->auth.aad.length = aad_len;
2051 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2052 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2053 TEST_HEXDUMP(stdout, "aad:",
2054 sym_op->auth.aad.data, aad_len);
2057 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2058 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2060 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2062 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2063 ut_params->ibuf, iv_pad_len);
2064 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2066 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2067 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2068 sym_op->cipher.iv.length = iv_pad_len;
2070 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2072 sym_op->cipher.data.length = cipher_len;
2073 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2075 sym_op->auth.data.length = auth_len;
2076 sym_op->auth.data.offset = auth_offset + cipher_offset;
2082 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2084 struct crypto_testsuite_params *ts_params = &testsuite_params;
2085 struct crypto_unittest_params *ut_params = &unittest_params;
2088 unsigned plaintext_pad_len;
2089 unsigned plaintext_len;
2092 /* Create SNOW 3G session */
2093 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2094 tdata->key.data, tdata->key.len,
2095 tdata->aad.len, tdata->digest.len,
2096 RTE_CRYPTO_AUTH_OP_GENERATE,
2097 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2101 /* alloc mbuf and set payload */
2102 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2104 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2105 rte_pktmbuf_tailroom(ut_params->ibuf));
2107 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2108 /* Append data which is padded to a multiple of */
2109 /* the algorithms block size */
2110 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2111 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2113 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2115 /* Create SNOW 3G operation */
2116 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2117 tdata->aad.data, tdata->aad.len,
2118 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2119 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2120 tdata->validAuthLenInBits.len,
2121 tdata->validAuthOffsetLenInBits.len);
2125 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2127 ut_params->obuf = ut_params->op->sym->m_src;
2128 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2129 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2130 + plaintext_pad_len + tdata->aad.len;
2133 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2136 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2137 "SNOW 3G Generated auth tag not as expected");
2143 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2145 struct crypto_testsuite_params *ts_params = &testsuite_params;
2146 struct crypto_unittest_params *ut_params = &unittest_params;
2149 unsigned plaintext_pad_len;
2150 unsigned plaintext_len;
2153 /* Create SNOW 3G session */
2154 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2155 tdata->key.data, tdata->key.len,
2156 tdata->aad.len, tdata->digest.len,
2157 RTE_CRYPTO_AUTH_OP_VERIFY,
2158 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2161 /* alloc mbuf and set payload */
2162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2164 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2165 rte_pktmbuf_tailroom(ut_params->ibuf));
2167 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2168 /* Append data which is padded to a multiple of */
2169 /* the algorithms block size */
2170 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2171 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2173 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2175 /* Create SNOW 3G operation */
2176 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2178 tdata->aad.data, tdata->aad.len,
2180 RTE_CRYPTO_AUTH_OP_VERIFY,
2181 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2182 tdata->validAuthLenInBits.len,
2183 tdata->validAuthOffsetLenInBits.len);
2187 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2189 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2190 ut_params->obuf = ut_params->op->sym->m_src;
2191 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2192 + plaintext_pad_len + tdata->aad.len;
2195 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2204 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2206 struct crypto_testsuite_params *ts_params = &testsuite_params;
2207 struct crypto_unittest_params *ut_params = &unittest_params;
2210 unsigned plaintext_pad_len;
2211 unsigned plaintext_len;
2214 /* Create KASUMI session */
2215 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2216 tdata->key.data, tdata->key.len,
2217 tdata->aad.len, tdata->digest.len,
2218 RTE_CRYPTO_AUTH_OP_GENERATE,
2219 RTE_CRYPTO_AUTH_KASUMI_F9);
2223 /* alloc mbuf and set payload */
2224 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2226 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2227 rte_pktmbuf_tailroom(ut_params->ibuf));
2229 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2230 /* Append data which is padded to a multiple of */
2231 /* the algorithms block size */
2232 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2233 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2235 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2237 /* Create KASUMI operation */
2238 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2239 tdata->aad.data, tdata->aad.len,
2240 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2241 RTE_CRYPTO_AUTH_KASUMI_F9,
2242 tdata->validAuthLenInBits.len,
2243 tdata->validAuthOffsetLenInBits.len);
2247 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2249 ut_params->obuf = ut_params->op->sym->m_src;
2250 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2251 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2252 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2255 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2258 DIGEST_BYTE_LENGTH_KASUMI_F9,
2259 "KASUMI Generated auth tag not as expected");
2265 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2267 struct crypto_testsuite_params *ts_params = &testsuite_params;
2268 struct crypto_unittest_params *ut_params = &unittest_params;
2271 unsigned plaintext_pad_len;
2272 unsigned plaintext_len;
2275 /* Create KASUMI session */
2276 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2277 tdata->key.data, tdata->key.len,
2278 tdata->aad.len, tdata->digest.len,
2279 RTE_CRYPTO_AUTH_OP_VERIFY,
2280 RTE_CRYPTO_AUTH_KASUMI_F9);
2283 /* alloc mbuf and set payload */
2284 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2286 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2287 rte_pktmbuf_tailroom(ut_params->ibuf));
2289 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2290 /* Append data which is padded to a multiple */
2291 /* of the algorithms block size */
2292 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2293 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2295 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2297 /* Create KASUMI operation */
2298 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2300 tdata->aad.data, tdata->aad.len,
2302 RTE_CRYPTO_AUTH_OP_VERIFY,
2303 RTE_CRYPTO_AUTH_KASUMI_F9,
2304 tdata->validAuthLenInBits.len,
2305 tdata->validAuthOffsetLenInBits.len);
2309 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2311 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2312 ut_params->obuf = ut_params->op->sym->m_src;
2313 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2314 + plaintext_pad_len + tdata->aad.len;
2317 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2326 test_snow3g_hash_generate_test_case_1(void)
2328 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2332 test_snow3g_hash_generate_test_case_2(void)
2334 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2338 test_snow3g_hash_generate_test_case_3(void)
2340 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2344 test_snow3g_hash_generate_test_case_4(void)
2346 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2350 test_snow3g_hash_generate_test_case_5(void)
2352 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2356 test_snow3g_hash_generate_test_case_6(void)
2358 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2362 test_snow3g_hash_verify_test_case_1(void)
2364 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2369 test_snow3g_hash_verify_test_case_2(void)
2371 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2375 test_snow3g_hash_verify_test_case_3(void)
2377 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2381 test_snow3g_hash_verify_test_case_4(void)
2383 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2387 test_snow3g_hash_verify_test_case_5(void)
2389 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2393 test_snow3g_hash_verify_test_case_6(void)
2395 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2399 test_kasumi_hash_generate_test_case_1(void)
2401 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2405 test_kasumi_hash_generate_test_case_2(void)
2407 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2411 test_kasumi_hash_generate_test_case_3(void)
2413 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2417 test_kasumi_hash_generate_test_case_4(void)
2419 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2423 test_kasumi_hash_generate_test_case_5(void)
2425 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2429 test_kasumi_hash_generate_test_case_6(void)
2431 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2435 test_kasumi_hash_verify_test_case_1(void)
2437 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2441 test_kasumi_hash_verify_test_case_2(void)
2443 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2447 test_kasumi_hash_verify_test_case_3(void)
2449 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2453 test_kasumi_hash_verify_test_case_4(void)
2455 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2459 test_kasumi_hash_verify_test_case_5(void)
2461 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2465 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2467 struct crypto_testsuite_params *ts_params = &testsuite_params;
2468 struct crypto_unittest_params *ut_params = &unittest_params;
2471 uint8_t *plaintext, *ciphertext;
2472 unsigned plaintext_pad_len;
2473 unsigned plaintext_len;
2475 /* Create KASUMI session */
2476 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2477 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2478 RTE_CRYPTO_CIPHER_KASUMI_F8,
2479 tdata->key.data, tdata->key.len);
2483 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2485 /* Clear mbuf payload */
2486 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2487 rte_pktmbuf_tailroom(ut_params->ibuf));
2489 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2490 /* Append data which is padded to a multiple */
2491 /* of the algorithms block size */
2492 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2493 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2495 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2497 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2499 /* Create KASUMI operation */
2500 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2501 tdata->plaintext.len,
2502 tdata->validCipherOffsetLenInBits.len,
2503 RTE_CRYPTO_CIPHER_KASUMI_F8);
2507 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2509 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2511 ut_params->obuf = ut_params->op->sym->m_dst;
2512 if (ut_params->obuf)
2513 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2516 ciphertext = plaintext;
2518 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2521 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2523 tdata->ciphertext.data,
2524 tdata->validCipherLenInBits.len,
2525 "KASUMI Ciphertext data not as expected");
2530 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2532 struct crypto_testsuite_params *ts_params = &testsuite_params;
2533 struct crypto_unittest_params *ut_params = &unittest_params;
2536 uint8_t *plaintext, *ciphertext;
2537 unsigned plaintext_pad_len;
2538 unsigned plaintext_len;
2540 /* Create KASUMI session */
2541 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2542 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2543 RTE_CRYPTO_CIPHER_KASUMI_F8,
2544 tdata->key.data, tdata->key.len);
2548 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2549 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2551 /* Clear mbuf payload */
2552 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2553 rte_pktmbuf_tailroom(ut_params->ibuf));
2555 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2556 /* Append data which is padded to a multiple */
2557 /* of the algorithms block size */
2558 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2559 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2561 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2562 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2564 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2566 /* Create KASUMI operation */
2567 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2569 tdata->plaintext.len,
2570 tdata->validCipherOffsetLenInBits.len,
2571 RTE_CRYPTO_CIPHER_KASUMI_F8);
2575 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2577 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2579 ut_params->obuf = ut_params->op->sym->m_dst;
2580 if (ut_params->obuf)
2581 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2584 ciphertext = plaintext;
2586 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2589 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2591 tdata->ciphertext.data,
2592 tdata->validCipherLenInBits.len,
2593 "KASUMI Ciphertext data not as expected");
2598 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2600 struct crypto_testsuite_params *ts_params = &testsuite_params;
2601 struct crypto_unittest_params *ut_params = &unittest_params;
2604 uint8_t *ciphertext, *plaintext;
2605 unsigned ciphertext_pad_len;
2606 unsigned ciphertext_len;
2608 /* Create KASUMI session */
2609 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2610 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2611 RTE_CRYPTO_CIPHER_KASUMI_F8,
2612 tdata->key.data, tdata->key.len);
2616 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2617 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2619 /* Clear mbuf payload */
2620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2621 rte_pktmbuf_tailroom(ut_params->ibuf));
2623 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2624 /* Append data which is padded to a multiple */
2625 /* of the algorithms block size */
2626 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2627 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2628 ciphertext_pad_len);
2629 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2630 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2632 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2634 /* Create KASUMI operation */
2635 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2637 tdata->ciphertext.len,
2638 tdata->validCipherOffsetLenInBits.len,
2639 RTE_CRYPTO_CIPHER_KASUMI_F8);
2643 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2645 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2647 ut_params->obuf = ut_params->op->sym->m_dst;
2648 if (ut_params->obuf)
2649 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2652 plaintext = ciphertext;
2654 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2657 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2659 tdata->plaintext.data,
2660 tdata->validCipherLenInBits.len,
2661 "KASUMI Plaintext data not as expected");
2666 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2668 struct crypto_testsuite_params *ts_params = &testsuite_params;
2669 struct crypto_unittest_params *ut_params = &unittest_params;
2672 uint8_t *ciphertext, *plaintext;
2673 unsigned ciphertext_pad_len;
2674 unsigned ciphertext_len;
2676 /* Create KASUMI session */
2677 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2678 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2679 RTE_CRYPTO_CIPHER_KASUMI_F8,
2680 tdata->key.data, tdata->key.len);
2684 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2686 /* Clear mbuf payload */
2687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2688 rte_pktmbuf_tailroom(ut_params->ibuf));
2690 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2691 /* Append data which is padded to a multiple */
2692 /* of the algorithms block size */
2693 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2694 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2695 ciphertext_pad_len);
2696 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2698 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2700 /* Create KASUMI operation */
2701 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2703 tdata->ciphertext.len,
2704 tdata->validCipherOffsetLenInBits.len,
2705 RTE_CRYPTO_CIPHER_KASUMI_F8);
2709 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2711 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2713 ut_params->obuf = ut_params->op->sym->m_dst;
2714 if (ut_params->obuf)
2715 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2718 plaintext = ciphertext;
2720 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2723 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2725 tdata->plaintext.data,
2726 tdata->validCipherLenInBits.len,
2727 "KASUMI Plaintext data not as expected");
2732 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2734 struct crypto_testsuite_params *ts_params = &testsuite_params;
2735 struct crypto_unittest_params *ut_params = &unittest_params;
2738 uint8_t *plaintext, *ciphertext;
2739 unsigned plaintext_pad_len;
2740 unsigned plaintext_len;
2742 /* Create SNOW 3G session */
2743 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2744 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2745 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2746 tdata->key.data, tdata->key.len);
2750 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2752 /* Clear mbuf payload */
2753 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2754 rte_pktmbuf_tailroom(ut_params->ibuf));
2756 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2757 /* Append data which is padded to a multiple of */
2758 /* the algorithms block size */
2759 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2760 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2762 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2764 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2766 /* Create SNOW 3G operation */
2767 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2768 tdata->validCipherLenInBits.len,
2769 tdata->validCipherOffsetLenInBits.len,
2770 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2774 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2776 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2778 ut_params->obuf = ut_params->op->sym->m_dst;
2779 if (ut_params->obuf)
2780 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2783 ciphertext = plaintext;
2785 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2788 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2790 tdata->ciphertext.data,
2791 tdata->validDataLenInBits.len,
2792 "SNOW 3G Ciphertext data not as expected");
2798 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2800 struct crypto_testsuite_params *ts_params = &testsuite_params;
2801 struct crypto_unittest_params *ut_params = &unittest_params;
2802 uint8_t *plaintext, *ciphertext;
2805 unsigned plaintext_pad_len;
2806 unsigned plaintext_len;
2808 /* Create SNOW 3G session */
2809 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2810 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2811 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2812 tdata->key.data, tdata->key.len);
2816 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2817 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2819 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2820 "Failed to allocate input buffer in mempool");
2821 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2822 "Failed to allocate output buffer in mempool");
2824 /* Clear mbuf payload */
2825 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2826 rte_pktmbuf_tailroom(ut_params->ibuf));
2828 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2829 /* Append data which is padded to a multiple of */
2830 /* the algorithms block size */
2831 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2832 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2834 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2835 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2837 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2839 /* Create SNOW 3G operation */
2840 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2842 tdata->validCipherLenInBits.len,
2843 tdata->validCipherOffsetLenInBits.len,
2844 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2848 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2850 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2852 ut_params->obuf = ut_params->op->sym->m_dst;
2853 if (ut_params->obuf)
2854 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2857 ciphertext = plaintext;
2859 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2862 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2864 tdata->ciphertext.data,
2865 tdata->validDataLenInBits.len,
2866 "SNOW 3G Ciphertext data not as expected");
2870 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2872 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2874 uint8_t curr_byte, prev_byte;
2875 uint32_t length_in_bytes = ceil_byte_length(length + offset);
2876 uint8_t lower_byte_mask = (1 << offset) - 1;
2879 prev_byte = buffer[0];
2880 buffer[0] >>= offset;
2882 for (i = 1; i < length_in_bytes; i++) {
2883 curr_byte = buffer[i];
2884 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2885 (curr_byte >> offset);
2886 prev_byte = curr_byte;
2891 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2893 struct crypto_testsuite_params *ts_params = &testsuite_params;
2894 struct crypto_unittest_params *ut_params = &unittest_params;
2895 uint8_t *plaintext, *ciphertext;
2897 uint32_t plaintext_len;
2898 uint32_t plaintext_pad_len;
2899 uint8_t extra_offset = 4;
2900 uint8_t *expected_ciphertext_shifted;
2902 /* Create SNOW 3G session */
2903 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2904 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2905 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2906 tdata->key.data, tdata->key.len);
2910 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2911 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2913 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2914 "Failed to allocate input buffer in mempool");
2915 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2916 "Failed to allocate output buffer in mempool");
2918 /* Clear mbuf payload */
2919 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2920 rte_pktmbuf_tailroom(ut_params->ibuf));
2922 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2924 * Append data which is padded to a
2925 * multiple of the algorithms block size
2927 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2929 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2932 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2934 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2935 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2937 #ifdef RTE_APP_TEST_DEBUG
2938 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2940 /* Create SNOW 3G operation */
2941 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2943 tdata->validCipherLenInBits.len,
2944 tdata->validCipherOffsetLenInBits.len +
2946 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2950 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2952 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2954 ut_params->obuf = ut_params->op->sym->m_dst;
2955 if (ut_params->obuf)
2956 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2959 ciphertext = plaintext;
2961 #ifdef RTE_APP_TEST_DEBUG
2962 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2965 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
2967 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2968 "failed to reserve memory for ciphertext shifted\n");
2970 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
2971 ceil_byte_length(tdata->ciphertext.len));
2972 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
2975 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
2977 expected_ciphertext_shifted,
2978 tdata->validDataLenInBits.len,
2980 "SNOW 3G Ciphertext data not as expected");
2984 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2986 struct crypto_testsuite_params *ts_params = &testsuite_params;
2987 struct crypto_unittest_params *ut_params = &unittest_params;
2991 uint8_t *plaintext, *ciphertext;
2992 unsigned ciphertext_pad_len;
2993 unsigned ciphertext_len;
2995 /* Create SNOW 3G session */
2996 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2997 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2998 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2999 tdata->key.data, tdata->key.len);
3003 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3005 /* Clear mbuf payload */
3006 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3007 rte_pktmbuf_tailroom(ut_params->ibuf));
3009 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3010 /* Append data which is padded to a multiple of */
3011 /* the algorithms block size */
3012 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3013 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3014 ciphertext_pad_len);
3015 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3017 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3019 /* Create SNOW 3G operation */
3020 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3021 tdata->validCipherLenInBits.len,
3022 tdata->validCipherOffsetLenInBits.len,
3023 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3027 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3029 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3030 ut_params->obuf = ut_params->op->sym->m_dst;
3031 if (ut_params->obuf)
3032 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3035 plaintext = ciphertext;
3037 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3040 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3041 tdata->plaintext.data,
3042 tdata->validDataLenInBits.len,
3043 "SNOW 3G Plaintext data not as expected");
3047 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3049 struct crypto_testsuite_params *ts_params = &testsuite_params;
3050 struct crypto_unittest_params *ut_params = &unittest_params;
3054 uint8_t *plaintext, *ciphertext;
3055 unsigned ciphertext_pad_len;
3056 unsigned ciphertext_len;
3058 /* Create SNOW 3G session */
3059 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3060 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3061 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3062 tdata->key.data, tdata->key.len);
3066 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3067 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3069 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3070 "Failed to allocate input buffer");
3071 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3072 "Failed to allocate output buffer");
3074 /* Clear mbuf payload */
3075 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3076 rte_pktmbuf_tailroom(ut_params->ibuf));
3078 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3079 rte_pktmbuf_tailroom(ut_params->obuf));
3081 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3082 /* Append data which is padded to a multiple of */
3083 /* the algorithms block size */
3084 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3085 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3086 ciphertext_pad_len);
3087 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3088 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3090 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3092 /* Create SNOW 3G operation */
3093 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3095 tdata->validCipherLenInBits.len,
3096 tdata->validCipherOffsetLenInBits.len,
3097 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3101 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3103 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3104 ut_params->obuf = ut_params->op->sym->m_dst;
3105 if (ut_params->obuf)
3106 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3109 plaintext = ciphertext;
3111 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3114 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3115 tdata->plaintext.data,
3116 tdata->validDataLenInBits.len,
3117 "SNOW 3G Plaintext data not as expected");
3122 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3124 struct crypto_testsuite_params *ts_params = &testsuite_params;
3125 struct crypto_unittest_params *ut_params = &unittest_params;
3129 uint8_t *plaintext, *ciphertext;
3130 unsigned plaintext_pad_len;
3131 unsigned plaintext_len;
3133 /* Create SNOW 3G session */
3134 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3135 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3136 RTE_CRYPTO_AUTH_OP_GENERATE,
3137 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3138 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3139 tdata->key.data, tdata->key.len,
3140 tdata->aad.len, tdata->digest.len);
3143 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3145 /* clear mbuf payload */
3146 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3147 rte_pktmbuf_tailroom(ut_params->ibuf));
3149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3150 /* Append data which is padded to a multiple of */
3151 /* the algorithms block size */
3152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3153 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3155 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3157 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3159 /* Create SNOW 3G operation */
3160 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3161 tdata->digest.len, tdata->aad.data,
3162 tdata->aad.len, /*tdata->plaintext.len,*/
3163 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3164 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3165 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3166 tdata->iv.data, tdata->iv.len,
3167 tdata->validCipherLenInBits.len,
3168 tdata->validCipherOffsetLenInBits.len,
3169 tdata->validAuthLenInBits.len,
3170 tdata->validAuthOffsetLenInBits.len
3175 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3177 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3178 ut_params->obuf = ut_params->op->sym->m_src;
3179 if (ut_params->obuf)
3180 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3181 + tdata->iv.len + tdata->aad.len;
3183 ciphertext = plaintext;
3185 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3187 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3189 tdata->ciphertext.data,
3190 tdata->validDataLenInBits.len,
3191 "SNOW 3G Ciphertext data not as expected");
3193 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3194 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3197 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3200 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3201 "SNOW 3G Generated auth tag not as expected");
3205 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3207 struct crypto_testsuite_params *ts_params = &testsuite_params;
3208 struct crypto_unittest_params *ut_params = &unittest_params;
3212 uint8_t *plaintext, *ciphertext;
3213 unsigned plaintext_pad_len;
3214 unsigned plaintext_len;
3216 /* Create SNOW 3G session */
3217 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3218 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3219 RTE_CRYPTO_AUTH_OP_GENERATE,
3220 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3221 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3222 tdata->key.data, tdata->key.len,
3223 tdata->aad.len, tdata->digest.len);
3227 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3229 /* clear mbuf payload */
3230 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3231 rte_pktmbuf_tailroom(ut_params->ibuf));
3233 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3234 /* Append data which is padded to a multiple of */
3235 /* the algorithms block size */
3236 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3237 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3239 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3241 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3243 /* Create SNOW 3G operation */
3244 retval = create_wireless_algo_auth_cipher_operation(
3246 tdata->iv.data, tdata->iv.len,
3247 tdata->aad.data, tdata->aad.len,
3249 tdata->validCipherLenInBits.len,
3250 tdata->validCipherOffsetLenInBits.len,
3251 tdata->validAuthLenInBits.len,
3252 tdata->validAuthOffsetLenInBits.len,
3253 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3254 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3260 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3262 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3263 ut_params->obuf = ut_params->op->sym->m_src;
3264 if (ut_params->obuf)
3265 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3266 + tdata->aad.len + tdata->iv.len;
3268 ciphertext = plaintext;
3270 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3271 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3272 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3275 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3277 tdata->ciphertext.data,
3278 tdata->validDataLenInBits.len,
3279 "SNOW 3G Ciphertext data not as expected");
3282 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3285 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3286 "SNOW 3G Generated auth tag not as expected");
3291 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3293 struct crypto_testsuite_params *ts_params = &testsuite_params;
3294 struct crypto_unittest_params *ut_params = &unittest_params;
3298 uint8_t *plaintext, *ciphertext;
3299 unsigned plaintext_pad_len;
3300 unsigned plaintext_len;
3302 /* Create KASUMI session */
3303 retval = create_wireless_algo_auth_cipher_session(
3304 ts_params->valid_devs[0],
3305 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3306 RTE_CRYPTO_AUTH_OP_GENERATE,
3307 RTE_CRYPTO_AUTH_KASUMI_F9,
3308 RTE_CRYPTO_CIPHER_KASUMI_F8,
3309 tdata->key.data, tdata->key.len,
3310 tdata->aad.len, tdata->digest.len);
3313 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3315 /* clear mbuf payload */
3316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3317 rte_pktmbuf_tailroom(ut_params->ibuf));
3319 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3320 /* Append data which is padded to a multiple of */
3321 /* the algorithms block size */
3322 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3323 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3325 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3327 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3329 /* Create KASUMI operation */
3330 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3331 tdata->iv.data, tdata->iv.len,
3332 tdata->aad.data, tdata->aad.len,
3334 tdata->validCipherLenInBits.len,
3335 tdata->validCipherOffsetLenInBits.len,
3336 tdata->validAuthLenInBits.len,
3337 tdata->validAuthOffsetLenInBits.len,
3338 RTE_CRYPTO_AUTH_KASUMI_F9,
3339 RTE_CRYPTO_CIPHER_KASUMI_F8
3345 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3347 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3348 ut_params->obuf = ut_params->op->sym->m_src;
3349 if (ut_params->obuf)
3350 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3351 + tdata->iv.len + tdata->aad.len;
3353 ciphertext = plaintext;
3356 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3358 tdata->ciphertext.data,
3359 tdata->validCipherLenInBits.len,
3360 "KASUMI Ciphertext data not as expected");
3361 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3362 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3365 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3368 DIGEST_BYTE_LENGTH_KASUMI_F9,
3369 "KASUMI Generated auth tag not as expected");
3374 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3376 struct crypto_testsuite_params *ts_params = &testsuite_params;
3377 struct crypto_unittest_params *ut_params = &unittest_params;
3381 uint8_t *plaintext, *ciphertext;
3382 unsigned plaintext_pad_len;
3383 unsigned plaintext_len;
3385 /* Create KASUMI session */
3386 retval = create_wireless_algo_cipher_auth_session(
3387 ts_params->valid_devs[0],
3388 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3389 RTE_CRYPTO_AUTH_OP_GENERATE,
3390 RTE_CRYPTO_AUTH_KASUMI_F9,
3391 RTE_CRYPTO_CIPHER_KASUMI_F8,
3392 tdata->key.data, tdata->key.len,
3393 tdata->aad.len, tdata->digest.len);
3397 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3399 /* clear mbuf payload */
3400 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3401 rte_pktmbuf_tailroom(ut_params->ibuf));
3403 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3404 /* Append data which is padded to a multiple of */
3405 /* the algorithms block size */
3406 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3407 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3409 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3411 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3413 /* Create KASUMI operation */
3414 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3415 tdata->digest.len, tdata->aad.data,
3417 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3418 RTE_CRYPTO_AUTH_KASUMI_F9,
3419 RTE_CRYPTO_CIPHER_KASUMI_F8,
3420 tdata->iv.data, tdata->iv.len,
3421 tdata->validCipherLenInBits.len,
3422 tdata->validCipherOffsetLenInBits.len,
3423 tdata->validAuthLenInBits.len,
3424 tdata->validAuthOffsetLenInBits.len
3429 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3431 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3432 ut_params->obuf = ut_params->op->sym->m_src;
3433 if (ut_params->obuf)
3434 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3435 + tdata->aad.len + tdata->iv.len;
3437 ciphertext = plaintext;
3439 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3440 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3443 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3445 tdata->ciphertext.data,
3446 tdata->validCipherLenInBits.len,
3447 "KASUMI Ciphertext data not as expected");
3450 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3453 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3454 "KASUMI Generated auth tag not as expected");
3459 test_zuc_encryption(const struct zuc_test_data *tdata)
3461 struct crypto_testsuite_params *ts_params = &testsuite_params;
3462 struct crypto_unittest_params *ut_params = &unittest_params;
3465 uint8_t *plaintext, *ciphertext;
3466 unsigned plaintext_pad_len;
3467 unsigned plaintext_len;
3469 /* Create ZUC session */
3470 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3471 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3472 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3473 tdata->key.data, tdata->key.len);
3477 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 /* Clear mbuf payload */
3480 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3481 rte_pktmbuf_tailroom(ut_params->ibuf));
3483 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3484 /* Append data which is padded to a multiple */
3485 /* of the algorithms block size */
3486 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3487 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3489 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3491 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3493 /* Create ZUC operation */
3494 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3495 tdata->plaintext.len,
3496 tdata->validCipherOffsetLenInBits.len,
3497 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3501 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3503 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3505 ut_params->obuf = ut_params->op->sym->m_dst;
3506 if (ut_params->obuf)
3507 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3510 ciphertext = plaintext;
3512 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3515 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3517 tdata->ciphertext.data,
3518 tdata->validCipherLenInBits.len,
3519 "ZUC Ciphertext data not as expected");
3524 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3526 struct crypto_testsuite_params *ts_params = &testsuite_params;
3527 struct crypto_unittest_params *ut_params = &unittest_params;
3530 unsigned plaintext_pad_len;
3531 unsigned plaintext_len;
3534 /* Create ZUC session */
3535 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3536 tdata->key.data, tdata->key.len,
3537 tdata->aad.len, tdata->digest.len,
3538 RTE_CRYPTO_AUTH_OP_GENERATE,
3539 RTE_CRYPTO_AUTH_ZUC_EIA3);
3543 /* alloc mbuf and set payload */
3544 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3546 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3547 rte_pktmbuf_tailroom(ut_params->ibuf));
3549 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3550 /* Append data which is padded to a multiple of */
3551 /* the algorithms block size */
3552 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3553 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3555 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3557 /* Create ZUC operation */
3558 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3559 tdata->aad.data, tdata->aad.len,
3560 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3561 RTE_CRYPTO_AUTH_ZUC_EIA3,
3562 tdata->validAuthLenInBits.len,
3563 tdata->validAuthOffsetLenInBits.len);
3567 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3569 ut_params->obuf = ut_params->op->sym->m_src;
3570 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3571 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3572 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3575 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3578 DIGEST_BYTE_LENGTH_KASUMI_F9,
3579 "ZUC Generated auth tag not as expected");
3585 test_kasumi_encryption_test_case_1(void)
3587 return test_kasumi_encryption(&kasumi_test_case_1);
3591 test_kasumi_encryption_test_case_1_oop(void)
3593 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3597 test_kasumi_encryption_test_case_2(void)
3599 return test_kasumi_encryption(&kasumi_test_case_2);
3603 test_kasumi_encryption_test_case_3(void)
3605 return test_kasumi_encryption(&kasumi_test_case_3);
3609 test_kasumi_encryption_test_case_4(void)
3611 return test_kasumi_encryption(&kasumi_test_case_4);
3615 test_kasumi_encryption_test_case_5(void)
3617 return test_kasumi_encryption(&kasumi_test_case_5);
3621 test_kasumi_decryption_test_case_1(void)
3623 return test_kasumi_decryption(&kasumi_test_case_1);
3627 test_kasumi_decryption_test_case_1_oop(void)
3629 return test_kasumi_decryption_oop(&kasumi_test_case_1);
3633 test_kasumi_decryption_test_case_2(void)
3635 return test_kasumi_decryption(&kasumi_test_case_2);
3639 test_kasumi_decryption_test_case_3(void)
3641 return test_kasumi_decryption(&kasumi_test_case_3);
3645 test_kasumi_decryption_test_case_4(void)
3647 return test_kasumi_decryption(&kasumi_test_case_4);
3651 test_kasumi_decryption_test_case_5(void)
3653 return test_kasumi_decryption(&kasumi_test_case_5);
3656 test_snow3g_encryption_test_case_1(void)
3658 return test_snow3g_encryption(&snow3g_test_case_1);
3662 test_snow3g_encryption_test_case_1_oop(void)
3664 return test_snow3g_encryption_oop(&snow3g_test_case_1);
3668 test_snow3g_encryption_test_case_1_offset_oop(void)
3670 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
3674 test_snow3g_encryption_test_case_2(void)
3676 return test_snow3g_encryption(&snow3g_test_case_2);
3680 test_snow3g_encryption_test_case_3(void)
3682 return test_snow3g_encryption(&snow3g_test_case_3);
3686 test_snow3g_encryption_test_case_4(void)
3688 return test_snow3g_encryption(&snow3g_test_case_4);
3692 test_snow3g_encryption_test_case_5(void)
3694 return test_snow3g_encryption(&snow3g_test_case_5);
3698 test_snow3g_decryption_test_case_1(void)
3700 return test_snow3g_decryption(&snow3g_test_case_1);
3704 test_snow3g_decryption_test_case_1_oop(void)
3706 return test_snow3g_decryption_oop(&snow3g_test_case_1);
3710 test_snow3g_decryption_test_case_2(void)
3712 return test_snow3g_decryption(&snow3g_test_case_2);
3716 test_snow3g_decryption_test_case_3(void)
3718 return test_snow3g_decryption(&snow3g_test_case_3);
3722 test_snow3g_decryption_test_case_4(void)
3724 return test_snow3g_decryption(&snow3g_test_case_4);
3728 test_snow3g_decryption_test_case_5(void)
3730 return test_snow3g_decryption(&snow3g_test_case_5);
3733 test_snow3g_cipher_auth_test_case_1(void)
3735 return test_snow3g_cipher_auth(&snow3g_test_case_3);
3739 test_snow3g_auth_cipher_test_case_1(void)
3741 return test_snow3g_auth_cipher(&snow3g_test_case_6);
3745 test_kasumi_auth_cipher_test_case_1(void)
3747 return test_kasumi_auth_cipher(&kasumi_test_case_3);
3751 test_kasumi_cipher_auth_test_case_1(void)
3753 return test_kasumi_cipher_auth(&kasumi_test_case_6);
3757 test_zuc_encryption_test_case_1(void)
3759 return test_zuc_encryption(&zuc_test_case_1);
3763 test_zuc_encryption_test_case_2(void)
3765 return test_zuc_encryption(&zuc_test_case_2);
3769 test_zuc_encryption_test_case_3(void)
3771 return test_zuc_encryption(&zuc_test_case_3);
3775 test_zuc_encryption_test_case_4(void)
3777 return test_zuc_encryption(&zuc_test_case_4);
3781 test_zuc_encryption_test_case_5(void)
3783 return test_zuc_encryption(&zuc_test_case_5);
3787 test_zuc_hash_generate_test_case_1(void)
3789 return test_zuc_authentication(&zuc_hash_test_case_1);
3793 test_zuc_hash_generate_test_case_2(void)
3795 return test_zuc_authentication(&zuc_hash_test_case_2);
3799 test_zuc_hash_generate_test_case_3(void)
3801 return test_zuc_authentication(&zuc_hash_test_case_3);
3805 test_zuc_hash_generate_test_case_4(void)
3807 return test_zuc_authentication(&zuc_hash_test_case_4);
3811 test_zuc_hash_generate_test_case_5(void)
3813 return test_zuc_authentication(&zuc_hash_test_case_5);
3817 test_3DES_chain_qat_all(void)
3819 struct crypto_testsuite_params *ts_params = &testsuite_params;
3822 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3823 ts_params->op_mpool, ts_params->valid_devs[0],
3824 RTE_CRYPTODEV_QAT_SYM_PMD,
3825 BLKCIPHER_3DES_CHAIN_TYPE);
3827 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3829 return TEST_SUCCESS;
3833 test_3DES_cipheronly_qat_all(void)
3835 struct crypto_testsuite_params *ts_params = &testsuite_params;
3838 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3839 ts_params->op_mpool, ts_params->valid_devs[0],
3840 RTE_CRYPTODEV_QAT_SYM_PMD,
3841 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3843 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3845 return TEST_SUCCESS;
3849 test_3DES_chain_openssl_all(void)
3851 struct crypto_testsuite_params *ts_params = &testsuite_params;
3854 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3855 ts_params->op_mpool, ts_params->valid_devs[0],
3856 RTE_CRYPTODEV_OPENSSL_PMD,
3857 BLKCIPHER_3DES_CHAIN_TYPE);
3859 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3861 return TEST_SUCCESS;
3865 test_3DES_cipheronly_openssl_all(void)
3867 struct crypto_testsuite_params *ts_params = &testsuite_params;
3870 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3871 ts_params->op_mpool, ts_params->valid_devs[0],
3872 RTE_CRYPTODEV_OPENSSL_PMD,
3873 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3875 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3877 return TEST_SUCCESS;
3880 /* ***** AES-GCM Tests ***** */
3883 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3884 const uint8_t *key, const uint8_t key_len,
3885 const uint8_t aad_len, const uint8_t auth_len,
3886 enum rte_crypto_auth_operation auth_op)
3888 uint8_t cipher_key[key_len];
3890 struct crypto_unittest_params *ut_params = &unittest_params;
3892 memcpy(cipher_key, key, key_len);
3894 /* Setup Cipher Parameters */
3895 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3896 ut_params->cipher_xform.next = NULL;
3898 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3899 ut_params->auth_xform.auth.op = auth_op;
3900 ut_params->cipher_xform.cipher.op = op;
3901 ut_params->cipher_xform.cipher.key.data = cipher_key;
3902 ut_params->cipher_xform.cipher.key.length = key_len;
3904 TEST_HEXDUMP(stdout, "key:", key, key_len);
3906 /* Setup Authentication Parameters */
3907 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3908 ut_params->auth_xform.next = NULL;
3910 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3912 ut_params->auth_xform.auth.digest_length = auth_len;
3913 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3914 ut_params->auth_xform.auth.key.length = 0;
3915 ut_params->auth_xform.auth.key.data = NULL;
3917 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3918 ut_params->cipher_xform.next = &ut_params->auth_xform;
3920 /* Create Crypto session*/
3921 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3922 &ut_params->cipher_xform);
3923 } else {/* Create Crypto session*/
3924 ut_params->auth_xform.next = &ut_params->cipher_xform;
3925 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3926 &ut_params->auth_xform);
3929 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3935 create_gcm_operation(enum rte_crypto_cipher_operation op,
3936 const uint8_t *auth_tag, const unsigned auth_tag_len,
3937 const uint8_t *iv, const unsigned iv_len,
3938 const uint8_t *aad, const unsigned aad_len,
3939 const unsigned data_len, unsigned data_pad_len)
3941 struct crypto_testsuite_params *ts_params = &testsuite_params;
3942 struct crypto_unittest_params *ut_params = &unittest_params;
3944 unsigned iv_pad_len = 0, aad_buffer_len;
3946 /* Generate Crypto op data structure */
3947 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3948 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3949 TEST_ASSERT_NOT_NULL(ut_params->op,
3950 "Failed to allocate symmetric crypto operation struct");
3952 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3954 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3955 ut_params->ibuf, auth_tag_len);
3956 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3957 "no room to append digest");
3958 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3959 ut_params->ibuf, data_pad_len);
3960 sym_op->auth.digest.length = auth_tag_len;
3962 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3963 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3964 TEST_HEXDUMP(stdout, "digest:",
3965 sym_op->auth.digest.data,
3966 sym_op->auth.digest.length);
3970 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3972 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3973 ut_params->ibuf, iv_pad_len);
3974 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3976 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3977 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3978 sym_op->cipher.iv.length = iv_len;
3980 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3983 * Always allocate the aad up to the block size.
3984 * The cryptodev API calls out -
3985 * - the array must be big enough to hold the AAD, plus any
3986 * space to round this up to the nearest multiple of the
3987 * block size (16 bytes).
3989 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
3991 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
3992 ut_params->ibuf, aad_buffer_len);
3993 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
3994 "no room to prepend aad");
3995 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
3997 sym_op->auth.aad.length = aad_len;
3999 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
4000 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
4002 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
4003 TEST_HEXDUMP(stdout, "aad:",
4004 sym_op->auth.aad.data, aad_len);
4006 sym_op->cipher.data.length = data_len;
4007 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
4009 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
4010 sym_op->auth.data.length = data_len;
4016 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4018 struct crypto_testsuite_params *ts_params = &testsuite_params;
4019 struct crypto_unittest_params *ut_params = &unittest_params;
4023 uint8_t *plaintext, *ciphertext, *auth_tag;
4024 uint16_t plaintext_pad_len;
4026 /* Create GCM session */
4027 retval = create_gcm_session(ts_params->valid_devs[0],
4028 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4029 tdata->key.data, tdata->key.len,
4030 tdata->aad.len, tdata->auth_tag.len,
4031 RTE_CRYPTO_AUTH_OP_GENERATE);
4036 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4038 /* clear mbuf payload */
4039 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4040 rte_pktmbuf_tailroom(ut_params->ibuf));
4043 * Append data which is padded to a multiple
4044 * of the algorithms block size
4046 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4048 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4050 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4052 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4054 /* Create GCM opertaion */
4055 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4056 tdata->auth_tag.data, tdata->auth_tag.len,
4057 tdata->iv.data, tdata->iv.len,
4058 tdata->aad.data, tdata->aad.len,
4059 tdata->plaintext.len, plaintext_pad_len);
4063 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4065 ut_params->op->sym->m_src = ut_params->ibuf;
4067 /* Process crypto operation */
4068 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4069 ut_params->op), "failed to process sym crypto op");
4071 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4072 "crypto op processing failed");
4074 if (ut_params->op->sym->m_dst) {
4075 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4077 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4078 uint8_t *, plaintext_pad_len);
4080 ciphertext = plaintext;
4081 auth_tag = plaintext + plaintext_pad_len;
4084 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4085 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4088 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4090 tdata->ciphertext.data,
4091 tdata->ciphertext.len,
4092 "GCM Ciphertext data not as expected");
4094 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4096 tdata->auth_tag.data,
4097 tdata->auth_tag.len,
4098 "GCM Generated auth tag not as expected");
4105 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4107 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4111 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4113 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4117 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4119 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4123 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4125 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4129 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4131 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4135 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4137 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4141 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4143 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4147 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4149 struct crypto_testsuite_params *ts_params = &testsuite_params;
4150 struct crypto_unittest_params *ut_params = &unittest_params;
4154 uint8_t *plaintext, *ciphertext;
4155 uint16_t ciphertext_pad_len;
4157 /* Create GCM session */
4158 retval = create_gcm_session(ts_params->valid_devs[0],
4159 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4160 tdata->key.data, tdata->key.len,
4161 tdata->aad.len, tdata->auth_tag.len,
4162 RTE_CRYPTO_AUTH_OP_VERIFY);
4167 /* alloc mbuf and set payload */
4168 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4170 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4171 rte_pktmbuf_tailroom(ut_params->ibuf));
4173 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4175 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4176 ciphertext_pad_len);
4177 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
4179 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4181 /* Create GCM opertaion */
4182 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
4183 tdata->auth_tag.data, tdata->auth_tag.len,
4184 tdata->iv.data, tdata->iv.len,
4185 tdata->aad.data, tdata->aad.len,
4186 tdata->ciphertext.len, ciphertext_pad_len);
4191 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4193 ut_params->op->sym->m_src = ut_params->ibuf;
4195 /* Process crypto operation */
4196 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4197 ut_params->op), "failed to process sym crypto op");
4199 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4200 "crypto op processing failed");
4202 if (ut_params->op->sym->m_dst)
4203 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4206 plaintext = ciphertext;
4208 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4211 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4213 tdata->plaintext.data,
4214 tdata->plaintext.len,
4215 "GCM plaintext data not as expected");
4217 TEST_ASSERT_EQUAL(ut_params->op->status,
4218 RTE_CRYPTO_OP_STATUS_SUCCESS,
4219 "GCM authentication failed");
4224 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4226 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4230 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4232 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4236 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4238 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4242 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4244 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4248 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4250 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4254 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4256 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4260 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4262 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4268 struct crypto_testsuite_params *ts_params = &testsuite_params;
4269 struct rte_cryptodev_stats stats;
4270 struct rte_cryptodev *dev;
4271 cryptodev_stats_get_t temp_pfn;
4273 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4274 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
4275 &stats) == -ENODEV),
4276 "rte_cryptodev_stats_get invalid dev failed");
4277 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
4278 "rte_cryptodev_stats_get invalid Param failed");
4279 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
4280 temp_pfn = dev->dev_ops->stats_get;
4281 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
4282 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
4284 "rte_cryptodev_stats_get invalid Param failed");
4285 dev->dev_ops->stats_get = temp_pfn;
4287 /* Test expected values */
4289 test_AES_CBC_HMAC_SHA1_encrypt_digest();
4291 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4293 "rte_cryptodev_stats_get failed");
4294 TEST_ASSERT((stats.enqueued_count == 1),
4295 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4296 TEST_ASSERT((stats.dequeued_count == 1),
4297 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4298 TEST_ASSERT((stats.enqueue_err_count == 0),
4299 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4300 TEST_ASSERT((stats.dequeue_err_count == 0),
4301 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4303 /* invalid device but should ignore and not reset device stats*/
4304 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
4305 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4307 "rte_cryptodev_stats_get failed");
4308 TEST_ASSERT((stats.enqueued_count == 1),
4309 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4311 /* check that a valid reset clears stats */
4312 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4313 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4315 "rte_cryptodev_stats_get failed");
4316 TEST_ASSERT((stats.enqueued_count == 0),
4317 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4318 TEST_ASSERT((stats.dequeued_count == 0),
4319 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4321 return TEST_SUCCESS;
4324 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
4325 struct crypto_unittest_params *ut_params,
4326 enum rte_crypto_auth_operation op,
4327 const struct HMAC_MD5_vector *test_case)
4331 memcpy(key, test_case->key.data, test_case->key.len);
4333 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4334 ut_params->auth_xform.next = NULL;
4335 ut_params->auth_xform.auth.op = op;
4337 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
4339 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
4340 ut_params->auth_xform.auth.add_auth_data_length = 0;
4341 ut_params->auth_xform.auth.key.length = test_case->key.len;
4342 ut_params->auth_xform.auth.key.data = key;
4344 ut_params->sess = rte_cryptodev_sym_session_create(
4345 ts_params->valid_devs[0], &ut_params->auth_xform);
4347 if (ut_params->sess == NULL)
4350 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4352 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4353 rte_pktmbuf_tailroom(ut_params->ibuf));
4358 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
4359 const struct HMAC_MD5_vector *test_case,
4360 uint8_t **plaintext)
4362 uint16_t plaintext_pad_len;
4364 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4366 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4369 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4371 memcpy(*plaintext, test_case->plaintext.data,
4372 test_case->plaintext.len);
4374 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4375 ut_params->ibuf, MD5_DIGEST_LEN);
4376 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4377 "no room to append digest");
4378 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4379 ut_params->ibuf, plaintext_pad_len);
4380 sym_op->auth.digest.length = MD5_DIGEST_LEN;
4382 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
4383 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
4384 test_case->auth_tag.len);
4387 sym_op->auth.data.offset = 0;
4388 sym_op->auth.data.length = test_case->plaintext.len;
4390 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4391 ut_params->op->sym->m_src = ut_params->ibuf;
4397 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
4399 uint16_t plaintext_pad_len;
4400 uint8_t *plaintext, *auth_tag;
4402 struct crypto_testsuite_params *ts_params = &testsuite_params;
4403 struct crypto_unittest_params *ut_params = &unittest_params;
4405 if (MD5_HMAC_create_session(ts_params, ut_params,
4406 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
4409 /* Generate Crypto op data structure */
4410 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4411 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4412 TEST_ASSERT_NOT_NULL(ut_params->op,
4413 "Failed to allocate symmetric crypto operation struct");
4415 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4418 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4421 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4422 ut_params->op), "failed to process sym crypto op");
4424 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4425 "crypto op processing failed");
4427 if (ut_params->op->sym->m_dst) {
4428 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4429 uint8_t *, plaintext_pad_len);
4431 auth_tag = plaintext + plaintext_pad_len;
4434 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4436 test_case->auth_tag.data,
4437 test_case->auth_tag.len,
4438 "HMAC_MD5 generated tag not as expected");
4440 return TEST_SUCCESS;
4444 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
4448 struct crypto_testsuite_params *ts_params = &testsuite_params;
4449 struct crypto_unittest_params *ut_params = &unittest_params;
4451 if (MD5_HMAC_create_session(ts_params, ut_params,
4452 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
4456 /* Generate Crypto op data structure */
4457 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4458 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4459 TEST_ASSERT_NOT_NULL(ut_params->op,
4460 "Failed to allocate symmetric crypto operation struct");
4462 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4465 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4466 ut_params->op), "failed to process sym crypto op");
4468 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4469 "HMAC_MD5 crypto op processing failed");
4471 return TEST_SUCCESS;
4475 test_MD5_HMAC_generate_case_1(void)
4477 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
4481 test_MD5_HMAC_verify_case_1(void)
4483 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
4487 test_MD5_HMAC_generate_case_2(void)
4489 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
4493 test_MD5_HMAC_verify_case_2(void)
4495 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
4499 test_multi_session(void)
4501 struct crypto_testsuite_params *ts_params = &testsuite_params;
4502 struct crypto_unittest_params *ut_params = &unittest_params;
4504 struct rte_cryptodev_info dev_info;
4505 struct rte_cryptodev_sym_session **sessions;
4509 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
4510 aes_cbc_key, hmac_sha512_key);
4513 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4515 sessions = rte_malloc(NULL,
4516 (sizeof(struct rte_cryptodev_sym_session *) *
4517 dev_info.sym.max_nb_sessions) + 1, 0);
4519 /* Create multiple crypto sessions*/
4520 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
4521 sessions[i] = rte_cryptodev_sym_session_create(
4522 ts_params->valid_devs[0],
4523 &ut_params->auth_xform);
4524 TEST_ASSERT_NOT_NULL(sessions[i],
4525 "Session creation failed at session number %u",
4528 /* Attempt to send a request on each session */
4529 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
4533 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
4534 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
4536 "Failed to perform decrypt on request number %u.", i);
4537 /* free crypto operation structure */
4539 rte_crypto_op_free(ut_params->op);
4542 * free mbuf - both obuf and ibuf are usually the same,
4543 * so check if they point at the same address is necessary,
4544 * to avoid freeing the mbuf twice.
4546 if (ut_params->obuf) {
4547 rte_pktmbuf_free(ut_params->obuf);
4548 if (ut_params->ibuf == ut_params->obuf)
4549 ut_params->ibuf = 0;
4550 ut_params->obuf = 0;
4552 if (ut_params->ibuf) {
4553 rte_pktmbuf_free(ut_params->ibuf);
4554 ut_params->ibuf = 0;
4558 /* Next session create should fail */
4559 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
4560 &ut_params->auth_xform);
4561 TEST_ASSERT_NULL(sessions[i],
4562 "Session creation succeeded unexpectedly!");
4564 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
4565 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4570 return TEST_SUCCESS;
4573 struct multi_session_params {
4574 struct crypto_unittest_params ut_params;
4575 uint8_t *cipher_key;
4577 const uint8_t *cipher;
4578 const uint8_t *digest;
4582 #define MB_SESSION_NUMBER 3
4585 test_multi_session_random_usage(void)
4587 struct crypto_testsuite_params *ts_params = &testsuite_params;
4588 struct rte_cryptodev_info dev_info;
4589 struct rte_cryptodev_sym_session **sessions;
4591 struct multi_session_params ut_paramz[] = {
4594 .cipher_key = ms_aes_cbc_key0,
4595 .hmac_key = ms_hmac_key0,
4596 .cipher = ms_aes_cbc_cipher0,
4597 .digest = ms_hmac_digest0,
4598 .iv = ms_aes_cbc_iv0
4601 .cipher_key = ms_aes_cbc_key1,
4602 .hmac_key = ms_hmac_key1,
4603 .cipher = ms_aes_cbc_cipher1,
4604 .digest = ms_hmac_digest1,
4605 .iv = ms_aes_cbc_iv1
4608 .cipher_key = ms_aes_cbc_key2,
4609 .hmac_key = ms_hmac_key2,
4610 .cipher = ms_aes_cbc_cipher2,
4611 .digest = ms_hmac_digest2,
4612 .iv = ms_aes_cbc_iv2
4617 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4619 sessions = rte_malloc(NULL,
4620 (sizeof(struct rte_cryptodev_sym_session *)
4621 * dev_info.sym.max_nb_sessions) + 1, 0);
4623 for (i = 0; i < MB_SESSION_NUMBER; i++) {
4624 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
4625 sizeof(struct crypto_unittest_params));
4627 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
4628 &ut_paramz[i].ut_params,
4629 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
4631 /* Create multiple crypto sessions*/
4632 sessions[i] = rte_cryptodev_sym_session_create(
4633 ts_params->valid_devs[0],
4634 &ut_paramz[i].ut_params.auth_xform);
4636 TEST_ASSERT_NOT_NULL(sessions[i],
4637 "Session creation failed at session number %u",
4643 for (i = 0; i < 40000; i++) {
4645 j = rand() % MB_SESSION_NUMBER;
4647 TEST_ASSERT_SUCCESS(
4648 test_AES_CBC_HMAC_SHA512_decrypt_perform(
4650 &ut_paramz[j].ut_params,
4651 ts_params, ut_paramz[j].cipher,
4652 ut_paramz[j].digest,
4654 "Failed to perform decrypt on request number %u.", i);
4656 if (ut_paramz[j].ut_params.op)
4657 rte_crypto_op_free(ut_paramz[j].ut_params.op);
4660 * free mbuf - both obuf and ibuf are usually the same,
4661 * so check if they point at the same address is necessary,
4662 * to avoid freeing the mbuf twice.
4664 if (ut_paramz[j].ut_params.obuf) {
4665 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
4666 if (ut_paramz[j].ut_params.ibuf
4667 == ut_paramz[j].ut_params.obuf)
4668 ut_paramz[j].ut_params.ibuf = 0;
4669 ut_paramz[j].ut_params.obuf = 0;
4671 if (ut_paramz[j].ut_params.ibuf) {
4672 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
4673 ut_paramz[j].ut_params.ibuf = 0;
4677 for (i = 0; i < MB_SESSION_NUMBER; i++)
4678 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4683 return TEST_SUCCESS;
4687 test_null_cipher_only_operation(void)
4689 struct crypto_testsuite_params *ts_params = &testsuite_params;
4690 struct crypto_unittest_params *ut_params = &unittest_params;
4692 /* Generate test mbuf data and space for digest */
4693 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4694 catch_22_quote, QUOTE_512_BYTES, 0);
4696 /* Setup Cipher Parameters */
4697 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4698 ut_params->cipher_xform.next = NULL;
4700 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4701 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4703 /* Create Crypto session*/
4704 ut_params->sess = rte_cryptodev_sym_session_create(
4705 ts_params->valid_devs[0], &ut_params->cipher_xform);
4706 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4708 /* Generate Crypto op data structure */
4709 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4710 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4711 TEST_ASSERT_NOT_NULL(ut_params->op,
4712 "Failed to allocate symmetric crypto operation struct");
4714 /* Set crypto operation data parameters */
4715 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4717 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4719 /* set crypto operation source mbuf */
4720 sym_op->m_src = ut_params->ibuf;
4722 sym_op->cipher.data.offset = 0;
4723 sym_op->cipher.data.length = QUOTE_512_BYTES;
4725 /* Process crypto operation */
4726 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4728 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4730 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4731 "crypto operation processing failed");
4734 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4735 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4738 "Ciphertext data not as expected");
4740 return TEST_SUCCESS;
4744 test_null_auth_only_operation(void)
4746 struct crypto_testsuite_params *ts_params = &testsuite_params;
4747 struct crypto_unittest_params *ut_params = &unittest_params;
4749 /* Generate test mbuf data and space for digest */
4750 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4751 catch_22_quote, QUOTE_512_BYTES, 0);
4753 /* Setup HMAC Parameters */
4754 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4755 ut_params->auth_xform.next = NULL;
4757 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4758 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4760 /* Create Crypto session*/
4761 ut_params->sess = rte_cryptodev_sym_session_create(
4762 ts_params->valid_devs[0], &ut_params->auth_xform);
4763 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4765 /* Generate Crypto op data structure */
4766 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4767 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4768 TEST_ASSERT_NOT_NULL(ut_params->op,
4769 "Failed to allocate symmetric crypto operation struct");
4771 /* Set crypto operation data parameters */
4772 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4774 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4776 sym_op->m_src = ut_params->ibuf;
4778 sym_op->auth.data.offset = 0;
4779 sym_op->auth.data.length = QUOTE_512_BYTES;
4781 /* Process crypto operation */
4782 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4784 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4786 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4787 "crypto operation processing failed");
4789 return TEST_SUCCESS;
4793 test_null_cipher_auth_operation(void)
4795 struct crypto_testsuite_params *ts_params = &testsuite_params;
4796 struct crypto_unittest_params *ut_params = &unittest_params;
4798 /* Generate test mbuf data and space for digest */
4799 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4800 catch_22_quote, QUOTE_512_BYTES, 0);
4802 /* Setup Cipher Parameters */
4803 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4804 ut_params->cipher_xform.next = &ut_params->auth_xform;
4806 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4807 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4809 /* Setup HMAC Parameters */
4810 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4811 ut_params->auth_xform.next = NULL;
4813 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4814 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4816 /* Create Crypto session*/
4817 ut_params->sess = rte_cryptodev_sym_session_create(
4818 ts_params->valid_devs[0], &ut_params->cipher_xform);
4819 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4821 /* Generate Crypto op data structure */
4822 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4823 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4824 TEST_ASSERT_NOT_NULL(ut_params->op,
4825 "Failed to allocate symmetric crypto operation struct");
4827 /* Set crypto operation data parameters */
4828 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4830 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4832 sym_op->m_src = ut_params->ibuf;
4834 sym_op->cipher.data.offset = 0;
4835 sym_op->cipher.data.length = QUOTE_512_BYTES;
4837 sym_op->auth.data.offset = 0;
4838 sym_op->auth.data.length = QUOTE_512_BYTES;
4840 /* Process crypto operation */
4841 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4843 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4845 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4846 "crypto operation processing failed");
4849 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4850 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4853 "Ciphertext data not as expected");
4855 return TEST_SUCCESS;
4859 test_null_auth_cipher_operation(void)
4861 struct crypto_testsuite_params *ts_params = &testsuite_params;
4862 struct crypto_unittest_params *ut_params = &unittest_params;
4864 /* Generate test mbuf data and space for digest */
4865 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4866 catch_22_quote, QUOTE_512_BYTES, 0);
4868 /* Setup Cipher Parameters */
4869 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4870 ut_params->cipher_xform.next = NULL;
4872 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4873 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4875 /* Setup HMAC Parameters */
4876 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4877 ut_params->auth_xform.next = &ut_params->cipher_xform;
4879 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4880 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4882 /* Create Crypto session*/
4883 ut_params->sess = rte_cryptodev_sym_session_create(
4884 ts_params->valid_devs[0], &ut_params->cipher_xform);
4885 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4887 /* Generate Crypto op data structure */
4888 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4889 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4890 TEST_ASSERT_NOT_NULL(ut_params->op,
4891 "Failed to allocate symmetric crypto operation struct");
4893 /* Set crypto operation data parameters */
4894 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4896 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4898 sym_op->m_src = ut_params->ibuf;
4900 sym_op->cipher.data.offset = 0;
4901 sym_op->cipher.data.length = QUOTE_512_BYTES;
4903 sym_op->auth.data.offset = 0;
4904 sym_op->auth.data.length = QUOTE_512_BYTES;
4906 /* Process crypto operation */
4907 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4909 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4911 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4912 "crypto operation processing failed");
4915 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4916 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4919 "Ciphertext data not as expected");
4921 return TEST_SUCCESS;
4926 test_null_invalid_operation(void)
4928 struct crypto_testsuite_params *ts_params = &testsuite_params;
4929 struct crypto_unittest_params *ut_params = &unittest_params;
4931 /* Setup Cipher Parameters */
4932 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4933 ut_params->cipher_xform.next = NULL;
4935 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
4936 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4938 /* Create Crypto session*/
4939 ut_params->sess = rte_cryptodev_sym_session_create(
4940 ts_params->valid_devs[0], &ut_params->cipher_xform);
4941 TEST_ASSERT_NULL(ut_params->sess,
4942 "Session creation succeeded unexpectedly");
4945 /* Setup HMAC Parameters */
4946 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4947 ut_params->auth_xform.next = NULL;
4949 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
4950 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4952 /* Create Crypto session*/
4953 ut_params->sess = rte_cryptodev_sym_session_create(
4954 ts_params->valid_devs[0], &ut_params->auth_xform);
4955 TEST_ASSERT_NULL(ut_params->sess,
4956 "Session creation succeeded unexpectedly");
4958 return TEST_SUCCESS;
4962 #define NULL_BURST_LENGTH (32)
4965 test_null_burst_operation(void)
4967 struct crypto_testsuite_params *ts_params = &testsuite_params;
4968 struct crypto_unittest_params *ut_params = &unittest_params;
4970 unsigned i, burst_len = NULL_BURST_LENGTH;
4972 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
4973 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
4975 /* Setup Cipher Parameters */
4976 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4977 ut_params->cipher_xform.next = &ut_params->auth_xform;
4979 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4980 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4982 /* Setup HMAC Parameters */
4983 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4984 ut_params->auth_xform.next = NULL;
4986 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4987 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4989 /* Create Crypto session*/
4990 ut_params->sess = rte_cryptodev_sym_session_create(
4991 ts_params->valid_devs[0], &ut_params->cipher_xform);
4992 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4994 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
4995 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
4996 burst_len, "failed to generate burst of crypto ops");
4998 /* Generate an operation for each mbuf in burst */
4999 for (i = 0; i < burst_len; i++) {
5000 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5002 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
5004 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
5008 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
5010 burst[i]->sym->m_src = m;
5013 /* Process crypto operation */
5014 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
5015 0, burst, burst_len),
5017 "Error enqueuing burst");
5019 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
5020 0, burst_dequeued, burst_len),
5022 "Error dequeuing burst");
5025 for (i = 0; i < burst_len; i++) {
5027 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
5028 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
5030 "data not as expected");
5032 rte_pktmbuf_free(burst[i]->sym->m_src);
5033 rte_crypto_op_free(burst[i]);
5036 return TEST_SUCCESS;
5040 generate_gmac_large_plaintext(uint8_t *data)
5044 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5045 memcpy(&data[i], &data[0], 32);
5049 create_gmac_operation(enum rte_crypto_auth_operation op,
5050 const struct gmac_test_data *tdata)
5052 struct crypto_testsuite_params *ts_params = &testsuite_params;
5053 struct crypto_unittest_params *ut_params = &unittest_params;
5054 struct rte_crypto_sym_op *sym_op;
5056 unsigned iv_pad_len;
5057 unsigned aad_pad_len;
5059 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5060 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5063 * Runtime generate the large plain text instead of use hard code
5064 * plain text vector. It is done to avoid create huge source file
5065 * with the test vector.
5067 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5068 generate_gmac_large_plaintext(tdata->aad.data);
5070 /* Generate Crypto op data structure */
5071 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5072 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5073 TEST_ASSERT_NOT_NULL(ut_params->op,
5074 "Failed to allocate symmetric crypto operation struct");
5076 sym_op = ut_params->op->sym;
5077 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5079 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5080 "no room to append aad");
5082 sym_op->auth.aad.length = tdata->aad.len;
5083 sym_op->auth.aad.phys_addr =
5084 rte_pktmbuf_mtophys(ut_params->ibuf);
5085 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5087 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5088 ut_params->ibuf, tdata->gmac_tag.len);
5089 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5090 "no room to append digest");
5092 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5093 ut_params->ibuf, aad_pad_len);
5094 sym_op->auth.digest.length = tdata->gmac_tag.len;
5096 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5097 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
5098 tdata->gmac_tag.len);
5099 TEST_HEXDUMP(stdout, "digest:",
5100 sym_op->auth.digest.data,
5101 sym_op->auth.digest.length);
5104 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5105 ut_params->ibuf, iv_pad_len);
5106 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5108 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5109 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5110 sym_op->cipher.iv.length = tdata->iv.len;
5112 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
5114 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
5116 sym_op->cipher.data.length = 0;
5117 sym_op->cipher.data.offset = 0;
5119 sym_op->auth.data.offset = 0;
5120 sym_op->auth.data.length = 0;
5125 static int create_gmac_session(uint8_t dev_id,
5126 enum rte_crypto_cipher_operation op,
5127 const struct gmac_test_data *tdata,
5128 enum rte_crypto_auth_operation auth_op)
5130 uint8_t cipher_key[tdata->key.len];
5132 struct crypto_unittest_params *ut_params = &unittest_params;
5134 memcpy(cipher_key, tdata->key.data, tdata->key.len);
5136 /* For GMAC we setup cipher parameters */
5137 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5138 ut_params->cipher_xform.next = NULL;
5139 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
5140 ut_params->cipher_xform.cipher.op = op;
5141 ut_params->cipher_xform.cipher.key.data = cipher_key;
5142 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
5144 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5145 ut_params->auth_xform.next = NULL;
5147 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
5148 ut_params->auth_xform.auth.op = auth_op;
5149 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
5150 ut_params->auth_xform.auth.add_auth_data_length = 0;
5151 ut_params->auth_xform.auth.key.length = 0;
5152 ut_params->auth_xform.auth.key.data = NULL;
5154 ut_params->cipher_xform.next = &ut_params->auth_xform;
5156 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5157 &ut_params->cipher_xform);
5159 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5165 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
5167 struct crypto_testsuite_params *ts_params = &testsuite_params;
5168 struct crypto_unittest_params *ut_params = &unittest_params;
5172 uint8_t *auth_tag, *p;
5173 uint16_t aad_pad_len;
5175 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5176 "No GMAC length in the source data");
5178 retval = create_gmac_session(ts_params->valid_devs[0],
5179 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5180 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
5185 if (tdata->aad.len > MBUF_SIZE)
5186 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5188 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5189 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5190 "Failed to allocate input buffer in mempool");
5192 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5193 rte_pktmbuf_tailroom(ut_params->ibuf));
5195 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5197 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
5199 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
5205 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5207 ut_params->op->sym->m_src = ut_params->ibuf;
5209 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5210 ut_params->op), "failed to process sym crypto op");
5212 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5213 "crypto op processing failed");
5215 if (ut_params->op->sym->m_dst) {
5216 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5217 uint8_t *, aad_pad_len);
5219 auth_tag = p + aad_pad_len;
5222 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
5224 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5226 tdata->gmac_tag.data,
5227 tdata->gmac_tag.len,
5228 "GMAC Generated auth tag not as expected");
5234 test_AES_GMAC_authentication_test_case_1(void)
5236 return test_AES_GMAC_authentication(&gmac_test_case_1);
5240 test_AES_GMAC_authentication_test_case_2(void)
5242 return test_AES_GMAC_authentication(&gmac_test_case_2);
5246 test_AES_GMAC_authentication_test_case_3(void)
5248 return test_AES_GMAC_authentication(&gmac_test_case_3);
5252 test_AES_GMAC_authentication_test_case_4(void)
5254 return test_AES_GMAC_authentication(&gmac_test_case_4);
5258 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
5260 struct crypto_testsuite_params *ts_params = &testsuite_params;
5261 struct crypto_unittest_params *ut_params = &unittest_params;
5264 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5265 "No GMAC length in the source data");
5267 retval = create_gmac_session(ts_params->valid_devs[0],
5268 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5269 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
5274 if (tdata->aad.len > MBUF_SIZE)
5275 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5277 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5278 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5279 "Failed to allocate input buffer in mempool");
5281 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5282 rte_pktmbuf_tailroom(ut_params->ibuf));
5284 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
5290 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5292 ut_params->op->sym->m_src = ut_params->ibuf;
5294 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5295 ut_params->op), "failed to process sym crypto op");
5297 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5298 "crypto op processing failed");
5305 test_AES_GMAC_authentication_verify_test_case_1(void)
5307 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
5311 test_AES_GMAC_authentication_verify_test_case_2(void)
5313 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
5317 test_AES_GMAC_authentication_verify_test_case_3(void)
5319 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
5323 test_AES_GMAC_authentication_verify_test_case_4(void)
5325 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
5328 struct test_crypto_vector {
5329 enum rte_crypto_cipher_algorithm crypto_algo;
5342 const uint8_t *data;
5347 const uint8_t *data;
5351 enum rte_crypto_auth_algorithm auth_algo;
5359 const uint8_t *data;
5369 static const struct test_crypto_vector
5370 hmac_sha1_test_crypto_vector = {
5371 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5373 .data = plaintext_hash,
5378 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5379 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5380 0xDE, 0xF4, 0xDE, 0xAD
5386 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
5387 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
5388 0x3F, 0x91, 0x64, 0x59
5394 static const struct test_crypto_vector
5395 aes128_gmac_test_vector = {
5396 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
5397 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
5399 .data = plaintext_hash,
5404 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5405 0x08, 0x09, 0x0A, 0x0B
5411 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5412 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
5418 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
5419 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
5425 static const struct test_crypto_vector
5426 aes128cbc_hmac_sha1_test_vector = {
5427 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
5430 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
5431 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
5437 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5438 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
5443 .data = plaintext_hash,
5447 .data = ciphertext512_aes128cbc,
5450 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5453 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5454 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5455 0xDE, 0xF4, 0xDE, 0xAD
5461 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
5462 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5463 0x18, 0x8C, 0x1D, 0x32
5470 data_corruption(uint8_t *data)
5476 tag_corruption(uint8_t *data, unsigned int tag_offset)
5478 data[tag_offset] += 1;
5482 create_auth_session(struct crypto_unittest_params *ut_params,
5484 const struct test_crypto_vector *reference,
5485 enum rte_crypto_auth_operation auth_op)
5487 uint8_t auth_key[reference->auth_key.len + 1];
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 = NULL;
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 /* Create Crypto session*/
5502 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5503 &ut_params->auth_xform);
5505 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5511 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
5513 const struct test_crypto_vector *reference,
5514 enum rte_crypto_auth_operation auth_op,
5515 enum rte_crypto_cipher_operation cipher_op)
5517 uint8_t cipher_key[reference->cipher_key.len + 1];
5518 uint8_t auth_key[reference->auth_key.len + 1];
5520 memcpy(cipher_key, reference->cipher_key.data,
5521 reference->cipher_key.len);
5522 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5524 /* Setup Authentication Parameters */
5525 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5526 ut_params->auth_xform.auth.op = auth_op;
5527 ut_params->auth_xform.next = &ut_params->cipher_xform;
5528 ut_params->auth_xform.auth.algo = reference->auth_algo;
5529 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5530 ut_params->auth_xform.auth.key.data = auth_key;
5531 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5532 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5534 /* Setup Cipher Parameters */
5535 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5536 ut_params->cipher_xform.next = NULL;
5537 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
5538 ut_params->cipher_xform.cipher.op = cipher_op;
5539 ut_params->cipher_xform.cipher.key.data = cipher_key;
5540 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
5542 /* Create Crypto session*/
5543 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5544 &ut_params->auth_xform);
5546 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5552 create_auth_operation(struct crypto_testsuite_params *ts_params,
5553 struct crypto_unittest_params *ut_params,
5554 const struct test_crypto_vector *reference,
5555 unsigned int auth_generate)
5557 /* Generate Crypto op data structure */
5558 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5559 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5560 TEST_ASSERT_NOT_NULL(ut_params->op,
5561 "Failed to allocate pktmbuf offload");
5563 /* Set crypto operation data parameters */
5564 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5566 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5568 /* set crypto operation source mbuf */
5569 sym_op->m_src = ut_params->ibuf;
5572 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5573 ut_params->ibuf, reference->digest.len);
5575 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5576 "no room to append auth tag");
5578 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5579 ut_params->ibuf, reference->plaintext.len);
5580 sym_op->auth.digest.length = reference->digest.len;
5583 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5585 memcpy(sym_op->auth.digest.data,
5586 reference->digest.data,
5587 reference->digest.len);
5589 TEST_HEXDUMP(stdout, "digest:",
5590 sym_op->auth.digest.data,
5591 sym_op->auth.digest.length);
5593 sym_op->auth.data.length = reference->plaintext.len;
5594 sym_op->auth.data.offset = 0;
5600 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
5601 struct crypto_unittest_params *ut_params,
5602 const struct test_crypto_vector *reference,
5603 unsigned int auth_generate)
5605 /* Generate Crypto op data structure */
5606 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5607 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5608 TEST_ASSERT_NOT_NULL(ut_params->op,
5609 "Failed to allocate pktmbuf offload");
5611 /* Set crypto operation data parameters */
5612 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5614 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5616 /* set crypto operation source mbuf */
5617 sym_op->m_src = ut_params->ibuf;
5620 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5621 reference->aad.len);
5622 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
5623 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
5625 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
5627 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5628 sym_op->auth.aad.length = reference->aad.len;
5631 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5632 ut_params->ibuf, reference->digest.len);
5634 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5635 "no room to append auth tag");
5637 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5638 ut_params->ibuf, reference->ciphertext.len);
5639 sym_op->auth.digest.length = reference->digest.len;
5642 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5644 memcpy(sym_op->auth.digest.data,
5645 reference->digest.data,
5646 reference->digest.len);
5648 TEST_HEXDUMP(stdout, "digest:",
5649 sym_op->auth.digest.data,
5650 sym_op->auth.digest.length);
5652 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5653 ut_params->ibuf, reference->iv.len);
5654 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5656 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5657 sym_op->cipher.iv.length = reference->iv.len;
5659 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5661 sym_op->cipher.data.length = 0;
5662 sym_op->cipher.data.offset = 0;
5664 sym_op->auth.data.length = 0;
5665 sym_op->auth.data.offset = 0;
5671 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
5672 struct crypto_unittest_params *ut_params,
5673 const struct test_crypto_vector *reference,
5674 unsigned int auth_generate)
5676 /* Generate Crypto op data structure */
5677 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5678 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5679 TEST_ASSERT_NOT_NULL(ut_params->op,
5680 "Failed to allocate pktmbuf offload");
5682 /* Set crypto operation data parameters */
5683 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5685 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5687 /* set crypto operation source mbuf */
5688 sym_op->m_src = ut_params->ibuf;
5691 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5692 ut_params->ibuf, reference->digest.len);
5694 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5695 "no room to append auth tag");
5697 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5698 ut_params->ibuf, reference->ciphertext.len);
5699 sym_op->auth.digest.length = reference->digest.len;
5702 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5704 memcpy(sym_op->auth.digest.data,
5705 reference->digest.data,
5706 reference->digest.len);
5708 TEST_HEXDUMP(stdout, "digest:",
5709 sym_op->auth.digest.data,
5710 sym_op->auth.digest.length);
5712 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5713 ut_params->ibuf, reference->iv.len);
5714 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5716 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5717 sym_op->cipher.iv.length = reference->iv.len;
5719 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5721 sym_op->cipher.data.length = reference->ciphertext.len;
5722 sym_op->cipher.data.offset = reference->iv.len;
5724 sym_op->auth.data.length = reference->ciphertext.len;
5725 sym_op->auth.data.offset = reference->iv.len;
5731 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5732 struct crypto_unittest_params *ut_params,
5733 const struct test_crypto_vector *reference)
5735 return create_auth_operation(ts_params, ut_params, reference, 0);
5739 create_auth_verify_GMAC_operation(
5740 struct crypto_testsuite_params *ts_params,
5741 struct crypto_unittest_params *ut_params,
5742 const struct test_crypto_vector *reference)
5744 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
5748 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5749 struct crypto_unittest_params *ut_params,
5750 const struct test_crypto_vector *reference)
5752 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
5756 test_authentication_verify_fail_when_data_corruption(
5757 struct crypto_testsuite_params *ts_params,
5758 struct crypto_unittest_params *ut_params,
5759 const struct test_crypto_vector *reference,
5760 unsigned int data_corrupted)
5766 /* Create session */
5767 retval = create_auth_session(ut_params,
5768 ts_params->valid_devs[0],
5770 RTE_CRYPTO_AUTH_OP_VERIFY);
5774 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5775 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5776 "Failed to allocate input buffer in mempool");
5778 /* clear mbuf payload */
5779 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5780 rte_pktmbuf_tailroom(ut_params->ibuf));
5782 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5783 reference->plaintext.len);
5784 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5785 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
5787 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
5789 /* Create operation */
5790 retval = create_auth_verify_operation(ts_params, ut_params, reference);
5796 data_corruption(plaintext);
5798 tag_corruption(plaintext, reference->plaintext.len);
5800 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5802 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5803 TEST_ASSERT_EQUAL(ut_params->op->status,
5804 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5805 "authentication not failed");
5807 ut_params->obuf = ut_params->op->sym->m_src;
5808 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5814 test_authentication_verify_GMAC_fail_when_corruption(
5815 struct crypto_testsuite_params *ts_params,
5816 struct crypto_unittest_params *ut_params,
5817 const struct test_crypto_vector *reference,
5818 unsigned int data_corrupted)
5822 /* Create session */
5823 retval = create_auth_cipher_session(ut_params,
5824 ts_params->valid_devs[0],
5826 RTE_CRYPTO_AUTH_OP_VERIFY,
5827 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5831 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5832 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5833 "Failed to allocate input buffer in mempool");
5835 /* clear mbuf payload */
5836 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5837 rte_pktmbuf_tailroom(ut_params->ibuf));
5839 /* Create operation */
5840 retval = create_auth_verify_GMAC_operation(ts_params,
5848 data_corruption(ut_params->op->sym->auth.aad.data);
5850 tag_corruption(ut_params->op->sym->auth.aad.data,
5851 reference->aad.len);
5853 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5855 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5856 TEST_ASSERT_EQUAL(ut_params->op->status,
5857 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5858 "authentication not failed");
5860 ut_params->obuf = ut_params->op->sym->m_src;
5861 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5867 test_authenticated_decryption_fail_when_corruption(
5868 struct crypto_testsuite_params *ts_params,
5869 struct crypto_unittest_params *ut_params,
5870 const struct test_crypto_vector *reference,
5871 unsigned int data_corrupted)
5875 uint8_t *ciphertext;
5877 /* Create session */
5878 retval = create_auth_cipher_session(ut_params,
5879 ts_params->valid_devs[0],
5881 RTE_CRYPTO_AUTH_OP_VERIFY,
5882 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5886 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5887 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5888 "Failed to allocate input buffer in mempool");
5890 /* clear mbuf payload */
5891 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5892 rte_pktmbuf_tailroom(ut_params->ibuf));
5894 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5895 reference->ciphertext.len);
5896 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
5897 memcpy(ciphertext, reference->ciphertext.data,
5898 reference->ciphertext.len);
5900 /* Create operation */
5901 retval = create_cipher_auth_verify_operation(ts_params,
5909 data_corruption(ciphertext);
5911 tag_corruption(ciphertext, reference->ciphertext.len);
5913 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5916 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5917 TEST_ASSERT_EQUAL(ut_params->op->status,
5918 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5919 "authentication not failed");
5921 ut_params->obuf = ut_params->op->sym->m_src;
5922 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5928 test_authentication_verify_fail_when_data_corrupted(
5929 struct crypto_testsuite_params *ts_params,
5930 struct crypto_unittest_params *ut_params,
5931 const struct test_crypto_vector *reference)
5933 return test_authentication_verify_fail_when_data_corruption(
5934 ts_params, ut_params, reference, 1);
5938 test_authentication_verify_fail_when_tag_corrupted(
5939 struct crypto_testsuite_params *ts_params,
5940 struct crypto_unittest_params *ut_params,
5941 const struct test_crypto_vector *reference)
5943 return test_authentication_verify_fail_when_data_corruption(
5944 ts_params, ut_params, reference, 0);
5948 test_authentication_verify_GMAC_fail_when_data_corrupted(
5949 struct crypto_testsuite_params *ts_params,
5950 struct crypto_unittest_params *ut_params,
5951 const struct test_crypto_vector *reference)
5953 return test_authentication_verify_GMAC_fail_when_corruption(
5954 ts_params, ut_params, reference, 1);
5958 test_authentication_verify_GMAC_fail_when_tag_corrupted(
5959 struct crypto_testsuite_params *ts_params,
5960 struct crypto_unittest_params *ut_params,
5961 const struct test_crypto_vector *reference)
5963 return test_authentication_verify_GMAC_fail_when_corruption(
5964 ts_params, ut_params, reference, 0);
5968 test_authenticated_decryption_fail_when_data_corrupted(
5969 struct crypto_testsuite_params *ts_params,
5970 struct crypto_unittest_params *ut_params,
5971 const struct test_crypto_vector *reference)
5973 return test_authenticated_decryption_fail_when_corruption(
5974 ts_params, ut_params, reference, 1);
5978 test_authenticated_decryption_fail_when_tag_corrupted(
5979 struct crypto_testsuite_params *ts_params,
5980 struct crypto_unittest_params *ut_params,
5981 const struct test_crypto_vector *reference)
5983 return test_authenticated_decryption_fail_when_corruption(
5984 ts_params, ut_params, reference, 0);
5988 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
5990 return test_authentication_verify_fail_when_data_corrupted(
5991 &testsuite_params, &unittest_params,
5992 &hmac_sha1_test_crypto_vector);
5996 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
5998 return test_authentication_verify_fail_when_tag_corrupted(
5999 &testsuite_params, &unittest_params,
6000 &hmac_sha1_test_crypto_vector);
6004 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
6006 return test_authentication_verify_GMAC_fail_when_data_corrupted(
6007 &testsuite_params, &unittest_params,
6008 &aes128_gmac_test_vector);
6012 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
6014 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
6015 &testsuite_params, &unittest_params,
6016 &aes128_gmac_test_vector);
6020 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
6022 return test_authenticated_decryption_fail_when_data_corrupted(
6025 &aes128cbc_hmac_sha1_test_vector);
6029 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
6031 return test_authenticated_decryption_fail_when_tag_corrupted(
6034 &aes128cbc_hmac_sha1_test_vector);
6037 static struct unit_test_suite cryptodev_qat_testsuite = {
6038 .suite_name = "Crypto QAT Unit Test Suite",
6039 .setup = testsuite_setup,
6040 .teardown = testsuite_teardown,
6041 .unit_test_cases = {
6042 TEST_CASE_ST(ut_setup, ut_teardown,
6043 test_device_configure_invalid_dev_id),
6044 TEST_CASE_ST(ut_setup, ut_teardown,
6045 test_device_configure_invalid_queue_pair_ids),
6046 TEST_CASE_ST(ut_setup, ut_teardown,
6047 test_queue_pair_descriptor_setup),
6048 TEST_CASE_ST(ut_setup, ut_teardown,
6049 test_multi_session),
6051 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
6052 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
6053 TEST_CASE_ST(ut_setup, ut_teardown,
6054 test_3DES_cipheronly_qat_all),
6055 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
6056 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
6058 /** AES GCM Authenticated Encryption */
6059 TEST_CASE_ST(ut_setup, ut_teardown,
6060 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6061 TEST_CASE_ST(ut_setup, ut_teardown,
6062 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6063 TEST_CASE_ST(ut_setup, ut_teardown,
6064 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6065 TEST_CASE_ST(ut_setup, ut_teardown,
6066 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6067 TEST_CASE_ST(ut_setup, ut_teardown,
6068 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6069 TEST_CASE_ST(ut_setup, ut_teardown,
6070 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6071 TEST_CASE_ST(ut_setup, ut_teardown,
6072 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6074 /** AES GCM Authenticated Decryption */
6075 TEST_CASE_ST(ut_setup, ut_teardown,
6076 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6077 TEST_CASE_ST(ut_setup, ut_teardown,
6078 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6079 TEST_CASE_ST(ut_setup, ut_teardown,
6080 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6081 TEST_CASE_ST(ut_setup, ut_teardown,
6082 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6083 TEST_CASE_ST(ut_setup, ut_teardown,
6084 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6085 TEST_CASE_ST(ut_setup, ut_teardown,
6086 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6087 TEST_CASE_ST(ut_setup, ut_teardown,
6088 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6090 /** AES GMAC Authentication */
6091 TEST_CASE_ST(ut_setup, ut_teardown,
6092 test_AES_GMAC_authentication_test_case_1),
6093 TEST_CASE_ST(ut_setup, ut_teardown,
6094 test_AES_GMAC_authentication_verify_test_case_1),
6095 TEST_CASE_ST(ut_setup, ut_teardown,
6096 test_AES_GMAC_authentication_test_case_2),
6097 TEST_CASE_ST(ut_setup, ut_teardown,
6098 test_AES_GMAC_authentication_verify_test_case_2),
6099 TEST_CASE_ST(ut_setup, ut_teardown,
6100 test_AES_GMAC_authentication_test_case_3),
6101 TEST_CASE_ST(ut_setup, ut_teardown,
6102 test_AES_GMAC_authentication_verify_test_case_3),
6104 /** SNOW 3G encrypt only (UEA2) */
6105 TEST_CASE_ST(ut_setup, ut_teardown,
6106 test_snow3g_encryption_test_case_1),
6107 TEST_CASE_ST(ut_setup, ut_teardown,
6108 test_snow3g_encryption_test_case_2),
6109 TEST_CASE_ST(ut_setup, ut_teardown,
6110 test_snow3g_encryption_test_case_3),
6111 TEST_CASE_ST(ut_setup, ut_teardown,
6112 test_snow3g_encryption_test_case_4),
6113 TEST_CASE_ST(ut_setup, ut_teardown,
6114 test_snow3g_encryption_test_case_5),
6116 TEST_CASE_ST(ut_setup, ut_teardown,
6117 test_snow3g_encryption_test_case_1_oop),
6118 TEST_CASE_ST(ut_setup, ut_teardown,
6119 test_snow3g_decryption_test_case_1_oop),
6121 /** SNOW 3G decrypt only (UEA2) */
6122 TEST_CASE_ST(ut_setup, ut_teardown,
6123 test_snow3g_decryption_test_case_1),
6124 TEST_CASE_ST(ut_setup, ut_teardown,
6125 test_snow3g_decryption_test_case_2),
6126 TEST_CASE_ST(ut_setup, ut_teardown,
6127 test_snow3g_decryption_test_case_3),
6128 TEST_CASE_ST(ut_setup, ut_teardown,
6129 test_snow3g_decryption_test_case_4),
6130 TEST_CASE_ST(ut_setup, ut_teardown,
6131 test_snow3g_decryption_test_case_5),
6132 TEST_CASE_ST(ut_setup, ut_teardown,
6133 test_snow3g_hash_generate_test_case_1),
6134 TEST_CASE_ST(ut_setup, ut_teardown,
6135 test_snow3g_hash_generate_test_case_2),
6136 TEST_CASE_ST(ut_setup, ut_teardown,
6137 test_snow3g_hash_generate_test_case_3),
6138 TEST_CASE_ST(ut_setup, ut_teardown,
6139 test_snow3g_hash_verify_test_case_1),
6140 TEST_CASE_ST(ut_setup, ut_teardown,
6141 test_snow3g_hash_verify_test_case_2),
6142 TEST_CASE_ST(ut_setup, ut_teardown,
6143 test_snow3g_hash_verify_test_case_3),
6144 TEST_CASE_ST(ut_setup, ut_teardown,
6145 test_snow3g_cipher_auth_test_case_1),
6146 TEST_CASE_ST(ut_setup, ut_teardown,
6147 test_snow3g_auth_cipher_test_case_1),
6149 /** HMAC_MD5 Authentication */
6150 TEST_CASE_ST(ut_setup, ut_teardown,
6151 test_MD5_HMAC_generate_case_1),
6152 TEST_CASE_ST(ut_setup, ut_teardown,
6153 test_MD5_HMAC_verify_case_1),
6154 TEST_CASE_ST(ut_setup, ut_teardown,
6155 test_MD5_HMAC_generate_case_2),
6156 TEST_CASE_ST(ut_setup, ut_teardown,
6157 test_MD5_HMAC_verify_case_2),
6160 TEST_CASE_ST(ut_setup, ut_teardown,
6161 test_null_auth_only_operation),
6162 TEST_CASE_ST(ut_setup, ut_teardown,
6163 test_null_cipher_only_operation),
6164 TEST_CASE_ST(ut_setup, ut_teardown,
6165 test_null_cipher_auth_operation),
6166 TEST_CASE_ST(ut_setup, ut_teardown,
6167 test_null_auth_cipher_operation),
6169 TEST_CASE_ST(ut_setup, ut_teardown,
6170 test_kasumi_hash_generate_test_case_6),
6173 TEST_CASE_ST(ut_setup, ut_teardown,
6174 test_kasumi_encryption_test_case_1),
6175 TEST_CASE_ST(ut_setup, ut_teardown,
6176 test_kasumi_encryption_test_case_3),
6177 TEST_CASE_ST(ut_setup, ut_teardown,
6178 test_kasumi_auth_cipher_test_case_1),
6179 TEST_CASE_ST(ut_setup, ut_teardown,
6180 test_kasumi_cipher_auth_test_case_1),
6182 /** Negative tests */
6183 TEST_CASE_ST(ut_setup, ut_teardown,
6184 authentication_verify_HMAC_SHA1_fail_data_corrupt),
6185 TEST_CASE_ST(ut_setup, ut_teardown,
6186 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6187 TEST_CASE_ST(ut_setup, ut_teardown,
6188 authentication_verify_AES128_GMAC_fail_data_corrupt),
6189 TEST_CASE_ST(ut_setup, ut_teardown,
6190 authentication_verify_AES128_GMAC_fail_tag_corrupt),
6191 TEST_CASE_ST(ut_setup, ut_teardown,
6192 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6193 TEST_CASE_ST(ut_setup, ut_teardown,
6194 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6196 TEST_CASES_END() /**< NULL terminate unit test array */
6200 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
6201 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
6202 .setup = testsuite_setup,
6203 .teardown = testsuite_teardown,
6204 .unit_test_cases = {
6205 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
6207 TEST_CASES_END() /**< NULL terminate unit test array */
6211 static struct unit_test_suite cryptodev_openssl_testsuite = {
6212 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
6213 .setup = testsuite_setup,
6214 .teardown = testsuite_teardown,
6215 .unit_test_cases = {
6216 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
6217 TEST_CASE_ST(ut_setup, ut_teardown,
6218 test_multi_session_random_usage),
6219 TEST_CASE_ST(ut_setup, ut_teardown,
6220 test_AES_chain_openssl_all),
6221 TEST_CASE_ST(ut_setup, ut_teardown,
6222 test_AES_cipheronly_openssl_all),
6223 TEST_CASE_ST(ut_setup, ut_teardown,
6224 test_3DES_chain_openssl_all),
6225 TEST_CASE_ST(ut_setup, ut_teardown,
6226 test_3DES_cipheronly_openssl_all),
6227 TEST_CASE_ST(ut_setup, ut_teardown,
6228 test_authonly_openssl_all),
6230 /** AES GCM Authenticated Encryption */
6231 TEST_CASE_ST(ut_setup, ut_teardown,
6232 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6233 TEST_CASE_ST(ut_setup, ut_teardown,
6234 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6235 TEST_CASE_ST(ut_setup, ut_teardown,
6236 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6237 TEST_CASE_ST(ut_setup, ut_teardown,
6238 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6239 TEST_CASE_ST(ut_setup, ut_teardown,
6240 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6241 TEST_CASE_ST(ut_setup, ut_teardown,
6242 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6243 TEST_CASE_ST(ut_setup, ut_teardown,
6244 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6246 /** AES GCM Authenticated Decryption */
6247 TEST_CASE_ST(ut_setup, ut_teardown,
6248 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6249 TEST_CASE_ST(ut_setup, ut_teardown,
6250 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6251 TEST_CASE_ST(ut_setup, ut_teardown,
6252 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6253 TEST_CASE_ST(ut_setup, ut_teardown,
6254 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6255 TEST_CASE_ST(ut_setup, ut_teardown,
6256 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6257 TEST_CASE_ST(ut_setup, ut_teardown,
6258 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6259 TEST_CASE_ST(ut_setup, ut_teardown,
6260 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6262 /** AES GMAC Authentication */
6263 TEST_CASE_ST(ut_setup, ut_teardown,
6264 test_AES_GMAC_authentication_test_case_1),
6265 TEST_CASE_ST(ut_setup, ut_teardown,
6266 test_AES_GMAC_authentication_verify_test_case_1),
6267 TEST_CASE_ST(ut_setup, ut_teardown,
6268 test_AES_GMAC_authentication_test_case_2),
6269 TEST_CASE_ST(ut_setup, ut_teardown,
6270 test_AES_GMAC_authentication_verify_test_case_2),
6271 TEST_CASE_ST(ut_setup, ut_teardown,
6272 test_AES_GMAC_authentication_test_case_3),
6273 TEST_CASE_ST(ut_setup, ut_teardown,
6274 test_AES_GMAC_authentication_verify_test_case_3),
6275 TEST_CASE_ST(ut_setup, ut_teardown,
6276 test_AES_GMAC_authentication_test_case_4),
6277 TEST_CASE_ST(ut_setup, ut_teardown,
6278 test_AES_GMAC_authentication_verify_test_case_4),
6280 /** Negative tests */
6281 TEST_CASE_ST(ut_setup, ut_teardown,
6282 authentication_verify_HMAC_SHA1_fail_data_corrupt),
6283 TEST_CASE_ST(ut_setup, ut_teardown,
6284 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6285 TEST_CASE_ST(ut_setup, ut_teardown,
6286 authentication_verify_AES128_GMAC_fail_data_corrupt),
6287 TEST_CASE_ST(ut_setup, ut_teardown,
6288 authentication_verify_AES128_GMAC_fail_tag_corrupt),
6289 TEST_CASE_ST(ut_setup, ut_teardown,
6290 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6291 TEST_CASE_ST(ut_setup, ut_teardown,
6292 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6294 TEST_CASES_END() /**< NULL terminate unit test array */
6298 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
6299 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
6300 .setup = testsuite_setup,
6301 .teardown = testsuite_teardown,
6302 .unit_test_cases = {
6303 /** AES GCM Authenticated Encryption */
6304 TEST_CASE_ST(ut_setup, ut_teardown,
6305 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6306 TEST_CASE_ST(ut_setup, ut_teardown,
6307 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6308 TEST_CASE_ST(ut_setup, ut_teardown,
6309 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6310 TEST_CASE_ST(ut_setup, ut_teardown,
6311 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6312 TEST_CASE_ST(ut_setup, ut_teardown,
6313 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6314 TEST_CASE_ST(ut_setup, ut_teardown,
6315 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6316 TEST_CASE_ST(ut_setup, ut_teardown,
6317 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6319 /** AES GCM Authenticated Decryption */
6320 TEST_CASE_ST(ut_setup, ut_teardown,
6321 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6322 TEST_CASE_ST(ut_setup, ut_teardown,
6323 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6324 TEST_CASE_ST(ut_setup, ut_teardown,
6325 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6326 TEST_CASE_ST(ut_setup, ut_teardown,
6327 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6328 TEST_CASE_ST(ut_setup, ut_teardown,
6329 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6330 TEST_CASE_ST(ut_setup, ut_teardown,
6331 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6332 TEST_CASE_ST(ut_setup, ut_teardown,
6333 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6335 TEST_CASES_END() /**< NULL terminate unit test array */
6339 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
6340 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
6341 .setup = testsuite_setup,
6342 .teardown = testsuite_teardown,
6343 .unit_test_cases = {
6344 /** KASUMI encrypt only (UEA1) */
6345 TEST_CASE_ST(ut_setup, ut_teardown,
6346 test_kasumi_encryption_test_case_1),
6347 TEST_CASE_ST(ut_setup, ut_teardown,
6348 test_kasumi_encryption_test_case_2),
6349 TEST_CASE_ST(ut_setup, ut_teardown,
6350 test_kasumi_encryption_test_case_3),
6351 TEST_CASE_ST(ut_setup, ut_teardown,
6352 test_kasumi_encryption_test_case_4),
6353 TEST_CASE_ST(ut_setup, ut_teardown,
6354 test_kasumi_encryption_test_case_5),
6355 /** KASUMI decrypt only (UEA1) */
6356 TEST_CASE_ST(ut_setup, ut_teardown,
6357 test_kasumi_decryption_test_case_1),
6358 TEST_CASE_ST(ut_setup, ut_teardown,
6359 test_kasumi_decryption_test_case_2),
6360 TEST_CASE_ST(ut_setup, ut_teardown,
6361 test_kasumi_decryption_test_case_3),
6362 TEST_CASE_ST(ut_setup, ut_teardown,
6363 test_kasumi_decryption_test_case_4),
6364 TEST_CASE_ST(ut_setup, ut_teardown,
6365 test_kasumi_decryption_test_case_5),
6367 TEST_CASE_ST(ut_setup, ut_teardown,
6368 test_kasumi_encryption_test_case_1_oop),
6369 TEST_CASE_ST(ut_setup, ut_teardown,
6370 test_kasumi_decryption_test_case_1_oop),
6372 /** KASUMI hash only (UIA1) */
6373 TEST_CASE_ST(ut_setup, ut_teardown,
6374 test_kasumi_hash_generate_test_case_1),
6375 TEST_CASE_ST(ut_setup, ut_teardown,
6376 test_kasumi_hash_generate_test_case_2),
6377 TEST_CASE_ST(ut_setup, ut_teardown,
6378 test_kasumi_hash_generate_test_case_3),
6379 TEST_CASE_ST(ut_setup, ut_teardown,
6380 test_kasumi_hash_generate_test_case_4),
6381 TEST_CASE_ST(ut_setup, ut_teardown,
6382 test_kasumi_hash_generate_test_case_5),
6383 TEST_CASE_ST(ut_setup, ut_teardown,
6384 test_kasumi_hash_generate_test_case_6),
6385 TEST_CASE_ST(ut_setup, ut_teardown,
6386 test_kasumi_hash_verify_test_case_1),
6387 TEST_CASE_ST(ut_setup, ut_teardown,
6388 test_kasumi_hash_verify_test_case_2),
6389 TEST_CASE_ST(ut_setup, ut_teardown,
6390 test_kasumi_hash_verify_test_case_3),
6391 TEST_CASE_ST(ut_setup, ut_teardown,
6392 test_kasumi_hash_verify_test_case_4),
6393 TEST_CASE_ST(ut_setup, ut_teardown,
6394 test_kasumi_hash_verify_test_case_5),
6395 TEST_CASE_ST(ut_setup, ut_teardown,
6396 test_kasumi_auth_cipher_test_case_1),
6397 TEST_CASE_ST(ut_setup, ut_teardown,
6398 test_kasumi_cipher_auth_test_case_1),
6399 TEST_CASES_END() /**< NULL terminate unit test array */
6402 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
6403 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
6404 .setup = testsuite_setup,
6405 .teardown = testsuite_teardown,
6406 .unit_test_cases = {
6407 /** SNOW 3G encrypt only (UEA2) */
6408 TEST_CASE_ST(ut_setup, ut_teardown,
6409 test_snow3g_encryption_test_case_1),
6410 TEST_CASE_ST(ut_setup, ut_teardown,
6411 test_snow3g_encryption_test_case_2),
6412 TEST_CASE_ST(ut_setup, ut_teardown,
6413 test_snow3g_encryption_test_case_3),
6414 TEST_CASE_ST(ut_setup, ut_teardown,
6415 test_snow3g_encryption_test_case_4),
6416 TEST_CASE_ST(ut_setup, ut_teardown,
6417 test_snow3g_encryption_test_case_5),
6419 TEST_CASE_ST(ut_setup, ut_teardown,
6420 test_snow3g_encryption_test_case_1_oop),
6421 TEST_CASE_ST(ut_setup, ut_teardown,
6422 test_snow3g_decryption_test_case_1_oop),
6424 TEST_CASE_ST(ut_setup, ut_teardown,
6425 test_snow3g_encryption_test_case_1_offset_oop),
6427 /** SNOW 3G decrypt only (UEA2) */
6428 TEST_CASE_ST(ut_setup, ut_teardown,
6429 test_snow3g_decryption_test_case_1),
6430 TEST_CASE_ST(ut_setup, ut_teardown,
6431 test_snow3g_decryption_test_case_2),
6432 TEST_CASE_ST(ut_setup, ut_teardown,
6433 test_snow3g_decryption_test_case_3),
6434 TEST_CASE_ST(ut_setup, ut_teardown,
6435 test_snow3g_decryption_test_case_4),
6436 TEST_CASE_ST(ut_setup, ut_teardown,
6437 test_snow3g_decryption_test_case_5),
6438 TEST_CASE_ST(ut_setup, ut_teardown,
6439 test_snow3g_hash_generate_test_case_1),
6440 TEST_CASE_ST(ut_setup, ut_teardown,
6441 test_snow3g_hash_generate_test_case_2),
6442 TEST_CASE_ST(ut_setup, ut_teardown,
6443 test_snow3g_hash_generate_test_case_3),
6444 /* Tests with buffers which length is not byte-aligned */
6445 TEST_CASE_ST(ut_setup, ut_teardown,
6446 test_snow3g_hash_generate_test_case_4),
6447 TEST_CASE_ST(ut_setup, ut_teardown,
6448 test_snow3g_hash_generate_test_case_5),
6449 TEST_CASE_ST(ut_setup, ut_teardown,
6450 test_snow3g_hash_generate_test_case_6),
6451 TEST_CASE_ST(ut_setup, ut_teardown,
6452 test_snow3g_hash_verify_test_case_1),
6453 TEST_CASE_ST(ut_setup, ut_teardown,
6454 test_snow3g_hash_verify_test_case_2),
6455 TEST_CASE_ST(ut_setup, ut_teardown,
6456 test_snow3g_hash_verify_test_case_3),
6457 /* Tests with buffers which length is not byte-aligned */
6458 TEST_CASE_ST(ut_setup, ut_teardown,
6459 test_snow3g_hash_verify_test_case_4),
6460 TEST_CASE_ST(ut_setup, ut_teardown,
6461 test_snow3g_hash_verify_test_case_5),
6462 TEST_CASE_ST(ut_setup, ut_teardown,
6463 test_snow3g_hash_verify_test_case_6),
6464 TEST_CASE_ST(ut_setup, ut_teardown,
6465 test_snow3g_cipher_auth_test_case_1),
6466 TEST_CASE_ST(ut_setup, ut_teardown,
6467 test_snow3g_auth_cipher_test_case_1),
6469 TEST_CASES_END() /**< NULL terminate unit test array */
6473 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
6474 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
6475 .setup = testsuite_setup,
6476 .teardown = testsuite_teardown,
6477 .unit_test_cases = {
6478 /** ZUC encrypt only (EEA3) */
6479 TEST_CASE_ST(ut_setup, ut_teardown,
6480 test_zuc_encryption_test_case_1),
6481 TEST_CASE_ST(ut_setup, ut_teardown,
6482 test_zuc_encryption_test_case_2),
6483 TEST_CASE_ST(ut_setup, ut_teardown,
6484 test_zuc_encryption_test_case_3),
6485 TEST_CASE_ST(ut_setup, ut_teardown,
6486 test_zuc_encryption_test_case_4),
6487 TEST_CASE_ST(ut_setup, ut_teardown,
6488 test_zuc_encryption_test_case_5),
6489 TEST_CASE_ST(ut_setup, ut_teardown,
6490 test_zuc_hash_generate_test_case_1),
6491 TEST_CASE_ST(ut_setup, ut_teardown,
6492 test_zuc_hash_generate_test_case_2),
6493 TEST_CASE_ST(ut_setup, ut_teardown,
6494 test_zuc_hash_generate_test_case_3),
6495 TEST_CASE_ST(ut_setup, ut_teardown,
6496 test_zuc_hash_generate_test_case_4),
6497 TEST_CASE_ST(ut_setup, ut_teardown,
6498 test_zuc_hash_generate_test_case_5),
6499 TEST_CASES_END() /**< NULL terminate unit test array */
6503 static struct unit_test_suite cryptodev_null_testsuite = {
6504 .suite_name = "Crypto Device NULL Unit Test Suite",
6505 .setup = testsuite_setup,
6506 .teardown = testsuite_teardown,
6507 .unit_test_cases = {
6508 TEST_CASE_ST(ut_setup, ut_teardown,
6509 test_null_auth_only_operation),
6510 TEST_CASE_ST(ut_setup, ut_teardown,
6511 test_null_cipher_only_operation),
6512 TEST_CASE_ST(ut_setup, ut_teardown,
6513 test_null_cipher_auth_operation),
6514 TEST_CASE_ST(ut_setup, ut_teardown,
6515 test_null_auth_cipher_operation),
6516 TEST_CASE_ST(ut_setup, ut_teardown,
6517 test_null_invalid_operation),
6518 TEST_CASE_ST(ut_setup, ut_teardown,
6519 test_null_burst_operation),
6521 TEST_CASES_END() /**< NULL terminate unit test array */
6526 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
6528 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
6529 return unit_test_suite_runner(&cryptodev_qat_testsuite);
6533 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
6535 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
6537 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
6541 test_cryptodev_openssl(void)
6543 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
6545 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
6549 test_cryptodev_aesni_gcm(void)
6551 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
6553 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
6557 test_cryptodev_null(void)
6559 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
6561 return unit_test_suite_runner(&cryptodev_null_testsuite);
6565 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
6567 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
6569 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
6573 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
6575 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
6577 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
6581 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
6583 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
6585 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
6588 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
6589 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
6590 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
6591 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
6592 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
6593 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
6594 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
6595 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);