4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_aead_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static int gbl_driver_id;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_mempool *session_mpool;
71 struct rte_cryptodev_config conf;
72 struct rte_cryptodev_qp_conf qp_conf;
74 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
75 uint8_t valid_dev_count;
78 struct crypto_unittest_params {
79 struct rte_crypto_sym_xform cipher_xform;
80 struct rte_crypto_sym_xform auth_xform;
81 struct rte_crypto_sym_xform aead_xform;
83 struct rte_cryptodev_sym_session *sess;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
145 static struct rte_crypto_op *
146 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
148 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
149 printf("Error sending packet for encryption");
155 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
161 static struct crypto_testsuite_params testsuite_params = { NULL };
162 static struct crypto_unittest_params unittest_params;
165 testsuite_setup(void)
167 struct crypto_testsuite_params *ts_params = &testsuite_params;
168 struct rte_cryptodev_info info;
169 uint32_t i = 0, nb_devs, dev_id;
173 memset(ts_params, 0, sizeof(*ts_params));
175 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
176 if (ts_params->mbuf_pool == NULL) {
177 /* Not already created so create */
178 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
180 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
182 if (ts_params->mbuf_pool == NULL) {
183 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
188 ts_params->large_mbuf_pool = rte_mempool_lookup(
189 "CRYPTO_LARGE_MBUFPOOL");
190 if (ts_params->large_mbuf_pool == NULL) {
191 /* Not already created so create */
192 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
193 "CRYPTO_LARGE_MBUFPOOL",
196 if (ts_params->large_mbuf_pool == NULL) {
198 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
203 ts_params->op_mpool = rte_crypto_op_pool_create(
204 "MBUF_CRYPTO_SYM_OP_POOL",
205 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
206 NUM_MBUFS, MBUF_CACHE_SIZE,
208 sizeof(struct rte_crypto_sym_xform) +
211 if (ts_params->op_mpool == NULL) {
212 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
216 /* Create an AESNI MB device if required */
217 if (gbl_driver_id == rte_cryptodev_driver_id_get(
218 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
219 nb_devs = rte_cryptodev_device_count_by_driver(
220 rte_cryptodev_driver_id_get(
221 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
224 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
226 TEST_ASSERT(ret == 0,
227 "Failed to create instance of"
229 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
233 /* Create an AESNI GCM device if required */
234 if (gbl_driver_id == rte_cryptodev_driver_id_get(
235 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
236 nb_devs = rte_cryptodev_device_count_by_driver(
237 rte_cryptodev_driver_id_get(
238 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
240 TEST_ASSERT_SUCCESS(rte_vdev_init(
241 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
242 "Failed to create instance of"
244 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
248 /* Create a SNOW 3G device if required */
249 if (gbl_driver_id == rte_cryptodev_driver_id_get(
250 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
251 nb_devs = rte_cryptodev_device_count_by_driver(
252 rte_cryptodev_driver_id_get(
253 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
255 TEST_ASSERT_SUCCESS(rte_vdev_init(
256 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
257 "Failed to create instance of"
259 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
263 /* Create a KASUMI device if required */
264 if (gbl_driver_id == rte_cryptodev_driver_id_get(
265 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
266 nb_devs = rte_cryptodev_device_count_by_driver(
267 rte_cryptodev_driver_id_get(
268 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
270 TEST_ASSERT_SUCCESS(rte_vdev_init(
271 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
272 "Failed to create instance of"
274 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
278 /* Create a ZUC device if required */
279 if (gbl_driver_id == rte_cryptodev_driver_id_get(
280 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
281 nb_devs = rte_cryptodev_device_count_by_driver(
282 rte_cryptodev_driver_id_get(
283 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
285 TEST_ASSERT_SUCCESS(rte_vdev_init(
286 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
287 "Failed to create instance of"
289 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
293 /* Create a NULL device if required */
294 if (gbl_driver_id == rte_cryptodev_driver_id_get(
295 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
296 nb_devs = rte_cryptodev_device_count_by_driver(
297 rte_cryptodev_driver_id_get(
298 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
301 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
303 TEST_ASSERT(ret == 0,
304 "Failed to create instance of"
306 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
310 /* Create an OPENSSL device if required */
311 if (gbl_driver_id == rte_cryptodev_driver_id_get(
312 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
313 nb_devs = rte_cryptodev_device_count_by_driver(
314 rte_cryptodev_driver_id_get(
315 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
318 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
321 TEST_ASSERT(ret == 0, "Failed to create "
322 "instance of pmd : %s",
323 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
327 /* Create a ARMv8 device if required */
328 if (gbl_driver_id == rte_cryptodev_driver_id_get(
329 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
330 nb_devs = rte_cryptodev_device_count_by_driver(
331 rte_cryptodev_driver_id_get(
332 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
335 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
338 TEST_ASSERT(ret == 0, "Failed to create "
339 "instance of pmd : %s",
340 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
344 /* Create a MRVL device if required */
345 if (gbl_driver_id == rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_MRVL_PMD))) {
347 #ifndef RTE_LIBRTE_PMD_MRVL_CRYPTO
348 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO must be"
349 " enabled in config file to run this testsuite.\n");
352 nb_devs = rte_cryptodev_device_count_by_driver(
353 rte_cryptodev_driver_id_get(
354 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)));
357 RTE_STR(CRYPTODEV_NAME_MRVL_PMD),
360 TEST_ASSERT(ret == 0, "Failed to create "
361 "instance of pmd : %s",
362 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
366 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
367 if (gbl_driver_id == rte_cryptodev_driver_id_get(
368 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
370 nb_devs = rte_cryptodev_device_count_by_driver(
371 rte_cryptodev_driver_id_get(
372 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
375 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
378 TEST_ASSERT(ret == 0,
379 "Failed to create instance %u of"
381 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
384 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
386 nb_devs = rte_cryptodev_count();
388 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
392 /* Create list of valid crypto devs */
393 for (i = 0; i < nb_devs; i++) {
394 rte_cryptodev_info_get(i, &info);
395 if (info.driver_id == gbl_driver_id)
396 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
399 if (ts_params->valid_dev_count < 1)
402 /* Set up all the qps on the first of the valid devices found */
404 dev_id = ts_params->valid_devs[0];
406 rte_cryptodev_info_get(dev_id, &info);
408 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
409 ts_params->conf.socket_id = SOCKET_ID_ANY;
411 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
414 * Create mempool with maximum number of sessions * 2,
415 * to include the session headers
417 ts_params->session_mpool = rte_mempool_create(
419 info.sym.max_nb_sessions * 2,
421 0, 0, NULL, NULL, NULL,
425 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
426 "session mempool allocation failed");
428 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
430 "Failed to configure cryptodev %u with %u qps",
431 dev_id, ts_params->conf.nb_queue_pairs);
433 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
435 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
436 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
437 dev_id, qp_id, &ts_params->qp_conf,
438 rte_cryptodev_socket_id(dev_id),
439 ts_params->session_mpool),
440 "Failed to setup queue pair %u on cryptodev %u",
448 testsuite_teardown(void)
450 struct crypto_testsuite_params *ts_params = &testsuite_params;
452 if (ts_params->mbuf_pool != NULL) {
453 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
454 rte_mempool_avail_count(ts_params->mbuf_pool));
457 if (ts_params->op_mpool != NULL) {
458 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
459 rte_mempool_avail_count(ts_params->op_mpool));
462 /* Free session mempools */
463 if (ts_params->session_mpool != NULL) {
464 rte_mempool_free(ts_params->session_mpool);
465 ts_params->session_mpool = NULL;
472 struct crypto_testsuite_params *ts_params = &testsuite_params;
473 struct crypto_unittest_params *ut_params = &unittest_params;
477 /* Clear unit test parameters before running test */
478 memset(ut_params, 0, sizeof(*ut_params));
480 /* Reconfigure device to default parameters */
481 ts_params->conf.socket_id = SOCKET_ID_ANY;
483 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
485 "Failed to configure cryptodev %u",
486 ts_params->valid_devs[0]);
488 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
489 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
490 ts_params->valid_devs[0], qp_id,
492 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
493 ts_params->session_mpool),
494 "Failed to setup queue pair %u on cryptodev %u",
495 qp_id, ts_params->valid_devs[0]);
499 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
501 /* Start the device */
502 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
503 "Failed to start cryptodev %u",
504 ts_params->valid_devs[0]);
512 struct crypto_testsuite_params *ts_params = &testsuite_params;
513 struct crypto_unittest_params *ut_params = &unittest_params;
514 struct rte_cryptodev_stats stats;
516 /* free crypto session structure */
517 if (ut_params->sess) {
518 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
520 rte_cryptodev_sym_session_free(ut_params->sess);
521 ut_params->sess = NULL;
524 /* free crypto operation structure */
526 rte_crypto_op_free(ut_params->op);
529 * free mbuf - both obuf and ibuf are usually the same,
530 * so check if they point at the same address is necessary,
531 * to avoid freeing the mbuf twice.
533 if (ut_params->obuf) {
534 rte_pktmbuf_free(ut_params->obuf);
535 if (ut_params->ibuf == ut_params->obuf)
539 if (ut_params->ibuf) {
540 rte_pktmbuf_free(ut_params->ibuf);
544 if (ts_params->mbuf_pool != NULL)
545 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
546 rte_mempool_avail_count(ts_params->mbuf_pool));
548 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
550 /* Stop the device */
551 rte_cryptodev_stop(ts_params->valid_devs[0]);
555 test_device_configure_invalid_dev_id(void)
557 struct crypto_testsuite_params *ts_params = &testsuite_params;
558 uint16_t dev_id, num_devs = 0;
560 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
561 "Need at least %d devices for test", 1);
563 /* valid dev_id values */
564 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
566 /* Stop the device in case it's started so it can be configured */
567 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
569 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
570 "Failed test for rte_cryptodev_configure: "
571 "invalid dev_num %u", dev_id);
573 /* invalid dev_id values */
576 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
577 "Failed test for rte_cryptodev_configure: "
578 "invalid dev_num %u", dev_id);
582 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
583 "Failed test for rte_cryptodev_configure:"
584 "invalid dev_num %u", dev_id);
590 test_device_configure_invalid_queue_pair_ids(void)
592 struct crypto_testsuite_params *ts_params = &testsuite_params;
593 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
595 /* Stop the device in case it's started so it can be configured */
596 rte_cryptodev_stop(ts_params->valid_devs[0]);
598 /* valid - one queue pairs */
599 ts_params->conf.nb_queue_pairs = 1;
601 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
603 "Failed to configure cryptodev: dev_id %u, qp_id %u",
604 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
607 /* valid - max value queue pairs */
608 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
610 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
612 "Failed to configure cryptodev: dev_id %u, qp_id %u",
613 ts_params->valid_devs[0],
614 ts_params->conf.nb_queue_pairs);
617 /* invalid - zero queue pairs */
618 ts_params->conf.nb_queue_pairs = 0;
620 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
622 "Failed test for rte_cryptodev_configure, dev_id %u,"
624 ts_params->valid_devs[0],
625 ts_params->conf.nb_queue_pairs);
628 /* invalid - max value supported by field queue pairs */
629 ts_params->conf.nb_queue_pairs = UINT16_MAX;
631 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
633 "Failed test for rte_cryptodev_configure, dev_id %u,"
635 ts_params->valid_devs[0],
636 ts_params->conf.nb_queue_pairs);
639 /* invalid - max value + 1 queue pairs */
640 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
642 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
644 "Failed test for rte_cryptodev_configure, dev_id %u,"
646 ts_params->valid_devs[0],
647 ts_params->conf.nb_queue_pairs);
649 /* revert to original testsuite value */
650 ts_params->conf.nb_queue_pairs = orig_nb_qps;
656 test_queue_pair_descriptor_setup(void)
658 struct crypto_testsuite_params *ts_params = &testsuite_params;
659 struct rte_cryptodev_info dev_info;
660 struct rte_cryptodev_qp_conf qp_conf = {
661 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
666 /* Stop the device in case it's started so it can be configured */
667 rte_cryptodev_stop(ts_params->valid_devs[0]);
670 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
672 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
674 "Failed to configure cryptodev %u",
675 ts_params->valid_devs[0]);
678 * Test various ring sizes on this device. memzones can't be
679 * freed so are re-used if ring is released and re-created.
681 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
683 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
684 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
685 ts_params->valid_devs[0], qp_id, &qp_conf,
686 rte_cryptodev_socket_id(
687 ts_params->valid_devs[0]),
688 ts_params->session_mpool),
690 "rte_cryptodev_queue_pair_setup: num_inflights "
691 "%u on qp %u on cryptodev %u",
692 qp_conf.nb_descriptors, qp_id,
693 ts_params->valid_devs[0]);
696 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
698 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
699 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
700 ts_params->valid_devs[0], qp_id, &qp_conf,
701 rte_cryptodev_socket_id(
702 ts_params->valid_devs[0]),
703 ts_params->session_mpool),
705 " rte_cryptodev_queue_pair_setup: num_inflights"
706 " %u on qp %u on cryptodev %u",
707 qp_conf.nb_descriptors, qp_id,
708 ts_params->valid_devs[0]);
711 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
713 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
714 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
715 ts_params->valid_devs[0], qp_id, &qp_conf,
716 rte_cryptodev_socket_id(
717 ts_params->valid_devs[0]),
718 ts_params->session_mpool),
720 "rte_cryptodev_queue_pair_setup: num_inflights"
721 " %u on qp %u on cryptodev %u",
722 qp_conf.nb_descriptors, qp_id,
723 ts_params->valid_devs[0]);
726 /* invalid number of descriptors - max supported + 2 */
727 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
729 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
730 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
731 ts_params->valid_devs[0], qp_id, &qp_conf,
732 rte_cryptodev_socket_id(
733 ts_params->valid_devs[0]),
734 ts_params->session_mpool),
735 "Unexpectedly passed test for "
736 "rte_cryptodev_queue_pair_setup:"
737 "num_inflights %u on qp %u on cryptodev %u",
738 qp_conf.nb_descriptors, qp_id,
739 ts_params->valid_devs[0]);
742 /* invalid number of descriptors - max value of parameter */
743 qp_conf.nb_descriptors = UINT32_MAX-1;
745 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
746 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
747 ts_params->valid_devs[0], qp_id, &qp_conf,
748 rte_cryptodev_socket_id(
749 ts_params->valid_devs[0]),
750 ts_params->session_mpool),
751 "Unexpectedly passed test for "
752 "rte_cryptodev_queue_pair_setup:"
753 "num_inflights %u on qp %u on cryptodev %u",
754 qp_conf.nb_descriptors, qp_id,
755 ts_params->valid_devs[0]);
758 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
760 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
761 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
762 ts_params->valid_devs[0], qp_id, &qp_conf,
763 rte_cryptodev_socket_id(
764 ts_params->valid_devs[0]),
765 ts_params->session_mpool),
767 " rte_cryptodev_queue_pair_setup:"
768 "num_inflights %u on qp %u on cryptodev %u",
769 qp_conf.nb_descriptors, qp_id,
770 ts_params->valid_devs[0]);
773 /* invalid number of descriptors - max supported + 1 */
774 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
776 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
777 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
778 ts_params->valid_devs[0], qp_id, &qp_conf,
779 rte_cryptodev_socket_id(
780 ts_params->valid_devs[0]),
781 ts_params->session_mpool),
782 "Unexpectedly passed test for "
783 "rte_cryptodev_queue_pair_setup:"
784 "num_inflights %u on qp %u on cryptodev %u",
785 qp_conf.nb_descriptors, qp_id,
786 ts_params->valid_devs[0]);
789 /* test invalid queue pair id */
790 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
792 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
794 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
795 ts_params->valid_devs[0],
797 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
798 ts_params->session_mpool),
799 "Failed test for rte_cryptodev_queue_pair_setup:"
800 "invalid qp %u on cryptodev %u",
801 qp_id, ts_params->valid_devs[0]);
803 qp_id = 0xffff; /*invalid*/
805 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
806 ts_params->valid_devs[0],
808 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
809 ts_params->session_mpool),
810 "Failed test for rte_cryptodev_queue_pair_setup:"
811 "invalid qp %u on cryptodev %u",
812 qp_id, ts_params->valid_devs[0]);
817 /* ***** Plaintext data for tests ***** */
819 const char catch_22_quote_1[] =
820 "There was only one catch and that was Catch-22, which "
821 "specified that a concern for one's safety in the face of "
822 "dangers that were real and immediate was the process of a "
823 "rational mind. Orr was crazy and could be grounded. All he "
824 "had to do was ask; and as soon as he did, he would no longer "
825 "be crazy and would have to fly more missions. Orr would be "
826 "crazy to fly more missions and sane if he didn't, but if he "
827 "was sane he had to fly them. If he flew them he was crazy "
828 "and didn't have to; but if he didn't want to he was sane and "
829 "had to. Yossarian was moved very deeply by the absolute "
830 "simplicity of this clause of Catch-22 and let out a "
831 "respectful whistle. \"That's some catch, that Catch-22\", he "
832 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
834 const char catch_22_quote[] =
835 "What a lousy earth! He wondered how many people were "
836 "destitute that same night even in his own prosperous country, "
837 "how many homes were shanties, how many husbands were drunk "
838 "and wives socked, and how many children were bullied, abused, "
839 "or abandoned. How many families hungered for food they could "
840 "not afford to buy? How many hearts were broken? How many "
841 "suicides would take place that same night, how many people "
842 "would go insane? How many cockroaches and landlords would "
843 "triumph? How many winners were losers, successes failures, "
844 "and rich men poor men? How many wise guys were stupid? How "
845 "many happy endings were unhappy endings? How many honest men "
846 "were liars, brave men cowards, loyal men traitors, how many "
847 "sainted men were corrupt, how many people in positions of "
848 "trust had sold their souls to bodyguards, how many had never "
849 "had souls? How many straight-and-narrow paths were crooked "
850 "paths? How many best families were worst families and how "
851 "many good people were bad people? When you added them all up "
852 "and then subtracted, you might be left with only the children, "
853 "and perhaps with Albert Einstein and an old violinist or "
854 "sculptor somewhere.";
856 #define QUOTE_480_BYTES (480)
857 #define QUOTE_512_BYTES (512)
858 #define QUOTE_768_BYTES (768)
859 #define QUOTE_1024_BYTES (1024)
863 /* ***** SHA1 Hash Tests ***** */
865 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
867 static uint8_t hmac_sha1_key[] = {
868 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
869 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
870 0xDE, 0xF4, 0xDE, 0xAD };
872 /* ***** SHA224 Hash Tests ***** */
874 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
877 /* ***** AES-CBC Cipher Tests ***** */
879 #define CIPHER_KEY_LENGTH_AES_CBC (16)
880 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
882 static uint8_t aes_cbc_key[] = {
883 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
884 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
886 static uint8_t aes_cbc_iv[] = {
887 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
888 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
891 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
893 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
894 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
895 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
896 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
897 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
898 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
899 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
900 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
901 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
902 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
903 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
904 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
905 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
906 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
907 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
908 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
909 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
910 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
911 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
912 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
913 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
914 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
915 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
916 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
917 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
918 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
919 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
920 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
921 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
922 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
923 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
924 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
925 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
926 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
927 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
928 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
929 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
930 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
931 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
932 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
933 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
934 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
935 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
936 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
937 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
938 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
939 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
940 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
941 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
942 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
943 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
944 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
945 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
946 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
947 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
948 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
949 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
950 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
951 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
952 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
953 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
954 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
955 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
956 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
957 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
960 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
961 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
962 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
963 0x18, 0x8c, 0x1d, 0x32
967 /* Multisession Vector context Test */
969 static uint8_t ms_aes_cbc_key0[] = {
970 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
971 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
974 static uint8_t ms_aes_cbc_iv0[] = {
975 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
976 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
979 static const uint8_t ms_aes_cbc_cipher0[] = {
980 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
981 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
982 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
983 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
984 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
985 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
986 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
987 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
988 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
989 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
990 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
991 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
992 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
993 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
994 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
995 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
996 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
997 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
998 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
999 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1000 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1001 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1002 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1003 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1004 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1005 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1006 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1007 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1008 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1009 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1010 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1011 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1012 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1013 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1014 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1015 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1016 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1017 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1018 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1019 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1020 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1021 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1022 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1023 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1024 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1025 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1026 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1027 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1028 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1029 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1030 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1031 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1032 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1033 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1034 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1035 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1036 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1037 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1038 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1039 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1040 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1041 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1042 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1043 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1047 static uint8_t ms_hmac_key0[] = {
1048 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1049 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1050 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1051 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1052 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1053 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1054 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1055 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1058 static const uint8_t ms_hmac_digest0[] = {
1059 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1060 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1061 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1062 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1063 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1064 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1065 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1066 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1070 /* Begin session 1 */
1072 static uint8_t ms_aes_cbc_key1[] = {
1073 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1074 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1077 static uint8_t ms_aes_cbc_iv1[] = {
1078 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1079 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1082 static const uint8_t ms_aes_cbc_cipher1[] = {
1083 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1084 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1085 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1086 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1087 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1088 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1089 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1090 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1091 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1092 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1093 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1094 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1095 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1096 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1097 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1098 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1099 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1100 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1101 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1102 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1103 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1104 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1105 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1106 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1107 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1108 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1109 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1110 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1111 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1112 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1113 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1114 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1115 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1116 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1117 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1118 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1119 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1120 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1121 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1122 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1123 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1124 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1125 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1126 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1127 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1128 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1129 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1130 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1131 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1132 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1133 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1134 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1135 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1136 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1137 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1138 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1139 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1140 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1141 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1142 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1143 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1144 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1145 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1146 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1150 static uint8_t ms_hmac_key1[] = {
1151 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1152 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1153 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1154 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1155 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1156 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1157 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1158 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1161 static const uint8_t ms_hmac_digest1[] = {
1162 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1163 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1164 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1165 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1166 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1167 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1168 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1169 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1172 /* Begin Session 2 */
1173 static uint8_t ms_aes_cbc_key2[] = {
1174 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1175 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1178 static uint8_t ms_aes_cbc_iv2[] = {
1179 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1180 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1183 static const uint8_t ms_aes_cbc_cipher2[] = {
1184 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1185 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1186 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1187 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1188 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1189 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1190 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1191 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1192 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1193 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1194 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1195 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1196 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1197 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1198 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1199 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1200 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1201 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1202 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1203 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1204 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1205 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1206 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1207 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1208 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1209 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1210 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1211 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1212 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1213 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1214 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1215 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1216 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1217 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1218 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1219 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1220 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1221 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1222 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1223 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1224 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1225 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1226 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1227 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1228 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1229 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1230 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1231 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1232 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1233 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1234 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1235 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1236 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1237 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1238 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1239 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1240 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1241 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1242 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1243 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1244 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1245 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1246 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1247 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1250 static uint8_t ms_hmac_key2[] = {
1251 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1252 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1253 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1254 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1255 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1256 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1257 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1258 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1261 static const uint8_t ms_hmac_digest2[] = {
1262 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1263 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1264 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1265 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1266 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1267 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1268 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1269 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1276 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1278 struct crypto_testsuite_params *ts_params = &testsuite_params;
1279 struct crypto_unittest_params *ut_params = &unittest_params;
1281 /* Generate test mbuf data and space for digest */
1282 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1283 catch_22_quote, QUOTE_512_BYTES, 0);
1285 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1286 DIGEST_BYTE_LENGTH_SHA1);
1287 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1289 /* Setup Cipher Parameters */
1290 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1291 ut_params->cipher_xform.next = &ut_params->auth_xform;
1293 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1294 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1295 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1296 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1297 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1298 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1300 /* Setup HMAC Parameters */
1301 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1303 ut_params->auth_xform.next = NULL;
1305 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1306 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1307 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1308 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1309 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1311 ut_params->sess = rte_cryptodev_sym_session_create(
1312 ts_params->session_mpool);
1314 /* Create crypto session*/
1315 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1316 ut_params->sess, &ut_params->cipher_xform,
1317 ts_params->session_mpool);
1318 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1320 /* Generate crypto op data structure */
1321 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1322 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1323 TEST_ASSERT_NOT_NULL(ut_params->op,
1324 "Failed to allocate symmetric crypto operation struct");
1326 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1328 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1330 /* set crypto operation source mbuf */
1331 sym_op->m_src = ut_params->ibuf;
1333 /* Set crypto operation authentication parameters */
1334 sym_op->auth.digest.data = ut_params->digest;
1335 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1336 ut_params->ibuf, QUOTE_512_BYTES);
1338 sym_op->auth.data.offset = 0;
1339 sym_op->auth.data.length = QUOTE_512_BYTES;
1341 /* Copy IV at the end of the crypto operation */
1342 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1343 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1345 /* Set crypto operation cipher parameters */
1346 sym_op->cipher.data.offset = 0;
1347 sym_op->cipher.data.length = QUOTE_512_BYTES;
1349 /* Process crypto operation */
1350 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1351 ut_params->op), "failed to process sym crypto op");
1353 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1354 "crypto op processing failed");
1357 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1360 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1361 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1363 "ciphertext data not as expected");
1365 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1367 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1368 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1369 gbl_driver_id == rte_cryptodev_driver_id_get(
1370 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1371 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1372 DIGEST_BYTE_LENGTH_SHA1,
1373 "Generated digest data not as expected");
1375 return TEST_SUCCESS;
1378 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1380 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1382 static uint8_t hmac_sha512_key[] = {
1383 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1384 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1385 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1386 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1387 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1388 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1389 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1390 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1392 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1393 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1394 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1395 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1396 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1397 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1398 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1399 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1400 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1405 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1406 struct crypto_unittest_params *ut_params,
1407 uint8_t *cipher_key,
1411 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1412 struct crypto_unittest_params *ut_params,
1413 struct crypto_testsuite_params *ts_params,
1414 const uint8_t *cipher,
1415 const uint8_t *digest,
1420 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1421 struct crypto_unittest_params *ut_params,
1422 uint8_t *cipher_key,
1426 /* Setup Cipher Parameters */
1427 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1428 ut_params->cipher_xform.next = NULL;
1430 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1431 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1432 ut_params->cipher_xform.cipher.key.data = cipher_key;
1433 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1434 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1435 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1437 /* Setup HMAC Parameters */
1438 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1439 ut_params->auth_xform.next = &ut_params->cipher_xform;
1441 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1442 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1443 ut_params->auth_xform.auth.key.data = hmac_key;
1444 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1445 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1447 return TEST_SUCCESS;
1452 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1453 struct crypto_unittest_params *ut_params,
1454 struct crypto_testsuite_params *ts_params,
1455 const uint8_t *cipher,
1456 const uint8_t *digest,
1459 /* Generate test mbuf data and digest */
1460 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1463 QUOTE_512_BYTES, 0);
1465 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1466 DIGEST_BYTE_LENGTH_SHA512);
1467 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1469 rte_memcpy(ut_params->digest,
1471 DIGEST_BYTE_LENGTH_SHA512);
1473 /* Generate Crypto op data structure */
1474 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1475 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1476 TEST_ASSERT_NOT_NULL(ut_params->op,
1477 "Failed to allocate symmetric crypto operation struct");
1479 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1481 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1483 /* set crypto operation source mbuf */
1484 sym_op->m_src = ut_params->ibuf;
1486 sym_op->auth.digest.data = ut_params->digest;
1487 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1488 ut_params->ibuf, QUOTE_512_BYTES);
1490 sym_op->auth.data.offset = 0;
1491 sym_op->auth.data.length = QUOTE_512_BYTES;
1493 /* Copy IV at the end of the crypto operation */
1494 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1495 iv, CIPHER_IV_LENGTH_AES_CBC);
1497 sym_op->cipher.data.offset = 0;
1498 sym_op->cipher.data.length = QUOTE_512_BYTES;
1500 /* Process crypto operation */
1501 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1502 ut_params->op), "failed to process sym crypto op");
1504 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1505 "crypto op processing failed");
1507 ut_params->obuf = ut_params->op->sym->m_src;
1510 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1511 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1514 "Plaintext data not as expected");
1517 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1518 "Digest verification failed");
1520 return TEST_SUCCESS;
1524 test_AES_cipheronly_mb_all(void)
1526 struct crypto_testsuite_params *ts_params = &testsuite_params;
1529 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1530 ts_params->op_mpool,
1531 ts_params->session_mpool,
1532 ts_params->valid_devs[0],
1533 rte_cryptodev_driver_id_get(
1534 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1535 BLKCIPHER_AES_CIPHERONLY_TYPE);
1537 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1539 return TEST_SUCCESS;
1543 test_AES_docsis_mb_all(void)
1545 struct crypto_testsuite_params *ts_params = &testsuite_params;
1548 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1549 ts_params->op_mpool,
1550 ts_params->session_mpool,
1551 ts_params->valid_devs[0],
1552 rte_cryptodev_driver_id_get(
1553 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1554 BLKCIPHER_AES_DOCSIS_TYPE);
1556 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1558 return TEST_SUCCESS;
1562 test_AES_docsis_qat_all(void)
1564 struct crypto_testsuite_params *ts_params = &testsuite_params;
1567 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1568 ts_params->op_mpool,
1569 ts_params->session_mpool,
1570 ts_params->valid_devs[0],
1571 rte_cryptodev_driver_id_get(
1572 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1573 BLKCIPHER_AES_DOCSIS_TYPE);
1575 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1577 return TEST_SUCCESS;
1581 test_DES_docsis_qat_all(void)
1583 struct crypto_testsuite_params *ts_params = &testsuite_params;
1586 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1587 ts_params->op_mpool,
1588 ts_params->session_mpool,
1589 ts_params->valid_devs[0],
1590 rte_cryptodev_driver_id_get(
1591 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1592 BLKCIPHER_DES_DOCSIS_TYPE);
1594 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1596 return TEST_SUCCESS;
1600 test_authonly_mb_all(void)
1602 struct crypto_testsuite_params *ts_params = &testsuite_params;
1605 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1606 ts_params->op_mpool,
1607 ts_params->session_mpool,
1608 ts_params->valid_devs[0],
1609 rte_cryptodev_driver_id_get(
1610 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1611 BLKCIPHER_AUTHONLY_TYPE);
1613 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1615 return TEST_SUCCESS;
1619 test_authonly_qat_all(void)
1621 struct crypto_testsuite_params *ts_params = &testsuite_params;
1624 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1625 ts_params->op_mpool,
1626 ts_params->session_mpool,
1627 ts_params->valid_devs[0],
1628 rte_cryptodev_driver_id_get(
1629 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1630 BLKCIPHER_AUTHONLY_TYPE);
1632 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1634 return TEST_SUCCESS;
1637 test_AES_chain_mb_all(void)
1639 struct crypto_testsuite_params *ts_params = &testsuite_params;
1642 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1643 ts_params->op_mpool,
1644 ts_params->session_mpool,
1645 ts_params->valid_devs[0],
1646 rte_cryptodev_driver_id_get(
1647 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1648 BLKCIPHER_AES_CHAIN_TYPE);
1650 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1652 return TEST_SUCCESS;
1655 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1658 test_AES_cipheronly_scheduler_all(void)
1660 struct crypto_testsuite_params *ts_params = &testsuite_params;
1663 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1664 ts_params->op_mpool,
1665 ts_params->session_mpool,
1666 ts_params->valid_devs[0],
1667 rte_cryptodev_driver_id_get(
1668 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1669 BLKCIPHER_AES_CIPHERONLY_TYPE);
1671 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1673 return TEST_SUCCESS;
1677 test_AES_chain_scheduler_all(void)
1679 struct crypto_testsuite_params *ts_params = &testsuite_params;
1682 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1683 ts_params->op_mpool,
1684 ts_params->session_mpool,
1685 ts_params->valid_devs[0],
1686 rte_cryptodev_driver_id_get(
1687 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1688 BLKCIPHER_AES_CHAIN_TYPE);
1690 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1692 return TEST_SUCCESS;
1696 test_authonly_scheduler_all(void)
1698 struct crypto_testsuite_params *ts_params = &testsuite_params;
1701 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1702 ts_params->op_mpool,
1703 ts_params->session_mpool,
1704 ts_params->valid_devs[0],
1705 rte_cryptodev_driver_id_get(
1706 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1707 BLKCIPHER_AUTHONLY_TYPE);
1709 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1711 return TEST_SUCCESS;
1714 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1717 test_AES_chain_openssl_all(void)
1719 struct crypto_testsuite_params *ts_params = &testsuite_params;
1722 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1723 ts_params->op_mpool,
1724 ts_params->session_mpool,
1725 ts_params->valid_devs[0],
1726 rte_cryptodev_driver_id_get(
1727 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1728 BLKCIPHER_AES_CHAIN_TYPE);
1730 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1732 return TEST_SUCCESS;
1736 test_AES_cipheronly_openssl_all(void)
1738 struct crypto_testsuite_params *ts_params = &testsuite_params;
1741 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1742 ts_params->op_mpool,
1743 ts_params->session_mpool,
1744 ts_params->valid_devs[0],
1745 rte_cryptodev_driver_id_get(
1746 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1747 BLKCIPHER_AES_CIPHERONLY_TYPE);
1749 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1751 return TEST_SUCCESS;
1755 test_AES_chain_qat_all(void)
1757 struct crypto_testsuite_params *ts_params = &testsuite_params;
1760 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1761 ts_params->op_mpool,
1762 ts_params->session_mpool,
1763 ts_params->valid_devs[0],
1764 rte_cryptodev_driver_id_get(
1765 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1766 BLKCIPHER_AES_CHAIN_TYPE);
1768 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1770 return TEST_SUCCESS;
1774 test_AES_cipheronly_qat_all(void)
1776 struct crypto_testsuite_params *ts_params = &testsuite_params;
1779 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1780 ts_params->op_mpool,
1781 ts_params->session_mpool,
1782 ts_params->valid_devs[0],
1783 rte_cryptodev_driver_id_get(
1784 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1785 BLKCIPHER_AES_CIPHERONLY_TYPE);
1787 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1789 return TEST_SUCCESS;
1793 test_AES_chain_dpaa_sec_all(void)
1795 struct crypto_testsuite_params *ts_params = &testsuite_params;
1798 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1799 ts_params->op_mpool,
1800 ts_params->session_mpool,
1801 ts_params->valid_devs[0],
1802 rte_cryptodev_driver_id_get(
1803 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1804 BLKCIPHER_AES_CHAIN_TYPE);
1806 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1808 return TEST_SUCCESS;
1812 test_AES_cipheronly_dpaa_sec_all(void)
1814 struct crypto_testsuite_params *ts_params = &testsuite_params;
1817 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1818 ts_params->op_mpool,
1819 ts_params->session_mpool,
1820 ts_params->valid_devs[0],
1821 rte_cryptodev_driver_id_get(
1822 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1823 BLKCIPHER_AES_CIPHERONLY_TYPE);
1825 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1827 return TEST_SUCCESS;
1831 test_authonly_dpaa_sec_all(void)
1833 struct crypto_testsuite_params *ts_params = &testsuite_params;
1836 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1837 ts_params->op_mpool,
1838 ts_params->session_mpool,
1839 ts_params->valid_devs[0],
1840 rte_cryptodev_driver_id_get(
1841 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1842 BLKCIPHER_AUTHONLY_TYPE);
1844 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1846 return TEST_SUCCESS;
1850 test_AES_chain_dpaa2_sec_all(void)
1852 struct crypto_testsuite_params *ts_params = &testsuite_params;
1855 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1856 ts_params->op_mpool,
1857 ts_params->session_mpool,
1858 ts_params->valid_devs[0],
1859 rte_cryptodev_driver_id_get(
1860 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1861 BLKCIPHER_AES_CHAIN_TYPE);
1863 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1865 return TEST_SUCCESS;
1869 test_AES_cipheronly_dpaa2_sec_all(void)
1871 struct crypto_testsuite_params *ts_params = &testsuite_params;
1874 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1875 ts_params->op_mpool,
1876 ts_params->session_mpool,
1877 ts_params->valid_devs[0],
1878 rte_cryptodev_driver_id_get(
1879 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1880 BLKCIPHER_AES_CIPHERONLY_TYPE);
1882 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1884 return TEST_SUCCESS;
1888 test_authonly_dpaa2_sec_all(void)
1890 struct crypto_testsuite_params *ts_params = &testsuite_params;
1893 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1894 ts_params->op_mpool,
1895 ts_params->session_mpool,
1896 ts_params->valid_devs[0],
1897 rte_cryptodev_driver_id_get(
1898 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1899 BLKCIPHER_AUTHONLY_TYPE);
1901 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1903 return TEST_SUCCESS;
1907 test_authonly_openssl_all(void)
1909 struct crypto_testsuite_params *ts_params = &testsuite_params;
1912 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1913 ts_params->op_mpool,
1914 ts_params->session_mpool,
1915 ts_params->valid_devs[0],
1916 rte_cryptodev_driver_id_get(
1917 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1918 BLKCIPHER_AUTHONLY_TYPE);
1920 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1922 return TEST_SUCCESS;
1926 test_AES_chain_armv8_all(void)
1928 struct crypto_testsuite_params *ts_params = &testsuite_params;
1931 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1932 ts_params->op_mpool,
1933 ts_params->session_mpool,
1934 ts_params->valid_devs[0],
1935 rte_cryptodev_driver_id_get(
1936 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1937 BLKCIPHER_AES_CHAIN_TYPE);
1939 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1941 return TEST_SUCCESS;
1945 test_AES_chain_mrvl_all(void)
1947 struct crypto_testsuite_params *ts_params = &testsuite_params;
1950 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1951 ts_params->op_mpool,
1952 ts_params->session_mpool,
1953 ts_params->valid_devs[0],
1954 rte_cryptodev_driver_id_get(
1955 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1956 BLKCIPHER_AES_CHAIN_TYPE);
1958 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1960 return TEST_SUCCESS;
1964 test_AES_cipheronly_mrvl_all(void)
1966 struct crypto_testsuite_params *ts_params = &testsuite_params;
1969 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1970 ts_params->op_mpool,
1971 ts_params->session_mpool,
1972 ts_params->valid_devs[0],
1973 rte_cryptodev_driver_id_get(
1974 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1975 BLKCIPHER_AES_CIPHERONLY_TYPE);
1977 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1979 return TEST_SUCCESS;
1983 test_authonly_mrvl_all(void)
1985 struct crypto_testsuite_params *ts_params = &testsuite_params;
1988 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1989 ts_params->op_mpool,
1990 ts_params->session_mpool,
1991 ts_params->valid_devs[0],
1992 rte_cryptodev_driver_id_get(
1993 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1994 BLKCIPHER_AUTHONLY_TYPE);
1996 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1998 return TEST_SUCCESS;
2002 test_3DES_chain_mrvl_all(void)
2004 struct crypto_testsuite_params *ts_params = &testsuite_params;
2007 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2008 ts_params->op_mpool,
2009 ts_params->session_mpool,
2010 ts_params->valid_devs[0],
2011 rte_cryptodev_driver_id_get(
2012 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2013 BLKCIPHER_3DES_CHAIN_TYPE);
2015 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2017 return TEST_SUCCESS;
2021 test_3DES_cipheronly_mrvl_all(void)
2023 struct crypto_testsuite_params *ts_params = &testsuite_params;
2026 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2027 ts_params->op_mpool,
2028 ts_params->session_mpool,
2029 ts_params->valid_devs[0],
2030 rte_cryptodev_driver_id_get(
2031 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2032 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2034 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2036 return TEST_SUCCESS;
2039 /* ***** SNOW 3G Tests ***** */
2041 create_wireless_algo_hash_session(uint8_t dev_id,
2042 const uint8_t *key, const uint8_t key_len,
2043 const uint8_t iv_len, const uint8_t auth_len,
2044 enum rte_crypto_auth_operation op,
2045 enum rte_crypto_auth_algorithm algo)
2047 uint8_t hash_key[key_len];
2049 struct crypto_testsuite_params *ts_params = &testsuite_params;
2050 struct crypto_unittest_params *ut_params = &unittest_params;
2052 memcpy(hash_key, key, key_len);
2054 TEST_HEXDUMP(stdout, "key:", key, key_len);
2056 /* Setup Authentication Parameters */
2057 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2058 ut_params->auth_xform.next = NULL;
2060 ut_params->auth_xform.auth.op = op;
2061 ut_params->auth_xform.auth.algo = algo;
2062 ut_params->auth_xform.auth.key.length = key_len;
2063 ut_params->auth_xform.auth.key.data = hash_key;
2064 ut_params->auth_xform.auth.digest_length = auth_len;
2065 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2066 ut_params->auth_xform.auth.iv.length = iv_len;
2067 ut_params->sess = rte_cryptodev_sym_session_create(
2068 ts_params->session_mpool);
2070 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2071 &ut_params->auth_xform, ts_params->session_mpool);
2072 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2077 create_wireless_algo_cipher_session(uint8_t dev_id,
2078 enum rte_crypto_cipher_operation op,
2079 enum rte_crypto_cipher_algorithm algo,
2080 const uint8_t *key, const uint8_t key_len,
2083 uint8_t cipher_key[key_len];
2085 struct crypto_testsuite_params *ts_params = &testsuite_params;
2086 struct crypto_unittest_params *ut_params = &unittest_params;
2088 memcpy(cipher_key, key, key_len);
2090 /* Setup Cipher Parameters */
2091 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2092 ut_params->cipher_xform.next = NULL;
2094 ut_params->cipher_xform.cipher.algo = algo;
2095 ut_params->cipher_xform.cipher.op = op;
2096 ut_params->cipher_xform.cipher.key.data = cipher_key;
2097 ut_params->cipher_xform.cipher.key.length = key_len;
2098 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2099 ut_params->cipher_xform.cipher.iv.length = iv_len;
2101 TEST_HEXDUMP(stdout, "key:", key, key_len);
2103 /* Create Crypto session */
2104 ut_params->sess = rte_cryptodev_sym_session_create(
2105 ts_params->session_mpool);
2107 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2108 &ut_params->cipher_xform, ts_params->session_mpool);
2109 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2114 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2115 unsigned int cipher_len,
2116 unsigned int cipher_offset)
2118 struct crypto_testsuite_params *ts_params = &testsuite_params;
2119 struct crypto_unittest_params *ut_params = &unittest_params;
2121 /* Generate Crypto op data structure */
2122 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2123 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2124 TEST_ASSERT_NOT_NULL(ut_params->op,
2125 "Failed to allocate pktmbuf offload");
2127 /* Set crypto operation data parameters */
2128 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2130 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2132 /* set crypto operation source mbuf */
2133 sym_op->m_src = ut_params->ibuf;
2136 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2138 sym_op->cipher.data.length = cipher_len;
2139 sym_op->cipher.data.offset = cipher_offset;
2144 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2145 unsigned int cipher_len,
2146 unsigned int cipher_offset)
2148 struct crypto_testsuite_params *ts_params = &testsuite_params;
2149 struct crypto_unittest_params *ut_params = &unittest_params;
2151 /* Generate Crypto op data structure */
2152 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2153 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2154 TEST_ASSERT_NOT_NULL(ut_params->op,
2155 "Failed to allocate pktmbuf offload");
2157 /* Set crypto operation data parameters */
2158 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2160 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2162 /* set crypto operation source mbuf */
2163 sym_op->m_src = ut_params->ibuf;
2164 sym_op->m_dst = ut_params->obuf;
2167 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2169 sym_op->cipher.data.length = cipher_len;
2170 sym_op->cipher.data.offset = cipher_offset;
2175 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2176 enum rte_crypto_cipher_operation cipher_op,
2177 enum rte_crypto_auth_operation auth_op,
2178 enum rte_crypto_auth_algorithm auth_algo,
2179 enum rte_crypto_cipher_algorithm cipher_algo,
2180 const uint8_t *key, uint8_t key_len,
2181 uint8_t auth_iv_len, uint8_t auth_len,
2182 uint8_t cipher_iv_len)
2185 uint8_t cipher_auth_key[key_len];
2187 struct crypto_testsuite_params *ts_params = &testsuite_params;
2188 struct crypto_unittest_params *ut_params = &unittest_params;
2190 memcpy(cipher_auth_key, key, key_len);
2192 /* Setup Authentication Parameters */
2193 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2194 ut_params->auth_xform.next = NULL;
2196 ut_params->auth_xform.auth.op = auth_op;
2197 ut_params->auth_xform.auth.algo = auth_algo;
2198 ut_params->auth_xform.auth.key.length = key_len;
2199 /* Hash key = cipher key */
2200 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2201 ut_params->auth_xform.auth.digest_length = auth_len;
2202 /* Auth IV will be after cipher IV */
2203 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2204 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2206 /* Setup Cipher Parameters */
2207 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2208 ut_params->cipher_xform.next = &ut_params->auth_xform;
2210 ut_params->cipher_xform.cipher.algo = cipher_algo;
2211 ut_params->cipher_xform.cipher.op = cipher_op;
2212 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2213 ut_params->cipher_xform.cipher.key.length = key_len;
2214 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2215 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2217 TEST_HEXDUMP(stdout, "key:", key, key_len);
2219 /* Create Crypto session*/
2220 ut_params->sess = rte_cryptodev_sym_session_create(
2221 ts_params->session_mpool);
2223 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2224 &ut_params->cipher_xform, ts_params->session_mpool);
2226 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2231 create_wireless_cipher_auth_session(uint8_t dev_id,
2232 enum rte_crypto_cipher_operation cipher_op,
2233 enum rte_crypto_auth_operation auth_op,
2234 enum rte_crypto_auth_algorithm auth_algo,
2235 enum rte_crypto_cipher_algorithm cipher_algo,
2236 const struct wireless_test_data *tdata)
2238 const uint8_t key_len = tdata->key.len;
2239 uint8_t cipher_auth_key[key_len];
2241 struct crypto_testsuite_params *ts_params = &testsuite_params;
2242 struct crypto_unittest_params *ut_params = &unittest_params;
2243 const uint8_t *key = tdata->key.data;
2244 const uint8_t auth_len = tdata->digest.len;
2245 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2246 uint8_t auth_iv_len = tdata->auth_iv.len;
2248 memcpy(cipher_auth_key, key, key_len);
2250 /* Setup Authentication Parameters */
2251 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2252 ut_params->auth_xform.next = NULL;
2254 ut_params->auth_xform.auth.op = auth_op;
2255 ut_params->auth_xform.auth.algo = auth_algo;
2256 ut_params->auth_xform.auth.key.length = key_len;
2257 /* Hash key = cipher key */
2258 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2259 ut_params->auth_xform.auth.digest_length = auth_len;
2260 /* Auth IV will be after cipher IV */
2261 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2262 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2264 /* Setup Cipher Parameters */
2265 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2266 ut_params->cipher_xform.next = &ut_params->auth_xform;
2268 ut_params->cipher_xform.cipher.algo = cipher_algo;
2269 ut_params->cipher_xform.cipher.op = cipher_op;
2270 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2271 ut_params->cipher_xform.cipher.key.length = key_len;
2272 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2273 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2276 TEST_HEXDUMP(stdout, "key:", key, key_len);
2278 /* Create Crypto session*/
2279 ut_params->sess = rte_cryptodev_sym_session_create(
2280 ts_params->session_mpool);
2282 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2283 &ut_params->cipher_xform, ts_params->session_mpool);
2285 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2290 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2291 const struct wireless_test_data *tdata)
2293 return create_wireless_cipher_auth_session(dev_id,
2294 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2295 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2296 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2300 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2301 enum rte_crypto_cipher_operation cipher_op,
2302 enum rte_crypto_auth_operation auth_op,
2303 enum rte_crypto_auth_algorithm auth_algo,
2304 enum rte_crypto_cipher_algorithm cipher_algo,
2305 const uint8_t *key, const uint8_t key_len,
2306 uint8_t auth_iv_len, uint8_t auth_len,
2307 uint8_t cipher_iv_len)
2309 uint8_t auth_cipher_key[key_len];
2311 struct crypto_testsuite_params *ts_params = &testsuite_params;
2312 struct crypto_unittest_params *ut_params = &unittest_params;
2314 memcpy(auth_cipher_key, key, key_len);
2316 /* Setup Authentication Parameters */
2317 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2318 ut_params->auth_xform.auth.op = auth_op;
2319 ut_params->auth_xform.next = &ut_params->cipher_xform;
2320 ut_params->auth_xform.auth.algo = auth_algo;
2321 ut_params->auth_xform.auth.key.length = key_len;
2322 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2323 ut_params->auth_xform.auth.digest_length = auth_len;
2324 /* Auth IV will be after cipher IV */
2325 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2326 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2328 /* Setup Cipher Parameters */
2329 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2330 ut_params->cipher_xform.next = NULL;
2331 ut_params->cipher_xform.cipher.algo = cipher_algo;
2332 ut_params->cipher_xform.cipher.op = cipher_op;
2333 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2334 ut_params->cipher_xform.cipher.key.length = key_len;
2335 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2336 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2338 TEST_HEXDUMP(stdout, "key:", key, key_len);
2340 /* Create Crypto session*/
2341 ut_params->sess = rte_cryptodev_sym_session_create(
2342 ts_params->session_mpool);
2344 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2345 &ut_params->auth_xform, ts_params->session_mpool);
2347 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2353 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2354 unsigned int auth_tag_len,
2355 const uint8_t *iv, unsigned int iv_len,
2356 unsigned int data_pad_len,
2357 enum rte_crypto_auth_operation op,
2358 unsigned int auth_len, unsigned int auth_offset)
2360 struct crypto_testsuite_params *ts_params = &testsuite_params;
2362 struct crypto_unittest_params *ut_params = &unittest_params;
2364 /* Generate Crypto op data structure */
2365 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2366 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2367 TEST_ASSERT_NOT_NULL(ut_params->op,
2368 "Failed to allocate pktmbuf offload");
2370 /* Set crypto operation data parameters */
2371 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2373 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2375 /* set crypto operation source mbuf */
2376 sym_op->m_src = ut_params->ibuf;
2379 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2382 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2383 ut_params->ibuf, auth_tag_len);
2385 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2386 "no room to append auth tag");
2387 ut_params->digest = sym_op->auth.digest.data;
2388 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2389 ut_params->ibuf, data_pad_len);
2390 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2391 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2393 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2395 TEST_HEXDUMP(stdout, "digest:",
2396 sym_op->auth.digest.data,
2399 sym_op->auth.data.length = auth_len;
2400 sym_op->auth.data.offset = auth_offset;
2406 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2407 enum rte_crypto_auth_operation op)
2409 struct crypto_testsuite_params *ts_params = &testsuite_params;
2410 struct crypto_unittest_params *ut_params = &unittest_params;
2412 const uint8_t *auth_tag = tdata->digest.data;
2413 const unsigned int auth_tag_len = tdata->digest.len;
2414 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2415 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2417 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2418 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2419 const uint8_t *auth_iv = tdata->auth_iv.data;
2420 const uint8_t auth_iv_len = tdata->auth_iv.len;
2421 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2422 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2424 /* Generate Crypto op data structure */
2425 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2426 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2427 TEST_ASSERT_NOT_NULL(ut_params->op,
2428 "Failed to allocate pktmbuf offload");
2429 /* Set crypto operation data parameters */
2430 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2432 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2434 /* set crypto operation source mbuf */
2435 sym_op->m_src = ut_params->ibuf;
2438 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2439 ut_params->ibuf, auth_tag_len);
2441 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2442 "no room to append auth tag");
2443 ut_params->digest = sym_op->auth.digest.data;
2444 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2445 ut_params->ibuf, data_pad_len);
2446 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2447 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2449 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2451 TEST_HEXDUMP(stdout, "digest:",
2452 sym_op->auth.digest.data,
2455 /* Copy cipher and auth IVs at the end of the crypto operation */
2456 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2458 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2459 iv_ptr += cipher_iv_len;
2460 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2462 sym_op->cipher.data.length = cipher_len;
2463 sym_op->cipher.data.offset = 0;
2464 sym_op->auth.data.length = auth_len;
2465 sym_op->auth.data.offset = 0;
2471 create_zuc_cipher_hash_generate_operation(
2472 const struct wireless_test_data *tdata)
2474 return create_wireless_cipher_hash_operation(tdata,
2475 RTE_CRYPTO_AUTH_OP_GENERATE);
2479 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2480 const unsigned auth_tag_len,
2481 const uint8_t *auth_iv, uint8_t auth_iv_len,
2482 unsigned data_pad_len,
2483 enum rte_crypto_auth_operation op,
2484 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2485 const unsigned cipher_len, const unsigned cipher_offset,
2486 const unsigned auth_len, const unsigned auth_offset)
2488 struct crypto_testsuite_params *ts_params = &testsuite_params;
2489 struct crypto_unittest_params *ut_params = &unittest_params;
2491 /* Generate Crypto op data structure */
2492 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2493 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2494 TEST_ASSERT_NOT_NULL(ut_params->op,
2495 "Failed to allocate pktmbuf offload");
2496 /* Set crypto operation data parameters */
2497 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2499 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2501 /* set crypto operation source mbuf */
2502 sym_op->m_src = ut_params->ibuf;
2505 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2506 ut_params->ibuf, auth_tag_len);
2508 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2509 "no room to append auth tag");
2510 ut_params->digest = sym_op->auth.digest.data;
2511 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2512 ut_params->ibuf, data_pad_len);
2513 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2514 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2516 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2518 TEST_HEXDUMP(stdout, "digest:",
2519 sym_op->auth.digest.data,
2522 /* Copy cipher and auth IVs at the end of the crypto operation */
2523 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2525 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2526 iv_ptr += cipher_iv_len;
2527 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2529 sym_op->cipher.data.length = cipher_len;
2530 sym_op->cipher.data.offset = cipher_offset;
2531 sym_op->auth.data.length = auth_len;
2532 sym_op->auth.data.offset = auth_offset;
2538 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2539 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2540 const uint8_t *auth_iv, uint8_t auth_iv_len,
2541 unsigned int data_pad_len,
2542 unsigned int cipher_len, unsigned int cipher_offset,
2543 unsigned int auth_len, unsigned int auth_offset)
2545 struct crypto_testsuite_params *ts_params = &testsuite_params;
2546 struct crypto_unittest_params *ut_params = &unittest_params;
2548 /* Generate Crypto op data structure */
2549 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2550 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2551 TEST_ASSERT_NOT_NULL(ut_params->op,
2552 "Failed to allocate pktmbuf offload");
2554 /* Set crypto operation data parameters */
2555 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2557 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2559 /* set crypto operation source mbuf */
2560 sym_op->m_src = ut_params->ibuf;
2563 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2564 ut_params->ibuf, auth_tag_len);
2566 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2567 "no room to append auth tag");
2569 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2570 ut_params->ibuf, data_pad_len);
2572 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2574 TEST_HEXDUMP(stdout, "digest:",
2575 sym_op->auth.digest.data,
2578 /* Copy cipher and auth IVs at the end of the crypto operation */
2579 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2581 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2582 iv_ptr += cipher_iv_len;
2583 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2585 sym_op->cipher.data.length = cipher_len;
2586 sym_op->cipher.data.offset = cipher_offset;
2588 sym_op->auth.data.length = auth_len;
2589 sym_op->auth.data.offset = auth_offset;
2595 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2597 struct crypto_testsuite_params *ts_params = &testsuite_params;
2598 struct crypto_unittest_params *ut_params = &unittest_params;
2601 unsigned plaintext_pad_len;
2602 unsigned plaintext_len;
2605 /* Create SNOW 3G session */
2606 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2607 tdata->key.data, tdata->key.len,
2608 tdata->auth_iv.len, tdata->digest.len,
2609 RTE_CRYPTO_AUTH_OP_GENERATE,
2610 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2614 /* alloc mbuf and set payload */
2615 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2617 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2618 rte_pktmbuf_tailroom(ut_params->ibuf));
2620 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2621 /* Append data which is padded to a multiple of */
2622 /* the algorithms block size */
2623 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2624 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2626 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2628 /* Create SNOW 3G operation */
2629 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2630 tdata->auth_iv.data, tdata->auth_iv.len,
2631 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2632 tdata->validAuthLenInBits.len,
2637 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2639 ut_params->obuf = ut_params->op->sym->m_src;
2640 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2641 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2642 + plaintext_pad_len;
2645 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2648 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2649 "SNOW 3G Generated auth tag not as expected");
2655 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2657 struct crypto_testsuite_params *ts_params = &testsuite_params;
2658 struct crypto_unittest_params *ut_params = &unittest_params;
2661 unsigned plaintext_pad_len;
2662 unsigned plaintext_len;
2665 /* Create SNOW 3G session */
2666 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2667 tdata->key.data, tdata->key.len,
2668 tdata->auth_iv.len, tdata->digest.len,
2669 RTE_CRYPTO_AUTH_OP_VERIFY,
2670 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2673 /* alloc mbuf and set payload */
2674 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2676 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2677 rte_pktmbuf_tailroom(ut_params->ibuf));
2679 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2680 /* Append data which is padded to a multiple of */
2681 /* the algorithms block size */
2682 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2683 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2685 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2687 /* Create SNOW 3G operation */
2688 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2690 tdata->auth_iv.data, tdata->auth_iv.len,
2692 RTE_CRYPTO_AUTH_OP_VERIFY,
2693 tdata->validAuthLenInBits.len,
2698 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2700 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2701 ut_params->obuf = ut_params->op->sym->m_src;
2702 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2703 + plaintext_pad_len;
2706 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2715 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2717 struct crypto_testsuite_params *ts_params = &testsuite_params;
2718 struct crypto_unittest_params *ut_params = &unittest_params;
2721 unsigned plaintext_pad_len;
2722 unsigned plaintext_len;
2725 /* Create KASUMI session */
2726 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2727 tdata->key.data, tdata->key.len,
2728 0, tdata->digest.len,
2729 RTE_CRYPTO_AUTH_OP_GENERATE,
2730 RTE_CRYPTO_AUTH_KASUMI_F9);
2734 /* alloc mbuf and set payload */
2735 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2737 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2738 rte_pktmbuf_tailroom(ut_params->ibuf));
2740 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2741 /* Append data which is padded to a multiple of */
2742 /* the algorithms block size */
2743 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2744 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2746 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2748 /* Create KASUMI operation */
2749 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2751 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2752 tdata->plaintext.len,
2757 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2759 ut_params->obuf = ut_params->op->sym->m_src;
2760 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2761 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2762 + plaintext_pad_len;
2765 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2768 DIGEST_BYTE_LENGTH_KASUMI_F9,
2769 "KASUMI Generated auth tag not as expected");
2775 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2777 struct crypto_testsuite_params *ts_params = &testsuite_params;
2778 struct crypto_unittest_params *ut_params = &unittest_params;
2781 unsigned plaintext_pad_len;
2782 unsigned plaintext_len;
2785 /* Create KASUMI session */
2786 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2787 tdata->key.data, tdata->key.len,
2788 0, tdata->digest.len,
2789 RTE_CRYPTO_AUTH_OP_VERIFY,
2790 RTE_CRYPTO_AUTH_KASUMI_F9);
2793 /* alloc mbuf and set payload */
2794 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2796 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2797 rte_pktmbuf_tailroom(ut_params->ibuf));
2799 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2800 /* Append data which is padded to a multiple */
2801 /* of the algorithms block size */
2802 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2803 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2805 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2807 /* Create KASUMI operation */
2808 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2812 RTE_CRYPTO_AUTH_OP_VERIFY,
2813 tdata->plaintext.len,
2818 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2820 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2821 ut_params->obuf = ut_params->op->sym->m_src;
2822 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2823 + plaintext_pad_len;
2826 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2835 test_snow3g_hash_generate_test_case_1(void)
2837 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2841 test_snow3g_hash_generate_test_case_2(void)
2843 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2847 test_snow3g_hash_generate_test_case_3(void)
2849 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2853 test_snow3g_hash_generate_test_case_4(void)
2855 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2859 test_snow3g_hash_generate_test_case_5(void)
2861 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2865 test_snow3g_hash_generate_test_case_6(void)
2867 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2871 test_snow3g_hash_verify_test_case_1(void)
2873 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2878 test_snow3g_hash_verify_test_case_2(void)
2880 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2884 test_snow3g_hash_verify_test_case_3(void)
2886 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2890 test_snow3g_hash_verify_test_case_4(void)
2892 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2896 test_snow3g_hash_verify_test_case_5(void)
2898 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2902 test_snow3g_hash_verify_test_case_6(void)
2904 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2908 test_kasumi_hash_generate_test_case_1(void)
2910 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2914 test_kasumi_hash_generate_test_case_2(void)
2916 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2920 test_kasumi_hash_generate_test_case_3(void)
2922 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2926 test_kasumi_hash_generate_test_case_4(void)
2928 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2932 test_kasumi_hash_generate_test_case_5(void)
2934 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2938 test_kasumi_hash_generate_test_case_6(void)
2940 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2944 test_kasumi_hash_verify_test_case_1(void)
2946 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2950 test_kasumi_hash_verify_test_case_2(void)
2952 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2956 test_kasumi_hash_verify_test_case_3(void)
2958 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2962 test_kasumi_hash_verify_test_case_4(void)
2964 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2968 test_kasumi_hash_verify_test_case_5(void)
2970 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2974 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2976 struct crypto_testsuite_params *ts_params = &testsuite_params;
2977 struct crypto_unittest_params *ut_params = &unittest_params;
2980 uint8_t *plaintext, *ciphertext;
2981 unsigned plaintext_pad_len;
2982 unsigned plaintext_len;
2984 /* Create KASUMI session */
2985 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2986 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2987 RTE_CRYPTO_CIPHER_KASUMI_F8,
2988 tdata->key.data, tdata->key.len,
2989 tdata->cipher_iv.len);
2993 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2995 /* Clear mbuf payload */
2996 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2997 rte_pktmbuf_tailroom(ut_params->ibuf));
2999 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3000 /* Append data which is padded to a multiple */
3001 /* of the algorithms block size */
3002 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3003 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3005 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3007 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3009 /* Create KASUMI operation */
3010 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3011 tdata->cipher_iv.len,
3012 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3013 tdata->validCipherOffsetInBits.len);
3017 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3019 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3021 ut_params->obuf = ut_params->op->sym->m_dst;
3022 if (ut_params->obuf)
3023 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3025 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3027 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3029 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3030 (tdata->validCipherOffsetInBits.len >> 3);
3032 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3034 reference_ciphertext,
3035 tdata->validCipherLenInBits.len,
3036 "KASUMI Ciphertext data not as expected");
3041 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3043 struct crypto_testsuite_params *ts_params = &testsuite_params;
3044 struct crypto_unittest_params *ut_params = &unittest_params;
3048 unsigned int plaintext_pad_len;
3049 unsigned int plaintext_len;
3051 uint8_t buffer[10000];
3052 const uint8_t *ciphertext;
3054 struct rte_cryptodev_info dev_info;
3056 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3057 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3058 printf("Device doesn't support scatter-gather. "
3063 /* Create KASUMI session */
3064 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3065 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3066 RTE_CRYPTO_CIPHER_KASUMI_F8,
3067 tdata->key.data, tdata->key.len,
3068 tdata->cipher_iv.len);
3072 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3075 /* Append data which is padded to a multiple */
3076 /* of the algorithms block size */
3077 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3079 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3080 plaintext_pad_len, 10, 0);
3082 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3084 /* Create KASUMI operation */
3085 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3086 tdata->cipher_iv.len,
3087 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3088 tdata->validCipherOffsetInBits.len);
3092 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3094 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3096 ut_params->obuf = ut_params->op->sym->m_dst;
3098 if (ut_params->obuf)
3099 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3100 plaintext_len, buffer);
3102 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3103 tdata->validCipherOffsetInBits.len >> 3,
3104 plaintext_len, buffer);
3107 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3109 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3110 (tdata->validCipherOffsetInBits.len >> 3);
3112 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3114 reference_ciphertext,
3115 tdata->validCipherLenInBits.len,
3116 "KASUMI Ciphertext data not as expected");
3121 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3123 struct crypto_testsuite_params *ts_params = &testsuite_params;
3124 struct crypto_unittest_params *ut_params = &unittest_params;
3127 uint8_t *plaintext, *ciphertext;
3128 unsigned plaintext_pad_len;
3129 unsigned plaintext_len;
3131 /* Create KASUMI session */
3132 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3133 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3134 RTE_CRYPTO_CIPHER_KASUMI_F8,
3135 tdata->key.data, tdata->key.len,
3136 tdata->cipher_iv.len);
3140 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3141 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3143 /* Clear mbuf payload */
3144 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3145 rte_pktmbuf_tailroom(ut_params->ibuf));
3147 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3148 /* Append data which is padded to a multiple */
3149 /* of the algorithms block size */
3150 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3151 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3153 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3154 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3156 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3158 /* Create KASUMI operation */
3159 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3160 tdata->cipher_iv.len,
3161 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3162 tdata->validCipherOffsetInBits.len);
3166 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3168 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3170 ut_params->obuf = ut_params->op->sym->m_dst;
3171 if (ut_params->obuf)
3172 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3174 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3176 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3178 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3179 (tdata->validCipherOffsetInBits.len >> 3);
3181 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3183 reference_ciphertext,
3184 tdata->validCipherLenInBits.len,
3185 "KASUMI Ciphertext data not as expected");
3190 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3192 struct crypto_testsuite_params *ts_params = &testsuite_params;
3193 struct crypto_unittest_params *ut_params = &unittest_params;
3196 unsigned int plaintext_pad_len;
3197 unsigned int plaintext_len;
3199 const uint8_t *ciphertext;
3200 uint8_t buffer[2048];
3202 struct rte_cryptodev_info dev_info;
3204 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3205 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3206 printf("Device doesn't support scatter-gather. "
3211 /* Create KASUMI session */
3212 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3213 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3214 RTE_CRYPTO_CIPHER_KASUMI_F8,
3215 tdata->key.data, tdata->key.len,
3216 tdata->cipher_iv.len);
3220 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3221 /* Append data which is padded to a multiple */
3222 /* of the algorithms block size */
3223 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3225 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3226 plaintext_pad_len, 10, 0);
3227 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3228 plaintext_pad_len, 3, 0);
3230 /* Append data which is padded to a multiple */
3231 /* of the algorithms block size */
3232 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3234 /* Create KASUMI operation */
3235 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3236 tdata->cipher_iv.len,
3237 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3238 tdata->validCipherOffsetInBits.len);
3242 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3244 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3246 ut_params->obuf = ut_params->op->sym->m_dst;
3247 if (ut_params->obuf)
3248 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3249 plaintext_pad_len, buffer);
3251 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3252 tdata->validCipherOffsetInBits.len >> 3,
3253 plaintext_pad_len, buffer);
3255 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3256 (tdata->validCipherOffsetInBits.len >> 3);
3258 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3260 reference_ciphertext,
3261 tdata->validCipherLenInBits.len,
3262 "KASUMI Ciphertext data not as expected");
3268 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3270 struct crypto_testsuite_params *ts_params = &testsuite_params;
3271 struct crypto_unittest_params *ut_params = &unittest_params;
3274 uint8_t *ciphertext, *plaintext;
3275 unsigned ciphertext_pad_len;
3276 unsigned ciphertext_len;
3278 /* Create KASUMI session */
3279 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3280 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3281 RTE_CRYPTO_CIPHER_KASUMI_F8,
3282 tdata->key.data, tdata->key.len,
3283 tdata->cipher_iv.len);
3287 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3288 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3290 /* Clear mbuf payload */
3291 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3292 rte_pktmbuf_tailroom(ut_params->ibuf));
3294 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3295 /* Append data which is padded to a multiple */
3296 /* of the algorithms block size */
3297 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3298 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3299 ciphertext_pad_len);
3300 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3301 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3303 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3305 /* Create KASUMI operation */
3306 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3307 tdata->cipher_iv.len,
3308 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3309 tdata->validCipherOffsetInBits.len);
3313 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3315 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3317 ut_params->obuf = ut_params->op->sym->m_dst;
3318 if (ut_params->obuf)
3319 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3321 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3323 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3325 const uint8_t *reference_plaintext = tdata->plaintext.data +
3326 (tdata->validCipherOffsetInBits.len >> 3);
3328 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3330 reference_plaintext,
3331 tdata->validCipherLenInBits.len,
3332 "KASUMI Plaintext data not as expected");
3337 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3339 struct crypto_testsuite_params *ts_params = &testsuite_params;
3340 struct crypto_unittest_params *ut_params = &unittest_params;
3343 uint8_t *ciphertext, *plaintext;
3344 unsigned ciphertext_pad_len;
3345 unsigned ciphertext_len;
3347 /* Create KASUMI session */
3348 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3349 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3350 RTE_CRYPTO_CIPHER_KASUMI_F8,
3351 tdata->key.data, tdata->key.len,
3352 tdata->cipher_iv.len);
3356 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3358 /* Clear mbuf payload */
3359 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3360 rte_pktmbuf_tailroom(ut_params->ibuf));
3362 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3363 /* Append data which is padded to a multiple */
3364 /* of the algorithms block size */
3365 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3366 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3367 ciphertext_pad_len);
3368 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3370 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3372 /* Create KASUMI operation */
3373 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3374 tdata->cipher_iv.len,
3375 tdata->ciphertext.len,
3376 tdata->validCipherOffsetInBits.len);
3380 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3382 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3384 ut_params->obuf = ut_params->op->sym->m_dst;
3385 if (ut_params->obuf)
3386 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3388 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3390 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3392 const uint8_t *reference_plaintext = tdata->plaintext.data +
3393 (tdata->validCipherOffsetInBits.len >> 3);
3395 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3397 reference_plaintext,
3398 tdata->validCipherLenInBits.len,
3399 "KASUMI Plaintext data not as expected");
3404 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3406 struct crypto_testsuite_params *ts_params = &testsuite_params;
3407 struct crypto_unittest_params *ut_params = &unittest_params;
3410 uint8_t *plaintext, *ciphertext;
3411 unsigned plaintext_pad_len;
3412 unsigned plaintext_len;
3414 /* Create SNOW 3G session */
3415 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3416 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3417 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3418 tdata->key.data, tdata->key.len,
3419 tdata->cipher_iv.len);
3423 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3425 /* Clear mbuf payload */
3426 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3427 rte_pktmbuf_tailroom(ut_params->ibuf));
3429 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3430 /* Append data which is padded to a multiple of */
3431 /* the algorithms block size */
3432 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3433 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3435 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3437 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3439 /* Create SNOW 3G operation */
3440 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3441 tdata->cipher_iv.len,
3442 tdata->validCipherLenInBits.len,
3447 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3449 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3451 ut_params->obuf = ut_params->op->sym->m_dst;
3452 if (ut_params->obuf)
3453 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3455 ciphertext = plaintext;
3457 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3460 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3462 tdata->ciphertext.data,
3463 tdata->validDataLenInBits.len,
3464 "SNOW 3G Ciphertext data not as expected");
3470 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3472 struct crypto_testsuite_params *ts_params = &testsuite_params;
3473 struct crypto_unittest_params *ut_params = &unittest_params;
3474 uint8_t *plaintext, *ciphertext;
3477 unsigned plaintext_pad_len;
3478 unsigned plaintext_len;
3480 /* Create SNOW 3G session */
3481 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3482 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3483 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3484 tdata->key.data, tdata->key.len,
3485 tdata->cipher_iv.len);
3489 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3490 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3492 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3493 "Failed to allocate input buffer in mempool");
3494 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3495 "Failed to allocate output buffer in mempool");
3497 /* Clear mbuf payload */
3498 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3499 rte_pktmbuf_tailroom(ut_params->ibuf));
3501 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3502 /* Append data which is padded to a multiple of */
3503 /* the algorithms block size */
3504 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3505 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3507 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3508 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3510 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3512 /* Create SNOW 3G operation */
3513 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3514 tdata->cipher_iv.len,
3515 tdata->validCipherLenInBits.len,
3520 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3522 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3524 ut_params->obuf = ut_params->op->sym->m_dst;
3525 if (ut_params->obuf)
3526 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3528 ciphertext = plaintext;
3530 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3533 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3535 tdata->ciphertext.data,
3536 tdata->validDataLenInBits.len,
3537 "SNOW 3G Ciphertext data not as expected");
3542 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3544 struct crypto_testsuite_params *ts_params = &testsuite_params;
3545 struct crypto_unittest_params *ut_params = &unittest_params;
3548 unsigned int plaintext_pad_len;
3549 unsigned int plaintext_len;
3550 uint8_t buffer[10000];
3551 const uint8_t *ciphertext;
3553 struct rte_cryptodev_info dev_info;
3555 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3556 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3557 printf("Device doesn't support scatter-gather. "
3562 /* Create SNOW 3G session */
3563 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3564 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3565 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3566 tdata->key.data, tdata->key.len,
3567 tdata->cipher_iv.len);
3571 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3572 /* Append data which is padded to a multiple of */
3573 /* the algorithms block size */
3574 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3576 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3577 plaintext_pad_len, 10, 0);
3578 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3579 plaintext_pad_len, 3, 0);
3581 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3582 "Failed to allocate input buffer in mempool");
3583 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3584 "Failed to allocate output buffer in mempool");
3586 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3588 /* Create SNOW 3G operation */
3589 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3590 tdata->cipher_iv.len,
3591 tdata->validCipherLenInBits.len,
3596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3600 ut_params->obuf = ut_params->op->sym->m_dst;
3601 if (ut_params->obuf)
3602 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3603 plaintext_len, buffer);
3605 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3606 plaintext_len, buffer);
3608 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3611 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3613 tdata->ciphertext.data,
3614 tdata->validDataLenInBits.len,
3615 "SNOW 3G Ciphertext data not as expected");
3620 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3622 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3624 uint8_t curr_byte, prev_byte;
3625 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3626 uint8_t lower_byte_mask = (1 << offset) - 1;
3629 prev_byte = buffer[0];
3630 buffer[0] >>= offset;
3632 for (i = 1; i < length_in_bytes; i++) {
3633 curr_byte = buffer[i];
3634 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3635 (curr_byte >> offset);
3636 prev_byte = curr_byte;
3641 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3643 struct crypto_testsuite_params *ts_params = &testsuite_params;
3644 struct crypto_unittest_params *ut_params = &unittest_params;
3645 uint8_t *plaintext, *ciphertext;
3647 uint32_t plaintext_len;
3648 uint32_t plaintext_pad_len;
3649 uint8_t extra_offset = 4;
3650 uint8_t *expected_ciphertext_shifted;
3652 /* Create SNOW 3G session */
3653 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3654 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3655 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3656 tdata->key.data, tdata->key.len,
3657 tdata->cipher_iv.len);
3661 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3662 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3664 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3665 "Failed to allocate input buffer in mempool");
3666 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3667 "Failed to allocate output buffer in mempool");
3669 /* Clear mbuf payload */
3670 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3671 rte_pktmbuf_tailroom(ut_params->ibuf));
3673 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3675 * Append data which is padded to a
3676 * multiple of the algorithms block size
3678 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3680 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3683 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3685 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3686 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3688 #ifdef RTE_APP_TEST_DEBUG
3689 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3691 /* Create SNOW 3G operation */
3692 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3693 tdata->cipher_iv.len,
3694 tdata->validCipherLenInBits.len,
3699 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3701 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3703 ut_params->obuf = ut_params->op->sym->m_dst;
3704 if (ut_params->obuf)
3705 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3707 ciphertext = plaintext;
3709 #ifdef RTE_APP_TEST_DEBUG
3710 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3713 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3715 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3716 "failed to reserve memory for ciphertext shifted\n");
3718 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3719 ceil_byte_length(tdata->ciphertext.len));
3720 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3723 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3725 expected_ciphertext_shifted,
3726 tdata->validDataLenInBits.len,
3728 "SNOW 3G Ciphertext data not as expected");
3732 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3734 struct crypto_testsuite_params *ts_params = &testsuite_params;
3735 struct crypto_unittest_params *ut_params = &unittest_params;
3739 uint8_t *plaintext, *ciphertext;
3740 unsigned ciphertext_pad_len;
3741 unsigned ciphertext_len;
3743 /* Create SNOW 3G session */
3744 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3745 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3746 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3747 tdata->key.data, tdata->key.len,
3748 tdata->cipher_iv.len);
3752 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3754 /* Clear mbuf payload */
3755 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3756 rte_pktmbuf_tailroom(ut_params->ibuf));
3758 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3759 /* Append data which is padded to a multiple of */
3760 /* the algorithms block size */
3761 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3762 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3763 ciphertext_pad_len);
3764 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3766 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3768 /* Create SNOW 3G operation */
3769 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3770 tdata->cipher_iv.len,
3771 tdata->validCipherLenInBits.len,
3776 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3778 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3779 ut_params->obuf = ut_params->op->sym->m_dst;
3780 if (ut_params->obuf)
3781 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3783 plaintext = ciphertext;
3785 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3788 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3789 tdata->plaintext.data,
3790 tdata->validDataLenInBits.len,
3791 "SNOW 3G Plaintext data not as expected");
3795 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3797 struct crypto_testsuite_params *ts_params = &testsuite_params;
3798 struct crypto_unittest_params *ut_params = &unittest_params;
3802 uint8_t *plaintext, *ciphertext;
3803 unsigned ciphertext_pad_len;
3804 unsigned ciphertext_len;
3806 /* Create SNOW 3G session */
3807 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3808 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3809 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3810 tdata->key.data, tdata->key.len,
3811 tdata->cipher_iv.len);
3815 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3816 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3818 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3819 "Failed to allocate input buffer");
3820 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3821 "Failed to allocate output buffer");
3823 /* Clear mbuf payload */
3824 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3825 rte_pktmbuf_tailroom(ut_params->ibuf));
3827 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3828 rte_pktmbuf_tailroom(ut_params->obuf));
3830 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3831 /* Append data which is padded to a multiple of */
3832 /* the algorithms block size */
3833 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3834 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3835 ciphertext_pad_len);
3836 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3837 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3839 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3841 /* Create SNOW 3G operation */
3842 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3843 tdata->cipher_iv.len,
3844 tdata->validCipherLenInBits.len,
3849 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3851 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3852 ut_params->obuf = ut_params->op->sym->m_dst;
3853 if (ut_params->obuf)
3854 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3856 plaintext = ciphertext;
3858 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3861 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3862 tdata->plaintext.data,
3863 tdata->validDataLenInBits.len,
3864 "SNOW 3G Plaintext data not as expected");
3869 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3871 struct crypto_testsuite_params *ts_params = &testsuite_params;
3872 struct crypto_unittest_params *ut_params = &unittest_params;
3876 uint8_t *plaintext, *ciphertext;
3877 unsigned int plaintext_pad_len;
3878 unsigned int plaintext_len;
3880 struct rte_cryptodev_sym_capability_idx cap_idx;
3882 /* Check if device supports ZUC EEA3 */
3883 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3884 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3886 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3890 /* Check if device supports ZUC EIA3 */
3891 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3892 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3894 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3898 /* Create ZUC session */
3899 retval = create_zuc_cipher_auth_encrypt_generate_session(
3900 ts_params->valid_devs[0],
3904 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3906 /* clear mbuf payload */
3907 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3908 rte_pktmbuf_tailroom(ut_params->ibuf));
3910 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3911 /* Append data which is padded to a multiple of */
3912 /* the algorithms block size */
3913 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3914 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3916 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3918 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3920 /* Create ZUC operation */
3921 retval = create_zuc_cipher_hash_generate_operation(tdata);
3925 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3927 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3928 ut_params->obuf = ut_params->op->sym->m_src;
3929 if (ut_params->obuf)
3930 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3932 ciphertext = plaintext;
3934 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3936 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3938 tdata->ciphertext.data,
3939 tdata->validDataLenInBits.len,
3940 "ZUC Ciphertext data not as expected");
3942 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3943 + plaintext_pad_len;
3946 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3950 "ZUC Generated auth tag not as expected");
3955 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3957 struct crypto_testsuite_params *ts_params = &testsuite_params;
3958 struct crypto_unittest_params *ut_params = &unittest_params;
3962 uint8_t *plaintext, *ciphertext;
3963 unsigned plaintext_pad_len;
3964 unsigned plaintext_len;
3966 /* Create SNOW 3G session */
3967 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3968 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3969 RTE_CRYPTO_AUTH_OP_GENERATE,
3970 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3971 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3972 tdata->key.data, tdata->key.len,
3973 tdata->auth_iv.len, tdata->digest.len,
3974 tdata->cipher_iv.len);
3977 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3979 /* clear mbuf payload */
3980 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3981 rte_pktmbuf_tailroom(ut_params->ibuf));
3983 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3984 /* Append data which is padded to a multiple of */
3985 /* the algorithms block size */
3986 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3987 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3989 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3991 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3993 /* Create SNOW 3G operation */
3994 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3995 tdata->digest.len, tdata->auth_iv.data,
3997 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3998 tdata->cipher_iv.data, tdata->cipher_iv.len,
3999 tdata->validCipherLenInBits.len,
4001 tdata->validAuthLenInBits.len,
4007 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4009 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4010 ut_params->obuf = ut_params->op->sym->m_src;
4011 if (ut_params->obuf)
4012 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4014 ciphertext = plaintext;
4016 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4018 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4020 tdata->ciphertext.data,
4021 tdata->validDataLenInBits.len,
4022 "SNOW 3G Ciphertext data not as expected");
4024 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4025 + plaintext_pad_len;
4028 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4031 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4032 "SNOW 3G Generated auth tag not as expected");
4036 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4038 struct crypto_testsuite_params *ts_params = &testsuite_params;
4039 struct crypto_unittest_params *ut_params = &unittest_params;
4043 uint8_t *plaintext, *ciphertext;
4044 unsigned plaintext_pad_len;
4045 unsigned plaintext_len;
4047 /* Create SNOW 3G session */
4048 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4049 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4050 RTE_CRYPTO_AUTH_OP_GENERATE,
4051 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4052 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4053 tdata->key.data, tdata->key.len,
4054 tdata->auth_iv.len, tdata->digest.len,
4055 tdata->cipher_iv.len);
4059 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4061 /* clear mbuf payload */
4062 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4063 rte_pktmbuf_tailroom(ut_params->ibuf));
4065 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4066 /* Append data which is padded to a multiple of */
4067 /* the algorithms block size */
4068 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4069 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4071 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4073 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4075 /* Create SNOW 3G operation */
4076 retval = create_wireless_algo_auth_cipher_operation(
4078 tdata->cipher_iv.data, tdata->cipher_iv.len,
4079 tdata->auth_iv.data, tdata->auth_iv.len,
4081 tdata->validCipherLenInBits.len,
4083 tdata->validAuthLenInBits.len,
4089 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4091 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4092 ut_params->obuf = ut_params->op->sym->m_src;
4093 if (ut_params->obuf)
4094 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4096 ciphertext = plaintext;
4098 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4099 + plaintext_pad_len;
4100 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4103 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4105 tdata->ciphertext.data,
4106 tdata->validDataLenInBits.len,
4107 "SNOW 3G Ciphertext data not as expected");
4110 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4113 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4114 "SNOW 3G Generated auth tag not as expected");
4119 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4121 struct crypto_testsuite_params *ts_params = &testsuite_params;
4122 struct crypto_unittest_params *ut_params = &unittest_params;
4126 uint8_t *plaintext, *ciphertext;
4127 unsigned plaintext_pad_len;
4128 unsigned plaintext_len;
4130 /* Create KASUMI session */
4131 retval = create_wireless_algo_auth_cipher_session(
4132 ts_params->valid_devs[0],
4133 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4134 RTE_CRYPTO_AUTH_OP_GENERATE,
4135 RTE_CRYPTO_AUTH_KASUMI_F9,
4136 RTE_CRYPTO_CIPHER_KASUMI_F8,
4137 tdata->key.data, tdata->key.len,
4138 0, tdata->digest.len,
4139 tdata->cipher_iv.len);
4142 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4144 /* clear mbuf payload */
4145 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4146 rte_pktmbuf_tailroom(ut_params->ibuf));
4148 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4149 /* Append data which is padded to a multiple of */
4150 /* the algorithms block size */
4151 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4152 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4154 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4156 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4158 /* Create KASUMI operation */
4159 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4160 tdata->cipher_iv.data, tdata->cipher_iv.len,
4163 tdata->validCipherLenInBits.len,
4164 tdata->validCipherOffsetInBits.len,
4165 tdata->validAuthLenInBits.len,
4172 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4174 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4175 if (ut_params->op->sym->m_dst)
4176 ut_params->obuf = ut_params->op->sym->m_dst;
4178 ut_params->obuf = ut_params->op->sym->m_src;
4180 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4181 tdata->validCipherOffsetInBits.len >> 3);
4183 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4184 (tdata->validCipherOffsetInBits.len >> 3);
4186 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4188 reference_ciphertext,
4189 tdata->validCipherLenInBits.len,
4190 "KASUMI Ciphertext data not as expected");
4191 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4192 + plaintext_pad_len;
4195 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4198 DIGEST_BYTE_LENGTH_KASUMI_F9,
4199 "KASUMI Generated auth tag not as expected");
4204 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4206 struct crypto_testsuite_params *ts_params = &testsuite_params;
4207 struct crypto_unittest_params *ut_params = &unittest_params;
4211 uint8_t *plaintext, *ciphertext;
4212 unsigned plaintext_pad_len;
4213 unsigned plaintext_len;
4215 /* Create KASUMI session */
4216 retval = create_wireless_algo_cipher_auth_session(
4217 ts_params->valid_devs[0],
4218 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4219 RTE_CRYPTO_AUTH_OP_GENERATE,
4220 RTE_CRYPTO_AUTH_KASUMI_F9,
4221 RTE_CRYPTO_CIPHER_KASUMI_F8,
4222 tdata->key.data, tdata->key.len,
4223 0, tdata->digest.len,
4224 tdata->cipher_iv.len);
4228 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4230 /* clear mbuf payload */
4231 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4232 rte_pktmbuf_tailroom(ut_params->ibuf));
4234 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4235 /* Append data which is padded to a multiple of */
4236 /* the algorithms block size */
4237 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4238 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4240 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4242 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4244 /* Create KASUMI operation */
4245 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4246 tdata->digest.len, NULL, 0,
4247 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4248 tdata->cipher_iv.data, tdata->cipher_iv.len,
4249 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4250 tdata->validCipherOffsetInBits.len,
4251 tdata->validAuthLenInBits.len,
4257 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4259 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4261 if (ut_params->op->sym->m_dst)
4262 ut_params->obuf = ut_params->op->sym->m_dst;
4264 ut_params->obuf = ut_params->op->sym->m_src;
4266 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4267 tdata->validCipherOffsetInBits.len >> 3);
4269 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4270 + plaintext_pad_len;
4272 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4273 (tdata->validCipherOffsetInBits.len >> 3);
4275 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4277 reference_ciphertext,
4278 tdata->validCipherLenInBits.len,
4279 "KASUMI Ciphertext data not as expected");
4282 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4285 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4286 "KASUMI Generated auth tag not as expected");
4291 test_zuc_encryption(const struct wireless_test_data *tdata)
4293 struct crypto_testsuite_params *ts_params = &testsuite_params;
4294 struct crypto_unittest_params *ut_params = &unittest_params;
4297 uint8_t *plaintext, *ciphertext;
4298 unsigned plaintext_pad_len;
4299 unsigned plaintext_len;
4301 struct rte_cryptodev_sym_capability_idx cap_idx;
4303 /* Check if device supports ZUC EEA3 */
4304 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4305 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4307 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4311 /* Create ZUC session */
4312 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4313 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4314 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4315 tdata->key.data, tdata->key.len,
4316 tdata->cipher_iv.len);
4320 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4322 /* Clear mbuf payload */
4323 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4324 rte_pktmbuf_tailroom(ut_params->ibuf));
4326 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4327 /* Append data which is padded to a multiple */
4328 /* of the algorithms block size */
4329 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4330 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4332 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4334 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4336 /* Create ZUC operation */
4337 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4338 tdata->cipher_iv.len,
4339 tdata->plaintext.len,
4344 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4346 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4348 ut_params->obuf = ut_params->op->sym->m_dst;
4349 if (ut_params->obuf)
4350 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4352 ciphertext = plaintext;
4354 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4357 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4359 tdata->ciphertext.data,
4360 tdata->validCipherLenInBits.len,
4361 "ZUC Ciphertext data not as expected");
4366 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4368 struct crypto_testsuite_params *ts_params = &testsuite_params;
4369 struct crypto_unittest_params *ut_params = &unittest_params;
4373 unsigned int plaintext_pad_len;
4374 unsigned int plaintext_len;
4375 const uint8_t *ciphertext;
4376 uint8_t ciphertext_buffer[2048];
4377 struct rte_cryptodev_info dev_info;
4379 struct rte_cryptodev_sym_capability_idx cap_idx;
4381 /* Check if device supports ZUC EEA3 */
4382 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4383 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4385 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4389 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4390 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4391 printf("Device doesn't support scatter-gather. "
4396 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4398 /* Append data which is padded to a multiple */
4399 /* of the algorithms block size */
4400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4402 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4403 plaintext_pad_len, 10, 0);
4405 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4406 tdata->plaintext.data);
4408 /* Create ZUC session */
4409 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4410 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4411 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4412 tdata->key.data, tdata->key.len,
4413 tdata->cipher_iv.len);
4417 /* Clear mbuf payload */
4419 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4421 /* Create ZUC operation */
4422 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4423 tdata->cipher_iv.len, tdata->plaintext.len,
4428 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4430 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4432 ut_params->obuf = ut_params->op->sym->m_dst;
4433 if (ut_params->obuf)
4434 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4435 0, plaintext_len, ciphertext_buffer);
4437 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4438 0, plaintext_len, ciphertext_buffer);
4441 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4444 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4446 tdata->ciphertext.data,
4447 tdata->validCipherLenInBits.len,
4448 "ZUC Ciphertext data not as expected");
4454 test_zuc_authentication(const struct wireless_test_data *tdata)
4456 struct crypto_testsuite_params *ts_params = &testsuite_params;
4457 struct crypto_unittest_params *ut_params = &unittest_params;
4460 unsigned plaintext_pad_len;
4461 unsigned plaintext_len;
4464 struct rte_cryptodev_sym_capability_idx cap_idx;
4466 /* Check if device supports ZUC EIA3 */
4467 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4468 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4470 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4474 /* Create ZUC session */
4475 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4476 tdata->key.data, tdata->key.len,
4477 tdata->auth_iv.len, tdata->digest.len,
4478 RTE_CRYPTO_AUTH_OP_GENERATE,
4479 RTE_CRYPTO_AUTH_ZUC_EIA3);
4483 /* alloc mbuf and set payload */
4484 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4486 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4487 rte_pktmbuf_tailroom(ut_params->ibuf));
4489 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4490 /* Append data which is padded to a multiple of */
4491 /* the algorithms block size */
4492 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4493 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4495 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4497 /* Create ZUC operation */
4498 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4499 tdata->auth_iv.data, tdata->auth_iv.len,
4500 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4501 tdata->validAuthLenInBits.len,
4506 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4508 ut_params->obuf = ut_params->op->sym->m_src;
4509 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4510 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4511 + plaintext_pad_len;
4514 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4517 DIGEST_BYTE_LENGTH_KASUMI_F9,
4518 "ZUC Generated auth tag not as expected");
4524 test_kasumi_encryption_test_case_1(void)
4526 return test_kasumi_encryption(&kasumi_test_case_1);
4530 test_kasumi_encryption_test_case_1_sgl(void)
4532 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4536 test_kasumi_encryption_test_case_1_oop(void)
4538 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4542 test_kasumi_encryption_test_case_1_oop_sgl(void)
4544 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4548 test_kasumi_encryption_test_case_2(void)
4550 return test_kasumi_encryption(&kasumi_test_case_2);
4554 test_kasumi_encryption_test_case_3(void)
4556 return test_kasumi_encryption(&kasumi_test_case_3);
4560 test_kasumi_encryption_test_case_4(void)
4562 return test_kasumi_encryption(&kasumi_test_case_4);
4566 test_kasumi_encryption_test_case_5(void)
4568 return test_kasumi_encryption(&kasumi_test_case_5);
4572 test_kasumi_decryption_test_case_1(void)
4574 return test_kasumi_decryption(&kasumi_test_case_1);
4578 test_kasumi_decryption_test_case_1_oop(void)
4580 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4584 test_kasumi_decryption_test_case_2(void)
4586 return test_kasumi_decryption(&kasumi_test_case_2);
4590 test_kasumi_decryption_test_case_3(void)
4592 return test_kasumi_decryption(&kasumi_test_case_3);
4596 test_kasumi_decryption_test_case_4(void)
4598 return test_kasumi_decryption(&kasumi_test_case_4);
4602 test_kasumi_decryption_test_case_5(void)
4604 return test_kasumi_decryption(&kasumi_test_case_5);
4607 test_snow3g_encryption_test_case_1(void)
4609 return test_snow3g_encryption(&snow3g_test_case_1);
4613 test_snow3g_encryption_test_case_1_oop(void)
4615 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4619 test_snow3g_encryption_test_case_1_oop_sgl(void)
4621 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4626 test_snow3g_encryption_test_case_1_offset_oop(void)
4628 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4632 test_snow3g_encryption_test_case_2(void)
4634 return test_snow3g_encryption(&snow3g_test_case_2);
4638 test_snow3g_encryption_test_case_3(void)
4640 return test_snow3g_encryption(&snow3g_test_case_3);
4644 test_snow3g_encryption_test_case_4(void)
4646 return test_snow3g_encryption(&snow3g_test_case_4);
4650 test_snow3g_encryption_test_case_5(void)
4652 return test_snow3g_encryption(&snow3g_test_case_5);
4656 test_snow3g_decryption_test_case_1(void)
4658 return test_snow3g_decryption(&snow3g_test_case_1);
4662 test_snow3g_decryption_test_case_1_oop(void)
4664 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4668 test_snow3g_decryption_test_case_2(void)
4670 return test_snow3g_decryption(&snow3g_test_case_2);
4674 test_snow3g_decryption_test_case_3(void)
4676 return test_snow3g_decryption(&snow3g_test_case_3);
4680 test_snow3g_decryption_test_case_4(void)
4682 return test_snow3g_decryption(&snow3g_test_case_4);
4686 test_snow3g_decryption_test_case_5(void)
4688 return test_snow3g_decryption(&snow3g_test_case_5);
4691 test_snow3g_cipher_auth_test_case_1(void)
4693 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4697 test_snow3g_auth_cipher_test_case_1(void)
4699 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4703 test_kasumi_auth_cipher_test_case_1(void)
4705 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4709 test_kasumi_cipher_auth_test_case_1(void)
4711 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4715 test_zuc_encryption_test_case_1(void)
4717 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4721 test_zuc_encryption_test_case_2(void)
4723 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4727 test_zuc_encryption_test_case_3(void)
4729 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4733 test_zuc_encryption_test_case_4(void)
4735 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4739 test_zuc_encryption_test_case_5(void)
4741 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4745 test_zuc_encryption_test_case_6_sgl(void)
4747 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4751 test_zuc_hash_generate_test_case_1(void)
4753 return test_zuc_authentication(&zuc_test_case_auth_1b);
4757 test_zuc_hash_generate_test_case_2(void)
4759 return test_zuc_authentication(&zuc_test_case_auth_90b);
4763 test_zuc_hash_generate_test_case_3(void)
4765 return test_zuc_authentication(&zuc_test_case_auth_577b);
4769 test_zuc_hash_generate_test_case_4(void)
4771 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4775 test_zuc_hash_generate_test_case_5(void)
4777 return test_zuc_authentication(&zuc_test_auth_5670b);
4781 test_zuc_hash_generate_test_case_6(void)
4783 return test_zuc_authentication(&zuc_test_case_auth_128b);
4787 test_zuc_hash_generate_test_case_7(void)
4789 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4793 test_zuc_hash_generate_test_case_8(void)
4795 return test_zuc_authentication(&zuc_test_case_auth_584b);
4799 test_zuc_cipher_auth_test_case_1(void)
4801 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4805 test_zuc_cipher_auth_test_case_2(void)
4807 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4811 test_3DES_chain_qat_all(void)
4813 struct crypto_testsuite_params *ts_params = &testsuite_params;
4816 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4817 ts_params->op_mpool,
4818 ts_params->session_mpool,
4819 ts_params->valid_devs[0],
4820 rte_cryptodev_driver_id_get(
4821 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4822 BLKCIPHER_3DES_CHAIN_TYPE);
4824 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4826 return TEST_SUCCESS;
4830 test_DES_cipheronly_qat_all(void)
4832 struct crypto_testsuite_params *ts_params = &testsuite_params;
4835 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4836 ts_params->op_mpool,
4837 ts_params->session_mpool,
4838 ts_params->valid_devs[0],
4839 rte_cryptodev_driver_id_get(
4840 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4841 BLKCIPHER_DES_CIPHERONLY_TYPE);
4843 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4845 return TEST_SUCCESS;
4849 test_DES_cipheronly_openssl_all(void)
4851 struct crypto_testsuite_params *ts_params = &testsuite_params;
4854 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4855 ts_params->op_mpool,
4856 ts_params->session_mpool,
4857 ts_params->valid_devs[0],
4858 rte_cryptodev_driver_id_get(
4859 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4860 BLKCIPHER_DES_CIPHERONLY_TYPE);
4862 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4864 return TEST_SUCCESS;
4868 test_DES_docsis_openssl_all(void)
4870 struct crypto_testsuite_params *ts_params = &testsuite_params;
4873 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4874 ts_params->op_mpool,
4875 ts_params->session_mpool,
4876 ts_params->valid_devs[0],
4877 rte_cryptodev_driver_id_get(
4878 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4879 BLKCIPHER_DES_DOCSIS_TYPE);
4881 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4883 return TEST_SUCCESS;
4887 test_DES_cipheronly_mb_all(void)
4889 struct crypto_testsuite_params *ts_params = &testsuite_params;
4892 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4893 ts_params->op_mpool,
4894 ts_params->session_mpool,
4895 ts_params->valid_devs[0],
4896 rte_cryptodev_driver_id_get(
4897 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4898 BLKCIPHER_DES_CIPHERONLY_TYPE);
4900 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4902 return TEST_SUCCESS;
4906 test_DES_docsis_mb_all(void)
4908 struct crypto_testsuite_params *ts_params = &testsuite_params;
4911 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4912 ts_params->op_mpool,
4913 ts_params->session_mpool,
4914 ts_params->valid_devs[0],
4915 rte_cryptodev_driver_id_get(
4916 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4917 BLKCIPHER_DES_DOCSIS_TYPE);
4919 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4921 return TEST_SUCCESS;
4925 test_3DES_chain_dpaa_sec_all(void)
4927 struct crypto_testsuite_params *ts_params = &testsuite_params;
4930 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4931 ts_params->op_mpool,
4932 ts_params->session_mpool,
4933 ts_params->valid_devs[0],
4934 rte_cryptodev_driver_id_get(
4935 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4936 BLKCIPHER_3DES_CHAIN_TYPE);
4938 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4940 return TEST_SUCCESS;
4944 test_3DES_cipheronly_dpaa_sec_all(void)
4946 struct crypto_testsuite_params *ts_params = &testsuite_params;
4949 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4950 ts_params->op_mpool,
4951 ts_params->session_mpool,
4952 ts_params->valid_devs[0],
4953 rte_cryptodev_driver_id_get(
4954 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4955 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4957 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4959 return TEST_SUCCESS;
4963 test_3DES_chain_dpaa2_sec_all(void)
4965 struct crypto_testsuite_params *ts_params = &testsuite_params;
4968 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4969 ts_params->op_mpool,
4970 ts_params->session_mpool,
4971 ts_params->valid_devs[0],
4972 rte_cryptodev_driver_id_get(
4973 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4974 BLKCIPHER_3DES_CHAIN_TYPE);
4976 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4978 return TEST_SUCCESS;
4982 test_3DES_cipheronly_dpaa2_sec_all(void)
4984 struct crypto_testsuite_params *ts_params = &testsuite_params;
4987 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4988 ts_params->op_mpool,
4989 ts_params->session_mpool,
4990 ts_params->valid_devs[0],
4991 rte_cryptodev_driver_id_get(
4992 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4993 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4995 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4997 return TEST_SUCCESS;
5001 test_3DES_cipheronly_qat_all(void)
5003 struct crypto_testsuite_params *ts_params = &testsuite_params;
5006 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5007 ts_params->op_mpool,
5008 ts_params->session_mpool,
5009 ts_params->valid_devs[0],
5010 rte_cryptodev_driver_id_get(
5011 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5012 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5014 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5016 return TEST_SUCCESS;
5020 test_3DES_chain_openssl_all(void)
5022 struct crypto_testsuite_params *ts_params = &testsuite_params;
5025 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5026 ts_params->op_mpool,
5027 ts_params->session_mpool,
5028 ts_params->valid_devs[0],
5029 rte_cryptodev_driver_id_get(
5030 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5031 BLKCIPHER_3DES_CHAIN_TYPE);
5033 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5035 return TEST_SUCCESS;
5039 test_3DES_cipheronly_openssl_all(void)
5041 struct crypto_testsuite_params *ts_params = &testsuite_params;
5044 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5045 ts_params->op_mpool,
5046 ts_params->session_mpool,
5047 ts_params->valid_devs[0],
5048 rte_cryptodev_driver_id_get(
5049 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5050 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5052 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5054 return TEST_SUCCESS;
5057 /* ***** AEAD algorithm Tests ***** */
5060 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5061 enum rte_crypto_aead_operation op,
5062 const uint8_t *key, const uint8_t key_len,
5063 const uint16_t aad_len, const uint8_t auth_len,
5066 uint8_t aead_key[key_len];
5068 struct crypto_testsuite_params *ts_params = &testsuite_params;
5069 struct crypto_unittest_params *ut_params = &unittest_params;
5071 memcpy(aead_key, key, key_len);
5073 /* Setup AEAD Parameters */
5074 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5075 ut_params->aead_xform.next = NULL;
5076 ut_params->aead_xform.aead.algo = algo;
5077 ut_params->aead_xform.aead.op = op;
5078 ut_params->aead_xform.aead.key.data = aead_key;
5079 ut_params->aead_xform.aead.key.length = key_len;
5080 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5081 ut_params->aead_xform.aead.iv.length = iv_len;
5082 ut_params->aead_xform.aead.digest_length = auth_len;
5083 ut_params->aead_xform.aead.aad_length = aad_len;
5085 TEST_HEXDUMP(stdout, "key:", key, key_len);
5087 /* Create Crypto session*/
5088 ut_params->sess = rte_cryptodev_sym_session_create(
5089 ts_params->session_mpool);
5091 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5092 &ut_params->aead_xform, ts_params->session_mpool);
5094 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5100 create_aead_xform(struct rte_crypto_op *op,
5101 enum rte_crypto_aead_algorithm algo,
5102 enum rte_crypto_aead_operation aead_op,
5103 uint8_t *key, const uint8_t key_len,
5104 const uint8_t aad_len, const uint8_t auth_len,
5107 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5108 "failed to allocate space for crypto transform");
5110 struct rte_crypto_sym_op *sym_op = op->sym;
5112 /* Setup AEAD Parameters */
5113 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5114 sym_op->xform->next = NULL;
5115 sym_op->xform->aead.algo = algo;
5116 sym_op->xform->aead.op = aead_op;
5117 sym_op->xform->aead.key.data = key;
5118 sym_op->xform->aead.key.length = key_len;
5119 sym_op->xform->aead.iv.offset = IV_OFFSET;
5120 sym_op->xform->aead.iv.length = iv_len;
5121 sym_op->xform->aead.digest_length = auth_len;
5122 sym_op->xform->aead.aad_length = aad_len;
5124 TEST_HEXDUMP(stdout, "key:", key, key_len);
5130 create_aead_operation(enum rte_crypto_aead_operation op,
5131 const struct aead_test_data *tdata)
5133 struct crypto_testsuite_params *ts_params = &testsuite_params;
5134 struct crypto_unittest_params *ut_params = &unittest_params;
5136 uint8_t *plaintext, *ciphertext;
5137 unsigned int aad_pad_len, plaintext_pad_len;
5139 /* Generate Crypto op data structure */
5140 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5141 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5142 TEST_ASSERT_NOT_NULL(ut_params->op,
5143 "Failed to allocate symmetric crypto operation struct");
5145 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5147 /* Append aad data */
5148 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5149 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5150 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5152 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5153 "no room to append aad");
5155 sym_op->aead.aad.phys_addr =
5156 rte_pktmbuf_mtophys(ut_params->ibuf);
5157 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5158 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5159 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5162 /* Append IV at the end of the crypto operation*/
5163 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5164 uint8_t *, IV_OFFSET);
5166 /* Copy IV 1 byte after the IV pointer, according to the API */
5167 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5168 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5171 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5172 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5174 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5175 "no room to append aad");
5177 sym_op->aead.aad.phys_addr =
5178 rte_pktmbuf_mtophys(ut_params->ibuf);
5179 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5180 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5183 /* Append IV at the end of the crypto operation*/
5184 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5185 uint8_t *, IV_OFFSET);
5187 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5188 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5192 /* Append plaintext/ciphertext */
5193 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5194 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5195 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5197 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5199 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5200 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
5201 tdata->plaintext.len);
5203 if (ut_params->obuf) {
5204 ciphertext = (uint8_t *)rte_pktmbuf_append(
5206 plaintext_pad_len + aad_pad_len);
5207 TEST_ASSERT_NOT_NULL(ciphertext,
5208 "no room to append ciphertext");
5210 memset(ciphertext + aad_pad_len, 0,
5211 tdata->ciphertext.len);
5214 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5215 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5217 TEST_ASSERT_NOT_NULL(ciphertext,
5218 "no room to append ciphertext");
5220 memcpy(ciphertext, tdata->ciphertext.data,
5221 tdata->ciphertext.len);
5222 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
5223 tdata->ciphertext.len);
5225 if (ut_params->obuf) {
5226 plaintext = (uint8_t *)rte_pktmbuf_append(
5228 plaintext_pad_len + aad_pad_len);
5229 TEST_ASSERT_NOT_NULL(plaintext,
5230 "no room to append plaintext");
5232 memset(plaintext + aad_pad_len, 0,
5233 tdata->plaintext.len);
5237 /* Append digest data */
5238 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5239 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5240 ut_params->obuf ? ut_params->obuf :
5242 tdata->auth_tag.len);
5243 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5244 "no room to append digest");
5245 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5246 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5247 ut_params->obuf ? ut_params->obuf :
5252 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5253 ut_params->ibuf, tdata->auth_tag.len);
5254 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5255 "no room to append digest");
5256 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5258 plaintext_pad_len + aad_pad_len);
5260 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5261 tdata->auth_tag.len);
5262 TEST_HEXDUMP(stdout, "digest:",
5263 sym_op->aead.digest.data,
5264 tdata->auth_tag.len);
5267 sym_op->aead.data.length = tdata->plaintext.len;
5268 sym_op->aead.data.offset = aad_pad_len;
5274 test_authenticated_encryption(const struct aead_test_data *tdata)
5276 struct crypto_testsuite_params *ts_params = &testsuite_params;
5277 struct crypto_unittest_params *ut_params = &unittest_params;
5280 uint8_t *ciphertext, *auth_tag;
5281 uint16_t plaintext_pad_len;
5284 /* Create AEAD session */
5285 retval = create_aead_session(ts_params->valid_devs[0],
5287 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5288 tdata->key.data, tdata->key.len,
5289 tdata->aad.len, tdata->auth_tag.len,
5294 if (tdata->aad.len > MBUF_SIZE) {
5295 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5296 /* Populate full size of add data */
5297 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5298 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5300 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5302 /* clear mbuf payload */
5303 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5304 rte_pktmbuf_tailroom(ut_params->ibuf));
5306 /* Create AEAD operation */
5307 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5311 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5313 ut_params->op->sym->m_src = ut_params->ibuf;
5315 /* Process crypto operation */
5316 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5317 ut_params->op), "failed to process sym crypto op");
5319 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5320 "crypto op processing failed");
5322 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5324 if (ut_params->op->sym->m_dst) {
5325 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5327 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5328 uint8_t *, plaintext_pad_len);
5330 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5332 ut_params->op->sym->cipher.data.offset);
5333 auth_tag = ciphertext + plaintext_pad_len;
5336 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5337 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5340 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5342 tdata->ciphertext.data,
5343 tdata->ciphertext.len,
5344 "Ciphertext data not as expected");
5346 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5348 tdata->auth_tag.data,
5349 tdata->auth_tag.len,
5350 "Generated auth tag not as expected");
5357 test_AES_GCM_authenticated_encryption_test_case_1(void)
5359 return test_authenticated_encryption(&gcm_test_case_1);
5363 test_AES_GCM_authenticated_encryption_test_case_2(void)
5365 return test_authenticated_encryption(&gcm_test_case_2);
5369 test_AES_GCM_authenticated_encryption_test_case_3(void)
5371 return test_authenticated_encryption(&gcm_test_case_3);
5375 test_AES_GCM_authenticated_encryption_test_case_4(void)
5377 return test_authenticated_encryption(&gcm_test_case_4);
5381 test_AES_GCM_authenticated_encryption_test_case_5(void)
5383 return test_authenticated_encryption(&gcm_test_case_5);
5387 test_AES_GCM_authenticated_encryption_test_case_6(void)
5389 return test_authenticated_encryption(&gcm_test_case_6);
5393 test_AES_GCM_authenticated_encryption_test_case_7(void)
5395 return test_authenticated_encryption(&gcm_test_case_7);
5399 test_AES_GCM_auth_encryption_test_case_192_1(void)
5401 return test_authenticated_encryption(&gcm_test_case_192_1);
5405 test_AES_GCM_auth_encryption_test_case_192_2(void)
5407 return test_authenticated_encryption(&gcm_test_case_192_2);
5411 test_AES_GCM_auth_encryption_test_case_192_3(void)
5413 return test_authenticated_encryption(&gcm_test_case_192_3);
5417 test_AES_GCM_auth_encryption_test_case_192_4(void)
5419 return test_authenticated_encryption(&gcm_test_case_192_4);
5423 test_AES_GCM_auth_encryption_test_case_192_5(void)
5425 return test_authenticated_encryption(&gcm_test_case_192_5);
5429 test_AES_GCM_auth_encryption_test_case_192_6(void)
5431 return test_authenticated_encryption(&gcm_test_case_192_6);
5435 test_AES_GCM_auth_encryption_test_case_192_7(void)
5437 return test_authenticated_encryption(&gcm_test_case_192_7);
5441 test_AES_GCM_auth_encryption_test_case_256_1(void)
5443 return test_authenticated_encryption(&gcm_test_case_256_1);
5447 test_AES_GCM_auth_encryption_test_case_256_2(void)
5449 return test_authenticated_encryption(&gcm_test_case_256_2);
5453 test_AES_GCM_auth_encryption_test_case_256_3(void)
5455 return test_authenticated_encryption(&gcm_test_case_256_3);
5459 test_AES_GCM_auth_encryption_test_case_256_4(void)
5461 return test_authenticated_encryption(&gcm_test_case_256_4);
5465 test_AES_GCM_auth_encryption_test_case_256_5(void)
5467 return test_authenticated_encryption(&gcm_test_case_256_5);
5471 test_AES_GCM_auth_encryption_test_case_256_6(void)
5473 return test_authenticated_encryption(&gcm_test_case_256_6);
5477 test_AES_GCM_auth_encryption_test_case_256_7(void)
5479 return test_authenticated_encryption(&gcm_test_case_256_7);
5483 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5485 return test_authenticated_encryption(&gcm_test_case_aad_1);
5489 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5491 return test_authenticated_encryption(&gcm_test_case_aad_2);
5495 test_authenticated_decryption(const struct aead_test_data *tdata)
5497 struct crypto_testsuite_params *ts_params = &testsuite_params;
5498 struct crypto_unittest_params *ut_params = &unittest_params;
5504 /* Create AEAD session */
5505 retval = create_aead_session(ts_params->valid_devs[0],
5507 RTE_CRYPTO_AEAD_OP_DECRYPT,
5508 tdata->key.data, tdata->key.len,
5509 tdata->aad.len, tdata->auth_tag.len,
5514 /* alloc mbuf and set payload */
5515 if (tdata->aad.len > MBUF_SIZE) {
5516 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5517 /* Populate full size of add data */
5518 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5519 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5521 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5523 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5524 rte_pktmbuf_tailroom(ut_params->ibuf));
5526 /* Create AEAD operation */
5527 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5531 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5533 ut_params->op->sym->m_src = ut_params->ibuf;
5535 /* Process crypto operation */
5536 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5537 ut_params->op), "failed to process sym crypto op");
5539 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5540 "crypto op processing failed");
5542 if (ut_params->op->sym->m_dst)
5543 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5546 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5548 ut_params->op->sym->cipher.data.offset);
5550 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5553 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5555 tdata->plaintext.data,
5556 tdata->plaintext.len,
5557 "Plaintext data not as expected");
5559 TEST_ASSERT_EQUAL(ut_params->op->status,
5560 RTE_CRYPTO_OP_STATUS_SUCCESS,
5561 "Authentication failed");
5566 test_AES_GCM_authenticated_decryption_test_case_1(void)
5568 return test_authenticated_decryption(&gcm_test_case_1);
5572 test_AES_GCM_authenticated_decryption_test_case_2(void)
5574 return test_authenticated_decryption(&gcm_test_case_2);
5578 test_AES_GCM_authenticated_decryption_test_case_3(void)
5580 return test_authenticated_decryption(&gcm_test_case_3);
5584 test_AES_GCM_authenticated_decryption_test_case_4(void)
5586 return test_authenticated_decryption(&gcm_test_case_4);
5590 test_AES_GCM_authenticated_decryption_test_case_5(void)
5592 return test_authenticated_decryption(&gcm_test_case_5);
5596 test_AES_GCM_authenticated_decryption_test_case_6(void)
5598 return test_authenticated_decryption(&gcm_test_case_6);
5602 test_AES_GCM_authenticated_decryption_test_case_7(void)
5604 return test_authenticated_decryption(&gcm_test_case_7);
5608 test_AES_GCM_auth_decryption_test_case_192_1(void)
5610 return test_authenticated_decryption(&gcm_test_case_192_1);
5614 test_AES_GCM_auth_decryption_test_case_192_2(void)
5616 return test_authenticated_decryption(&gcm_test_case_192_2);
5620 test_AES_GCM_auth_decryption_test_case_192_3(void)
5622 return test_authenticated_decryption(&gcm_test_case_192_3);
5626 test_AES_GCM_auth_decryption_test_case_192_4(void)
5628 return test_authenticated_decryption(&gcm_test_case_192_4);
5632 test_AES_GCM_auth_decryption_test_case_192_5(void)
5634 return test_authenticated_decryption(&gcm_test_case_192_5);
5638 test_AES_GCM_auth_decryption_test_case_192_6(void)
5640 return test_authenticated_decryption(&gcm_test_case_192_6);
5644 test_AES_GCM_auth_decryption_test_case_192_7(void)
5646 return test_authenticated_decryption(&gcm_test_case_192_7);
5650 test_AES_GCM_auth_decryption_test_case_256_1(void)
5652 return test_authenticated_decryption(&gcm_test_case_256_1);
5656 test_AES_GCM_auth_decryption_test_case_256_2(void)
5658 return test_authenticated_decryption(&gcm_test_case_256_2);
5662 test_AES_GCM_auth_decryption_test_case_256_3(void)
5664 return test_authenticated_decryption(&gcm_test_case_256_3);
5668 test_AES_GCM_auth_decryption_test_case_256_4(void)
5670 return test_authenticated_decryption(&gcm_test_case_256_4);
5674 test_AES_GCM_auth_decryption_test_case_256_5(void)
5676 return test_authenticated_decryption(&gcm_test_case_256_5);
5680 test_AES_GCM_auth_decryption_test_case_256_6(void)
5682 return test_authenticated_decryption(&gcm_test_case_256_6);
5686 test_AES_GCM_auth_decryption_test_case_256_7(void)
5688 return test_authenticated_decryption(&gcm_test_case_256_7);
5692 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5694 return test_authenticated_decryption(&gcm_test_case_aad_1);
5698 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5700 return test_authenticated_decryption(&gcm_test_case_aad_2);
5704 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5706 struct crypto_testsuite_params *ts_params = &testsuite_params;
5707 struct crypto_unittest_params *ut_params = &unittest_params;
5710 uint8_t *ciphertext, *auth_tag;
5711 uint16_t plaintext_pad_len;
5713 /* Create AEAD session */
5714 retval = create_aead_session(ts_params->valid_devs[0],
5716 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5717 tdata->key.data, tdata->key.len,
5718 tdata->aad.len, tdata->auth_tag.len,
5723 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5724 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5726 /* clear mbuf payload */
5727 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5728 rte_pktmbuf_tailroom(ut_params->ibuf));
5729 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5730 rte_pktmbuf_tailroom(ut_params->obuf));
5732 /* Create AEAD operation */
5733 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5737 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5739 ut_params->op->sym->m_src = ut_params->ibuf;
5740 ut_params->op->sym->m_dst = ut_params->obuf;
5742 /* Process crypto operation */
5743 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5744 ut_params->op), "failed to process sym crypto op");
5746 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5747 "crypto op processing failed");
5749 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5751 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5752 ut_params->op->sym->cipher.data.offset);
5753 auth_tag = ciphertext + plaintext_pad_len;
5755 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5756 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5759 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5761 tdata->ciphertext.data,
5762 tdata->ciphertext.len,
5763 "Ciphertext data not as expected");
5765 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5767 tdata->auth_tag.data,
5768 tdata->auth_tag.len,
5769 "Generated auth tag not as expected");
5776 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5778 return test_authenticated_encryption_oop(&gcm_test_case_5);
5782 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5784 struct crypto_testsuite_params *ts_params = &testsuite_params;
5785 struct crypto_unittest_params *ut_params = &unittest_params;
5790 /* Create AEAD session */
5791 retval = create_aead_session(ts_params->valid_devs[0],
5793 RTE_CRYPTO_AEAD_OP_DECRYPT,
5794 tdata->key.data, tdata->key.len,
5795 tdata->aad.len, tdata->auth_tag.len,
5800 /* alloc mbuf and set payload */
5801 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5802 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5804 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5805 rte_pktmbuf_tailroom(ut_params->ibuf));
5806 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5807 rte_pktmbuf_tailroom(ut_params->obuf));
5809 /* Create AEAD operation */
5810 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5814 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5816 ut_params->op->sym->m_src = ut_params->ibuf;
5817 ut_params->op->sym->m_dst = ut_params->obuf;
5819 /* Process crypto operation */
5820 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5821 ut_params->op), "failed to process sym crypto op");
5823 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5824 "crypto op processing failed");
5826 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5827 ut_params->op->sym->cipher.data.offset);
5829 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5832 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5834 tdata->plaintext.data,
5835 tdata->plaintext.len,
5836 "Plaintext data not as expected");
5838 TEST_ASSERT_EQUAL(ut_params->op->status,
5839 RTE_CRYPTO_OP_STATUS_SUCCESS,
5840 "Authentication failed");
5845 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5847 return test_authenticated_decryption_oop(&gcm_test_case_5);
5851 test_authenticated_encryption_sessionless(
5852 const struct aead_test_data *tdata)
5854 struct crypto_testsuite_params *ts_params = &testsuite_params;
5855 struct crypto_unittest_params *ut_params = &unittest_params;
5858 uint8_t *ciphertext, *auth_tag;
5859 uint16_t plaintext_pad_len;
5860 uint8_t key[tdata->key.len + 1];
5862 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5864 /* clear mbuf payload */
5865 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5866 rte_pktmbuf_tailroom(ut_params->ibuf));
5868 /* Create AEAD operation */
5869 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5873 /* Create GCM xform */
5874 memcpy(key, tdata->key.data, tdata->key.len);
5875 retval = create_aead_xform(ut_params->op,
5877 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5878 key, tdata->key.len,
5879 tdata->aad.len, tdata->auth_tag.len,
5884 ut_params->op->sym->m_src = ut_params->ibuf;
5886 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5887 RTE_CRYPTO_OP_SESSIONLESS,
5888 "crypto op session type not sessionless");
5890 /* Process crypto operation */
5891 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5892 ut_params->op), "failed to process sym crypto op");
5894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5896 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5897 "crypto op status not success");
5899 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5901 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5902 ut_params->op->sym->cipher.data.offset);
5903 auth_tag = ciphertext + plaintext_pad_len;
5905 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5906 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5909 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5911 tdata->ciphertext.data,
5912 tdata->ciphertext.len,
5913 "Ciphertext data not as expected");
5915 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5917 tdata->auth_tag.data,
5918 tdata->auth_tag.len,
5919 "Generated auth tag not as expected");
5926 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5928 return test_authenticated_encryption_sessionless(
5933 test_authenticated_decryption_sessionless(
5934 const struct aead_test_data *tdata)
5936 struct crypto_testsuite_params *ts_params = &testsuite_params;
5937 struct crypto_unittest_params *ut_params = &unittest_params;
5941 uint8_t key[tdata->key.len + 1];
5943 /* alloc mbuf and set payload */
5944 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5946 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5947 rte_pktmbuf_tailroom(ut_params->ibuf));
5949 /* Create AEAD operation */
5950 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5954 /* Create AEAD xform */
5955 memcpy(key, tdata->key.data, tdata->key.len);
5956 retval = create_aead_xform(ut_params->op,
5958 RTE_CRYPTO_AEAD_OP_DECRYPT,
5959 key, tdata->key.len,
5960 tdata->aad.len, tdata->auth_tag.len,
5965 ut_params->op->sym->m_src = ut_params->ibuf;
5967 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5968 RTE_CRYPTO_OP_SESSIONLESS,
5969 "crypto op session type not sessionless");
5971 /* Process crypto operation */
5972 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5973 ut_params->op), "failed to process sym crypto op");
5975 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5977 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5978 "crypto op status not success");
5980 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5981 ut_params->op->sym->cipher.data.offset);
5983 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5986 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5988 tdata->plaintext.data,
5989 tdata->plaintext.len,
5990 "Plaintext data not as expected");
5992 TEST_ASSERT_EQUAL(ut_params->op->status,
5993 RTE_CRYPTO_OP_STATUS_SUCCESS,
5994 "Authentication failed");
5999 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6001 return test_authenticated_decryption_sessionless(
6006 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6008 return test_authenticated_encryption(&ccm_test_case_128_1);
6012 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6014 return test_authenticated_encryption(&ccm_test_case_128_2);
6018 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6020 return test_authenticated_encryption(&ccm_test_case_128_3);
6024 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6026 return test_authenticated_decryption(&ccm_test_case_128_1);
6030 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6032 return test_authenticated_decryption(&ccm_test_case_128_2);
6036 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6038 return test_authenticated_decryption(&ccm_test_case_128_3);
6042 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6044 return test_authenticated_encryption(&ccm_test_case_192_1);
6048 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6050 return test_authenticated_encryption(&ccm_test_case_192_2);
6054 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6056 return test_authenticated_encryption(&ccm_test_case_192_3);
6060 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6062 return test_authenticated_decryption(&ccm_test_case_192_1);
6066 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6068 return test_authenticated_decryption(&ccm_test_case_192_2);
6072 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6074 return test_authenticated_decryption(&ccm_test_case_192_3);
6078 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6080 return test_authenticated_encryption(&ccm_test_case_256_1);
6084 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6086 return test_authenticated_encryption(&ccm_test_case_256_2);
6090 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6092 return test_authenticated_encryption(&ccm_test_case_256_3);
6096 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6098 return test_authenticated_decryption(&ccm_test_case_256_1);
6102 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6104 return test_authenticated_decryption(&ccm_test_case_256_2);
6108 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6110 return test_authenticated_decryption(&ccm_test_case_256_3);
6116 struct crypto_testsuite_params *ts_params = &testsuite_params;
6117 struct rte_cryptodev_stats stats;
6118 struct rte_cryptodev *dev;
6119 cryptodev_stats_get_t temp_pfn;
6121 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6122 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6123 &stats) == -ENODEV),
6124 "rte_cryptodev_stats_get invalid dev failed");
6125 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6126 "rte_cryptodev_stats_get invalid Param failed");
6127 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6128 temp_pfn = dev->dev_ops->stats_get;
6129 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6130 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6132 "rte_cryptodev_stats_get invalid Param failed");
6133 dev->dev_ops->stats_get = temp_pfn;
6135 /* Test expected values */
6137 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6139 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6141 "rte_cryptodev_stats_get failed");
6142 TEST_ASSERT((stats.enqueued_count == 1),
6143 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6144 TEST_ASSERT((stats.dequeued_count == 1),
6145 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6146 TEST_ASSERT((stats.enqueue_err_count == 0),
6147 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6148 TEST_ASSERT((stats.dequeue_err_count == 0),
6149 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6151 /* invalid device but should ignore and not reset device stats*/
6152 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6153 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6155 "rte_cryptodev_stats_get failed");
6156 TEST_ASSERT((stats.enqueued_count == 1),
6157 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6159 /* check that a valid reset clears stats */
6160 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6161 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6163 "rte_cryptodev_stats_get failed");
6164 TEST_ASSERT((stats.enqueued_count == 0),
6165 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6166 TEST_ASSERT((stats.dequeued_count == 0),
6167 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6169 return TEST_SUCCESS;
6172 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6173 struct crypto_unittest_params *ut_params,
6174 enum rte_crypto_auth_operation op,
6175 const struct HMAC_MD5_vector *test_case)
6179 memcpy(key, test_case->key.data, test_case->key.len);
6181 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6182 ut_params->auth_xform.next = NULL;
6183 ut_params->auth_xform.auth.op = op;
6185 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6187 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6188 ut_params->auth_xform.auth.key.length = test_case->key.len;
6189 ut_params->auth_xform.auth.key.data = key;
6191 ut_params->sess = rte_cryptodev_sym_session_create(
6192 ts_params->session_mpool);
6194 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6195 ut_params->sess, &ut_params->auth_xform,
6196 ts_params->session_mpool);
6198 if (ut_params->sess == NULL)
6201 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6203 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6204 rte_pktmbuf_tailroom(ut_params->ibuf));
6209 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6210 const struct HMAC_MD5_vector *test_case,
6211 uint8_t **plaintext)
6213 uint16_t plaintext_pad_len;
6215 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6217 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6220 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6222 memcpy(*plaintext, test_case->plaintext.data,
6223 test_case->plaintext.len);
6225 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6226 ut_params->ibuf, MD5_DIGEST_LEN);
6227 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6228 "no room to append digest");
6229 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6230 ut_params->ibuf, plaintext_pad_len);
6232 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6233 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6234 test_case->auth_tag.len);
6237 sym_op->auth.data.offset = 0;
6238 sym_op->auth.data.length = test_case->plaintext.len;
6240 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6241 ut_params->op->sym->m_src = ut_params->ibuf;
6247 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6249 uint16_t plaintext_pad_len;
6250 uint8_t *plaintext, *auth_tag;
6252 struct crypto_testsuite_params *ts_params = &testsuite_params;
6253 struct crypto_unittest_params *ut_params = &unittest_params;
6255 if (MD5_HMAC_create_session(ts_params, ut_params,
6256 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6259 /* Generate Crypto op data structure */
6260 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6261 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6262 TEST_ASSERT_NOT_NULL(ut_params->op,
6263 "Failed to allocate symmetric crypto operation struct");
6265 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6268 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6271 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6272 ut_params->op), "failed to process sym crypto op");
6274 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6275 "crypto op processing failed");
6277 if (ut_params->op->sym->m_dst) {
6278 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6279 uint8_t *, plaintext_pad_len);
6281 auth_tag = plaintext + plaintext_pad_len;
6284 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6286 test_case->auth_tag.data,
6287 test_case->auth_tag.len,
6288 "HMAC_MD5 generated tag not as expected");
6290 return TEST_SUCCESS;
6294 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6298 struct crypto_testsuite_params *ts_params = &testsuite_params;
6299 struct crypto_unittest_params *ut_params = &unittest_params;
6301 if (MD5_HMAC_create_session(ts_params, ut_params,
6302 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6306 /* Generate Crypto op data structure */
6307 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6308 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6309 TEST_ASSERT_NOT_NULL(ut_params->op,
6310 "Failed to allocate symmetric crypto operation struct");
6312 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6315 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6316 ut_params->op), "failed to process sym crypto op");
6318 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6319 "HMAC_MD5 crypto op processing failed");
6321 return TEST_SUCCESS;
6325 test_MD5_HMAC_generate_case_1(void)
6327 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6331 test_MD5_HMAC_verify_case_1(void)
6333 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6337 test_MD5_HMAC_generate_case_2(void)
6339 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6343 test_MD5_HMAC_verify_case_2(void)
6345 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6349 test_multi_session(void)
6351 struct crypto_testsuite_params *ts_params = &testsuite_params;
6352 struct crypto_unittest_params *ut_params = &unittest_params;
6354 struct rte_cryptodev_info dev_info;
6355 struct rte_cryptodev_sym_session **sessions;
6359 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6360 aes_cbc_key, hmac_sha512_key);
6363 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6365 sessions = rte_malloc(NULL,
6366 (sizeof(struct rte_cryptodev_sym_session *) *
6367 dev_info.sym.max_nb_sessions) + 1, 0);
6369 /* Create multiple crypto sessions*/
6370 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6372 sessions[i] = rte_cryptodev_sym_session_create(
6373 ts_params->session_mpool);
6375 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6376 sessions[i], &ut_params->auth_xform,
6377 ts_params->session_mpool);
6378 TEST_ASSERT_NOT_NULL(sessions[i],
6379 "Session creation failed at session number %u",
6382 /* Attempt to send a request on each session */
6383 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6387 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6388 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6390 "Failed to perform decrypt on request number %u.", i);
6391 /* free crypto operation structure */
6393 rte_crypto_op_free(ut_params->op);
6396 * free mbuf - both obuf and ibuf are usually the same,
6397 * so check if they point at the same address is necessary,
6398 * to avoid freeing the mbuf twice.
6400 if (ut_params->obuf) {
6401 rte_pktmbuf_free(ut_params->obuf);
6402 if (ut_params->ibuf == ut_params->obuf)
6403 ut_params->ibuf = 0;
6404 ut_params->obuf = 0;
6406 if (ut_params->ibuf) {
6407 rte_pktmbuf_free(ut_params->ibuf);
6408 ut_params->ibuf = 0;
6412 /* Next session create should fail */
6413 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6414 sessions[i], &ut_params->auth_xform,
6415 ts_params->session_mpool);
6416 TEST_ASSERT_NULL(sessions[i],
6417 "Session creation succeeded unexpectedly!");
6419 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6420 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6422 rte_cryptodev_sym_session_free(sessions[i]);
6427 return TEST_SUCCESS;
6430 struct multi_session_params {
6431 struct crypto_unittest_params ut_params;
6432 uint8_t *cipher_key;
6434 const uint8_t *cipher;
6435 const uint8_t *digest;
6439 #define MB_SESSION_NUMBER 3
6442 test_multi_session_random_usage(void)
6444 struct crypto_testsuite_params *ts_params = &testsuite_params;
6445 struct rte_cryptodev_info dev_info;
6446 struct rte_cryptodev_sym_session **sessions;
6448 struct multi_session_params ut_paramz[] = {
6451 .cipher_key = ms_aes_cbc_key0,
6452 .hmac_key = ms_hmac_key0,
6453 .cipher = ms_aes_cbc_cipher0,
6454 .digest = ms_hmac_digest0,
6455 .iv = ms_aes_cbc_iv0
6458 .cipher_key = ms_aes_cbc_key1,
6459 .hmac_key = ms_hmac_key1,
6460 .cipher = ms_aes_cbc_cipher1,
6461 .digest = ms_hmac_digest1,
6462 .iv = ms_aes_cbc_iv1
6465 .cipher_key = ms_aes_cbc_key2,
6466 .hmac_key = ms_hmac_key2,
6467 .cipher = ms_aes_cbc_cipher2,
6468 .digest = ms_hmac_digest2,
6469 .iv = ms_aes_cbc_iv2
6474 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6476 sessions = rte_malloc(NULL,
6477 (sizeof(struct rte_cryptodev_sym_session *)
6478 * dev_info.sym.max_nb_sessions) + 1, 0);
6480 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6481 sessions[i] = rte_cryptodev_sym_session_create(
6482 ts_params->session_mpool);
6484 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6485 sizeof(struct crypto_unittest_params));
6487 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6488 &ut_paramz[i].ut_params,
6489 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6491 /* Create multiple crypto sessions*/
6492 rte_cryptodev_sym_session_init(
6493 ts_params->valid_devs[0],
6495 &ut_paramz[i].ut_params.auth_xform,
6496 ts_params->session_mpool);
6498 TEST_ASSERT_NOT_NULL(sessions[i],
6499 "Session creation failed at session number %u",
6505 for (i = 0; i < 40000; i++) {
6507 j = rand() % MB_SESSION_NUMBER;
6509 TEST_ASSERT_SUCCESS(
6510 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6512 &ut_paramz[j].ut_params,
6513 ts_params, ut_paramz[j].cipher,
6514 ut_paramz[j].digest,
6516 "Failed to perform decrypt on request number %u.", i);
6518 if (ut_paramz[j].ut_params.op)
6519 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6522 * free mbuf - both obuf and ibuf are usually the same,
6523 * so check if they point at the same address is necessary,
6524 * to avoid freeing the mbuf twice.
6526 if (ut_paramz[j].ut_params.obuf) {
6527 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6528 if (ut_paramz[j].ut_params.ibuf
6529 == ut_paramz[j].ut_params.obuf)
6530 ut_paramz[j].ut_params.ibuf = 0;
6531 ut_paramz[j].ut_params.obuf = 0;
6533 if (ut_paramz[j].ut_params.ibuf) {
6534 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6535 ut_paramz[j].ut_params.ibuf = 0;
6539 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6540 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6542 rte_cryptodev_sym_session_free(sessions[i]);
6547 return TEST_SUCCESS;
6551 test_null_cipher_only_operation(void)
6553 struct crypto_testsuite_params *ts_params = &testsuite_params;
6554 struct crypto_unittest_params *ut_params = &unittest_params;
6556 /* Generate test mbuf data and space for digest */
6557 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6558 catch_22_quote, QUOTE_512_BYTES, 0);
6560 /* Setup Cipher Parameters */
6561 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6562 ut_params->cipher_xform.next = NULL;
6564 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6565 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6567 ut_params->sess = rte_cryptodev_sym_session_create(
6568 ts_params->session_mpool);
6570 /* Create Crypto session*/
6571 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6573 &ut_params->cipher_xform,
6574 ts_params->session_mpool);
6575 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6577 /* Generate Crypto op data structure */
6578 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6579 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6580 TEST_ASSERT_NOT_NULL(ut_params->op,
6581 "Failed to allocate symmetric crypto operation struct");
6583 /* Set crypto operation data parameters */
6584 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6586 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6588 /* set crypto operation source mbuf */
6589 sym_op->m_src = ut_params->ibuf;
6591 sym_op->cipher.data.offset = 0;
6592 sym_op->cipher.data.length = QUOTE_512_BYTES;
6594 /* Process crypto operation */
6595 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6597 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6599 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6600 "crypto operation processing failed");
6603 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6604 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6607 "Ciphertext data not as expected");
6609 return TEST_SUCCESS;
6613 test_null_auth_only_operation(void)
6615 struct crypto_testsuite_params *ts_params = &testsuite_params;
6616 struct crypto_unittest_params *ut_params = &unittest_params;
6618 /* Generate test mbuf data and space for digest */
6619 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6620 catch_22_quote, QUOTE_512_BYTES, 0);
6622 /* Setup HMAC Parameters */
6623 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6624 ut_params->auth_xform.next = NULL;
6626 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6627 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6629 ut_params->sess = rte_cryptodev_sym_session_create(
6630 ts_params->session_mpool);
6632 /* Create Crypto session*/
6633 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6634 ut_params->sess, &ut_params->auth_xform,
6635 ts_params->session_mpool);
6636 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6638 /* Generate Crypto op data structure */
6639 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6640 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6641 TEST_ASSERT_NOT_NULL(ut_params->op,
6642 "Failed to allocate symmetric crypto operation struct");
6644 /* Set crypto operation data parameters */
6645 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6647 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6649 sym_op->m_src = ut_params->ibuf;
6651 sym_op->auth.data.offset = 0;
6652 sym_op->auth.data.length = QUOTE_512_BYTES;
6654 /* Process crypto operation */
6655 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6657 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6659 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6660 "crypto operation processing failed");
6662 return TEST_SUCCESS;
6666 test_null_cipher_auth_operation(void)
6668 struct crypto_testsuite_params *ts_params = &testsuite_params;
6669 struct crypto_unittest_params *ut_params = &unittest_params;
6671 /* Generate test mbuf data and space for digest */
6672 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6673 catch_22_quote, QUOTE_512_BYTES, 0);
6675 /* Setup Cipher Parameters */
6676 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6677 ut_params->cipher_xform.next = &ut_params->auth_xform;
6679 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6680 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6682 /* Setup HMAC Parameters */
6683 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6684 ut_params->auth_xform.next = NULL;
6686 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6687 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6689 ut_params->sess = rte_cryptodev_sym_session_create(
6690 ts_params->session_mpool);
6692 /* Create Crypto session*/
6693 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6694 ut_params->sess, &ut_params->cipher_xform,
6695 ts_params->session_mpool);
6696 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6698 /* Generate Crypto op data structure */
6699 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6700 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6701 TEST_ASSERT_NOT_NULL(ut_params->op,
6702 "Failed to allocate symmetric crypto operation struct");
6704 /* Set crypto operation data parameters */
6705 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6707 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6709 sym_op->m_src = ut_params->ibuf;
6711 sym_op->cipher.data.offset = 0;
6712 sym_op->cipher.data.length = QUOTE_512_BYTES;
6714 sym_op->auth.data.offset = 0;
6715 sym_op->auth.data.length = QUOTE_512_BYTES;
6717 /* Process crypto operation */
6718 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6720 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6722 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6723 "crypto operation processing failed");
6726 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6727 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6730 "Ciphertext data not as expected");
6732 return TEST_SUCCESS;
6736 test_null_auth_cipher_operation(void)
6738 struct crypto_testsuite_params *ts_params = &testsuite_params;
6739 struct crypto_unittest_params *ut_params = &unittest_params;
6741 /* Generate test mbuf data and space for digest */
6742 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6743 catch_22_quote, QUOTE_512_BYTES, 0);
6745 /* Setup Cipher Parameters */
6746 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6747 ut_params->cipher_xform.next = NULL;
6749 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6750 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6752 /* Setup HMAC Parameters */
6753 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6754 ut_params->auth_xform.next = &ut_params->cipher_xform;
6756 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6757 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6759 ut_params->sess = rte_cryptodev_sym_session_create(
6760 ts_params->session_mpool);
6762 /* Create Crypto session*/
6763 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6764 ut_params->sess, &ut_params->cipher_xform,
6765 ts_params->session_mpool);
6766 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6768 /* Generate Crypto op data structure */
6769 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6770 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6771 TEST_ASSERT_NOT_NULL(ut_params->op,
6772 "Failed to allocate symmetric crypto operation struct");
6774 /* Set crypto operation data parameters */
6775 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6777 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6779 sym_op->m_src = ut_params->ibuf;
6781 sym_op->cipher.data.offset = 0;
6782 sym_op->cipher.data.length = QUOTE_512_BYTES;
6784 sym_op->auth.data.offset = 0;
6785 sym_op->auth.data.length = QUOTE_512_BYTES;
6787 /* Process crypto operation */
6788 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6790 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6792 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6793 "crypto operation processing failed");
6796 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6797 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6800 "Ciphertext data not as expected");
6802 return TEST_SUCCESS;
6807 test_null_invalid_operation(void)
6809 struct crypto_testsuite_params *ts_params = &testsuite_params;
6810 struct crypto_unittest_params *ut_params = &unittest_params;
6813 /* Setup Cipher Parameters */
6814 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6815 ut_params->cipher_xform.next = NULL;
6817 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6818 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6820 ut_params->sess = rte_cryptodev_sym_session_create(
6821 ts_params->session_mpool);
6823 /* Create Crypto session*/
6824 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6825 ut_params->sess, &ut_params->cipher_xform,
6826 ts_params->session_mpool);
6827 TEST_ASSERT(ret < 0,
6828 "Session creation succeeded unexpectedly");
6831 /* Setup HMAC Parameters */
6832 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6833 ut_params->auth_xform.next = NULL;
6835 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6836 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6838 ut_params->sess = rte_cryptodev_sym_session_create(
6839 ts_params->session_mpool);
6841 /* Create Crypto session*/
6842 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6843 ut_params->sess, &ut_params->auth_xform,
6844 ts_params->session_mpool);
6845 TEST_ASSERT(ret < 0,
6846 "Session creation succeeded unexpectedly");
6848 return TEST_SUCCESS;
6852 #define NULL_BURST_LENGTH (32)
6855 test_null_burst_operation(void)
6857 struct crypto_testsuite_params *ts_params = &testsuite_params;
6858 struct crypto_unittest_params *ut_params = &unittest_params;
6860 unsigned i, burst_len = NULL_BURST_LENGTH;
6862 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6863 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6865 /* Setup Cipher Parameters */
6866 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6867 ut_params->cipher_xform.next = &ut_params->auth_xform;
6869 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6870 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6872 /* Setup HMAC Parameters */
6873 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6874 ut_params->auth_xform.next = NULL;
6876 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6877 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6879 ut_params->sess = rte_cryptodev_sym_session_create(
6880 ts_params->session_mpool);
6882 /* Create Crypto session*/
6883 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6884 ut_params->sess, &ut_params->cipher_xform,
6885 ts_params->session_mpool);
6886 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6888 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6889 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6890 burst_len, "failed to generate burst of crypto ops");
6892 /* Generate an operation for each mbuf in burst */
6893 for (i = 0; i < burst_len; i++) {
6894 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6896 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6898 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6902 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6904 burst[i]->sym->m_src = m;
6907 /* Process crypto operation */
6908 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6909 0, burst, burst_len),
6911 "Error enqueuing burst");
6913 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6914 0, burst_dequeued, burst_len),
6916 "Error dequeuing burst");
6919 for (i = 0; i < burst_len; i++) {
6921 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6922 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6924 "data not as expected");
6926 rte_pktmbuf_free(burst[i]->sym->m_src);
6927 rte_crypto_op_free(burst[i]);
6930 return TEST_SUCCESS;
6934 generate_gmac_large_plaintext(uint8_t *data)
6938 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6939 memcpy(&data[i], &data[0], 32);
6943 create_gmac_operation(enum rte_crypto_auth_operation op,
6944 const struct gmac_test_data *tdata)
6946 struct crypto_testsuite_params *ts_params = &testsuite_params;
6947 struct crypto_unittest_params *ut_params = &unittest_params;
6948 struct rte_crypto_sym_op *sym_op;
6950 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6952 /* Generate Crypto op data structure */
6953 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6954 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6955 TEST_ASSERT_NOT_NULL(ut_params->op,
6956 "Failed to allocate symmetric crypto operation struct");
6958 sym_op = ut_params->op->sym;
6960 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6961 ut_params->ibuf, tdata->gmac_tag.len);
6962 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6963 "no room to append digest");
6965 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6966 ut_params->ibuf, plaintext_pad_len);
6968 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6969 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6970 tdata->gmac_tag.len);
6971 TEST_HEXDUMP(stdout, "digest:",
6972 sym_op->auth.digest.data,
6973 tdata->gmac_tag.len);
6976 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6977 uint8_t *, IV_OFFSET);
6979 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6981 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6983 sym_op->cipher.data.length = 0;
6984 sym_op->cipher.data.offset = 0;
6986 sym_op->auth.data.offset = 0;
6987 sym_op->auth.data.length = tdata->plaintext.len;
6992 static int create_gmac_session(uint8_t dev_id,
6993 const struct gmac_test_data *tdata,
6994 enum rte_crypto_auth_operation auth_op)
6996 uint8_t auth_key[tdata->key.len];
6998 struct crypto_testsuite_params *ts_params = &testsuite_params;
6999 struct crypto_unittest_params *ut_params = &unittest_params;
7001 memcpy(auth_key, tdata->key.data, tdata->key.len);
7003 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7004 ut_params->auth_xform.next = NULL;
7006 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7007 ut_params->auth_xform.auth.op = auth_op;
7008 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7009 ut_params->auth_xform.auth.key.length = tdata->key.len;
7010 ut_params->auth_xform.auth.key.data = auth_key;
7011 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7012 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7015 ut_params->sess = rte_cryptodev_sym_session_create(
7016 ts_params->session_mpool);
7018 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7019 &ut_params->auth_xform,
7020 ts_params->session_mpool);
7022 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7028 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7030 struct crypto_testsuite_params *ts_params = &testsuite_params;
7031 struct crypto_unittest_params *ut_params = &unittest_params;
7035 uint8_t *auth_tag, *plaintext;
7036 uint16_t plaintext_pad_len;
7038 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7039 "No GMAC length in the source data");
7041 retval = create_gmac_session(ts_params->valid_devs[0],
7042 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7047 if (tdata->plaintext.len > MBUF_SIZE)
7048 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7050 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7051 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7052 "Failed to allocate input buffer in mempool");
7054 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7055 rte_pktmbuf_tailroom(ut_params->ibuf));
7057 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7059 * Runtime generate the large plain text instead of use hard code
7060 * plain text vector. It is done to avoid create huge source file
7061 * with the test vector.
7063 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7064 generate_gmac_large_plaintext(tdata->plaintext.data);
7066 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7068 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7070 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7071 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7072 tdata->plaintext.len);
7074 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7080 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7082 ut_params->op->sym->m_src = ut_params->ibuf;
7084 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7085 ut_params->op), "failed to process sym crypto op");
7087 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7088 "crypto op processing failed");
7090 if (ut_params->op->sym->m_dst) {
7091 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7092 uint8_t *, plaintext_pad_len);
7094 auth_tag = plaintext + plaintext_pad_len;
7097 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7099 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7101 tdata->gmac_tag.data,
7102 tdata->gmac_tag.len,
7103 "GMAC Generated auth tag not as expected");
7109 test_AES_GMAC_authentication_test_case_1(void)
7111 return test_AES_GMAC_authentication(&gmac_test_case_1);
7115 test_AES_GMAC_authentication_test_case_2(void)
7117 return test_AES_GMAC_authentication(&gmac_test_case_2);
7121 test_AES_GMAC_authentication_test_case_3(void)
7123 return test_AES_GMAC_authentication(&gmac_test_case_3);
7127 test_AES_GMAC_authentication_test_case_4(void)
7129 return test_AES_GMAC_authentication(&gmac_test_case_4);
7133 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7135 struct crypto_testsuite_params *ts_params = &testsuite_params;
7136 struct crypto_unittest_params *ut_params = &unittest_params;
7138 uint32_t plaintext_pad_len;
7141 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7142 "No GMAC length in the source data");
7144 retval = create_gmac_session(ts_params->valid_devs[0],
7145 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7150 if (tdata->plaintext.len > MBUF_SIZE)
7151 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7153 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7154 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7155 "Failed to allocate input buffer in mempool");
7157 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7158 rte_pktmbuf_tailroom(ut_params->ibuf));
7160 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7163 * Runtime generate the large plain text instead of use hard code
7164 * plain text vector. It is done to avoid create huge source file
7165 * with the test vector.
7167 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7168 generate_gmac_large_plaintext(tdata->plaintext.data);
7170 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7172 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7174 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7175 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7176 tdata->plaintext.len);
7178 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7184 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7186 ut_params->op->sym->m_src = ut_params->ibuf;
7188 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7189 ut_params->op), "failed to process sym crypto op");
7191 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7192 "crypto op processing failed");
7199 test_AES_GMAC_authentication_verify_test_case_1(void)
7201 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7205 test_AES_GMAC_authentication_verify_test_case_2(void)
7207 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7211 test_AES_GMAC_authentication_verify_test_case_3(void)
7213 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7217 test_AES_GMAC_authentication_verify_test_case_4(void)
7219 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7222 struct test_crypto_vector {
7223 enum rte_crypto_cipher_algorithm crypto_algo;
7236 const uint8_t *data;
7241 const uint8_t *data;
7245 enum rte_crypto_auth_algorithm auth_algo;
7253 const uint8_t *data;
7263 static const struct test_crypto_vector
7264 hmac_sha1_test_crypto_vector = {
7265 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7267 .data = plaintext_hash,
7272 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7273 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7274 0xDE, 0xF4, 0xDE, 0xAD
7280 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7281 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7282 0x3F, 0x91, 0x64, 0x59
7288 static const struct test_crypto_vector
7289 aes128_gmac_test_vector = {
7290 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7292 .data = plaintext_hash,
7297 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7298 0x08, 0x09, 0x0A, 0x0B
7304 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7305 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7311 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7312 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7318 static const struct test_crypto_vector
7319 aes128cbc_hmac_sha1_test_vector = {
7320 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7323 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7324 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7330 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7331 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7336 .data = plaintext_hash,
7340 .data = ciphertext512_aes128cbc,
7343 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7346 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7347 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7348 0xDE, 0xF4, 0xDE, 0xAD
7354 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7355 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7356 0x18, 0x8C, 0x1D, 0x32
7363 data_corruption(uint8_t *data)
7369 tag_corruption(uint8_t *data, unsigned int tag_offset)
7371 data[tag_offset] += 1;
7375 create_auth_session(struct crypto_unittest_params *ut_params,
7377 const struct test_crypto_vector *reference,
7378 enum rte_crypto_auth_operation auth_op)
7380 struct crypto_testsuite_params *ts_params = &testsuite_params;
7381 uint8_t auth_key[reference->auth_key.len + 1];
7383 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7385 /* Setup Authentication Parameters */
7386 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7387 ut_params->auth_xform.auth.op = auth_op;
7388 ut_params->auth_xform.next = NULL;
7389 ut_params->auth_xform.auth.algo = reference->auth_algo;
7390 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7391 ut_params->auth_xform.auth.key.data = auth_key;
7392 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7394 /* Create Crypto session*/
7395 ut_params->sess = rte_cryptodev_sym_session_create(
7396 ts_params->session_mpool);
7398 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7399 &ut_params->auth_xform,
7400 ts_params->session_mpool);
7402 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7408 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7410 const struct test_crypto_vector *reference,
7411 enum rte_crypto_auth_operation auth_op,
7412 enum rte_crypto_cipher_operation cipher_op)
7414 struct crypto_testsuite_params *ts_params = &testsuite_params;
7415 uint8_t cipher_key[reference->cipher_key.len + 1];
7416 uint8_t auth_key[reference->auth_key.len + 1];
7418 memcpy(cipher_key, reference->cipher_key.data,
7419 reference->cipher_key.len);
7420 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7422 /* Setup Authentication Parameters */
7423 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7424 ut_params->auth_xform.auth.op = auth_op;
7425 ut_params->auth_xform.auth.algo = reference->auth_algo;
7426 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7427 ut_params->auth_xform.auth.key.data = auth_key;
7428 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7430 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7431 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7432 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7434 ut_params->auth_xform.next = &ut_params->cipher_xform;
7436 /* Setup Cipher Parameters */
7437 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7438 ut_params->cipher_xform.next = NULL;
7439 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7440 ut_params->cipher_xform.cipher.op = cipher_op;
7441 ut_params->cipher_xform.cipher.key.data = cipher_key;
7442 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7443 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7444 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7447 /* Create Crypto session*/
7448 ut_params->sess = rte_cryptodev_sym_session_create(
7449 ts_params->session_mpool);
7451 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7452 &ut_params->auth_xform,
7453 ts_params->session_mpool);
7455 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7461 create_auth_operation(struct crypto_testsuite_params *ts_params,
7462 struct crypto_unittest_params *ut_params,
7463 const struct test_crypto_vector *reference,
7464 unsigned int auth_generate)
7466 /* Generate Crypto op data structure */
7467 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7468 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7469 TEST_ASSERT_NOT_NULL(ut_params->op,
7470 "Failed to allocate pktmbuf offload");
7472 /* Set crypto operation data parameters */
7473 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7475 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7477 /* set crypto operation source mbuf */
7478 sym_op->m_src = ut_params->ibuf;
7481 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7482 ut_params->ibuf, reference->digest.len);
7484 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7485 "no room to append auth tag");
7487 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7488 ut_params->ibuf, reference->plaintext.len);
7491 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7493 memcpy(sym_op->auth.digest.data,
7494 reference->digest.data,
7495 reference->digest.len);
7497 TEST_HEXDUMP(stdout, "digest:",
7498 sym_op->auth.digest.data,
7499 reference->digest.len);
7501 sym_op->auth.data.length = reference->plaintext.len;
7502 sym_op->auth.data.offset = 0;
7508 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7509 struct crypto_unittest_params *ut_params,
7510 const struct test_crypto_vector *reference,
7511 unsigned int auth_generate)
7513 /* Generate Crypto op data structure */
7514 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7515 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7516 TEST_ASSERT_NOT_NULL(ut_params->op,
7517 "Failed to allocate pktmbuf offload");
7519 /* Set crypto operation data parameters */
7520 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7522 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7524 /* set crypto operation source mbuf */
7525 sym_op->m_src = ut_params->ibuf;
7528 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7529 ut_params->ibuf, reference->digest.len);
7531 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7532 "no room to append auth tag");
7534 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7535 ut_params->ibuf, reference->ciphertext.len);
7538 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7540 memcpy(sym_op->auth.digest.data,
7541 reference->digest.data,
7542 reference->digest.len);
7544 TEST_HEXDUMP(stdout, "digest:",
7545 sym_op->auth.digest.data,
7546 reference->digest.len);
7548 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7549 reference->iv.data, reference->iv.len);
7551 sym_op->cipher.data.length = 0;
7552 sym_op->cipher.data.offset = 0;
7554 sym_op->auth.data.length = reference->plaintext.len;
7555 sym_op->auth.data.offset = 0;
7561 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7562 struct crypto_unittest_params *ut_params,
7563 const struct test_crypto_vector *reference,
7564 unsigned int auth_generate)
7566 /* Generate Crypto op data structure */
7567 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7568 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7569 TEST_ASSERT_NOT_NULL(ut_params->op,
7570 "Failed to allocate pktmbuf offload");
7572 /* Set crypto operation data parameters */
7573 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7575 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7577 /* set crypto operation source mbuf */
7578 sym_op->m_src = ut_params->ibuf;
7581 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7582 ut_params->ibuf, reference->digest.len);
7584 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7585 "no room to append auth tag");
7587 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7588 ut_params->ibuf, reference->ciphertext.len);
7591 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7593 memcpy(sym_op->auth.digest.data,
7594 reference->digest.data,
7595 reference->digest.len);
7597 TEST_HEXDUMP(stdout, "digest:",
7598 sym_op->auth.digest.data,
7599 reference->digest.len);
7601 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7602 reference->iv.data, reference->iv.len);
7604 sym_op->cipher.data.length = reference->ciphertext.len;
7605 sym_op->cipher.data.offset = 0;
7607 sym_op->auth.data.length = reference->ciphertext.len;
7608 sym_op->auth.data.offset = 0;
7614 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7615 struct crypto_unittest_params *ut_params,
7616 const struct test_crypto_vector *reference)
7618 return create_auth_operation(ts_params, ut_params, reference, 0);
7622 create_auth_verify_GMAC_operation(
7623 struct crypto_testsuite_params *ts_params,
7624 struct crypto_unittest_params *ut_params,
7625 const struct test_crypto_vector *reference)
7627 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7631 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7632 struct crypto_unittest_params *ut_params,
7633 const struct test_crypto_vector *reference)
7635 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7639 test_authentication_verify_fail_when_data_corruption(
7640 struct crypto_testsuite_params *ts_params,
7641 struct crypto_unittest_params *ut_params,
7642 const struct test_crypto_vector *reference,
7643 unsigned int data_corrupted)
7649 /* Create session */
7650 retval = create_auth_session(ut_params,
7651 ts_params->valid_devs[0],
7653 RTE_CRYPTO_AUTH_OP_VERIFY);
7657 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7658 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7659 "Failed to allocate input buffer in mempool");
7661 /* clear mbuf payload */
7662 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7663 rte_pktmbuf_tailroom(ut_params->ibuf));
7665 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7666 reference->plaintext.len);
7667 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7668 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7670 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7672 /* Create operation */
7673 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7679 data_corruption(plaintext);
7681 tag_corruption(plaintext, reference->plaintext.len);
7683 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7685 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7686 TEST_ASSERT_EQUAL(ut_params->op->status,
7687 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7688 "authentication not failed");
7690 ut_params->obuf = ut_params->op->sym->m_src;
7691 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7697 test_authentication_verify_GMAC_fail_when_corruption(
7698 struct crypto_testsuite_params *ts_params,
7699 struct crypto_unittest_params *ut_params,
7700 const struct test_crypto_vector *reference,
7701 unsigned int data_corrupted)
7706 /* Create session */
7707 retval = create_auth_cipher_session(ut_params,
7708 ts_params->valid_devs[0],
7710 RTE_CRYPTO_AUTH_OP_VERIFY,
7711 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7715 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7716 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7717 "Failed to allocate input buffer in mempool");
7719 /* clear mbuf payload */
7720 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7721 rte_pktmbuf_tailroom(ut_params->ibuf));
7723 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7724 reference->plaintext.len);
7725 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7726 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7728 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7730 /* Create operation */
7731 retval = create_auth_verify_GMAC_operation(ts_params,
7739 data_corruption(plaintext);
7741 tag_corruption(plaintext, reference->aad.len);
7743 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7745 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7746 TEST_ASSERT_EQUAL(ut_params->op->status,
7747 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7748 "authentication not failed");
7750 ut_params->obuf = ut_params->op->sym->m_src;
7751 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7757 test_authenticated_decryption_fail_when_corruption(
7758 struct crypto_testsuite_params *ts_params,
7759 struct crypto_unittest_params *ut_params,
7760 const struct test_crypto_vector *reference,
7761 unsigned int data_corrupted)
7765 uint8_t *ciphertext;
7767 /* Create session */
7768 retval = create_auth_cipher_session(ut_params,
7769 ts_params->valid_devs[0],
7771 RTE_CRYPTO_AUTH_OP_VERIFY,
7772 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7776 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7777 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7778 "Failed to allocate input buffer in mempool");
7780 /* clear mbuf payload */
7781 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7782 rte_pktmbuf_tailroom(ut_params->ibuf));
7784 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7785 reference->ciphertext.len);
7786 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7787 memcpy(ciphertext, reference->ciphertext.data,
7788 reference->ciphertext.len);
7790 /* Create operation */
7791 retval = create_cipher_auth_verify_operation(ts_params,
7799 data_corruption(ciphertext);
7801 tag_corruption(ciphertext, reference->ciphertext.len);
7803 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7806 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7807 TEST_ASSERT_EQUAL(ut_params->op->status,
7808 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7809 "authentication not failed");
7811 ut_params->obuf = ut_params->op->sym->m_src;
7812 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7818 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7819 const struct aead_test_data *tdata,
7820 void *digest_mem, uint64_t digest_phys)
7822 struct crypto_testsuite_params *ts_params = &testsuite_params;
7823 struct crypto_unittest_params *ut_params = &unittest_params;
7825 const unsigned int auth_tag_len = tdata->auth_tag.len;
7826 const unsigned int iv_len = tdata->iv.len;
7827 unsigned int aad_len = tdata->aad.len;
7829 /* Generate Crypto op data structure */
7830 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7831 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7832 TEST_ASSERT_NOT_NULL(ut_params->op,
7833 "Failed to allocate symmetric crypto operation struct");
7835 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7837 sym_op->aead.digest.data = digest_mem;
7839 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7840 "no room to append digest");
7842 sym_op->aead.digest.phys_addr = digest_phys;
7844 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7845 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7847 TEST_HEXDUMP(stdout, "digest:",
7848 sym_op->aead.digest.data,
7852 /* Append aad data */
7853 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7854 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7855 uint8_t *, IV_OFFSET);
7857 /* Copy IV 1 byte after the IV pointer, according to the API */
7858 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
7860 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
7862 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7863 ut_params->ibuf, aad_len);
7864 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7865 "no room to prepend aad");
7866 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7869 memset(sym_op->aead.aad.data, 0, aad_len);
7870 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7871 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7873 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7874 TEST_HEXDUMP(stdout, "aad:",
7875 sym_op->aead.aad.data, aad_len);
7877 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7878 uint8_t *, IV_OFFSET);
7880 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7882 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7883 ut_params->ibuf, aad_len);
7884 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7885 "no room to prepend aad");
7886 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7889 memset(sym_op->aead.aad.data, 0, aad_len);
7890 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7892 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7893 TEST_HEXDUMP(stdout, "aad:",
7894 sym_op->aead.aad.data, aad_len);
7897 sym_op->aead.data.length = tdata->plaintext.len;
7898 sym_op->aead.data.offset = aad_len;
7903 #define SGL_MAX_NO 16
7906 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
7907 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7909 struct crypto_testsuite_params *ts_params = &testsuite_params;
7910 struct crypto_unittest_params *ut_params = &unittest_params;
7911 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7914 int to_trn_tbl[SGL_MAX_NO];
7916 unsigned int trn_data = 0;
7917 uint8_t *plaintext, *ciphertext, *auth_tag;
7919 if (fragsz > tdata->plaintext.len)
7920 fragsz = tdata->plaintext.len;
7922 uint16_t plaintext_len = fragsz;
7923 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7925 if (fragsz_oop > tdata->plaintext.len)
7926 frag_size_oop = tdata->plaintext.len;
7929 void *digest_mem = NULL;
7931 uint32_t prepend_len = tdata->aad.len;
7933 if (tdata->plaintext.len % fragsz != 0) {
7934 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7937 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7942 * For out-op-place we need to alloc another mbuf
7945 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7946 rte_pktmbuf_append(ut_params->obuf,
7947 frag_size_oop + prepend_len);
7948 buf_oop = ut_params->obuf;
7951 /* Create AEAD session */
7952 retval = create_aead_session(ts_params->valid_devs[0],
7954 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7955 tdata->key.data, tdata->key.len,
7956 tdata->aad.len, tdata->auth_tag.len,
7961 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7963 /* clear mbuf payload */
7964 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7965 rte_pktmbuf_tailroom(ut_params->ibuf));
7967 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7970 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7972 trn_data += plaintext_len;
7974 buf = ut_params->ibuf;
7977 * Loop until no more fragments
7980 while (trn_data < tdata->plaintext.len) {
7982 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7983 (tdata->plaintext.len - trn_data) : fragsz;
7985 to_trn_tbl[ecx++] = to_trn;
7987 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7990 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7991 rte_pktmbuf_tailroom(buf));
7994 if (oop && !fragsz_oop) {
7995 buf_last_oop = buf_oop->next =
7996 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7997 buf_oop = buf_oop->next;
7998 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7999 0, rte_pktmbuf_tailroom(buf_oop));
8000 rte_pktmbuf_append(buf_oop, to_trn);
8003 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8006 memcpy(plaintext, tdata->plaintext.data + trn_data,
8009 if (trn_data == tdata->plaintext.len) {
8012 digest_mem = rte_pktmbuf_append(buf_oop,
8013 tdata->auth_tag.len);
8015 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8016 tdata->auth_tag.len);
8020 uint64_t digest_phys = 0;
8022 ut_params->ibuf->nb_segs = segs;
8025 if (fragsz_oop && oop) {
8029 if (frag_size_oop == tdata->plaintext.len) {
8030 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8031 tdata->auth_tag.len);
8033 digest_phys = rte_pktmbuf_mtophys_offset(
8035 tdata->plaintext.len + prepend_len);
8038 trn_data = frag_size_oop;
8039 while (trn_data < tdata->plaintext.len) {
8042 (tdata->plaintext.len - trn_data <
8044 (tdata->plaintext.len - trn_data) :
8047 to_trn_tbl[ecx++] = to_trn;
8049 buf_last_oop = buf_oop->next =
8050 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8051 buf_oop = buf_oop->next;
8052 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8053 0, rte_pktmbuf_tailroom(buf_oop));
8054 rte_pktmbuf_append(buf_oop, to_trn);
8058 if (trn_data == tdata->plaintext.len) {
8059 digest_mem = rte_pktmbuf_append(buf_oop,
8060 tdata->auth_tag.len);
8064 ut_params->obuf->nb_segs = segs;
8068 * Place digest at the end of the last buffer
8071 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
8072 if (oop && buf_last_oop)
8073 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
8075 if (!digest_mem && !oop) {
8076 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8077 + tdata->auth_tag.len);
8078 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
8079 tdata->plaintext.len);
8082 /* Create AEAD operation */
8083 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8084 tdata, digest_mem, digest_phys);
8089 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8091 ut_params->op->sym->m_src = ut_params->ibuf;
8093 ut_params->op->sym->m_dst = ut_params->obuf;
8095 /* Process crypto operation */
8096 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8097 ut_params->op), "failed to process sym crypto op");
8099 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8100 "crypto op processing failed");
8103 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8104 uint8_t *, prepend_len);
8106 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8107 uint8_t *, prepend_len);
8111 fragsz = fragsz_oop;
8113 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8115 tdata->ciphertext.data,
8117 "Ciphertext data not as expected");
8119 buf = ut_params->op->sym->m_src->next;
8121 buf = ut_params->op->sym->m_dst->next;
8123 unsigned int off = fragsz;
8127 ciphertext = rte_pktmbuf_mtod(buf,
8130 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8132 tdata->ciphertext.data + off,
8134 "Ciphertext data not as expected");
8136 off += to_trn_tbl[ecx++];
8140 auth_tag = digest_mem;
8141 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8143 tdata->auth_tag.data,
8144 tdata->auth_tag.len,
8145 "Generated auth tag not as expected");
8151 #define OUT_OF_PLACE 1
8154 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8156 return test_authenticated_encryption_SGL(
8157 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8161 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8163 return test_authenticated_encryption_SGL(
8164 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8168 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8170 return test_authenticated_encryption_SGL(
8171 &gcm_test_case_8, OUT_OF_PLACE, 400,
8172 gcm_test_case_8.plaintext.len);
8176 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8179 return test_authenticated_encryption_SGL(
8180 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8184 test_authentication_verify_fail_when_data_corrupted(
8185 struct crypto_testsuite_params *ts_params,
8186 struct crypto_unittest_params *ut_params,
8187 const struct test_crypto_vector *reference)
8189 return test_authentication_verify_fail_when_data_corruption(
8190 ts_params, ut_params, reference, 1);
8194 test_authentication_verify_fail_when_tag_corrupted(
8195 struct crypto_testsuite_params *ts_params,
8196 struct crypto_unittest_params *ut_params,
8197 const struct test_crypto_vector *reference)
8199 return test_authentication_verify_fail_when_data_corruption(
8200 ts_params, ut_params, reference, 0);
8204 test_authentication_verify_GMAC_fail_when_data_corrupted(
8205 struct crypto_testsuite_params *ts_params,
8206 struct crypto_unittest_params *ut_params,
8207 const struct test_crypto_vector *reference)
8209 return test_authentication_verify_GMAC_fail_when_corruption(
8210 ts_params, ut_params, reference, 1);
8214 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8215 struct crypto_testsuite_params *ts_params,
8216 struct crypto_unittest_params *ut_params,
8217 const struct test_crypto_vector *reference)
8219 return test_authentication_verify_GMAC_fail_when_corruption(
8220 ts_params, ut_params, reference, 0);
8224 test_authenticated_decryption_fail_when_data_corrupted(
8225 struct crypto_testsuite_params *ts_params,
8226 struct crypto_unittest_params *ut_params,
8227 const struct test_crypto_vector *reference)
8229 return test_authenticated_decryption_fail_when_corruption(
8230 ts_params, ut_params, reference, 1);
8234 test_authenticated_decryption_fail_when_tag_corrupted(
8235 struct crypto_testsuite_params *ts_params,
8236 struct crypto_unittest_params *ut_params,
8237 const struct test_crypto_vector *reference)
8239 return test_authenticated_decryption_fail_when_corruption(
8240 ts_params, ut_params, reference, 0);
8244 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8246 return test_authentication_verify_fail_when_data_corrupted(
8247 &testsuite_params, &unittest_params,
8248 &hmac_sha1_test_crypto_vector);
8252 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8254 return test_authentication_verify_fail_when_tag_corrupted(
8255 &testsuite_params, &unittest_params,
8256 &hmac_sha1_test_crypto_vector);
8260 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8262 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8263 &testsuite_params, &unittest_params,
8264 &aes128_gmac_test_vector);
8268 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8270 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8271 &testsuite_params, &unittest_params,
8272 &aes128_gmac_test_vector);
8276 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8278 return test_authenticated_decryption_fail_when_data_corrupted(
8281 &aes128cbc_hmac_sha1_test_vector);
8285 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8287 return test_authenticated_decryption_fail_when_tag_corrupted(
8290 &aes128cbc_hmac_sha1_test_vector);
8293 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8295 /* global AESNI slave IDs for the scheduler test */
8296 uint8_t aesni_ids[2];
8299 test_scheduler_attach_slave_op(void)
8301 struct crypto_testsuite_params *ts_params = &testsuite_params;
8302 uint8_t sched_id = ts_params->valid_devs[0];
8303 uint32_t nb_devs, i, nb_devs_attached = 0;
8307 /* create 2 AESNI_MB if necessary */
8308 nb_devs = rte_cryptodev_device_count_by_driver(
8309 rte_cryptodev_driver_id_get(
8310 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8312 for (i = nb_devs; i < 2; i++) {
8313 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8314 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8316 ret = rte_vdev_init(vdev_name, NULL);
8318 TEST_ASSERT(ret == 0,
8319 "Failed to create instance %u of"
8321 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8325 /* attach 2 AESNI_MB cdevs */
8326 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8328 struct rte_cryptodev_info info;
8330 rte_cryptodev_info_get(i, &info);
8331 if (info.driver_id != rte_cryptodev_driver_id_get(
8332 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8336 * Create the session mempool again, since now there are new devices
8337 * to use the mempool.
8339 if (ts_params->session_mpool) {
8340 rte_mempool_free(ts_params->session_mpool);
8341 ts_params->session_mpool = NULL;
8343 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8346 * Create mempool with maximum number of sessions * 2,
8347 * to include the session headers
8349 if (ts_params->session_mpool == NULL) {
8350 ts_params->session_mpool = rte_mempool_create(
8352 info.sym.max_nb_sessions * 2,
8354 0, 0, NULL, NULL, NULL,
8355 NULL, SOCKET_ID_ANY,
8358 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8359 "session mempool allocation failed");
8362 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8365 TEST_ASSERT(ret == 0,
8366 "Failed to attach device %u of pmd : %s", i,
8367 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8369 aesni_ids[nb_devs_attached] = (uint8_t)i;
8378 test_scheduler_detach_slave_op(void)
8380 struct crypto_testsuite_params *ts_params = &testsuite_params;
8381 uint8_t sched_id = ts_params->valid_devs[0];
8385 for (i = 0; i < 2; i++) {
8386 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8388 TEST_ASSERT(ret == 0,
8389 "Failed to detach device %u", aesni_ids[i]);
8396 test_scheduler_mode_op(void)
8398 struct crypto_testsuite_params *ts_params = &testsuite_params;
8399 uint8_t sched_id = ts_params->valid_devs[0];
8400 struct rte_cryptodev_scheduler_ops op = {0};
8401 struct rte_cryptodev_scheduler dummy_scheduler = {
8402 .description = "dummy scheduler to test mode",
8403 .name = "dummy scheduler",
8404 .mode = CDEV_SCHED_MODE_USERDEFINED,
8409 /* set user defined mode */
8410 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8412 TEST_ASSERT(ret == 0,
8413 "Failed to set cdev %u to user defined mode", sched_id);
8415 /* set round robin mode */
8416 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8417 CDEV_SCHED_MODE_ROUNDROBIN);
8418 TEST_ASSERT(ret == 0,
8419 "Failed to set cdev %u to round-robin mode", sched_id);
8420 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8421 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8427 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8428 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8429 .setup = testsuite_setup,
8430 .teardown = testsuite_teardown,
8431 .unit_test_cases = {
8432 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8433 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8434 TEST_CASE_ST(ut_setup, ut_teardown,
8435 test_AES_chain_scheduler_all),
8436 TEST_CASE_ST(ut_setup, ut_teardown,
8437 test_AES_cipheronly_scheduler_all),
8438 TEST_CASE_ST(ut_setup, ut_teardown,
8439 test_authonly_scheduler_all),
8440 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8441 TEST_CASES_END() /**< NULL terminate unit test array */
8445 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8447 static struct unit_test_suite cryptodev_qat_testsuite = {
8448 .suite_name = "Crypto QAT Unit Test Suite",
8449 .setup = testsuite_setup,
8450 .teardown = testsuite_teardown,
8451 .unit_test_cases = {
8452 TEST_CASE_ST(ut_setup, ut_teardown,
8453 test_device_configure_invalid_dev_id),
8454 TEST_CASE_ST(ut_setup, ut_teardown,
8455 test_device_configure_invalid_queue_pair_ids),
8456 TEST_CASE_ST(ut_setup, ut_teardown,
8457 test_queue_pair_descriptor_setup),
8458 TEST_CASE_ST(ut_setup, ut_teardown,
8459 test_multi_session),
8461 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8462 TEST_CASE_ST(ut_setup, ut_teardown,
8463 test_AES_cipheronly_qat_all),
8464 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8465 TEST_CASE_ST(ut_setup, ut_teardown,
8466 test_3DES_cipheronly_qat_all),
8467 TEST_CASE_ST(ut_setup, ut_teardown,
8468 test_DES_cipheronly_qat_all),
8469 TEST_CASE_ST(ut_setup, ut_teardown,
8470 test_AES_docsis_qat_all),
8471 TEST_CASE_ST(ut_setup, ut_teardown,
8472 test_DES_docsis_qat_all),
8473 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8474 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8476 /** AES CCM Authenticated Encryption 128 bits key */
8477 TEST_CASE_ST(ut_setup, ut_teardown,
8478 test_AES_CCM_authenticated_encryption_test_case_128_1),
8479 TEST_CASE_ST(ut_setup, ut_teardown,
8480 test_AES_CCM_authenticated_encryption_test_case_128_2),
8481 TEST_CASE_ST(ut_setup, ut_teardown,
8482 test_AES_CCM_authenticated_encryption_test_case_128_3),
8484 /** AES CCM Authenticated Decryption 128 bits key*/
8485 TEST_CASE_ST(ut_setup, ut_teardown,
8486 test_AES_CCM_authenticated_decryption_test_case_128_1),
8487 TEST_CASE_ST(ut_setup, ut_teardown,
8488 test_AES_CCM_authenticated_decryption_test_case_128_2),
8489 TEST_CASE_ST(ut_setup, ut_teardown,
8490 test_AES_CCM_authenticated_decryption_test_case_128_3),
8492 /** AES GCM Authenticated Encryption */
8493 TEST_CASE_ST(ut_setup, ut_teardown,
8494 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8495 TEST_CASE_ST(ut_setup, ut_teardown,
8496 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8497 TEST_CASE_ST(ut_setup, ut_teardown,
8498 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8499 TEST_CASE_ST(ut_setup, ut_teardown,
8500 test_AES_GCM_authenticated_encryption_test_case_1),
8501 TEST_CASE_ST(ut_setup, ut_teardown,
8502 test_AES_GCM_authenticated_encryption_test_case_2),
8503 TEST_CASE_ST(ut_setup, ut_teardown,
8504 test_AES_GCM_authenticated_encryption_test_case_3),
8505 TEST_CASE_ST(ut_setup, ut_teardown,
8506 test_AES_GCM_authenticated_encryption_test_case_4),
8507 TEST_CASE_ST(ut_setup, ut_teardown,
8508 test_AES_GCM_authenticated_encryption_test_case_5),
8509 TEST_CASE_ST(ut_setup, ut_teardown,
8510 test_AES_GCM_authenticated_encryption_test_case_6),
8511 TEST_CASE_ST(ut_setup, ut_teardown,
8512 test_AES_GCM_authenticated_encryption_test_case_7),
8514 /** AES GCM Authenticated Decryption */
8515 TEST_CASE_ST(ut_setup, ut_teardown,
8516 test_AES_GCM_authenticated_decryption_test_case_1),
8517 TEST_CASE_ST(ut_setup, ut_teardown,
8518 test_AES_GCM_authenticated_decryption_test_case_2),
8519 TEST_CASE_ST(ut_setup, ut_teardown,
8520 test_AES_GCM_authenticated_decryption_test_case_3),
8521 TEST_CASE_ST(ut_setup, ut_teardown,
8522 test_AES_GCM_authenticated_decryption_test_case_4),
8523 TEST_CASE_ST(ut_setup, ut_teardown,
8524 test_AES_GCM_authenticated_decryption_test_case_5),
8525 TEST_CASE_ST(ut_setup, ut_teardown,
8526 test_AES_GCM_authenticated_decryption_test_case_6),
8527 TEST_CASE_ST(ut_setup, ut_teardown,
8528 test_AES_GCM_authenticated_decryption_test_case_7),
8530 /** AES GCM Authenticated Encryption 192 bits key */
8531 TEST_CASE_ST(ut_setup, ut_teardown,
8532 test_AES_GCM_auth_encryption_test_case_192_1),
8533 TEST_CASE_ST(ut_setup, ut_teardown,
8534 test_AES_GCM_auth_encryption_test_case_192_2),
8535 TEST_CASE_ST(ut_setup, ut_teardown,
8536 test_AES_GCM_auth_encryption_test_case_192_3),
8537 TEST_CASE_ST(ut_setup, ut_teardown,
8538 test_AES_GCM_auth_encryption_test_case_192_4),
8539 TEST_CASE_ST(ut_setup, ut_teardown,
8540 test_AES_GCM_auth_encryption_test_case_192_5),
8541 TEST_CASE_ST(ut_setup, ut_teardown,
8542 test_AES_GCM_auth_encryption_test_case_192_6),
8543 TEST_CASE_ST(ut_setup, ut_teardown,
8544 test_AES_GCM_auth_encryption_test_case_192_7),
8546 /** AES GCM Authenticated Decryption 192 bits key */
8547 TEST_CASE_ST(ut_setup, ut_teardown,
8548 test_AES_GCM_auth_decryption_test_case_192_1),
8549 TEST_CASE_ST(ut_setup, ut_teardown,
8550 test_AES_GCM_auth_decryption_test_case_192_2),
8551 TEST_CASE_ST(ut_setup, ut_teardown,
8552 test_AES_GCM_auth_decryption_test_case_192_3),
8553 TEST_CASE_ST(ut_setup, ut_teardown,
8554 test_AES_GCM_auth_decryption_test_case_192_4),
8555 TEST_CASE_ST(ut_setup, ut_teardown,
8556 test_AES_GCM_auth_decryption_test_case_192_5),
8557 TEST_CASE_ST(ut_setup, ut_teardown,
8558 test_AES_GCM_auth_decryption_test_case_192_6),
8559 TEST_CASE_ST(ut_setup, ut_teardown,
8560 test_AES_GCM_auth_decryption_test_case_192_7),
8562 /** AES GCM Authenticated Encryption 256 bits key */
8563 TEST_CASE_ST(ut_setup, ut_teardown,
8564 test_AES_GCM_auth_encryption_test_case_256_1),
8565 TEST_CASE_ST(ut_setup, ut_teardown,
8566 test_AES_GCM_auth_encryption_test_case_256_2),
8567 TEST_CASE_ST(ut_setup, ut_teardown,
8568 test_AES_GCM_auth_encryption_test_case_256_3),
8569 TEST_CASE_ST(ut_setup, ut_teardown,
8570 test_AES_GCM_auth_encryption_test_case_256_4),
8571 TEST_CASE_ST(ut_setup, ut_teardown,
8572 test_AES_GCM_auth_encryption_test_case_256_5),
8573 TEST_CASE_ST(ut_setup, ut_teardown,
8574 test_AES_GCM_auth_encryption_test_case_256_6),
8575 TEST_CASE_ST(ut_setup, ut_teardown,
8576 test_AES_GCM_auth_encryption_test_case_256_7),
8578 /** AES GMAC Authentication */
8579 TEST_CASE_ST(ut_setup, ut_teardown,
8580 test_AES_GMAC_authentication_test_case_1),
8581 TEST_CASE_ST(ut_setup, ut_teardown,
8582 test_AES_GMAC_authentication_verify_test_case_1),
8583 TEST_CASE_ST(ut_setup, ut_teardown,
8584 test_AES_GMAC_authentication_test_case_2),
8585 TEST_CASE_ST(ut_setup, ut_teardown,
8586 test_AES_GMAC_authentication_verify_test_case_2),
8587 TEST_CASE_ST(ut_setup, ut_teardown,
8588 test_AES_GMAC_authentication_test_case_3),
8589 TEST_CASE_ST(ut_setup, ut_teardown,
8590 test_AES_GMAC_authentication_verify_test_case_3),
8592 /** SNOW 3G encrypt only (UEA2) */
8593 TEST_CASE_ST(ut_setup, ut_teardown,
8594 test_snow3g_encryption_test_case_1),
8595 TEST_CASE_ST(ut_setup, ut_teardown,
8596 test_snow3g_encryption_test_case_2),
8597 TEST_CASE_ST(ut_setup, ut_teardown,
8598 test_snow3g_encryption_test_case_3),
8599 TEST_CASE_ST(ut_setup, ut_teardown,
8600 test_snow3g_encryption_test_case_4),
8601 TEST_CASE_ST(ut_setup, ut_teardown,
8602 test_snow3g_encryption_test_case_5),
8604 TEST_CASE_ST(ut_setup, ut_teardown,
8605 test_snow3g_encryption_test_case_1_oop),
8606 TEST_CASE_ST(ut_setup, ut_teardown,
8607 test_snow3g_decryption_test_case_1_oop),
8609 /** SNOW 3G decrypt only (UEA2) */
8610 TEST_CASE_ST(ut_setup, ut_teardown,
8611 test_snow3g_decryption_test_case_1),
8612 TEST_CASE_ST(ut_setup, ut_teardown,
8613 test_snow3g_decryption_test_case_2),
8614 TEST_CASE_ST(ut_setup, ut_teardown,
8615 test_snow3g_decryption_test_case_3),
8616 TEST_CASE_ST(ut_setup, ut_teardown,
8617 test_snow3g_decryption_test_case_4),
8618 TEST_CASE_ST(ut_setup, ut_teardown,
8619 test_snow3g_decryption_test_case_5),
8620 TEST_CASE_ST(ut_setup, ut_teardown,
8621 test_snow3g_hash_generate_test_case_1),
8622 TEST_CASE_ST(ut_setup, ut_teardown,
8623 test_snow3g_hash_generate_test_case_2),
8624 TEST_CASE_ST(ut_setup, ut_teardown,
8625 test_snow3g_hash_generate_test_case_3),
8626 TEST_CASE_ST(ut_setup, ut_teardown,
8627 test_snow3g_hash_verify_test_case_1),
8628 TEST_CASE_ST(ut_setup, ut_teardown,
8629 test_snow3g_hash_verify_test_case_2),
8630 TEST_CASE_ST(ut_setup, ut_teardown,
8631 test_snow3g_hash_verify_test_case_3),
8632 TEST_CASE_ST(ut_setup, ut_teardown,
8633 test_snow3g_cipher_auth_test_case_1),
8634 TEST_CASE_ST(ut_setup, ut_teardown,
8635 test_snow3g_auth_cipher_test_case_1),
8637 /** ZUC encrypt only (EEA3) */
8638 TEST_CASE_ST(ut_setup, ut_teardown,
8639 test_zuc_encryption_test_case_1),
8640 TEST_CASE_ST(ut_setup, ut_teardown,
8641 test_zuc_encryption_test_case_2),
8642 TEST_CASE_ST(ut_setup, ut_teardown,
8643 test_zuc_encryption_test_case_3),
8644 TEST_CASE_ST(ut_setup, ut_teardown,
8645 test_zuc_encryption_test_case_4),
8646 TEST_CASE_ST(ut_setup, ut_teardown,
8647 test_zuc_encryption_test_case_5),
8649 /** ZUC authenticate (EIA3) */
8650 TEST_CASE_ST(ut_setup, ut_teardown,
8651 test_zuc_hash_generate_test_case_6),
8652 TEST_CASE_ST(ut_setup, ut_teardown,
8653 test_zuc_hash_generate_test_case_7),
8654 TEST_CASE_ST(ut_setup, ut_teardown,
8655 test_zuc_hash_generate_test_case_8),
8657 /** ZUC alg-chain (EEA3/EIA3) */
8658 TEST_CASE_ST(ut_setup, ut_teardown,
8659 test_zuc_cipher_auth_test_case_1),
8660 TEST_CASE_ST(ut_setup, ut_teardown,
8661 test_zuc_cipher_auth_test_case_2),
8663 /** HMAC_MD5 Authentication */
8664 TEST_CASE_ST(ut_setup, ut_teardown,
8665 test_MD5_HMAC_generate_case_1),
8666 TEST_CASE_ST(ut_setup, ut_teardown,
8667 test_MD5_HMAC_verify_case_1),
8668 TEST_CASE_ST(ut_setup, ut_teardown,
8669 test_MD5_HMAC_generate_case_2),
8670 TEST_CASE_ST(ut_setup, ut_teardown,
8671 test_MD5_HMAC_verify_case_2),
8674 TEST_CASE_ST(ut_setup, ut_teardown,
8675 test_null_auth_only_operation),
8676 TEST_CASE_ST(ut_setup, ut_teardown,
8677 test_null_cipher_only_operation),
8678 TEST_CASE_ST(ut_setup, ut_teardown,
8679 test_null_cipher_auth_operation),
8680 TEST_CASE_ST(ut_setup, ut_teardown,
8681 test_null_auth_cipher_operation),
8684 TEST_CASE_ST(ut_setup, ut_teardown,
8685 test_kasumi_hash_generate_test_case_1),
8686 TEST_CASE_ST(ut_setup, ut_teardown,
8687 test_kasumi_hash_generate_test_case_2),
8688 TEST_CASE_ST(ut_setup, ut_teardown,
8689 test_kasumi_hash_generate_test_case_3),
8690 TEST_CASE_ST(ut_setup, ut_teardown,
8691 test_kasumi_hash_generate_test_case_4),
8692 TEST_CASE_ST(ut_setup, ut_teardown,
8693 test_kasumi_hash_generate_test_case_5),
8694 TEST_CASE_ST(ut_setup, ut_teardown,
8695 test_kasumi_hash_generate_test_case_6),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_kasumi_hash_verify_test_case_1),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_kasumi_hash_verify_test_case_2),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_kasumi_hash_verify_test_case_3),
8703 TEST_CASE_ST(ut_setup, ut_teardown,
8704 test_kasumi_hash_verify_test_case_4),
8705 TEST_CASE_ST(ut_setup, ut_teardown,
8706 test_kasumi_hash_verify_test_case_5),
8708 TEST_CASE_ST(ut_setup, ut_teardown,
8709 test_kasumi_encryption_test_case_1),
8710 TEST_CASE_ST(ut_setup, ut_teardown,
8711 test_kasumi_encryption_test_case_3),
8712 TEST_CASE_ST(ut_setup, ut_teardown,
8713 test_kasumi_auth_cipher_test_case_1),
8714 TEST_CASE_ST(ut_setup, ut_teardown,
8715 test_kasumi_cipher_auth_test_case_1),
8717 /** Negative tests */
8718 TEST_CASE_ST(ut_setup, ut_teardown,
8719 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8720 TEST_CASE_ST(ut_setup, ut_teardown,
8721 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8722 TEST_CASE_ST(ut_setup, ut_teardown,
8723 authentication_verify_AES128_GMAC_fail_data_corrupt),
8724 TEST_CASE_ST(ut_setup, ut_teardown,
8725 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8726 TEST_CASE_ST(ut_setup, ut_teardown,
8727 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8728 TEST_CASE_ST(ut_setup, ut_teardown,
8729 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8731 TEST_CASES_END() /**< NULL terminate unit test array */
8735 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8736 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8737 .setup = testsuite_setup,
8738 .teardown = testsuite_teardown,
8739 .unit_test_cases = {
8740 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8741 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8742 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8743 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_DES_cipheronly_mb_all),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_DES_docsis_mb_all),
8749 TEST_CASES_END() /**< NULL terminate unit test array */
8753 static struct unit_test_suite cryptodev_openssl_testsuite = {
8754 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8755 .setup = testsuite_setup,
8756 .teardown = testsuite_teardown,
8757 .unit_test_cases = {
8758 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8759 TEST_CASE_ST(ut_setup, ut_teardown,
8760 test_multi_session_random_usage),
8761 TEST_CASE_ST(ut_setup, ut_teardown,
8762 test_AES_chain_openssl_all),
8763 TEST_CASE_ST(ut_setup, ut_teardown,
8764 test_AES_cipheronly_openssl_all),
8765 TEST_CASE_ST(ut_setup, ut_teardown,
8766 test_3DES_chain_openssl_all),
8767 TEST_CASE_ST(ut_setup, ut_teardown,
8768 test_3DES_cipheronly_openssl_all),
8769 TEST_CASE_ST(ut_setup, ut_teardown,
8770 test_DES_cipheronly_openssl_all),
8771 TEST_CASE_ST(ut_setup, ut_teardown,
8772 test_DES_docsis_openssl_all),
8773 TEST_CASE_ST(ut_setup, ut_teardown,
8774 test_authonly_openssl_all),
8776 /** AES GCM Authenticated Encryption */
8777 TEST_CASE_ST(ut_setup, ut_teardown,
8778 test_AES_GCM_authenticated_encryption_test_case_1),
8779 TEST_CASE_ST(ut_setup, ut_teardown,
8780 test_AES_GCM_authenticated_encryption_test_case_2),
8781 TEST_CASE_ST(ut_setup, ut_teardown,
8782 test_AES_GCM_authenticated_encryption_test_case_3),
8783 TEST_CASE_ST(ut_setup, ut_teardown,
8784 test_AES_GCM_authenticated_encryption_test_case_4),
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_AES_GCM_authenticated_encryption_test_case_5),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_AES_GCM_authenticated_encryption_test_case_6),
8789 TEST_CASE_ST(ut_setup, ut_teardown,
8790 test_AES_GCM_authenticated_encryption_test_case_7),
8792 /** AES GCM Authenticated Decryption */
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_AES_GCM_authenticated_decryption_test_case_1),
8795 TEST_CASE_ST(ut_setup, ut_teardown,
8796 test_AES_GCM_authenticated_decryption_test_case_2),
8797 TEST_CASE_ST(ut_setup, ut_teardown,
8798 test_AES_GCM_authenticated_decryption_test_case_3),
8799 TEST_CASE_ST(ut_setup, ut_teardown,
8800 test_AES_GCM_authenticated_decryption_test_case_4),
8801 TEST_CASE_ST(ut_setup, ut_teardown,
8802 test_AES_GCM_authenticated_decryption_test_case_5),
8803 TEST_CASE_ST(ut_setup, ut_teardown,
8804 test_AES_GCM_authenticated_decryption_test_case_6),
8805 TEST_CASE_ST(ut_setup, ut_teardown,
8806 test_AES_GCM_authenticated_decryption_test_case_7),
8809 /** AES GCM Authenticated Encryption 192 bits key */
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_AES_GCM_auth_encryption_test_case_192_1),
8812 TEST_CASE_ST(ut_setup, ut_teardown,
8813 test_AES_GCM_auth_encryption_test_case_192_2),
8814 TEST_CASE_ST(ut_setup, ut_teardown,
8815 test_AES_GCM_auth_encryption_test_case_192_3),
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_AES_GCM_auth_encryption_test_case_192_4),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_AES_GCM_auth_encryption_test_case_192_5),
8820 TEST_CASE_ST(ut_setup, ut_teardown,
8821 test_AES_GCM_auth_encryption_test_case_192_6),
8822 TEST_CASE_ST(ut_setup, ut_teardown,
8823 test_AES_GCM_auth_encryption_test_case_192_7),
8825 /** AES GCM Authenticated Decryption 192 bits key */
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_AES_GCM_auth_decryption_test_case_192_1),
8828 TEST_CASE_ST(ut_setup, ut_teardown,
8829 test_AES_GCM_auth_decryption_test_case_192_2),
8830 TEST_CASE_ST(ut_setup, ut_teardown,
8831 test_AES_GCM_auth_decryption_test_case_192_3),
8832 TEST_CASE_ST(ut_setup, ut_teardown,
8833 test_AES_GCM_auth_decryption_test_case_192_4),
8834 TEST_CASE_ST(ut_setup, ut_teardown,
8835 test_AES_GCM_auth_decryption_test_case_192_5),
8836 TEST_CASE_ST(ut_setup, ut_teardown,
8837 test_AES_GCM_auth_decryption_test_case_192_6),
8838 TEST_CASE_ST(ut_setup, ut_teardown,
8839 test_AES_GCM_auth_decryption_test_case_192_7),
8841 /** AES GCM Authenticated Encryption 256 bits key */
8842 TEST_CASE_ST(ut_setup, ut_teardown,
8843 test_AES_GCM_auth_encryption_test_case_256_1),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_AES_GCM_auth_encryption_test_case_256_2),
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_AES_GCM_auth_encryption_test_case_256_3),
8848 TEST_CASE_ST(ut_setup, ut_teardown,
8849 test_AES_GCM_auth_encryption_test_case_256_4),
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_AES_GCM_auth_encryption_test_case_256_5),
8852 TEST_CASE_ST(ut_setup, ut_teardown,
8853 test_AES_GCM_auth_encryption_test_case_256_6),
8854 TEST_CASE_ST(ut_setup, ut_teardown,
8855 test_AES_GCM_auth_encryption_test_case_256_7),
8857 /** AES GCM Authenticated Decryption 256 bits key */
8858 TEST_CASE_ST(ut_setup, ut_teardown,
8859 test_AES_GCM_auth_decryption_test_case_256_1),
8860 TEST_CASE_ST(ut_setup, ut_teardown,
8861 test_AES_GCM_auth_decryption_test_case_256_2),
8862 TEST_CASE_ST(ut_setup, ut_teardown,
8863 test_AES_GCM_auth_decryption_test_case_256_3),
8864 TEST_CASE_ST(ut_setup, ut_teardown,
8865 test_AES_GCM_auth_decryption_test_case_256_4),
8866 TEST_CASE_ST(ut_setup, ut_teardown,
8867 test_AES_GCM_auth_decryption_test_case_256_5),
8868 TEST_CASE_ST(ut_setup, ut_teardown,
8869 test_AES_GCM_auth_decryption_test_case_256_6),
8870 TEST_CASE_ST(ut_setup, ut_teardown,
8871 test_AES_GCM_auth_decryption_test_case_256_7),
8873 /** AES GMAC Authentication */
8874 TEST_CASE_ST(ut_setup, ut_teardown,
8875 test_AES_GMAC_authentication_test_case_1),
8876 TEST_CASE_ST(ut_setup, ut_teardown,
8877 test_AES_GMAC_authentication_verify_test_case_1),
8878 TEST_CASE_ST(ut_setup, ut_teardown,
8879 test_AES_GMAC_authentication_test_case_2),
8880 TEST_CASE_ST(ut_setup, ut_teardown,
8881 test_AES_GMAC_authentication_verify_test_case_2),
8882 TEST_CASE_ST(ut_setup, ut_teardown,
8883 test_AES_GMAC_authentication_test_case_3),
8884 TEST_CASE_ST(ut_setup, ut_teardown,
8885 test_AES_GMAC_authentication_verify_test_case_3),
8886 TEST_CASE_ST(ut_setup, ut_teardown,
8887 test_AES_GMAC_authentication_test_case_4),
8888 TEST_CASE_ST(ut_setup, ut_teardown,
8889 test_AES_GMAC_authentication_verify_test_case_4),
8891 /** AES CCM Authenticated Encryption 128 bits key */
8892 TEST_CASE_ST(ut_setup, ut_teardown,
8893 test_AES_CCM_authenticated_encryption_test_case_128_1),
8894 TEST_CASE_ST(ut_setup, ut_teardown,
8895 test_AES_CCM_authenticated_encryption_test_case_128_2),
8896 TEST_CASE_ST(ut_setup, ut_teardown,
8897 test_AES_CCM_authenticated_encryption_test_case_128_3),
8899 /** AES CCM Authenticated Decryption 128 bits key*/
8900 TEST_CASE_ST(ut_setup, ut_teardown,
8901 test_AES_CCM_authenticated_decryption_test_case_128_1),
8902 TEST_CASE_ST(ut_setup, ut_teardown,
8903 test_AES_CCM_authenticated_decryption_test_case_128_2),
8904 TEST_CASE_ST(ut_setup, ut_teardown,
8905 test_AES_CCM_authenticated_decryption_test_case_128_3),
8907 /** AES CCM Authenticated Encryption 192 bits key */
8908 TEST_CASE_ST(ut_setup, ut_teardown,
8909 test_AES_CCM_authenticated_encryption_test_case_192_1),
8910 TEST_CASE_ST(ut_setup, ut_teardown,
8911 test_AES_CCM_authenticated_encryption_test_case_192_2),
8912 TEST_CASE_ST(ut_setup, ut_teardown,
8913 test_AES_CCM_authenticated_encryption_test_case_192_3),
8915 /** AES CCM Authenticated Decryption 192 bits key*/
8916 TEST_CASE_ST(ut_setup, ut_teardown,
8917 test_AES_CCM_authenticated_decryption_test_case_192_1),
8918 TEST_CASE_ST(ut_setup, ut_teardown,
8919 test_AES_CCM_authenticated_decryption_test_case_192_2),
8920 TEST_CASE_ST(ut_setup, ut_teardown,
8921 test_AES_CCM_authenticated_decryption_test_case_192_3),
8923 /** AES CCM Authenticated Encryption 256 bits key */
8924 TEST_CASE_ST(ut_setup, ut_teardown,
8925 test_AES_CCM_authenticated_encryption_test_case_256_1),
8926 TEST_CASE_ST(ut_setup, ut_teardown,
8927 test_AES_CCM_authenticated_encryption_test_case_256_2),
8928 TEST_CASE_ST(ut_setup, ut_teardown,
8929 test_AES_CCM_authenticated_encryption_test_case_256_3),
8931 /** AES CCM Authenticated Decryption 256 bits key*/
8932 TEST_CASE_ST(ut_setup, ut_teardown,
8933 test_AES_CCM_authenticated_decryption_test_case_256_1),
8934 TEST_CASE_ST(ut_setup, ut_teardown,
8935 test_AES_CCM_authenticated_decryption_test_case_256_2),
8936 TEST_CASE_ST(ut_setup, ut_teardown,
8937 test_AES_CCM_authenticated_decryption_test_case_256_3),
8939 /** Scatter-Gather */
8940 TEST_CASE_ST(ut_setup, ut_teardown,
8941 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8943 /** Negative tests */
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 authentication_verify_AES128_GMAC_fail_data_corrupt),
8950 TEST_CASE_ST(ut_setup, ut_teardown,
8951 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8952 TEST_CASE_ST(ut_setup, ut_teardown,
8953 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8954 TEST_CASE_ST(ut_setup, ut_teardown,
8955 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8957 TEST_CASES_END() /**< NULL terminate unit test array */
8961 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8962 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8963 .setup = testsuite_setup,
8964 .teardown = testsuite_teardown,
8965 .unit_test_cases = {
8966 /** AES GCM Authenticated Encryption */
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 test_AES_GCM_authenticated_encryption_test_case_1),
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 test_AES_GCM_authenticated_encryption_test_case_2),
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 test_AES_GCM_authenticated_encryption_test_case_3),
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_AES_GCM_authenticated_encryption_test_case_4),
8975 TEST_CASE_ST(ut_setup, ut_teardown,
8976 test_AES_GCM_authenticated_encryption_test_case_5),
8977 TEST_CASE_ST(ut_setup, ut_teardown,
8978 test_AES_GCM_authenticated_encryption_test_case_6),
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_AES_GCM_authenticated_encryption_test_case_7),
8982 /** AES GCM Authenticated Decryption */
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_AES_GCM_authenticated_decryption_test_case_1),
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_AES_GCM_authenticated_decryption_test_case_2),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_AES_GCM_authenticated_decryption_test_case_3),
8989 TEST_CASE_ST(ut_setup, ut_teardown,
8990 test_AES_GCM_authenticated_decryption_test_case_4),
8991 TEST_CASE_ST(ut_setup, ut_teardown,
8992 test_AES_GCM_authenticated_decryption_test_case_5),
8993 TEST_CASE_ST(ut_setup, ut_teardown,
8994 test_AES_GCM_authenticated_decryption_test_case_6),
8995 TEST_CASE_ST(ut_setup, ut_teardown,
8996 test_AES_GCM_authenticated_decryption_test_case_7),
8998 /** AES GCM Authenticated Encryption 192 bits key */
8999 TEST_CASE_ST(ut_setup, ut_teardown,
9000 test_AES_GCM_auth_encryption_test_case_192_1),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 test_AES_GCM_auth_encryption_test_case_192_2),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_AES_GCM_auth_encryption_test_case_192_3),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_AES_GCM_auth_encryption_test_case_192_4),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_GCM_auth_encryption_test_case_192_5),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_AES_GCM_auth_encryption_test_case_192_6),
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_AES_GCM_auth_encryption_test_case_192_7),
9014 /** AES GCM Authenticated Decryption 192 bits key */
9015 TEST_CASE_ST(ut_setup, ut_teardown,
9016 test_AES_GCM_auth_decryption_test_case_192_1),
9017 TEST_CASE_ST(ut_setup, ut_teardown,
9018 test_AES_GCM_auth_decryption_test_case_192_2),
9019 TEST_CASE_ST(ut_setup, ut_teardown,
9020 test_AES_GCM_auth_decryption_test_case_192_3),
9021 TEST_CASE_ST(ut_setup, ut_teardown,
9022 test_AES_GCM_auth_decryption_test_case_192_4),
9023 TEST_CASE_ST(ut_setup, ut_teardown,
9024 test_AES_GCM_auth_decryption_test_case_192_5),
9025 TEST_CASE_ST(ut_setup, ut_teardown,
9026 test_AES_GCM_auth_decryption_test_case_192_6),
9027 TEST_CASE_ST(ut_setup, ut_teardown,
9028 test_AES_GCM_auth_decryption_test_case_192_7),
9030 /** AES GCM Authenticated Encryption 256 bits key */
9031 TEST_CASE_ST(ut_setup, ut_teardown,
9032 test_AES_GCM_auth_encryption_test_case_256_1),
9033 TEST_CASE_ST(ut_setup, ut_teardown,
9034 test_AES_GCM_auth_encryption_test_case_256_2),
9035 TEST_CASE_ST(ut_setup, ut_teardown,
9036 test_AES_GCM_auth_encryption_test_case_256_3),
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_AES_GCM_auth_encryption_test_case_256_4),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_AES_GCM_auth_encryption_test_case_256_5),
9041 TEST_CASE_ST(ut_setup, ut_teardown,
9042 test_AES_GCM_auth_encryption_test_case_256_6),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_AES_GCM_auth_encryption_test_case_256_7),
9046 /** AES GCM Authenticated Decryption 256 bits key */
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_GCM_auth_decryption_test_case_256_1),
9049 TEST_CASE_ST(ut_setup, ut_teardown,
9050 test_AES_GCM_auth_decryption_test_case_256_2),
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_AES_GCM_auth_decryption_test_case_256_3),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_AES_GCM_auth_decryption_test_case_256_4),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_AES_GCM_auth_decryption_test_case_256_5),
9057 TEST_CASE_ST(ut_setup, ut_teardown,
9058 test_AES_GCM_auth_decryption_test_case_256_6),
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_AES_GCM_auth_decryption_test_case_256_7),
9062 /** AES GCM Authenticated Encryption big aad size */
9063 TEST_CASE_ST(ut_setup, ut_teardown,
9064 test_AES_GCM_auth_encryption_test_case_aad_1),
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_AES_GCM_auth_encryption_test_case_aad_2),
9068 /** AES GCM Authenticated Decryption big aad size */
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_AES_GCM_auth_decryption_test_case_aad_1),
9071 TEST_CASE_ST(ut_setup, ut_teardown,
9072 test_AES_GCM_auth_decryption_test_case_aad_2),
9074 /** AES GMAC Authentication */
9075 TEST_CASE_ST(ut_setup, ut_teardown,
9076 test_AES_GMAC_authentication_test_case_1),
9077 TEST_CASE_ST(ut_setup, ut_teardown,
9078 test_AES_GMAC_authentication_verify_test_case_1),
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_AES_GMAC_authentication_test_case_3),
9081 TEST_CASE_ST(ut_setup, ut_teardown,
9082 test_AES_GMAC_authentication_verify_test_case_3),
9083 TEST_CASE_ST(ut_setup, ut_teardown,
9084 test_AES_GMAC_authentication_test_case_4),
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_AES_GMAC_authentication_verify_test_case_4),
9088 /** Negative tests */
9089 TEST_CASE_ST(ut_setup, ut_teardown,
9090 authentication_verify_AES128_GMAC_fail_data_corrupt),
9091 TEST_CASE_ST(ut_setup, ut_teardown,
9092 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9094 /** Out of place tests */
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9097 TEST_CASE_ST(ut_setup, ut_teardown,
9098 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9100 /** Session-less tests */
9101 TEST_CASE_ST(ut_setup, ut_teardown,
9102 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9103 TEST_CASE_ST(ut_setup, ut_teardown,
9104 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9106 /** Scatter-Gather */
9107 TEST_CASE_ST(ut_setup, ut_teardown,
9108 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9110 TEST_CASES_END() /**< NULL terminate unit test array */
9114 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9115 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9116 .setup = testsuite_setup,
9117 .teardown = testsuite_teardown,
9118 .unit_test_cases = {
9119 /** KASUMI encrypt only (UEA1) */
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_kasumi_encryption_test_case_1),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_kasumi_encryption_test_case_1_sgl),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_kasumi_encryption_test_case_2),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_kasumi_encryption_test_case_3),
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_kasumi_encryption_test_case_4),
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_kasumi_encryption_test_case_5),
9132 /** KASUMI decrypt only (UEA1) */
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_kasumi_decryption_test_case_1),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 test_kasumi_decryption_test_case_2),
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 test_kasumi_decryption_test_case_3),
9139 TEST_CASE_ST(ut_setup, ut_teardown,
9140 test_kasumi_decryption_test_case_4),
9141 TEST_CASE_ST(ut_setup, ut_teardown,
9142 test_kasumi_decryption_test_case_5),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_kasumi_encryption_test_case_1_oop),
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_kasumi_encryption_test_case_1_oop_sgl),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_kasumi_decryption_test_case_1_oop),
9153 /** KASUMI hash only (UIA1) */
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_kasumi_hash_generate_test_case_1),
9156 TEST_CASE_ST(ut_setup, ut_teardown,
9157 test_kasumi_hash_generate_test_case_2),
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_kasumi_hash_generate_test_case_3),
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_kasumi_hash_generate_test_case_4),
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_kasumi_hash_generate_test_case_5),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_kasumi_hash_generate_test_case_6),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_kasumi_hash_verify_test_case_1),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_kasumi_hash_verify_test_case_2),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_kasumi_hash_verify_test_case_3),
9172 TEST_CASE_ST(ut_setup, ut_teardown,
9173 test_kasumi_hash_verify_test_case_4),
9174 TEST_CASE_ST(ut_setup, ut_teardown,
9175 test_kasumi_hash_verify_test_case_5),
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_kasumi_auth_cipher_test_case_1),
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_kasumi_cipher_auth_test_case_1),
9180 TEST_CASES_END() /**< NULL terminate unit test array */
9183 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9184 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9185 .setup = testsuite_setup,
9186 .teardown = testsuite_teardown,
9187 .unit_test_cases = {
9188 /** SNOW 3G encrypt only (UEA2) */
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_snow3g_encryption_test_case_1),
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_snow3g_encryption_test_case_2),
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_snow3g_encryption_test_case_3),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_snow3g_encryption_test_case_4),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_snow3g_encryption_test_case_5),
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 test_snow3g_encryption_test_case_1_oop),
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 test_snow3g_encryption_test_case_1_oop_sgl),
9204 TEST_CASE_ST(ut_setup, ut_teardown,
9205 test_snow3g_decryption_test_case_1_oop),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_snow3g_encryption_test_case_1_offset_oop),
9210 /** SNOW 3G decrypt only (UEA2) */
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_snow3g_decryption_test_case_1),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 test_snow3g_decryption_test_case_2),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_snow3g_decryption_test_case_3),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 test_snow3g_decryption_test_case_4),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_snow3g_decryption_test_case_5),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_snow3g_hash_generate_test_case_1),
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 test_snow3g_hash_generate_test_case_2),
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_snow3g_hash_generate_test_case_3),
9227 /* Tests with buffers which length is not byte-aligned */
9228 TEST_CASE_ST(ut_setup, ut_teardown,
9229 test_snow3g_hash_generate_test_case_4),
9230 TEST_CASE_ST(ut_setup, ut_teardown,
9231 test_snow3g_hash_generate_test_case_5),
9232 TEST_CASE_ST(ut_setup, ut_teardown,
9233 test_snow3g_hash_generate_test_case_6),
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 test_snow3g_hash_verify_test_case_1),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_snow3g_hash_verify_test_case_2),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_snow3g_hash_verify_test_case_3),
9240 /* Tests with buffers which length is not byte-aligned */
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_snow3g_hash_verify_test_case_4),
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 test_snow3g_hash_verify_test_case_5),
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 test_snow3g_hash_verify_test_case_6),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_snow3g_cipher_auth_test_case_1),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_snow3g_auth_cipher_test_case_1),
9252 TEST_CASES_END() /**< NULL terminate unit test array */
9256 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9257 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9258 .setup = testsuite_setup,
9259 .teardown = testsuite_teardown,
9260 .unit_test_cases = {
9261 /** ZUC encrypt only (EEA3) */
9262 TEST_CASE_ST(ut_setup, ut_teardown,
9263 test_zuc_encryption_test_case_1),
9264 TEST_CASE_ST(ut_setup, ut_teardown,
9265 test_zuc_encryption_test_case_2),
9266 TEST_CASE_ST(ut_setup, ut_teardown,
9267 test_zuc_encryption_test_case_3),
9268 TEST_CASE_ST(ut_setup, ut_teardown,
9269 test_zuc_encryption_test_case_4),
9270 TEST_CASE_ST(ut_setup, ut_teardown,
9271 test_zuc_encryption_test_case_5),
9272 TEST_CASE_ST(ut_setup, ut_teardown,
9273 test_zuc_hash_generate_test_case_1),
9274 TEST_CASE_ST(ut_setup, ut_teardown,
9275 test_zuc_hash_generate_test_case_2),
9276 TEST_CASE_ST(ut_setup, ut_teardown,
9277 test_zuc_hash_generate_test_case_3),
9278 TEST_CASE_ST(ut_setup, ut_teardown,
9279 test_zuc_hash_generate_test_case_4),
9280 TEST_CASE_ST(ut_setup, ut_teardown,
9281 test_zuc_hash_generate_test_case_5),
9282 TEST_CASE_ST(ut_setup, ut_teardown,
9283 test_zuc_encryption_test_case_6_sgl),
9284 TEST_CASES_END() /**< NULL terminate unit test array */
9288 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9289 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9290 .setup = testsuite_setup,
9291 .teardown = testsuite_teardown,
9292 .unit_test_cases = {
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_device_configure_invalid_dev_id),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_multi_session),
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_AES_chain_dpaa_sec_all),
9300 TEST_CASE_ST(ut_setup, ut_teardown,
9301 test_3DES_chain_dpaa_sec_all),
9302 TEST_CASE_ST(ut_setup, ut_teardown,
9303 test_AES_cipheronly_dpaa_sec_all),
9304 TEST_CASE_ST(ut_setup, ut_teardown,
9305 test_3DES_cipheronly_dpaa_sec_all),
9306 TEST_CASE_ST(ut_setup, ut_teardown,
9307 test_authonly_dpaa_sec_all),
9309 /** AES GCM Authenticated Encryption */
9310 TEST_CASE_ST(ut_setup, ut_teardown,
9311 test_AES_GCM_authenticated_encryption_test_case_1),
9312 TEST_CASE_ST(ut_setup, ut_teardown,
9313 test_AES_GCM_authenticated_encryption_test_case_2),
9314 TEST_CASE_ST(ut_setup, ut_teardown,
9315 test_AES_GCM_authenticated_encryption_test_case_3),
9316 TEST_CASE_ST(ut_setup, ut_teardown,
9317 test_AES_GCM_authenticated_encryption_test_case_4),
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_AES_GCM_authenticated_encryption_test_case_5),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_AES_GCM_authenticated_encryption_test_case_6),
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_AES_GCM_authenticated_encryption_test_case_7),
9325 /** AES GCM Authenticated Decryption */
9326 TEST_CASE_ST(ut_setup, ut_teardown,
9327 test_AES_GCM_authenticated_decryption_test_case_1),
9328 TEST_CASE_ST(ut_setup, ut_teardown,
9329 test_AES_GCM_authenticated_decryption_test_case_2),
9330 TEST_CASE_ST(ut_setup, ut_teardown,
9331 test_AES_GCM_authenticated_decryption_test_case_3),
9332 TEST_CASE_ST(ut_setup, ut_teardown,
9333 test_AES_GCM_authenticated_decryption_test_case_4),
9334 TEST_CASE_ST(ut_setup, ut_teardown,
9335 test_AES_GCM_authenticated_decryption_test_case_5),
9336 TEST_CASE_ST(ut_setup, ut_teardown,
9337 test_AES_GCM_authenticated_decryption_test_case_6),
9338 TEST_CASE_ST(ut_setup, ut_teardown,
9339 test_AES_GCM_authenticated_decryption_test_case_7),
9341 /** AES GCM Authenticated Encryption 256 bits key */
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GCM_auth_encryption_test_case_256_1),
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_AES_GCM_auth_encryption_test_case_256_2),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GCM_auth_encryption_test_case_256_3),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_AES_GCM_auth_encryption_test_case_256_4),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GCM_auth_encryption_test_case_256_5),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_AES_GCM_auth_encryption_test_case_256_6),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_AES_GCM_auth_encryption_test_case_256_7),
9357 /** AES GCM Authenticated Decryption 256 bits key */
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_AES_GCM_auth_decryption_test_case_256_1),
9360 TEST_CASE_ST(ut_setup, ut_teardown,
9361 test_AES_GCM_auth_decryption_test_case_256_2),
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_GCM_auth_decryption_test_case_256_3),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_GCM_auth_decryption_test_case_256_4),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_GCM_auth_decryption_test_case_256_5),
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_AES_GCM_auth_decryption_test_case_256_6),
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_GCM_auth_decryption_test_case_256_7),
9373 TEST_CASES_END() /**< NULL terminate unit test array */
9377 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9378 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9379 .setup = testsuite_setup,
9380 .teardown = testsuite_teardown,
9381 .unit_test_cases = {
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_device_configure_invalid_dev_id),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_multi_session),
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_AES_chain_dpaa2_sec_all),
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_3DES_chain_dpaa2_sec_all),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_AES_cipheronly_dpaa2_sec_all),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_3DES_cipheronly_dpaa2_sec_all),
9395 TEST_CASE_ST(ut_setup, ut_teardown,
9396 test_authonly_dpaa2_sec_all),
9398 /** AES GCM Authenticated Encryption */
9399 TEST_CASE_ST(ut_setup, ut_teardown,
9400 test_AES_GCM_authenticated_encryption_test_case_1),
9401 TEST_CASE_ST(ut_setup, ut_teardown,
9402 test_AES_GCM_authenticated_encryption_test_case_2),
9403 TEST_CASE_ST(ut_setup, ut_teardown,
9404 test_AES_GCM_authenticated_encryption_test_case_3),
9405 TEST_CASE_ST(ut_setup, ut_teardown,
9406 test_AES_GCM_authenticated_encryption_test_case_4),
9407 TEST_CASE_ST(ut_setup, ut_teardown,
9408 test_AES_GCM_authenticated_encryption_test_case_5),
9409 TEST_CASE_ST(ut_setup, ut_teardown,
9410 test_AES_GCM_authenticated_encryption_test_case_6),
9411 TEST_CASE_ST(ut_setup, ut_teardown,
9412 test_AES_GCM_authenticated_encryption_test_case_7),
9414 /** AES GCM Authenticated Decryption */
9415 TEST_CASE_ST(ut_setup, ut_teardown,
9416 test_AES_GCM_authenticated_decryption_test_case_1),
9417 TEST_CASE_ST(ut_setup, ut_teardown,
9418 test_AES_GCM_authenticated_decryption_test_case_2),
9419 TEST_CASE_ST(ut_setup, ut_teardown,
9420 test_AES_GCM_authenticated_decryption_test_case_3),
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_AES_GCM_authenticated_decryption_test_case_4),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_AES_GCM_authenticated_decryption_test_case_5),
9425 TEST_CASE_ST(ut_setup, ut_teardown,
9426 test_AES_GCM_authenticated_decryption_test_case_6),
9427 TEST_CASE_ST(ut_setup, ut_teardown,
9428 test_AES_GCM_authenticated_decryption_test_case_7),
9430 /** AES GCM Authenticated Encryption 192 bits key */
9431 TEST_CASE_ST(ut_setup, ut_teardown,
9432 test_AES_GCM_auth_encryption_test_case_192_1),
9433 TEST_CASE_ST(ut_setup, ut_teardown,
9434 test_AES_GCM_auth_encryption_test_case_192_2),
9435 TEST_CASE_ST(ut_setup, ut_teardown,
9436 test_AES_GCM_auth_encryption_test_case_192_3),
9437 TEST_CASE_ST(ut_setup, ut_teardown,
9438 test_AES_GCM_auth_encryption_test_case_192_4),
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_AES_GCM_auth_encryption_test_case_192_5),
9441 TEST_CASE_ST(ut_setup, ut_teardown,
9442 test_AES_GCM_auth_encryption_test_case_192_6),
9443 TEST_CASE_ST(ut_setup, ut_teardown,
9444 test_AES_GCM_auth_encryption_test_case_192_7),
9446 /** AES GCM Authenticated Decryption 192 bits key */
9447 TEST_CASE_ST(ut_setup, ut_teardown,
9448 test_AES_GCM_auth_decryption_test_case_192_1),
9449 TEST_CASE_ST(ut_setup, ut_teardown,
9450 test_AES_GCM_auth_decryption_test_case_192_2),
9451 TEST_CASE_ST(ut_setup, ut_teardown,
9452 test_AES_GCM_auth_decryption_test_case_192_3),
9453 TEST_CASE_ST(ut_setup, ut_teardown,
9454 test_AES_GCM_auth_decryption_test_case_192_4),
9455 TEST_CASE_ST(ut_setup, ut_teardown,
9456 test_AES_GCM_auth_decryption_test_case_192_5),
9457 TEST_CASE_ST(ut_setup, ut_teardown,
9458 test_AES_GCM_auth_decryption_test_case_192_6),
9459 TEST_CASE_ST(ut_setup, ut_teardown,
9460 test_AES_GCM_auth_decryption_test_case_192_7),
9462 /** AES GCM Authenticated Encryption 256 bits key */
9463 TEST_CASE_ST(ut_setup, ut_teardown,
9464 test_AES_GCM_auth_encryption_test_case_256_1),
9465 TEST_CASE_ST(ut_setup, ut_teardown,
9466 test_AES_GCM_auth_encryption_test_case_256_2),
9467 TEST_CASE_ST(ut_setup, ut_teardown,
9468 test_AES_GCM_auth_encryption_test_case_256_3),
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_AES_GCM_auth_encryption_test_case_256_4),
9471 TEST_CASE_ST(ut_setup, ut_teardown,
9472 test_AES_GCM_auth_encryption_test_case_256_5),
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_AES_GCM_auth_encryption_test_case_256_6),
9475 TEST_CASE_ST(ut_setup, ut_teardown,
9476 test_AES_GCM_auth_encryption_test_case_256_7),
9478 /** AES GCM Authenticated Decryption 256 bits key */
9479 TEST_CASE_ST(ut_setup, ut_teardown,
9480 test_AES_GCM_auth_decryption_test_case_256_1),
9481 TEST_CASE_ST(ut_setup, ut_teardown,
9482 test_AES_GCM_auth_decryption_test_case_256_2),
9483 TEST_CASE_ST(ut_setup, ut_teardown,
9484 test_AES_GCM_auth_decryption_test_case_256_3),
9485 TEST_CASE_ST(ut_setup, ut_teardown,
9486 test_AES_GCM_auth_decryption_test_case_256_4),
9487 TEST_CASE_ST(ut_setup, ut_teardown,
9488 test_AES_GCM_auth_decryption_test_case_256_5),
9489 TEST_CASE_ST(ut_setup, ut_teardown,
9490 test_AES_GCM_auth_decryption_test_case_256_6),
9491 TEST_CASE_ST(ut_setup, ut_teardown,
9492 test_AES_GCM_auth_decryption_test_case_256_7),
9494 TEST_CASES_END() /**< NULL terminate unit test array */
9498 static struct unit_test_suite cryptodev_null_testsuite = {
9499 .suite_name = "Crypto Device NULL Unit Test Suite",
9500 .setup = testsuite_setup,
9501 .teardown = testsuite_teardown,
9502 .unit_test_cases = {
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_null_auth_only_operation),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_null_cipher_only_operation),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_null_cipher_auth_operation),
9509 TEST_CASE_ST(ut_setup, ut_teardown,
9510 test_null_auth_cipher_operation),
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_null_invalid_operation),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_null_burst_operation),
9516 TEST_CASES_END() /**< NULL terminate unit test array */
9520 static struct unit_test_suite cryptodev_armv8_testsuite = {
9521 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9522 .setup = testsuite_setup,
9523 .teardown = testsuite_teardown,
9524 .unit_test_cases = {
9525 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9527 /** Negative tests */
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9530 TEST_CASE_ST(ut_setup, ut_teardown,
9531 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9533 TEST_CASES_END() /**< NULL terminate unit test array */
9537 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9538 .suite_name = "Crypto Device Marvell Component Test Suite",
9539 .setup = testsuite_setup,
9540 .teardown = testsuite_teardown,
9541 .unit_test_cases = {
9542 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_multi_session_random_usage),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_AES_chain_mrvl_all),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_AES_cipheronly_mrvl_all),
9549 TEST_CASE_ST(ut_setup, ut_teardown,
9550 test_authonly_mrvl_all),
9551 TEST_CASE_ST(ut_setup, ut_teardown,
9552 test_3DES_chain_mrvl_all),
9553 TEST_CASE_ST(ut_setup, ut_teardown,
9554 test_3DES_cipheronly_mrvl_all),
9556 /** Negative tests */
9557 TEST_CASE_ST(ut_setup, ut_teardown,
9558 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9559 TEST_CASE_ST(ut_setup, ut_teardown,
9560 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9561 TEST_CASE_ST(ut_setup, ut_teardown,
9562 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9563 TEST_CASE_ST(ut_setup, ut_teardown,
9564 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9566 TEST_CASES_END() /**< NULL terminate unit test array */
9572 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9574 gbl_driver_id = rte_cryptodev_driver_id_get(
9575 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9577 if (gbl_driver_id == -1) {
9578 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9579 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9580 "in config file to run this testsuite.\n");
9584 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9588 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9590 gbl_driver_id = rte_cryptodev_driver_id_get(
9591 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9593 if (gbl_driver_id == -1) {
9594 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9595 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9596 "in config file to run this testsuite.\n");
9600 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9604 test_cryptodev_openssl(void)
9606 gbl_driver_id = rte_cryptodev_driver_id_get(
9607 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9609 if (gbl_driver_id == -1) {
9610 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9611 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9612 "in config file to run this testsuite.\n");
9616 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9620 test_cryptodev_aesni_gcm(void)
9622 gbl_driver_id = rte_cryptodev_driver_id_get(
9623 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9625 if (gbl_driver_id == -1) {
9626 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9627 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9628 "in config file to run this testsuite.\n");
9632 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9636 test_cryptodev_null(void)
9638 gbl_driver_id = rte_cryptodev_driver_id_get(
9639 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9641 if (gbl_driver_id == -1) {
9642 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9643 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9644 "in config file to run this testsuite.\n");
9648 return unit_test_suite_runner(&cryptodev_null_testsuite);
9652 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9654 gbl_driver_id = rte_cryptodev_driver_id_get(
9655 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9657 if (gbl_driver_id == -1) {
9658 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9659 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9660 "in config file to run this testsuite.\n");
9664 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9668 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9670 gbl_driver_id = rte_cryptodev_driver_id_get(
9671 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9673 if (gbl_driver_id == -1) {
9674 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9675 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9676 "in config file to run this testsuite.\n");
9680 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9684 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9686 gbl_driver_id = rte_cryptodev_driver_id_get(
9687 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9689 if (gbl_driver_id == -1) {
9690 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9691 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9692 "in config file to run this testsuite.\n");
9696 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9700 test_cryptodev_armv8(void)
9702 gbl_driver_id = rte_cryptodev_driver_id_get(
9703 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9705 if (gbl_driver_id == -1) {
9706 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9707 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9708 "in config file to run this testsuite.\n");
9712 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9716 test_cryptodev_mrvl(void)
9718 gbl_driver_id = rte_cryptodev_driver_id_get(
9719 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
9721 if (gbl_driver_id == -1) {
9722 RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if "
9723 "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled "
9724 "in config file to run this testsuite.\n");
9728 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
9731 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9734 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9736 gbl_driver_id = rte_cryptodev_driver_id_get(
9737 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9739 if (gbl_driver_id == -1) {
9740 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9741 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9742 "in config file to run this testsuite.\n");
9746 if (rte_cryptodev_driver_id_get(
9747 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9748 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9749 " enabled in config file to run this testsuite.\n");
9752 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9755 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9760 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9762 gbl_driver_id = rte_cryptodev_driver_id_get(
9763 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9765 if (gbl_driver_id == -1) {
9766 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9767 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9768 "in config file to run this testsuite.\n");
9772 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9776 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9778 gbl_driver_id = rte_cryptodev_driver_id_get(
9779 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
9781 if (gbl_driver_id == -1) {
9782 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
9783 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
9784 "in config file to run this testsuite.\n");
9788 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
9791 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9792 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9793 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9794 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9795 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9796 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9797 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9798 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9799 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9800 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
9801 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
9802 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);