1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2017 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
42 #define VDEV_ARGS_SIZE 100
43 #define MAX_NB_SESSIONS 4
45 static int gbl_driver_id;
47 struct crypto_testsuite_params {
48 struct rte_mempool *mbuf_pool;
49 struct rte_mempool *large_mbuf_pool;
50 struct rte_mempool *op_mpool;
51 struct rte_mempool *session_mpool;
52 struct rte_mempool *session_priv_mpool;
53 struct rte_cryptodev_config conf;
54 struct rte_cryptodev_qp_conf qp_conf;
56 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
57 uint8_t valid_dev_count;
60 struct crypto_unittest_params {
61 struct rte_crypto_sym_xform cipher_xform;
62 struct rte_crypto_sym_xform auth_xform;
63 struct rte_crypto_sym_xform aead_xform;
65 struct rte_cryptodev_sym_session *sess;
67 struct rte_crypto_op *op;
69 struct rte_mbuf *obuf, *ibuf;
74 #define ALIGN_POW2_ROUNDUP(num, align) \
75 (((num) + (align) - 1) & ~((align) - 1))
78 * Forward declarations.
81 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
82 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
86 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
87 struct crypto_unittest_params *ut_params,
88 struct crypto_testsuite_params *ts_param,
89 const uint8_t *cipher,
90 const uint8_t *digest,
93 static struct rte_mbuf *
94 setup_test_string(struct rte_mempool *mpool,
95 const char *string, size_t len, uint8_t blocksize)
97 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
98 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
100 memset(m->buf_addr, 0, m->buf_len);
102 char *dst = rte_pktmbuf_append(m, t_len);
109 rte_memcpy(dst, string, t_len);
111 memset(dst, 0, t_len);
117 /* Get number of bytes in X bits (rounding up) */
119 ceil_byte_length(uint32_t num_bits)
122 return ((num_bits >> 3) + 1);
124 return (num_bits >> 3);
127 static struct rte_crypto_op *
128 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
130 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
131 printf("Error sending packet for encryption");
137 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
143 static struct crypto_testsuite_params testsuite_params = { NULL };
144 static struct crypto_unittest_params unittest_params;
147 testsuite_setup(void)
149 struct crypto_testsuite_params *ts_params = &testsuite_params;
150 struct rte_cryptodev_info info;
151 uint32_t i = 0, nb_devs, dev_id;
155 memset(ts_params, 0, sizeof(*ts_params));
157 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
158 if (ts_params->mbuf_pool == NULL) {
159 /* Not already created so create */
160 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
162 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
164 if (ts_params->mbuf_pool == NULL) {
165 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
170 ts_params->large_mbuf_pool = rte_mempool_lookup(
171 "CRYPTO_LARGE_MBUFPOOL");
172 if (ts_params->large_mbuf_pool == NULL) {
173 /* Not already created so create */
174 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
175 "CRYPTO_LARGE_MBUFPOOL",
178 if (ts_params->large_mbuf_pool == NULL) {
180 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
185 ts_params->op_mpool = rte_crypto_op_pool_create(
186 "MBUF_CRYPTO_SYM_OP_POOL",
187 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
188 NUM_MBUFS, MBUF_CACHE_SIZE,
190 sizeof(struct rte_crypto_sym_xform) +
193 if (ts_params->op_mpool == NULL) {
194 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
198 /* Create an AESNI MB device if required */
199 if (gbl_driver_id == rte_cryptodev_driver_id_get(
200 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
201 nb_devs = rte_cryptodev_device_count_by_driver(
202 rte_cryptodev_driver_id_get(
203 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
206 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
208 TEST_ASSERT(ret == 0,
209 "Failed to create instance of"
211 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
215 /* Create an AESNI GCM device if required */
216 if (gbl_driver_id == rte_cryptodev_driver_id_get(
217 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
218 nb_devs = rte_cryptodev_device_count_by_driver(
219 rte_cryptodev_driver_id_get(
220 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
222 TEST_ASSERT_SUCCESS(rte_vdev_init(
223 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
224 "Failed to create instance of"
226 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
230 /* Create a SNOW 3G device if required */
231 if (gbl_driver_id == rte_cryptodev_driver_id_get(
232 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
233 nb_devs = rte_cryptodev_device_count_by_driver(
234 rte_cryptodev_driver_id_get(
235 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
237 TEST_ASSERT_SUCCESS(rte_vdev_init(
238 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
239 "Failed to create instance of"
241 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
245 /* Create a KASUMI device if required */
246 if (gbl_driver_id == rte_cryptodev_driver_id_get(
247 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
248 nb_devs = rte_cryptodev_device_count_by_driver(
249 rte_cryptodev_driver_id_get(
250 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
252 TEST_ASSERT_SUCCESS(rte_vdev_init(
253 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
254 "Failed to create instance of"
256 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
260 /* Create a ZUC device if required */
261 if (gbl_driver_id == rte_cryptodev_driver_id_get(
262 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
263 nb_devs = rte_cryptodev_device_count_by_driver(
264 rte_cryptodev_driver_id_get(
265 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
267 TEST_ASSERT_SUCCESS(rte_vdev_init(
268 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
269 "Failed to create instance of"
271 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
275 /* Create a NULL device if required */
276 if (gbl_driver_id == rte_cryptodev_driver_id_get(
277 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
278 nb_devs = rte_cryptodev_device_count_by_driver(
279 rte_cryptodev_driver_id_get(
280 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
283 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
285 TEST_ASSERT(ret == 0,
286 "Failed to create instance of"
288 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
292 /* Create an OPENSSL device if required */
293 if (gbl_driver_id == rte_cryptodev_driver_id_get(
294 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
295 nb_devs = rte_cryptodev_device_count_by_driver(
296 rte_cryptodev_driver_id_get(
297 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
300 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
303 TEST_ASSERT(ret == 0, "Failed to create "
304 "instance of pmd : %s",
305 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
309 /* Create a ARMv8 device if required */
310 if (gbl_driver_id == rte_cryptodev_driver_id_get(
311 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
312 nb_devs = rte_cryptodev_device_count_by_driver(
313 rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
317 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
320 TEST_ASSERT(ret == 0, "Failed to create "
321 "instance of pmd : %s",
322 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
326 /* Create a MVSAM device if required */
327 if (gbl_driver_id == rte_cryptodev_driver_id_get(
328 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
329 nb_devs = rte_cryptodev_device_count_by_driver(
330 rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
334 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
337 TEST_ASSERT(ret == 0, "Failed to create "
338 "instance of pmd : %s",
339 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
343 /* Create an CCP device if required */
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
346 nb_devs = rte_cryptodev_device_count_by_driver(
347 rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
351 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
354 TEST_ASSERT(ret == 0, "Failed to create "
355 "instance of pmd : %s",
356 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
360 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
361 char vdev_args[VDEV_ARGS_SIZE] = {""};
362 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
363 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
364 uint16_t slave_core_count = 0;
365 uint16_t socket_id = 0;
367 if (gbl_driver_id == rte_cryptodev_driver_id_get(
368 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
370 /* Identify the Slave Cores
371 * Use 2 slave cores for the device args
373 RTE_LCORE_FOREACH_SLAVE(i) {
374 if (slave_core_count > 1)
376 snprintf(vdev_args, sizeof(vdev_args),
377 "%s%d", temp_str, i);
378 strcpy(temp_str, vdev_args);
379 strlcat(temp_str, ";", sizeof(temp_str));
381 socket_id = rte_lcore_to_socket_id(i);
383 if (slave_core_count != 2) {
385 "Cryptodev scheduler test require at least "
386 "two slave cores to run. "
387 "Please use the correct coremask.\n");
390 strcpy(temp_str, vdev_args);
391 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
392 temp_str, socket_id);
393 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
394 nb_devs = rte_cryptodev_device_count_by_driver(
395 rte_cryptodev_driver_id_get(
396 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
399 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
401 TEST_ASSERT(ret == 0,
402 "Failed to create instance %u of"
404 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
407 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
409 nb_devs = rte_cryptodev_count();
411 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
415 /* Create list of valid crypto devs */
416 for (i = 0; i < nb_devs; i++) {
417 rte_cryptodev_info_get(i, &info);
418 if (info.driver_id == gbl_driver_id)
419 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
422 if (ts_params->valid_dev_count < 1)
425 /* Set up all the qps on the first of the valid devices found */
427 dev_id = ts_params->valid_devs[0];
429 rte_cryptodev_info_get(dev_id, &info);
431 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
432 ts_params->conf.socket_id = SOCKET_ID_ANY;
433 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
435 unsigned int session_size =
436 rte_cryptodev_sym_get_private_session_size(dev_id);
439 * Create mempool with maximum number of sessions * 2,
440 * to include the session headers
442 if (info.sym.max_nb_sessions != 0 &&
443 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
444 RTE_LOG(ERR, USER1, "Device does not support "
445 "at least %u sessions\n",
450 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
451 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
453 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
454 "session mempool allocation failed");
456 ts_params->session_priv_mpool = rte_mempool_create(
460 0, 0, NULL, NULL, NULL,
463 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
464 "session mempool allocation failed");
468 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
470 "Failed to configure cryptodev %u with %u qps",
471 dev_id, ts_params->conf.nb_queue_pairs);
473 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
474 ts_params->qp_conf.mp_session = ts_params->session_mpool;
475 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
477 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
478 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
479 dev_id, qp_id, &ts_params->qp_conf,
480 rte_cryptodev_socket_id(dev_id)),
481 "Failed to setup queue pair %u on cryptodev %u",
489 testsuite_teardown(void)
491 struct crypto_testsuite_params *ts_params = &testsuite_params;
493 if (ts_params->mbuf_pool != NULL) {
494 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
495 rte_mempool_avail_count(ts_params->mbuf_pool));
498 if (ts_params->op_mpool != NULL) {
499 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
500 rte_mempool_avail_count(ts_params->op_mpool));
503 /* Free session mempools */
504 if (ts_params->session_priv_mpool != NULL) {
505 rte_mempool_free(ts_params->session_priv_mpool);
506 ts_params->session_priv_mpool = NULL;
509 if (ts_params->session_mpool != NULL) {
510 rte_mempool_free(ts_params->session_mpool);
511 ts_params->session_mpool = NULL;
518 struct crypto_testsuite_params *ts_params = &testsuite_params;
519 struct crypto_unittest_params *ut_params = &unittest_params;
523 /* Clear unit test parameters before running test */
524 memset(ut_params, 0, sizeof(*ut_params));
526 /* Reconfigure device to default parameters */
527 ts_params->conf.socket_id = SOCKET_ID_ANY;
528 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
529 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
530 ts_params->qp_conf.mp_session = ts_params->session_mpool;
531 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
533 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
535 "Failed to configure cryptodev %u",
536 ts_params->valid_devs[0]);
538 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
539 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
540 ts_params->valid_devs[0], qp_id,
542 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
543 "Failed to setup queue pair %u on cryptodev %u",
544 qp_id, ts_params->valid_devs[0]);
548 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
550 /* Start the device */
551 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
552 "Failed to start cryptodev %u",
553 ts_params->valid_devs[0]);
561 struct crypto_testsuite_params *ts_params = &testsuite_params;
562 struct crypto_unittest_params *ut_params = &unittest_params;
563 struct rte_cryptodev_stats stats;
565 /* free crypto session structure */
566 if (ut_params->sess) {
567 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
569 rte_cryptodev_sym_session_free(ut_params->sess);
570 ut_params->sess = NULL;
573 /* free crypto operation structure */
575 rte_crypto_op_free(ut_params->op);
578 * free mbuf - both obuf and ibuf are usually the same,
579 * so check if they point at the same address is necessary,
580 * to avoid freeing the mbuf twice.
582 if (ut_params->obuf) {
583 rte_pktmbuf_free(ut_params->obuf);
584 if (ut_params->ibuf == ut_params->obuf)
588 if (ut_params->ibuf) {
589 rte_pktmbuf_free(ut_params->ibuf);
593 if (ts_params->mbuf_pool != NULL)
594 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
595 rte_mempool_avail_count(ts_params->mbuf_pool));
597 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
599 /* Stop the device */
600 rte_cryptodev_stop(ts_params->valid_devs[0]);
604 test_device_configure_invalid_dev_id(void)
606 struct crypto_testsuite_params *ts_params = &testsuite_params;
607 uint16_t dev_id, num_devs = 0;
609 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
610 "Need at least %d devices for test", 1);
612 /* valid dev_id values */
613 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
615 /* Stop the device in case it's started so it can be configured */
616 rte_cryptodev_stop(dev_id);
618 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
619 "Failed test for rte_cryptodev_configure: "
620 "invalid dev_num %u", dev_id);
622 /* invalid dev_id values */
625 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
626 "Failed test for rte_cryptodev_configure: "
627 "invalid dev_num %u", dev_id);
631 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
632 "Failed test for rte_cryptodev_configure:"
633 "invalid dev_num %u", dev_id);
639 test_device_configure_invalid_queue_pair_ids(void)
641 struct crypto_testsuite_params *ts_params = &testsuite_params;
642 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
644 /* Stop the device in case it's started so it can be configured */
645 rte_cryptodev_stop(ts_params->valid_devs[0]);
647 /* valid - one queue pairs */
648 ts_params->conf.nb_queue_pairs = 1;
650 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
652 "Failed to configure cryptodev: dev_id %u, qp_id %u",
653 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
656 /* valid - max value queue pairs */
657 ts_params->conf.nb_queue_pairs = orig_nb_qps;
659 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
661 "Failed to configure cryptodev: dev_id %u, qp_id %u",
662 ts_params->valid_devs[0],
663 ts_params->conf.nb_queue_pairs);
666 /* invalid - zero queue pairs */
667 ts_params->conf.nb_queue_pairs = 0;
669 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
671 "Failed test for rte_cryptodev_configure, dev_id %u,"
673 ts_params->valid_devs[0],
674 ts_params->conf.nb_queue_pairs);
677 /* invalid - max value supported by field queue pairs */
678 ts_params->conf.nb_queue_pairs = UINT16_MAX;
680 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
682 "Failed test for rte_cryptodev_configure, dev_id %u,"
684 ts_params->valid_devs[0],
685 ts_params->conf.nb_queue_pairs);
688 /* invalid - max value + 1 queue pairs */
689 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
691 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
693 "Failed test for rte_cryptodev_configure, dev_id %u,"
695 ts_params->valid_devs[0],
696 ts_params->conf.nb_queue_pairs);
698 /* revert to original testsuite value */
699 ts_params->conf.nb_queue_pairs = orig_nb_qps;
705 test_queue_pair_descriptor_setup(void)
707 struct crypto_testsuite_params *ts_params = &testsuite_params;
708 struct rte_cryptodev_info dev_info;
709 struct rte_cryptodev_qp_conf qp_conf = {
710 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
715 /* Stop the device in case it's started so it can be configured */
716 rte_cryptodev_stop(ts_params->valid_devs[0]);
719 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
721 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
723 "Failed to configure cryptodev %u",
724 ts_params->valid_devs[0]);
727 * Test various ring sizes on this device. memzones can't be
728 * freed so are re-used if ring is released and re-created.
730 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
731 qp_conf.mp_session = ts_params->session_mpool;
732 qp_conf.mp_session_private = ts_params->session_priv_mpool;
734 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
735 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
736 ts_params->valid_devs[0], qp_id, &qp_conf,
737 rte_cryptodev_socket_id(
738 ts_params->valid_devs[0])),
740 "rte_cryptodev_queue_pair_setup: num_inflights "
741 "%u on qp %u on cryptodev %u",
742 qp_conf.nb_descriptors, qp_id,
743 ts_params->valid_devs[0]);
746 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
748 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
749 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
750 ts_params->valid_devs[0], qp_id, &qp_conf,
751 rte_cryptodev_socket_id(
752 ts_params->valid_devs[0])),
754 " rte_cryptodev_queue_pair_setup: num_inflights"
755 " %u on qp %u on cryptodev %u",
756 qp_conf.nb_descriptors, qp_id,
757 ts_params->valid_devs[0]);
760 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
762 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
763 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
764 ts_params->valid_devs[0], qp_id, &qp_conf,
765 rte_cryptodev_socket_id(
766 ts_params->valid_devs[0])),
768 "rte_cryptodev_queue_pair_setup: num_inflights"
769 " %u on qp %u on cryptodev %u",
770 qp_conf.nb_descriptors, qp_id,
771 ts_params->valid_devs[0]);
774 /* invalid number of descriptors - max supported + 2 */
775 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
777 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
778 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
779 ts_params->valid_devs[0], qp_id, &qp_conf,
780 rte_cryptodev_socket_id(
781 ts_params->valid_devs[0])),
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 /* invalid number of descriptors - max value of parameter */
790 qp_conf.nb_descriptors = UINT32_MAX-1;
792 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
793 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
794 ts_params->valid_devs[0], qp_id, &qp_conf,
795 rte_cryptodev_socket_id(
796 ts_params->valid_devs[0])),
797 "Unexpectedly passed test for "
798 "rte_cryptodev_queue_pair_setup:"
799 "num_inflights %u on qp %u on cryptodev %u",
800 qp_conf.nb_descriptors, qp_id,
801 ts_params->valid_devs[0]);
804 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
806 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
807 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
808 ts_params->valid_devs[0], qp_id, &qp_conf,
809 rte_cryptodev_socket_id(
810 ts_params->valid_devs[0])),
812 " rte_cryptodev_queue_pair_setup:"
813 "num_inflights %u on qp %u on cryptodev %u",
814 qp_conf.nb_descriptors, qp_id,
815 ts_params->valid_devs[0]);
818 /* invalid number of descriptors - max supported + 1 */
819 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
821 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
822 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
823 ts_params->valid_devs[0], qp_id, &qp_conf,
824 rte_cryptodev_socket_id(
825 ts_params->valid_devs[0])),
826 "Unexpectedly passed test for "
827 "rte_cryptodev_queue_pair_setup:"
828 "num_inflights %u on qp %u on cryptodev %u",
829 qp_conf.nb_descriptors, qp_id,
830 ts_params->valid_devs[0]);
833 /* test invalid queue pair id */
834 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
836 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
838 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
839 ts_params->valid_devs[0],
841 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
842 "Failed test for rte_cryptodev_queue_pair_setup:"
843 "invalid qp %u on cryptodev %u",
844 qp_id, ts_params->valid_devs[0]);
846 qp_id = 0xffff; /*invalid*/
848 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
849 ts_params->valid_devs[0],
851 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
852 "Failed test for rte_cryptodev_queue_pair_setup:"
853 "invalid qp %u on cryptodev %u",
854 qp_id, ts_params->valid_devs[0]);
859 /* ***** Plaintext data for tests ***** */
861 const char catch_22_quote_1[] =
862 "There was only one catch and that was Catch-22, which "
863 "specified that a concern for one's safety in the face of "
864 "dangers that were real and immediate was the process of a "
865 "rational mind. Orr was crazy and could be grounded. All he "
866 "had to do was ask; and as soon as he did, he would no longer "
867 "be crazy and would have to fly more missions. Orr would be "
868 "crazy to fly more missions and sane if he didn't, but if he "
869 "was sane he had to fly them. If he flew them he was crazy "
870 "and didn't have to; but if he didn't want to he was sane and "
871 "had to. Yossarian was moved very deeply by the absolute "
872 "simplicity of this clause of Catch-22 and let out a "
873 "respectful whistle. \"That's some catch, that Catch-22\", he "
874 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
876 const char catch_22_quote[] =
877 "What a lousy earth! He wondered how many people were "
878 "destitute that same night even in his own prosperous country, "
879 "how many homes were shanties, how many husbands were drunk "
880 "and wives socked, and how many children were bullied, abused, "
881 "or abandoned. How many families hungered for food they could "
882 "not afford to buy? How many hearts were broken? How many "
883 "suicides would take place that same night, how many people "
884 "would go insane? How many cockroaches and landlords would "
885 "triumph? How many winners were losers, successes failures, "
886 "and rich men poor men? How many wise guys were stupid? How "
887 "many happy endings were unhappy endings? How many honest men "
888 "were liars, brave men cowards, loyal men traitors, how many "
889 "sainted men were corrupt, how many people in positions of "
890 "trust had sold their souls to bodyguards, how many had never "
891 "had souls? How many straight-and-narrow paths were crooked "
892 "paths? How many best families were worst families and how "
893 "many good people were bad people? When you added them all up "
894 "and then subtracted, you might be left with only the children, "
895 "and perhaps with Albert Einstein and an old violinist or "
896 "sculptor somewhere.";
898 #define QUOTE_480_BYTES (480)
899 #define QUOTE_512_BYTES (512)
900 #define QUOTE_768_BYTES (768)
901 #define QUOTE_1024_BYTES (1024)
905 /* ***** SHA1 Hash Tests ***** */
907 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
909 static uint8_t hmac_sha1_key[] = {
910 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
911 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
912 0xDE, 0xF4, 0xDE, 0xAD };
914 /* ***** SHA224 Hash Tests ***** */
916 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
919 /* ***** AES-CBC Cipher Tests ***** */
921 #define CIPHER_KEY_LENGTH_AES_CBC (16)
922 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
924 static uint8_t aes_cbc_key[] = {
925 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
926 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
928 static uint8_t aes_cbc_iv[] = {
929 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
930 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
933 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
935 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
936 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
937 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
938 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
939 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
940 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
941 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
942 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
943 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
944 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
945 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
946 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
947 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
948 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
949 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
950 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
951 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
952 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
953 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
954 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
955 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
956 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
957 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
958 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
959 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
960 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
961 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
962 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
963 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
964 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
965 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
966 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
967 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
968 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
969 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
970 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
971 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
972 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
973 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
974 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
975 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
976 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
977 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
978 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
979 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
980 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
981 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
982 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
983 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
984 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
985 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
986 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
987 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
988 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
989 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
990 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
991 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
992 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
993 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
994 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
995 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
996 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
997 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
998 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
999 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1002 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1003 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1004 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1005 0x18, 0x8c, 0x1d, 0x32
1009 /* Multisession Vector context Test */
1010 /*Begin Session 0 */
1011 static uint8_t ms_aes_cbc_key0[] = {
1012 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1013 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1016 static uint8_t ms_aes_cbc_iv0[] = {
1017 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1018 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1021 static const uint8_t ms_aes_cbc_cipher0[] = {
1022 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1023 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1024 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1025 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1026 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1027 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1028 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1029 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1030 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1031 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1032 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1033 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1034 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1035 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1036 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1037 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1038 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1039 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1040 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1041 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1042 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1043 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1044 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1045 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1046 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1047 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1048 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1049 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1050 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1051 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1052 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1053 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1054 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1055 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1056 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1057 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1058 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1059 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1060 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1061 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1062 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1063 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1064 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1065 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1066 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1067 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1068 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1069 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1070 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1071 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1072 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1073 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1074 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1075 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1076 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1077 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1078 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1079 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1080 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1081 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1082 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1083 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1084 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1085 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1089 static uint8_t ms_hmac_key0[] = {
1090 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1091 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1092 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1093 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1094 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1095 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1096 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1097 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1100 static const uint8_t ms_hmac_digest0[] = {
1101 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1102 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1103 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1104 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1105 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1106 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1107 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1108 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1112 /* Begin session 1 */
1114 static uint8_t ms_aes_cbc_key1[] = {
1115 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1116 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1119 static uint8_t ms_aes_cbc_iv1[] = {
1120 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1121 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1124 static const uint8_t ms_aes_cbc_cipher1[] = {
1125 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1126 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1127 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1128 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1129 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1130 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1131 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1132 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1133 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1134 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1135 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1136 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1137 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1138 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1139 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1140 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1141 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1142 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1143 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1144 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1145 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1146 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1147 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1148 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1149 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1150 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1151 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1152 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1153 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1154 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1155 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1156 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1157 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1158 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1159 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1160 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1161 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1162 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1163 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1164 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1165 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1166 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1167 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1168 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1169 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1170 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1171 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1172 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1173 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1174 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1175 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1176 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1177 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1178 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1179 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1180 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1181 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1182 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1183 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1184 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1185 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1186 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1187 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1188 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1192 static uint8_t ms_hmac_key1[] = {
1193 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1194 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1195 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1196 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1197 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1198 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1199 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1200 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1203 static const uint8_t ms_hmac_digest1[] = {
1204 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1205 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1206 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1207 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1208 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1209 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1210 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1211 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1214 /* Begin Session 2 */
1215 static uint8_t ms_aes_cbc_key2[] = {
1216 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1217 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1220 static uint8_t ms_aes_cbc_iv2[] = {
1221 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1222 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1225 static const uint8_t ms_aes_cbc_cipher2[] = {
1226 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1227 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1228 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1229 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1230 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1231 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1232 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1233 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1234 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1235 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1236 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1237 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1238 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1239 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1240 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1241 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1242 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1243 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1244 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1245 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1246 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1247 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1248 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1249 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1250 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1251 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1252 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1253 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1254 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1255 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1256 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1257 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1258 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1259 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1260 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1261 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1262 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1263 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1264 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1265 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1266 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1267 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1268 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1269 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1270 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1271 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1272 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1273 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1274 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1275 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1276 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1277 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1278 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1279 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1280 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1281 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1282 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1283 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1284 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1285 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1286 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1287 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1288 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1289 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1292 static uint8_t ms_hmac_key2[] = {
1293 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1294 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1295 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1296 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1297 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1298 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1299 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1300 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1303 static const uint8_t ms_hmac_digest2[] = {
1304 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1305 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1306 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1307 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1308 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1309 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1310 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1311 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1318 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1320 struct crypto_testsuite_params *ts_params = &testsuite_params;
1321 struct crypto_unittest_params *ut_params = &unittest_params;
1323 /* Generate test mbuf data and space for digest */
1324 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1325 catch_22_quote, QUOTE_512_BYTES, 0);
1327 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1328 DIGEST_BYTE_LENGTH_SHA1);
1329 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1331 /* Setup Cipher Parameters */
1332 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1333 ut_params->cipher_xform.next = &ut_params->auth_xform;
1335 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1336 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1337 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1338 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1339 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1340 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1342 /* Setup HMAC Parameters */
1343 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1345 ut_params->auth_xform.next = NULL;
1347 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1348 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1349 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1350 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1351 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1353 ut_params->sess = rte_cryptodev_sym_session_create(
1354 ts_params->session_mpool);
1356 /* Create crypto session*/
1357 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1358 ut_params->sess, &ut_params->cipher_xform,
1359 ts_params->session_priv_mpool);
1360 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1362 /* Generate crypto op data structure */
1363 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1364 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1365 TEST_ASSERT_NOT_NULL(ut_params->op,
1366 "Failed to allocate symmetric crypto operation struct");
1368 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1370 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1372 /* set crypto operation source mbuf */
1373 sym_op->m_src = ut_params->ibuf;
1375 /* Set crypto operation authentication parameters */
1376 sym_op->auth.digest.data = ut_params->digest;
1377 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1378 ut_params->ibuf, QUOTE_512_BYTES);
1380 sym_op->auth.data.offset = 0;
1381 sym_op->auth.data.length = QUOTE_512_BYTES;
1383 /* Copy IV at the end of the crypto operation */
1384 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1385 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1387 /* Set crypto operation cipher parameters */
1388 sym_op->cipher.data.offset = 0;
1389 sym_op->cipher.data.length = QUOTE_512_BYTES;
1391 /* Process crypto operation */
1392 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1393 ut_params->op), "failed to process sym crypto op");
1395 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1396 "crypto op processing failed");
1399 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1402 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1403 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1405 "ciphertext data not as expected");
1407 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1409 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1410 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1411 gbl_driver_id == rte_cryptodev_driver_id_get(
1412 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1413 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1414 DIGEST_BYTE_LENGTH_SHA1,
1415 "Generated digest data not as expected");
1417 return TEST_SUCCESS;
1420 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1422 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1424 static uint8_t hmac_sha512_key[] = {
1425 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1426 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1427 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1428 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1429 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1430 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1431 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1432 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1434 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1435 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1436 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1437 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1438 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1439 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1440 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1441 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1442 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1447 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1448 struct crypto_unittest_params *ut_params,
1449 uint8_t *cipher_key,
1453 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1454 struct crypto_unittest_params *ut_params,
1455 struct crypto_testsuite_params *ts_params,
1456 const uint8_t *cipher,
1457 const uint8_t *digest,
1462 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1463 struct crypto_unittest_params *ut_params,
1464 uint8_t *cipher_key,
1468 /* Setup Cipher Parameters */
1469 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1470 ut_params->cipher_xform.next = NULL;
1472 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1473 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1474 ut_params->cipher_xform.cipher.key.data = cipher_key;
1475 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1476 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1477 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1479 /* Setup HMAC Parameters */
1480 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1481 ut_params->auth_xform.next = &ut_params->cipher_xform;
1483 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1484 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1485 ut_params->auth_xform.auth.key.data = hmac_key;
1486 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1487 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1489 return TEST_SUCCESS;
1494 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1495 struct crypto_unittest_params *ut_params,
1496 struct crypto_testsuite_params *ts_params,
1497 const uint8_t *cipher,
1498 const uint8_t *digest,
1501 /* Generate test mbuf data and digest */
1502 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1505 QUOTE_512_BYTES, 0);
1507 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1508 DIGEST_BYTE_LENGTH_SHA512);
1509 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1511 rte_memcpy(ut_params->digest,
1513 DIGEST_BYTE_LENGTH_SHA512);
1515 /* Generate Crypto op data structure */
1516 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1517 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1518 TEST_ASSERT_NOT_NULL(ut_params->op,
1519 "Failed to allocate symmetric crypto operation struct");
1521 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1523 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1525 /* set crypto operation source mbuf */
1526 sym_op->m_src = ut_params->ibuf;
1528 sym_op->auth.digest.data = ut_params->digest;
1529 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1530 ut_params->ibuf, QUOTE_512_BYTES);
1532 sym_op->auth.data.offset = 0;
1533 sym_op->auth.data.length = QUOTE_512_BYTES;
1535 /* Copy IV at the end of the crypto operation */
1536 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1537 iv, CIPHER_IV_LENGTH_AES_CBC);
1539 sym_op->cipher.data.offset = 0;
1540 sym_op->cipher.data.length = QUOTE_512_BYTES;
1542 /* Process crypto operation */
1543 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1544 ut_params->op), "failed to process sym crypto op");
1546 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1547 "crypto op processing failed");
1549 ut_params->obuf = ut_params->op->sym->m_src;
1552 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1553 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1556 "Plaintext data not as expected");
1559 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1560 "Digest verification failed");
1562 return TEST_SUCCESS;
1566 test_AES_cipheronly_mb_all(void)
1568 struct crypto_testsuite_params *ts_params = &testsuite_params;
1571 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1572 ts_params->op_mpool,
1573 ts_params->session_mpool, ts_params->session_priv_mpool,
1574 ts_params->valid_devs[0],
1575 rte_cryptodev_driver_id_get(
1576 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1577 BLKCIPHER_AES_CIPHERONLY_TYPE);
1579 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1581 return TEST_SUCCESS;
1585 test_AES_docsis_mb_all(void)
1587 struct crypto_testsuite_params *ts_params = &testsuite_params;
1590 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1591 ts_params->op_mpool,
1592 ts_params->session_mpool, ts_params->session_priv_mpool,
1593 ts_params->valid_devs[0],
1594 rte_cryptodev_driver_id_get(
1595 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1596 BLKCIPHER_AES_DOCSIS_TYPE);
1598 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1600 return TEST_SUCCESS;
1604 test_AES_docsis_qat_all(void)
1606 struct crypto_testsuite_params *ts_params = &testsuite_params;
1609 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1610 ts_params->op_mpool,
1611 ts_params->session_mpool, ts_params->session_priv_mpool,
1612 ts_params->valid_devs[0],
1613 rte_cryptodev_driver_id_get(
1614 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1615 BLKCIPHER_AES_DOCSIS_TYPE);
1617 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1619 return TEST_SUCCESS;
1623 test_DES_docsis_qat_all(void)
1625 struct crypto_testsuite_params *ts_params = &testsuite_params;
1628 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1629 ts_params->op_mpool,
1630 ts_params->session_mpool, ts_params->session_priv_mpool,
1631 ts_params->valid_devs[0],
1632 rte_cryptodev_driver_id_get(
1633 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1634 BLKCIPHER_DES_DOCSIS_TYPE);
1636 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1638 return TEST_SUCCESS;
1642 test_authonly_mb_all(void)
1644 struct crypto_testsuite_params *ts_params = &testsuite_params;
1647 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1648 ts_params->op_mpool,
1649 ts_params->session_mpool, ts_params->session_priv_mpool,
1650 ts_params->valid_devs[0],
1651 rte_cryptodev_driver_id_get(
1652 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1653 BLKCIPHER_AUTHONLY_TYPE);
1655 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1657 return TEST_SUCCESS;
1661 test_authonly_qat_all(void)
1663 struct crypto_testsuite_params *ts_params = &testsuite_params;
1666 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1667 ts_params->op_mpool,
1668 ts_params->session_mpool, ts_params->session_priv_mpool,
1669 ts_params->valid_devs[0],
1670 rte_cryptodev_driver_id_get(
1671 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1672 BLKCIPHER_AUTHONLY_TYPE);
1674 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1676 return TEST_SUCCESS;
1679 test_AES_chain_mb_all(void)
1681 struct crypto_testsuite_params *ts_params = &testsuite_params;
1684 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1685 ts_params->op_mpool,
1686 ts_params->session_mpool, ts_params->session_priv_mpool,
1687 ts_params->valid_devs[0],
1688 rte_cryptodev_driver_id_get(
1689 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1690 BLKCIPHER_AES_CHAIN_TYPE);
1692 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1694 return TEST_SUCCESS;
1697 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1700 test_AES_cipheronly_scheduler_all(void)
1702 struct crypto_testsuite_params *ts_params = &testsuite_params;
1705 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1706 ts_params->op_mpool,
1707 ts_params->session_mpool, ts_params->session_priv_mpool,
1708 ts_params->valid_devs[0],
1709 rte_cryptodev_driver_id_get(
1710 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1711 BLKCIPHER_AES_CIPHERONLY_TYPE);
1713 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1715 return TEST_SUCCESS;
1719 test_AES_chain_scheduler_all(void)
1721 struct crypto_testsuite_params *ts_params = &testsuite_params;
1724 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1725 ts_params->op_mpool,
1726 ts_params->session_mpool, ts_params->session_priv_mpool,
1727 ts_params->valid_devs[0],
1728 rte_cryptodev_driver_id_get(
1729 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1730 BLKCIPHER_AES_CHAIN_TYPE);
1732 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1734 return TEST_SUCCESS;
1738 test_authonly_scheduler_all(void)
1740 struct crypto_testsuite_params *ts_params = &testsuite_params;
1743 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1744 ts_params->op_mpool,
1745 ts_params->session_mpool, ts_params->session_priv_mpool,
1746 ts_params->valid_devs[0],
1747 rte_cryptodev_driver_id_get(
1748 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1749 BLKCIPHER_AUTHONLY_TYPE);
1751 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1753 return TEST_SUCCESS;
1756 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1759 test_AES_chain_openssl_all(void)
1761 struct crypto_testsuite_params *ts_params = &testsuite_params;
1764 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1765 ts_params->op_mpool,
1766 ts_params->session_mpool, ts_params->session_priv_mpool,
1767 ts_params->valid_devs[0],
1768 rte_cryptodev_driver_id_get(
1769 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1770 BLKCIPHER_AES_CHAIN_TYPE);
1772 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1774 return TEST_SUCCESS;
1778 test_AES_cipheronly_openssl_all(void)
1780 struct crypto_testsuite_params *ts_params = &testsuite_params;
1783 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1784 ts_params->op_mpool,
1785 ts_params->session_mpool, ts_params->session_priv_mpool,
1786 ts_params->valid_devs[0],
1787 rte_cryptodev_driver_id_get(
1788 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1789 BLKCIPHER_AES_CIPHERONLY_TYPE);
1791 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1793 return TEST_SUCCESS;
1797 test_AES_chain_ccp_all(void)
1799 struct crypto_testsuite_params *ts_params = &testsuite_params;
1802 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1803 ts_params->op_mpool,
1804 ts_params->session_mpool, ts_params->session_priv_mpool,
1805 ts_params->valid_devs[0],
1806 rte_cryptodev_driver_id_get(
1807 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1808 BLKCIPHER_AES_CHAIN_TYPE);
1810 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1812 return TEST_SUCCESS;
1816 test_AES_cipheronly_ccp_all(void)
1818 struct crypto_testsuite_params *ts_params = &testsuite_params;
1821 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1822 ts_params->op_mpool,
1823 ts_params->session_mpool, ts_params->session_priv_mpool,
1824 ts_params->valid_devs[0],
1825 rte_cryptodev_driver_id_get(
1826 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1827 BLKCIPHER_AES_CIPHERONLY_TYPE);
1829 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1831 return TEST_SUCCESS;
1835 test_AES_chain_qat_all(void)
1837 struct crypto_testsuite_params *ts_params = &testsuite_params;
1840 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1841 ts_params->op_mpool,
1842 ts_params->session_mpool, ts_params->session_priv_mpool,
1843 ts_params->valid_devs[0],
1844 rte_cryptodev_driver_id_get(
1845 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1846 BLKCIPHER_AES_CHAIN_TYPE);
1848 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1850 return TEST_SUCCESS;
1854 test_AES_cipheronly_qat_all(void)
1856 struct crypto_testsuite_params *ts_params = &testsuite_params;
1859 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1860 ts_params->op_mpool,
1861 ts_params->session_mpool, ts_params->session_priv_mpool,
1862 ts_params->valid_devs[0],
1863 rte_cryptodev_driver_id_get(
1864 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1865 BLKCIPHER_AES_CIPHERONLY_TYPE);
1867 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1869 return TEST_SUCCESS;
1873 test_AES_cipheronly_virtio_all(void)
1875 struct crypto_testsuite_params *ts_params = &testsuite_params;
1878 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1879 ts_params->op_mpool,
1880 ts_params->session_mpool, ts_params->session_priv_mpool,
1881 ts_params->valid_devs[0],
1882 rte_cryptodev_driver_id_get(
1883 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1884 BLKCIPHER_AES_CIPHERONLY_TYPE);
1886 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1888 return TEST_SUCCESS;
1892 test_AES_chain_caam_jr_all(void)
1894 struct crypto_testsuite_params *ts_params = &testsuite_params;
1897 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1898 ts_params->op_mpool,
1899 ts_params->session_mpool, ts_params->session_priv_mpool,
1900 ts_params->valid_devs[0],
1901 rte_cryptodev_driver_id_get(
1902 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1903 BLKCIPHER_AES_CHAIN_TYPE);
1905 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1907 return TEST_SUCCESS;
1911 test_AES_cipheronly_caam_jr_all(void)
1913 struct crypto_testsuite_params *ts_params = &testsuite_params;
1916 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1917 ts_params->op_mpool,
1918 ts_params->session_mpool, ts_params->session_priv_mpool,
1919 ts_params->valid_devs[0],
1920 rte_cryptodev_driver_id_get(
1921 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1922 BLKCIPHER_AES_CIPHERONLY_TYPE);
1924 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1926 return TEST_SUCCESS;
1930 test_authonly_caam_jr_all(void)
1932 struct crypto_testsuite_params *ts_params = &testsuite_params;
1935 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1936 ts_params->op_mpool,
1937 ts_params->session_mpool, ts_params->session_priv_mpool,
1938 ts_params->valid_devs[0],
1939 rte_cryptodev_driver_id_get(
1940 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1941 BLKCIPHER_AUTHONLY_TYPE);
1943 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1945 return TEST_SUCCESS;
1950 test_AES_chain_dpaa_sec_all(void)
1952 struct crypto_testsuite_params *ts_params = &testsuite_params;
1955 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1956 ts_params->op_mpool,
1957 ts_params->session_mpool, ts_params->session_priv_mpool,
1958 ts_params->valid_devs[0],
1959 rte_cryptodev_driver_id_get(
1960 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1961 BLKCIPHER_AES_CHAIN_TYPE);
1963 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1965 return TEST_SUCCESS;
1969 test_AES_cipheronly_dpaa_sec_all(void)
1971 struct crypto_testsuite_params *ts_params = &testsuite_params;
1974 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1975 ts_params->op_mpool,
1976 ts_params->session_mpool, ts_params->session_priv_mpool,
1977 ts_params->valid_devs[0],
1978 rte_cryptodev_driver_id_get(
1979 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1980 BLKCIPHER_AES_CIPHERONLY_TYPE);
1982 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1984 return TEST_SUCCESS;
1988 test_authonly_dpaa_sec_all(void)
1990 struct crypto_testsuite_params *ts_params = &testsuite_params;
1993 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1994 ts_params->op_mpool,
1995 ts_params->session_mpool, ts_params->session_priv_mpool,
1996 ts_params->valid_devs[0],
1997 rte_cryptodev_driver_id_get(
1998 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1999 BLKCIPHER_AUTHONLY_TYPE);
2001 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2003 return TEST_SUCCESS;
2007 test_AES_chain_dpaa2_sec_all(void)
2009 struct crypto_testsuite_params *ts_params = &testsuite_params;
2012 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2013 ts_params->op_mpool,
2014 ts_params->session_mpool, ts_params->session_priv_mpool,
2015 ts_params->valid_devs[0],
2016 rte_cryptodev_driver_id_get(
2017 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2018 BLKCIPHER_AES_CHAIN_TYPE);
2020 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2022 return TEST_SUCCESS;
2026 test_AES_cipheronly_dpaa2_sec_all(void)
2028 struct crypto_testsuite_params *ts_params = &testsuite_params;
2031 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2032 ts_params->op_mpool,
2033 ts_params->session_mpool, ts_params->session_priv_mpool,
2034 ts_params->valid_devs[0],
2035 rte_cryptodev_driver_id_get(
2036 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2037 BLKCIPHER_AES_CIPHERONLY_TYPE);
2039 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2041 return TEST_SUCCESS;
2045 test_authonly_dpaa2_sec_all(void)
2047 struct crypto_testsuite_params *ts_params = &testsuite_params;
2050 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2051 ts_params->op_mpool,
2052 ts_params->session_mpool, ts_params->session_priv_mpool,
2053 ts_params->valid_devs[0],
2054 rte_cryptodev_driver_id_get(
2055 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2056 BLKCIPHER_AUTHONLY_TYPE);
2058 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2060 return TEST_SUCCESS;
2064 test_authonly_openssl_all(void)
2066 struct crypto_testsuite_params *ts_params = &testsuite_params;
2069 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2070 ts_params->op_mpool,
2071 ts_params->session_mpool, ts_params->session_priv_mpool,
2072 ts_params->valid_devs[0],
2073 rte_cryptodev_driver_id_get(
2074 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2075 BLKCIPHER_AUTHONLY_TYPE);
2077 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2079 return TEST_SUCCESS;
2083 test_authonly_ccp_all(void)
2085 struct crypto_testsuite_params *ts_params = &testsuite_params;
2088 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2089 ts_params->op_mpool,
2090 ts_params->session_mpool, ts_params->session_priv_mpool,
2091 ts_params->valid_devs[0],
2092 rte_cryptodev_driver_id_get(
2093 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2094 BLKCIPHER_AUTHONLY_TYPE);
2096 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2098 return TEST_SUCCESS;
2102 test_AES_chain_armv8_all(void)
2104 struct crypto_testsuite_params *ts_params = &testsuite_params;
2107 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2108 ts_params->op_mpool,
2109 ts_params->session_mpool, ts_params->session_priv_mpool,
2110 ts_params->valid_devs[0],
2111 rte_cryptodev_driver_id_get(
2112 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2113 BLKCIPHER_AES_CHAIN_TYPE);
2115 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2117 return TEST_SUCCESS;
2121 test_AES_chain_mrvl_all(void)
2123 struct crypto_testsuite_params *ts_params = &testsuite_params;
2126 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2127 ts_params->op_mpool,
2128 ts_params->session_mpool, ts_params->session_priv_mpool,
2129 ts_params->valid_devs[0],
2130 rte_cryptodev_driver_id_get(
2131 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2132 BLKCIPHER_AES_CHAIN_TYPE);
2134 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2136 return TEST_SUCCESS;
2140 test_AES_cipheronly_mrvl_all(void)
2142 struct crypto_testsuite_params *ts_params = &testsuite_params;
2145 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2146 ts_params->op_mpool,
2147 ts_params->session_mpool, ts_params->session_priv_mpool,
2148 ts_params->valid_devs[0],
2149 rte_cryptodev_driver_id_get(
2150 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2151 BLKCIPHER_AES_CIPHERONLY_TYPE);
2153 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2155 return TEST_SUCCESS;
2159 test_authonly_mrvl_all(void)
2161 struct crypto_testsuite_params *ts_params = &testsuite_params;
2164 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2165 ts_params->op_mpool,
2166 ts_params->session_mpool, ts_params->session_priv_mpool,
2167 ts_params->valid_devs[0],
2168 rte_cryptodev_driver_id_get(
2169 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2170 BLKCIPHER_AUTHONLY_TYPE);
2172 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2174 return TEST_SUCCESS;
2178 test_3DES_chain_mrvl_all(void)
2180 struct crypto_testsuite_params *ts_params = &testsuite_params;
2183 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2184 ts_params->op_mpool,
2185 ts_params->session_mpool, ts_params->session_priv_mpool,
2186 ts_params->valid_devs[0],
2187 rte_cryptodev_driver_id_get(
2188 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2189 BLKCIPHER_3DES_CHAIN_TYPE);
2191 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2193 return TEST_SUCCESS;
2197 test_3DES_cipheronly_mrvl_all(void)
2199 struct crypto_testsuite_params *ts_params = &testsuite_params;
2202 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2203 ts_params->op_mpool,
2204 ts_params->session_mpool, ts_params->session_priv_mpool,
2205 ts_params->valid_devs[0],
2206 rte_cryptodev_driver_id_get(
2207 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2208 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2210 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2212 return TEST_SUCCESS;
2216 test_AES_chain_octeontx_all(void)
2218 struct crypto_testsuite_params *ts_params = &testsuite_params;
2221 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2222 ts_params->op_mpool, ts_params->session_mpool,
2223 ts_params->session_priv_mpool,
2224 ts_params->valid_devs[0],
2225 rte_cryptodev_driver_id_get(
2226 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2227 BLKCIPHER_AES_CHAIN_TYPE);
2229 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2231 return TEST_SUCCESS;
2235 test_AES_cipheronly_octeontx_all(void)
2237 struct crypto_testsuite_params *ts_params = &testsuite_params;
2240 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2241 ts_params->op_mpool, ts_params->session_mpool,
2242 ts_params->session_priv_mpool,
2243 ts_params->valid_devs[0],
2244 rte_cryptodev_driver_id_get(
2245 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2246 BLKCIPHER_AES_CIPHERONLY_TYPE);
2248 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2250 return TEST_SUCCESS;
2254 test_3DES_chain_octeontx_all(void)
2256 struct crypto_testsuite_params *ts_params = &testsuite_params;
2259 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2260 ts_params->op_mpool, ts_params->session_mpool,
2261 ts_params->session_priv_mpool,
2262 ts_params->valid_devs[0],
2263 rte_cryptodev_driver_id_get(
2264 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2265 BLKCIPHER_3DES_CHAIN_TYPE);
2267 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2269 return TEST_SUCCESS;
2273 test_3DES_cipheronly_octeontx_all(void)
2275 struct crypto_testsuite_params *ts_params = &testsuite_params;
2278 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2279 ts_params->op_mpool, ts_params->session_mpool,
2280 ts_params->session_priv_mpool,
2281 ts_params->valid_devs[0],
2282 rte_cryptodev_driver_id_get(
2283 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2284 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2286 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2288 return TEST_SUCCESS;
2292 test_authonly_octeontx_all(void)
2294 struct crypto_testsuite_params *ts_params = &testsuite_params;
2297 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2298 ts_params->op_mpool, ts_params->session_mpool,
2299 ts_params->session_priv_mpool,
2300 ts_params->valid_devs[0],
2301 rte_cryptodev_driver_id_get(
2302 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2303 BLKCIPHER_AUTHONLY_TYPE);
2305 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2307 return TEST_SUCCESS;
2310 /* ***** SNOW 3G Tests ***** */
2312 create_wireless_algo_hash_session(uint8_t dev_id,
2313 const uint8_t *key, const uint8_t key_len,
2314 const uint8_t iv_len, const uint8_t auth_len,
2315 enum rte_crypto_auth_operation op,
2316 enum rte_crypto_auth_algorithm algo)
2318 uint8_t hash_key[key_len];
2320 struct crypto_testsuite_params *ts_params = &testsuite_params;
2321 struct crypto_unittest_params *ut_params = &unittest_params;
2323 memcpy(hash_key, key, key_len);
2325 debug_hexdump(stdout, "key:", key, key_len);
2327 /* Setup Authentication Parameters */
2328 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2329 ut_params->auth_xform.next = NULL;
2331 ut_params->auth_xform.auth.op = op;
2332 ut_params->auth_xform.auth.algo = algo;
2333 ut_params->auth_xform.auth.key.length = key_len;
2334 ut_params->auth_xform.auth.key.data = hash_key;
2335 ut_params->auth_xform.auth.digest_length = auth_len;
2336 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2337 ut_params->auth_xform.auth.iv.length = iv_len;
2338 ut_params->sess = rte_cryptodev_sym_session_create(
2339 ts_params->session_mpool);
2341 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2342 &ut_params->auth_xform,
2343 ts_params->session_priv_mpool);
2344 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2349 create_wireless_algo_cipher_session(uint8_t dev_id,
2350 enum rte_crypto_cipher_operation op,
2351 enum rte_crypto_cipher_algorithm algo,
2352 const uint8_t *key, const uint8_t key_len,
2355 uint8_t cipher_key[key_len];
2357 struct crypto_testsuite_params *ts_params = &testsuite_params;
2358 struct crypto_unittest_params *ut_params = &unittest_params;
2360 memcpy(cipher_key, key, key_len);
2362 /* Setup Cipher Parameters */
2363 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2364 ut_params->cipher_xform.next = NULL;
2366 ut_params->cipher_xform.cipher.algo = algo;
2367 ut_params->cipher_xform.cipher.op = op;
2368 ut_params->cipher_xform.cipher.key.data = cipher_key;
2369 ut_params->cipher_xform.cipher.key.length = key_len;
2370 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2371 ut_params->cipher_xform.cipher.iv.length = iv_len;
2373 debug_hexdump(stdout, "key:", key, key_len);
2375 /* Create Crypto session */
2376 ut_params->sess = rte_cryptodev_sym_session_create(
2377 ts_params->session_mpool);
2379 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2380 &ut_params->cipher_xform,
2381 ts_params->session_priv_mpool);
2382 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2387 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2388 unsigned int cipher_len,
2389 unsigned int cipher_offset)
2391 struct crypto_testsuite_params *ts_params = &testsuite_params;
2392 struct crypto_unittest_params *ut_params = &unittest_params;
2394 /* Generate Crypto op data structure */
2395 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2396 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2397 TEST_ASSERT_NOT_NULL(ut_params->op,
2398 "Failed to allocate pktmbuf offload");
2400 /* Set crypto operation data parameters */
2401 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2403 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2405 /* set crypto operation source mbuf */
2406 sym_op->m_src = ut_params->ibuf;
2409 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2411 sym_op->cipher.data.length = cipher_len;
2412 sym_op->cipher.data.offset = cipher_offset;
2417 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2418 unsigned int cipher_len,
2419 unsigned int cipher_offset)
2421 struct crypto_testsuite_params *ts_params = &testsuite_params;
2422 struct crypto_unittest_params *ut_params = &unittest_params;
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");
2430 /* Set crypto operation data parameters */
2431 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2433 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2435 /* set crypto operation source mbuf */
2436 sym_op->m_src = ut_params->ibuf;
2437 sym_op->m_dst = ut_params->obuf;
2440 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2442 sym_op->cipher.data.length = cipher_len;
2443 sym_op->cipher.data.offset = cipher_offset;
2448 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2449 enum rte_crypto_cipher_operation cipher_op,
2450 enum rte_crypto_auth_operation auth_op,
2451 enum rte_crypto_auth_algorithm auth_algo,
2452 enum rte_crypto_cipher_algorithm cipher_algo,
2453 const uint8_t *key, uint8_t key_len,
2454 uint8_t auth_iv_len, uint8_t auth_len,
2455 uint8_t cipher_iv_len)
2458 uint8_t cipher_auth_key[key_len];
2460 struct crypto_testsuite_params *ts_params = &testsuite_params;
2461 struct crypto_unittest_params *ut_params = &unittest_params;
2463 memcpy(cipher_auth_key, key, key_len);
2465 /* Setup Authentication Parameters */
2466 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2467 ut_params->auth_xform.next = NULL;
2469 ut_params->auth_xform.auth.op = auth_op;
2470 ut_params->auth_xform.auth.algo = auth_algo;
2471 ut_params->auth_xform.auth.key.length = key_len;
2472 /* Hash key = cipher key */
2473 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2474 ut_params->auth_xform.auth.digest_length = auth_len;
2475 /* Auth IV will be after cipher IV */
2476 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2477 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2479 /* Setup Cipher Parameters */
2480 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2481 ut_params->cipher_xform.next = &ut_params->auth_xform;
2483 ut_params->cipher_xform.cipher.algo = cipher_algo;
2484 ut_params->cipher_xform.cipher.op = cipher_op;
2485 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2486 ut_params->cipher_xform.cipher.key.length = key_len;
2487 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2488 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2490 debug_hexdump(stdout, "key:", key, key_len);
2492 /* Create Crypto session*/
2493 ut_params->sess = rte_cryptodev_sym_session_create(
2494 ts_params->session_mpool);
2496 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2497 &ut_params->cipher_xform,
2498 ts_params->session_priv_mpool);
2500 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2505 create_wireless_cipher_auth_session(uint8_t dev_id,
2506 enum rte_crypto_cipher_operation cipher_op,
2507 enum rte_crypto_auth_operation auth_op,
2508 enum rte_crypto_auth_algorithm auth_algo,
2509 enum rte_crypto_cipher_algorithm cipher_algo,
2510 const struct wireless_test_data *tdata)
2512 const uint8_t key_len = tdata->key.len;
2513 uint8_t cipher_auth_key[key_len];
2515 struct crypto_testsuite_params *ts_params = &testsuite_params;
2516 struct crypto_unittest_params *ut_params = &unittest_params;
2517 const uint8_t *key = tdata->key.data;
2518 const uint8_t auth_len = tdata->digest.len;
2519 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2520 uint8_t auth_iv_len = tdata->auth_iv.len;
2522 memcpy(cipher_auth_key, key, key_len);
2524 /* Setup Authentication Parameters */
2525 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2526 ut_params->auth_xform.next = NULL;
2528 ut_params->auth_xform.auth.op = auth_op;
2529 ut_params->auth_xform.auth.algo = auth_algo;
2530 ut_params->auth_xform.auth.key.length = key_len;
2531 /* Hash key = cipher key */
2532 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2533 ut_params->auth_xform.auth.digest_length = auth_len;
2534 /* Auth IV will be after cipher IV */
2535 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2536 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2538 /* Setup Cipher Parameters */
2539 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2540 ut_params->cipher_xform.next = &ut_params->auth_xform;
2542 ut_params->cipher_xform.cipher.algo = cipher_algo;
2543 ut_params->cipher_xform.cipher.op = cipher_op;
2544 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2545 ut_params->cipher_xform.cipher.key.length = key_len;
2546 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2547 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2550 debug_hexdump(stdout, "key:", key, key_len);
2552 /* Create Crypto session*/
2553 ut_params->sess = rte_cryptodev_sym_session_create(
2554 ts_params->session_mpool);
2556 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2557 &ut_params->cipher_xform,
2558 ts_params->session_priv_mpool);
2560 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2565 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2566 const struct wireless_test_data *tdata)
2568 return create_wireless_cipher_auth_session(dev_id,
2569 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2570 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2571 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2575 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2576 enum rte_crypto_cipher_operation cipher_op,
2577 enum rte_crypto_auth_operation auth_op,
2578 enum rte_crypto_auth_algorithm auth_algo,
2579 enum rte_crypto_cipher_algorithm cipher_algo,
2580 const uint8_t *key, const uint8_t key_len,
2581 uint8_t auth_iv_len, uint8_t auth_len,
2582 uint8_t cipher_iv_len)
2584 uint8_t auth_cipher_key[key_len];
2586 struct crypto_testsuite_params *ts_params = &testsuite_params;
2587 struct crypto_unittest_params *ut_params = &unittest_params;
2589 memcpy(auth_cipher_key, key, key_len);
2591 /* Setup Authentication Parameters */
2592 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2593 ut_params->auth_xform.auth.op = auth_op;
2594 ut_params->auth_xform.next = &ut_params->cipher_xform;
2595 ut_params->auth_xform.auth.algo = auth_algo;
2596 ut_params->auth_xform.auth.key.length = key_len;
2597 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2598 ut_params->auth_xform.auth.digest_length = auth_len;
2599 /* Auth IV will be after cipher IV */
2600 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2601 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2603 /* Setup Cipher Parameters */
2604 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2605 ut_params->cipher_xform.next = NULL;
2606 ut_params->cipher_xform.cipher.algo = cipher_algo;
2607 ut_params->cipher_xform.cipher.op = cipher_op;
2608 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2609 ut_params->cipher_xform.cipher.key.length = key_len;
2610 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2611 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2613 debug_hexdump(stdout, "key:", key, key_len);
2615 /* Create Crypto session*/
2616 ut_params->sess = rte_cryptodev_sym_session_create(
2617 ts_params->session_mpool);
2619 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2620 &ut_params->auth_xform,
2621 ts_params->session_priv_mpool);
2623 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2629 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2630 unsigned int auth_tag_len,
2631 const uint8_t *iv, unsigned int iv_len,
2632 unsigned int data_pad_len,
2633 enum rte_crypto_auth_operation op,
2634 unsigned int auth_len, unsigned int auth_offset)
2636 struct crypto_testsuite_params *ts_params = &testsuite_params;
2638 struct crypto_unittest_params *ut_params = &unittest_params;
2640 /* Generate Crypto op data structure */
2641 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2642 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2643 TEST_ASSERT_NOT_NULL(ut_params->op,
2644 "Failed to allocate pktmbuf offload");
2646 /* Set crypto operation data parameters */
2647 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2649 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2651 /* set crypto operation source mbuf */
2652 sym_op->m_src = ut_params->ibuf;
2655 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2658 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2659 ut_params->ibuf, auth_tag_len);
2661 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2662 "no room to append auth tag");
2663 ut_params->digest = sym_op->auth.digest.data;
2664 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2665 ut_params->ibuf, data_pad_len);
2666 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2667 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2669 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2671 debug_hexdump(stdout, "digest:",
2672 sym_op->auth.digest.data,
2675 sym_op->auth.data.length = auth_len;
2676 sym_op->auth.data.offset = auth_offset;
2682 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2683 enum rte_crypto_auth_operation op)
2685 struct crypto_testsuite_params *ts_params = &testsuite_params;
2686 struct crypto_unittest_params *ut_params = &unittest_params;
2688 const uint8_t *auth_tag = tdata->digest.data;
2689 const unsigned int auth_tag_len = tdata->digest.len;
2690 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2691 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2693 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2694 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2695 const uint8_t *auth_iv = tdata->auth_iv.data;
2696 const uint8_t auth_iv_len = tdata->auth_iv.len;
2697 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2698 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2700 /* Generate Crypto op data structure */
2701 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2702 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2703 TEST_ASSERT_NOT_NULL(ut_params->op,
2704 "Failed to allocate pktmbuf offload");
2705 /* Set crypto operation data parameters */
2706 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2708 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2710 /* set crypto operation source mbuf */
2711 sym_op->m_src = ut_params->ibuf;
2714 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2715 ut_params->ibuf, auth_tag_len);
2717 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2718 "no room to append auth tag");
2719 ut_params->digest = sym_op->auth.digest.data;
2720 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2721 ut_params->ibuf, data_pad_len);
2722 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2723 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2725 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2727 debug_hexdump(stdout, "digest:",
2728 sym_op->auth.digest.data,
2731 /* Copy cipher and auth IVs at the end of the crypto operation */
2732 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2734 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2735 iv_ptr += cipher_iv_len;
2736 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2738 sym_op->cipher.data.length = cipher_len;
2739 sym_op->cipher.data.offset = 0;
2740 sym_op->auth.data.length = auth_len;
2741 sym_op->auth.data.offset = 0;
2747 create_zuc_cipher_hash_generate_operation(
2748 const struct wireless_test_data *tdata)
2750 return create_wireless_cipher_hash_operation(tdata,
2751 RTE_CRYPTO_AUTH_OP_GENERATE);
2755 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2756 const unsigned auth_tag_len,
2757 const uint8_t *auth_iv, uint8_t auth_iv_len,
2758 unsigned data_pad_len,
2759 enum rte_crypto_auth_operation op,
2760 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2761 const unsigned cipher_len, const unsigned cipher_offset,
2762 const unsigned auth_len, const unsigned auth_offset)
2764 struct crypto_testsuite_params *ts_params = &testsuite_params;
2765 struct crypto_unittest_params *ut_params = &unittest_params;
2767 /* Generate Crypto op data structure */
2768 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2769 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2770 TEST_ASSERT_NOT_NULL(ut_params->op,
2771 "Failed to allocate pktmbuf offload");
2772 /* Set crypto operation data parameters */
2773 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2775 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2777 /* set crypto operation source mbuf */
2778 sym_op->m_src = ut_params->ibuf;
2781 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2782 ut_params->ibuf, auth_tag_len);
2784 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2785 "no room to append auth tag");
2786 ut_params->digest = sym_op->auth.digest.data;
2787 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2788 ut_params->ibuf, data_pad_len);
2789 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2790 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2792 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2794 debug_hexdump(stdout, "digest:",
2795 sym_op->auth.digest.data,
2798 /* Copy cipher and auth IVs at the end of the crypto operation */
2799 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2801 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2802 iv_ptr += cipher_iv_len;
2803 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2805 sym_op->cipher.data.length = cipher_len;
2806 sym_op->cipher.data.offset = cipher_offset;
2807 sym_op->auth.data.length = auth_len;
2808 sym_op->auth.data.offset = auth_offset;
2814 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2815 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2816 const uint8_t *auth_iv, uint8_t auth_iv_len,
2817 unsigned int data_pad_len,
2818 unsigned int cipher_len, unsigned int cipher_offset,
2819 unsigned int auth_len, unsigned int auth_offset)
2821 struct crypto_testsuite_params *ts_params = &testsuite_params;
2822 struct crypto_unittest_params *ut_params = &unittest_params;
2824 /* Generate Crypto op data structure */
2825 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2826 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2827 TEST_ASSERT_NOT_NULL(ut_params->op,
2828 "Failed to allocate pktmbuf offload");
2830 /* Set crypto operation data parameters */
2831 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2833 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2835 /* set crypto operation source mbuf */
2836 sym_op->m_src = ut_params->ibuf;
2839 sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
2840 ut_params->ibuf, uint8_t *, data_pad_len);
2842 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2843 "no room to append auth tag");
2845 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2846 ut_params->ibuf, data_pad_len);
2848 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2850 /* Copy cipher and auth IVs at the end of the crypto operation */
2851 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2853 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2854 iv_ptr += cipher_iv_len;
2855 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2857 sym_op->cipher.data.length = cipher_len;
2858 sym_op->cipher.data.offset = cipher_offset;
2860 sym_op->auth.data.length = auth_len;
2861 sym_op->auth.data.offset = auth_offset;
2867 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2869 struct crypto_testsuite_params *ts_params = &testsuite_params;
2870 struct crypto_unittest_params *ut_params = &unittest_params;
2873 unsigned plaintext_pad_len;
2874 unsigned plaintext_len;
2877 /* Create SNOW 3G session */
2878 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2879 tdata->key.data, tdata->key.len,
2880 tdata->auth_iv.len, tdata->digest.len,
2881 RTE_CRYPTO_AUTH_OP_GENERATE,
2882 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2886 /* alloc mbuf and set payload */
2887 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2889 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2890 rte_pktmbuf_tailroom(ut_params->ibuf));
2892 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2893 /* Append data which is padded to a multiple of */
2894 /* the algorithms block size */
2895 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2896 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2898 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2900 /* Create SNOW 3G operation */
2901 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2902 tdata->auth_iv.data, tdata->auth_iv.len,
2903 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2904 tdata->validAuthLenInBits.len,
2909 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2911 ut_params->obuf = ut_params->op->sym->m_src;
2912 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2913 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2914 + plaintext_pad_len;
2917 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2920 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2921 "SNOW 3G Generated auth tag not as expected");
2927 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2929 struct crypto_testsuite_params *ts_params = &testsuite_params;
2930 struct crypto_unittest_params *ut_params = &unittest_params;
2933 unsigned plaintext_pad_len;
2934 unsigned plaintext_len;
2937 /* Create SNOW 3G session */
2938 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2939 tdata->key.data, tdata->key.len,
2940 tdata->auth_iv.len, tdata->digest.len,
2941 RTE_CRYPTO_AUTH_OP_VERIFY,
2942 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2945 /* alloc mbuf and set payload */
2946 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2948 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2949 rte_pktmbuf_tailroom(ut_params->ibuf));
2951 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2952 /* Append data which is padded to a multiple of */
2953 /* the algorithms block size */
2954 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2955 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2957 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2959 /* Create SNOW 3G operation */
2960 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2962 tdata->auth_iv.data, tdata->auth_iv.len,
2964 RTE_CRYPTO_AUTH_OP_VERIFY,
2965 tdata->validAuthLenInBits.len,
2970 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2972 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2973 ut_params->obuf = ut_params->op->sym->m_src;
2974 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2975 + plaintext_pad_len;
2978 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2987 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2989 struct crypto_testsuite_params *ts_params = &testsuite_params;
2990 struct crypto_unittest_params *ut_params = &unittest_params;
2993 unsigned plaintext_pad_len;
2994 unsigned plaintext_len;
2997 /* Create KASUMI session */
2998 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2999 tdata->key.data, tdata->key.len,
3000 0, tdata->digest.len,
3001 RTE_CRYPTO_AUTH_OP_GENERATE,
3002 RTE_CRYPTO_AUTH_KASUMI_F9);
3006 /* alloc mbuf and set payload */
3007 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3009 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3010 rte_pktmbuf_tailroom(ut_params->ibuf));
3012 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3013 /* Append data which is padded to a multiple of */
3014 /* the algorithms block size */
3015 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3016 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3018 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3020 /* Create KASUMI operation */
3021 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3023 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3024 tdata->plaintext.len,
3029 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3031 ut_params->obuf = ut_params->op->sym->m_src;
3032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3033 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3034 + plaintext_pad_len;
3037 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3040 DIGEST_BYTE_LENGTH_KASUMI_F9,
3041 "KASUMI Generated auth tag not as expected");
3047 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3049 struct crypto_testsuite_params *ts_params = &testsuite_params;
3050 struct crypto_unittest_params *ut_params = &unittest_params;
3053 unsigned plaintext_pad_len;
3054 unsigned plaintext_len;
3057 /* Create KASUMI session */
3058 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3059 tdata->key.data, tdata->key.len,
3060 0, tdata->digest.len,
3061 RTE_CRYPTO_AUTH_OP_VERIFY,
3062 RTE_CRYPTO_AUTH_KASUMI_F9);
3065 /* alloc mbuf and set payload */
3066 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3068 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3069 rte_pktmbuf_tailroom(ut_params->ibuf));
3071 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3072 /* Append data which is padded to a multiple */
3073 /* of the algorithms block size */
3074 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3075 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3077 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3079 /* Create KASUMI operation */
3080 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3084 RTE_CRYPTO_AUTH_OP_VERIFY,
3085 tdata->plaintext.len,
3090 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3092 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3093 ut_params->obuf = ut_params->op->sym->m_src;
3094 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3095 + plaintext_pad_len;
3098 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3107 test_snow3g_hash_generate_test_case_1(void)
3109 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3113 test_snow3g_hash_generate_test_case_2(void)
3115 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3119 test_snow3g_hash_generate_test_case_3(void)
3121 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3125 test_snow3g_hash_generate_test_case_4(void)
3127 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3131 test_snow3g_hash_generate_test_case_5(void)
3133 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3137 test_snow3g_hash_generate_test_case_6(void)
3139 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3143 test_snow3g_hash_verify_test_case_1(void)
3145 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3150 test_snow3g_hash_verify_test_case_2(void)
3152 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3156 test_snow3g_hash_verify_test_case_3(void)
3158 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3162 test_snow3g_hash_verify_test_case_4(void)
3164 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3168 test_snow3g_hash_verify_test_case_5(void)
3170 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3174 test_snow3g_hash_verify_test_case_6(void)
3176 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3180 test_kasumi_hash_generate_test_case_1(void)
3182 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3186 test_kasumi_hash_generate_test_case_2(void)
3188 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3192 test_kasumi_hash_generate_test_case_3(void)
3194 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3198 test_kasumi_hash_generate_test_case_4(void)
3200 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3204 test_kasumi_hash_generate_test_case_5(void)
3206 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3210 test_kasumi_hash_generate_test_case_6(void)
3212 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3216 test_kasumi_hash_verify_test_case_1(void)
3218 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3222 test_kasumi_hash_verify_test_case_2(void)
3224 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3228 test_kasumi_hash_verify_test_case_3(void)
3230 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3234 test_kasumi_hash_verify_test_case_4(void)
3236 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3240 test_kasumi_hash_verify_test_case_5(void)
3242 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3246 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3248 struct crypto_testsuite_params *ts_params = &testsuite_params;
3249 struct crypto_unittest_params *ut_params = &unittest_params;
3252 uint8_t *plaintext, *ciphertext;
3253 unsigned plaintext_pad_len;
3254 unsigned plaintext_len;
3256 /* Create KASUMI session */
3257 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3258 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3259 RTE_CRYPTO_CIPHER_KASUMI_F8,
3260 tdata->key.data, tdata->key.len,
3261 tdata->cipher_iv.len);
3265 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3267 /* Clear mbuf payload */
3268 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3269 rte_pktmbuf_tailroom(ut_params->ibuf));
3271 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3272 /* Append data which is padded to a multiple */
3273 /* of the algorithms block size */
3274 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3275 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3277 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3279 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3281 /* Create KASUMI operation */
3282 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3283 tdata->cipher_iv.len,
3284 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3285 tdata->validCipherOffsetInBits.len);
3289 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3291 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3293 ut_params->obuf = ut_params->op->sym->m_dst;
3294 if (ut_params->obuf)
3295 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3297 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3299 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3301 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3302 (tdata->validCipherOffsetInBits.len >> 3);
3304 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3306 reference_ciphertext,
3307 tdata->validCipherLenInBits.len,
3308 "KASUMI Ciphertext data not as expected");
3313 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3315 struct crypto_testsuite_params *ts_params = &testsuite_params;
3316 struct crypto_unittest_params *ut_params = &unittest_params;
3320 unsigned int plaintext_pad_len;
3321 unsigned int plaintext_len;
3323 uint8_t buffer[10000];
3324 const uint8_t *ciphertext;
3326 struct rte_cryptodev_info dev_info;
3328 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3330 uint64_t feat_flags = dev_info.feature_flags;
3332 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3333 printf("Device doesn't support in-place scatter-gather. "
3338 /* Create KASUMI session */
3339 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3340 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3341 RTE_CRYPTO_CIPHER_KASUMI_F8,
3342 tdata->key.data, tdata->key.len,
3343 tdata->cipher_iv.len);
3347 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3350 /* Append data which is padded to a multiple */
3351 /* of the algorithms block size */
3352 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3354 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3355 plaintext_pad_len, 10, 0);
3357 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3359 /* Create KASUMI operation */
3360 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3361 tdata->cipher_iv.len,
3362 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3363 tdata->validCipherOffsetInBits.len);
3367 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3369 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3371 ut_params->obuf = ut_params->op->sym->m_dst;
3373 if (ut_params->obuf)
3374 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3375 plaintext_len, buffer);
3377 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3378 tdata->validCipherOffsetInBits.len >> 3,
3379 plaintext_len, buffer);
3382 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3384 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3385 (tdata->validCipherOffsetInBits.len >> 3);
3387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3389 reference_ciphertext,
3390 tdata->validCipherLenInBits.len,
3391 "KASUMI Ciphertext data not as expected");
3396 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3398 struct crypto_testsuite_params *ts_params = &testsuite_params;
3399 struct crypto_unittest_params *ut_params = &unittest_params;
3402 uint8_t *plaintext, *ciphertext;
3403 unsigned plaintext_pad_len;
3404 unsigned plaintext_len;
3406 /* Create KASUMI session */
3407 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3408 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3409 RTE_CRYPTO_CIPHER_KASUMI_F8,
3410 tdata->key.data, tdata->key.len,
3411 tdata->cipher_iv.len);
3415 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3416 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3418 /* Clear mbuf payload */
3419 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3420 rte_pktmbuf_tailroom(ut_params->ibuf));
3422 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3423 /* Append data which is padded to a multiple */
3424 /* of the algorithms block size */
3425 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3426 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3428 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3429 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3431 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3433 /* Create KASUMI operation */
3434 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3435 tdata->cipher_iv.len,
3436 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3437 tdata->validCipherOffsetInBits.len);
3441 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3443 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3445 ut_params->obuf = ut_params->op->sym->m_dst;
3446 if (ut_params->obuf)
3447 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3449 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3451 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3453 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3454 (tdata->validCipherOffsetInBits.len >> 3);
3456 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3458 reference_ciphertext,
3459 tdata->validCipherLenInBits.len,
3460 "KASUMI Ciphertext data not as expected");
3465 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3467 struct crypto_testsuite_params *ts_params = &testsuite_params;
3468 struct crypto_unittest_params *ut_params = &unittest_params;
3471 unsigned int plaintext_pad_len;
3472 unsigned int plaintext_len;
3474 const uint8_t *ciphertext;
3475 uint8_t buffer[2048];
3477 struct rte_cryptodev_info dev_info;
3479 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3481 uint64_t feat_flags = dev_info.feature_flags;
3482 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3483 printf("Device doesn't support out-of-place scatter-gather "
3484 "in both input and output mbufs. "
3489 /* Create KASUMI session */
3490 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3491 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3492 RTE_CRYPTO_CIPHER_KASUMI_F8,
3493 tdata->key.data, tdata->key.len,
3494 tdata->cipher_iv.len);
3498 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3499 /* Append data which is padded to a multiple */
3500 /* of the algorithms block size */
3501 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3503 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3504 plaintext_pad_len, 10, 0);
3505 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3506 plaintext_pad_len, 3, 0);
3508 /* Append data which is padded to a multiple */
3509 /* of the algorithms block size */
3510 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3512 /* Create KASUMI operation */
3513 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3514 tdata->cipher_iv.len,
3515 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3516 tdata->validCipherOffsetInBits.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_read(ut_params->obuf, 0,
3527 plaintext_pad_len, buffer);
3529 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3530 tdata->validCipherOffsetInBits.len >> 3,
3531 plaintext_pad_len, buffer);
3533 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3534 (tdata->validCipherOffsetInBits.len >> 3);
3536 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3538 reference_ciphertext,
3539 tdata->validCipherLenInBits.len,
3540 "KASUMI Ciphertext data not as expected");
3546 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3548 struct crypto_testsuite_params *ts_params = &testsuite_params;
3549 struct crypto_unittest_params *ut_params = &unittest_params;
3552 uint8_t *ciphertext, *plaintext;
3553 unsigned ciphertext_pad_len;
3554 unsigned ciphertext_len;
3556 /* Create KASUMI session */
3557 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3558 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3559 RTE_CRYPTO_CIPHER_KASUMI_F8,
3560 tdata->key.data, tdata->key.len,
3561 tdata->cipher_iv.len);
3565 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3566 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3568 /* Clear mbuf payload */
3569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3570 rte_pktmbuf_tailroom(ut_params->ibuf));
3572 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3573 /* Append data which is padded to a multiple */
3574 /* of the algorithms block size */
3575 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3576 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3577 ciphertext_pad_len);
3578 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3579 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3581 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3583 /* Create KASUMI operation */
3584 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3585 tdata->cipher_iv.len,
3586 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3587 tdata->validCipherOffsetInBits.len);
3591 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3593 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3595 ut_params->obuf = ut_params->op->sym->m_dst;
3596 if (ut_params->obuf)
3597 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3599 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3601 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3603 const uint8_t *reference_plaintext = tdata->plaintext.data +
3604 (tdata->validCipherOffsetInBits.len >> 3);
3606 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3608 reference_plaintext,
3609 tdata->validCipherLenInBits.len,
3610 "KASUMI Plaintext data not as expected");
3615 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3617 struct crypto_testsuite_params *ts_params = &testsuite_params;
3618 struct crypto_unittest_params *ut_params = &unittest_params;
3621 uint8_t *ciphertext, *plaintext;
3622 unsigned ciphertext_pad_len;
3623 unsigned ciphertext_len;
3625 /* Create KASUMI session */
3626 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3627 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3628 RTE_CRYPTO_CIPHER_KASUMI_F8,
3629 tdata->key.data, tdata->key.len,
3630 tdata->cipher_iv.len);
3634 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3636 /* Clear mbuf payload */
3637 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3638 rte_pktmbuf_tailroom(ut_params->ibuf));
3640 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3641 /* Append data which is padded to a multiple */
3642 /* of the algorithms block size */
3643 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3644 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3645 ciphertext_pad_len);
3646 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3648 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3650 /* Create KASUMI operation */
3651 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3652 tdata->cipher_iv.len,
3653 tdata->ciphertext.len,
3654 tdata->validCipherOffsetInBits.len);
3658 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3660 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3662 ut_params->obuf = ut_params->op->sym->m_dst;
3663 if (ut_params->obuf)
3664 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3666 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3668 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3670 const uint8_t *reference_plaintext = tdata->plaintext.data +
3671 (tdata->validCipherOffsetInBits.len >> 3);
3673 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3675 reference_plaintext,
3676 tdata->validCipherLenInBits.len,
3677 "KASUMI Plaintext data not as expected");
3682 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3684 struct crypto_testsuite_params *ts_params = &testsuite_params;
3685 struct crypto_unittest_params *ut_params = &unittest_params;
3688 uint8_t *plaintext, *ciphertext;
3689 unsigned plaintext_pad_len;
3690 unsigned plaintext_len;
3692 /* Create SNOW 3G session */
3693 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3694 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3695 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3696 tdata->key.data, tdata->key.len,
3697 tdata->cipher_iv.len);
3701 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3703 /* Clear mbuf payload */
3704 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3705 rte_pktmbuf_tailroom(ut_params->ibuf));
3707 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3708 /* Append data which is padded to a multiple of */
3709 /* the algorithms block size */
3710 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3711 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3713 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3715 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3717 /* Create SNOW 3G operation */
3718 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3719 tdata->cipher_iv.len,
3720 tdata->validCipherLenInBits.len,
3725 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3727 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3729 ut_params->obuf = ut_params->op->sym->m_dst;
3730 if (ut_params->obuf)
3731 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3733 ciphertext = plaintext;
3735 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3738 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3740 tdata->ciphertext.data,
3741 tdata->validDataLenInBits.len,
3742 "SNOW 3G Ciphertext data not as expected");
3748 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3750 struct crypto_testsuite_params *ts_params = &testsuite_params;
3751 struct crypto_unittest_params *ut_params = &unittest_params;
3752 uint8_t *plaintext, *ciphertext;
3755 unsigned plaintext_pad_len;
3756 unsigned plaintext_len;
3758 /* Create SNOW 3G session */
3759 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3760 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3761 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3762 tdata->key.data, tdata->key.len,
3763 tdata->cipher_iv.len);
3767 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3768 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3770 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3771 "Failed to allocate input buffer in mempool");
3772 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3773 "Failed to allocate output buffer in mempool");
3775 /* Clear mbuf payload */
3776 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3777 rte_pktmbuf_tailroom(ut_params->ibuf));
3779 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3780 /* Append data which is padded to a multiple of */
3781 /* the algorithms block size */
3782 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3783 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3785 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3786 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3788 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3790 /* Create SNOW 3G operation */
3791 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3792 tdata->cipher_iv.len,
3793 tdata->validCipherLenInBits.len,
3798 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3800 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3802 ut_params->obuf = ut_params->op->sym->m_dst;
3803 if (ut_params->obuf)
3804 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3806 ciphertext = plaintext;
3808 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3811 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3813 tdata->ciphertext.data,
3814 tdata->validDataLenInBits.len,
3815 "SNOW 3G Ciphertext data not as expected");
3820 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3822 struct crypto_testsuite_params *ts_params = &testsuite_params;
3823 struct crypto_unittest_params *ut_params = &unittest_params;
3826 unsigned int plaintext_pad_len;
3827 unsigned int plaintext_len;
3828 uint8_t buffer[10000];
3829 const uint8_t *ciphertext;
3831 struct rte_cryptodev_info dev_info;
3833 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3835 uint64_t feat_flags = dev_info.feature_flags;
3837 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3838 printf("Device doesn't support out-of-place scatter-gather "
3839 "in both input and output mbufs. "
3844 /* Create SNOW 3G session */
3845 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3846 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3847 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3848 tdata->key.data, tdata->key.len,
3849 tdata->cipher_iv.len);
3853 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3854 /* Append data which is padded to a multiple of */
3855 /* the algorithms block size */
3856 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3858 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3859 plaintext_pad_len, 10, 0);
3860 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3861 plaintext_pad_len, 3, 0);
3863 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3864 "Failed to allocate input buffer in mempool");
3865 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3866 "Failed to allocate output buffer in mempool");
3868 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3870 /* Create SNOW 3G operation */
3871 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3872 tdata->cipher_iv.len,
3873 tdata->validCipherLenInBits.len,
3878 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3880 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3882 ut_params->obuf = ut_params->op->sym->m_dst;
3883 if (ut_params->obuf)
3884 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3885 plaintext_len, buffer);
3887 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3888 plaintext_len, buffer);
3890 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3893 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3895 tdata->ciphertext.data,
3896 tdata->validDataLenInBits.len,
3897 "SNOW 3G Ciphertext data not as expected");
3902 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3904 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3906 uint8_t curr_byte, prev_byte;
3907 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3908 uint8_t lower_byte_mask = (1 << offset) - 1;
3911 prev_byte = buffer[0];
3912 buffer[0] >>= offset;
3914 for (i = 1; i < length_in_bytes; i++) {
3915 curr_byte = buffer[i];
3916 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3917 (curr_byte >> offset);
3918 prev_byte = curr_byte;
3923 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3925 struct crypto_testsuite_params *ts_params = &testsuite_params;
3926 struct crypto_unittest_params *ut_params = &unittest_params;
3927 uint8_t *plaintext, *ciphertext;
3929 uint32_t plaintext_len;
3930 uint32_t plaintext_pad_len;
3931 uint8_t extra_offset = 4;
3932 uint8_t *expected_ciphertext_shifted;
3934 /* Create SNOW 3G session */
3935 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3936 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3937 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3938 tdata->key.data, tdata->key.len,
3939 tdata->cipher_iv.len);
3943 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3944 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3946 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3947 "Failed to allocate input buffer in mempool");
3948 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3949 "Failed to allocate output buffer in mempool");
3951 /* Clear mbuf payload */
3952 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3953 rte_pktmbuf_tailroom(ut_params->ibuf));
3955 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3957 * Append data which is padded to a
3958 * multiple of the algorithms block size
3960 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3962 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3965 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3967 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3968 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3970 #ifdef RTE_APP_TEST_DEBUG
3971 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3973 /* Create SNOW 3G operation */
3974 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3975 tdata->cipher_iv.len,
3976 tdata->validCipherLenInBits.len,
3981 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3983 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3985 ut_params->obuf = ut_params->op->sym->m_dst;
3986 if (ut_params->obuf)
3987 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3989 ciphertext = plaintext;
3991 #ifdef RTE_APP_TEST_DEBUG
3992 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3995 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3997 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3998 "failed to reserve memory for ciphertext shifted\n");
4000 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4001 ceil_byte_length(tdata->ciphertext.len));
4002 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4005 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4007 expected_ciphertext_shifted,
4008 tdata->validDataLenInBits.len,
4010 "SNOW 3G Ciphertext data not as expected");
4014 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4016 struct crypto_testsuite_params *ts_params = &testsuite_params;
4017 struct crypto_unittest_params *ut_params = &unittest_params;
4021 uint8_t *plaintext, *ciphertext;
4022 unsigned ciphertext_pad_len;
4023 unsigned ciphertext_len;
4025 /* Create SNOW 3G session */
4026 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4027 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4028 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4029 tdata->key.data, tdata->key.len,
4030 tdata->cipher_iv.len);
4034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4036 /* Clear mbuf payload */
4037 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4038 rte_pktmbuf_tailroom(ut_params->ibuf));
4040 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4041 /* Append data which is padded to a multiple of */
4042 /* the algorithms block size */
4043 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4044 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4045 ciphertext_pad_len);
4046 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4048 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4050 /* Create SNOW 3G operation */
4051 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4052 tdata->cipher_iv.len,
4053 tdata->validCipherLenInBits.len,
4054 tdata->cipher.offset_bits);
4058 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4060 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4061 ut_params->obuf = ut_params->op->sym->m_dst;
4062 if (ut_params->obuf)
4063 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4065 plaintext = ciphertext;
4067 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4070 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4071 tdata->plaintext.data,
4072 tdata->validDataLenInBits.len,
4073 "SNOW 3G Plaintext data not as expected");
4077 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4079 struct crypto_testsuite_params *ts_params = &testsuite_params;
4080 struct crypto_unittest_params *ut_params = &unittest_params;
4084 uint8_t *plaintext, *ciphertext;
4085 unsigned ciphertext_pad_len;
4086 unsigned ciphertext_len;
4088 /* Create SNOW 3G session */
4089 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4090 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4091 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4092 tdata->key.data, tdata->key.len,
4093 tdata->cipher_iv.len);
4097 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4098 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4100 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4101 "Failed to allocate input buffer");
4102 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4103 "Failed to allocate output buffer");
4105 /* Clear mbuf payload */
4106 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4107 rte_pktmbuf_tailroom(ut_params->ibuf));
4109 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4110 rte_pktmbuf_tailroom(ut_params->obuf));
4112 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4113 /* Append data which is padded to a multiple of */
4114 /* the algorithms block size */
4115 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4116 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4117 ciphertext_pad_len);
4118 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4119 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4121 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4123 /* Create SNOW 3G operation */
4124 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4125 tdata->cipher_iv.len,
4126 tdata->validCipherLenInBits.len,
4131 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4133 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4134 ut_params->obuf = ut_params->op->sym->m_dst;
4135 if (ut_params->obuf)
4136 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4138 plaintext = ciphertext;
4140 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4143 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4144 tdata->plaintext.data,
4145 tdata->validDataLenInBits.len,
4146 "SNOW 3G Plaintext data not as expected");
4151 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4153 struct crypto_testsuite_params *ts_params = &testsuite_params;
4154 struct crypto_unittest_params *ut_params = &unittest_params;
4158 uint8_t *plaintext, *ciphertext;
4159 unsigned int plaintext_pad_len;
4160 unsigned int plaintext_len;
4162 struct rte_cryptodev_sym_capability_idx cap_idx;
4164 /* Check if device supports ZUC EEA3 */
4165 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4166 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4168 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4172 /* Check if device supports ZUC EIA3 */
4173 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4174 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4176 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4180 /* Create ZUC session */
4181 retval = create_zuc_cipher_auth_encrypt_generate_session(
4182 ts_params->valid_devs[0],
4186 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4188 /* clear mbuf payload */
4189 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4190 rte_pktmbuf_tailroom(ut_params->ibuf));
4192 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4193 /* Append data which is padded to a multiple of */
4194 /* the algorithms block size */
4195 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4196 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4198 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4200 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4202 /* Create ZUC operation */
4203 retval = create_zuc_cipher_hash_generate_operation(tdata);
4207 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4209 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4210 ut_params->obuf = ut_params->op->sym->m_src;
4211 if (ut_params->obuf)
4212 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4214 ciphertext = plaintext;
4216 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4218 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4220 tdata->ciphertext.data,
4221 tdata->validDataLenInBits.len,
4222 "ZUC Ciphertext data not as expected");
4224 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4225 + plaintext_pad_len;
4228 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4232 "ZUC Generated auth tag not as expected");
4237 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4239 struct crypto_testsuite_params *ts_params = &testsuite_params;
4240 struct crypto_unittest_params *ut_params = &unittest_params;
4244 uint8_t *plaintext, *ciphertext;
4245 unsigned plaintext_pad_len;
4246 unsigned plaintext_len;
4248 /* Create SNOW 3G session */
4249 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4250 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4251 RTE_CRYPTO_AUTH_OP_GENERATE,
4252 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4253 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4254 tdata->key.data, tdata->key.len,
4255 tdata->auth_iv.len, tdata->digest.len,
4256 tdata->cipher_iv.len);
4259 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4261 /* clear mbuf payload */
4262 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4263 rte_pktmbuf_tailroom(ut_params->ibuf));
4265 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4266 /* Append data which is padded to a multiple of */
4267 /* the algorithms block size */
4268 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4269 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4271 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4273 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4275 /* Create SNOW 3G operation */
4276 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4277 tdata->digest.len, tdata->auth_iv.data,
4279 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4280 tdata->cipher_iv.data, tdata->cipher_iv.len,
4281 tdata->validCipherLenInBits.len,
4283 tdata->validAuthLenInBits.len,
4289 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4291 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4292 ut_params->obuf = ut_params->op->sym->m_src;
4293 if (ut_params->obuf)
4294 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4296 ciphertext = plaintext;
4298 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4300 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4302 tdata->ciphertext.data,
4303 tdata->validDataLenInBits.len,
4304 "SNOW 3G Ciphertext data not as expected");
4306 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4307 + plaintext_pad_len;
4310 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4313 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4314 "SNOW 3G Generated auth tag not as expected");
4318 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4320 struct crypto_testsuite_params *ts_params = &testsuite_params;
4321 struct crypto_unittest_params *ut_params = &unittest_params;
4325 uint8_t *plaintext, *ciphertext;
4326 unsigned plaintext_pad_len;
4327 unsigned plaintext_len;
4329 /* Create SNOW 3G session */
4330 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4331 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4332 RTE_CRYPTO_AUTH_OP_GENERATE,
4333 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4334 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4335 tdata->key.data, tdata->key.len,
4336 tdata->auth_iv.len, tdata->digest.len,
4337 tdata->cipher_iv.len);
4341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4343 /* clear mbuf payload */
4344 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4345 rte_pktmbuf_tailroom(ut_params->ibuf));
4347 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4348 /* Append data which is padded to a multiple of */
4349 /* the algorithms block size */
4350 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4351 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4353 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4355 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4357 /* Create SNOW 3G operation */
4358 retval = create_wireless_algo_auth_cipher_operation(
4360 tdata->cipher_iv.data, tdata->cipher_iv.len,
4361 tdata->auth_iv.data, tdata->auth_iv.len,
4362 tdata->digest.offset_bytes == 0 ?
4363 plaintext_pad_len : tdata->digest.offset_bytes,
4364 tdata->validCipherLenInBits.len,
4365 tdata->cipher.offset_bits,
4366 tdata->validAuthLenInBits.len,
4367 tdata->auth.offset_bits);
4372 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4374 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4375 ut_params->obuf = ut_params->op->sym->m_src;
4376 if (ut_params->obuf)
4377 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4379 ciphertext = plaintext;
4381 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4382 + (tdata->digest.offset_bytes == 0 ?
4383 plaintext_pad_len : tdata->digest.offset_bytes);
4385 debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
4386 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4389 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4391 tdata->ciphertext.data,
4392 tdata->validDataLenInBits.len,
4393 "SNOW 3G Ciphertext data not as expected");
4396 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4399 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4400 "SNOW 3G Generated auth tag not as expected");
4405 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4407 struct crypto_testsuite_params *ts_params = &testsuite_params;
4408 struct crypto_unittest_params *ut_params = &unittest_params;
4412 uint8_t *plaintext, *ciphertext;
4413 unsigned plaintext_pad_len;
4414 unsigned plaintext_len;
4416 /* Create KASUMI session */
4417 retval = create_wireless_algo_auth_cipher_session(
4418 ts_params->valid_devs[0],
4419 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4420 RTE_CRYPTO_AUTH_OP_GENERATE,
4421 RTE_CRYPTO_AUTH_KASUMI_F9,
4422 RTE_CRYPTO_CIPHER_KASUMI_F8,
4423 tdata->key.data, tdata->key.len,
4424 0, tdata->digest.len,
4425 tdata->cipher_iv.len);
4428 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4430 /* clear mbuf payload */
4431 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4432 rte_pktmbuf_tailroom(ut_params->ibuf));
4434 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4435 /* Append data which is padded to a multiple of */
4436 /* the algorithms block size */
4437 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4438 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4440 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4442 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4444 /* Create KASUMI operation */
4445 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4446 tdata->cipher_iv.data, tdata->cipher_iv.len,
4449 tdata->validCipherLenInBits.len,
4450 tdata->validCipherOffsetInBits.len,
4451 tdata->validAuthLenInBits.len,
4458 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4460 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4461 if (ut_params->op->sym->m_dst)
4462 ut_params->obuf = ut_params->op->sym->m_dst;
4464 ut_params->obuf = ut_params->op->sym->m_src;
4466 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4467 tdata->validCipherOffsetInBits.len >> 3);
4469 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4470 (tdata->validCipherOffsetInBits.len >> 3);
4472 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4474 reference_ciphertext,
4475 tdata->validCipherLenInBits.len,
4476 "KASUMI Ciphertext data not as expected");
4477 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4478 + plaintext_pad_len;
4481 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4484 DIGEST_BYTE_LENGTH_KASUMI_F9,
4485 "KASUMI Generated auth tag not as expected");
4490 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4492 struct crypto_testsuite_params *ts_params = &testsuite_params;
4493 struct crypto_unittest_params *ut_params = &unittest_params;
4497 uint8_t *plaintext, *ciphertext;
4498 unsigned plaintext_pad_len;
4499 unsigned plaintext_len;
4501 /* Create KASUMI session */
4502 retval = create_wireless_algo_cipher_auth_session(
4503 ts_params->valid_devs[0],
4504 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4505 RTE_CRYPTO_AUTH_OP_GENERATE,
4506 RTE_CRYPTO_AUTH_KASUMI_F9,
4507 RTE_CRYPTO_CIPHER_KASUMI_F8,
4508 tdata->key.data, tdata->key.len,
4509 0, tdata->digest.len,
4510 tdata->cipher_iv.len);
4514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4516 /* clear mbuf payload */
4517 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4518 rte_pktmbuf_tailroom(ut_params->ibuf));
4520 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4521 /* Append data which is padded to a multiple of */
4522 /* the algorithms block size */
4523 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4524 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4526 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4528 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4530 /* Create KASUMI operation */
4531 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4532 tdata->digest.len, NULL, 0,
4533 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4534 tdata->cipher_iv.data, tdata->cipher_iv.len,
4535 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4536 tdata->validCipherOffsetInBits.len,
4537 tdata->validAuthLenInBits.len,
4543 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4545 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4547 if (ut_params->op->sym->m_dst)
4548 ut_params->obuf = ut_params->op->sym->m_dst;
4550 ut_params->obuf = ut_params->op->sym->m_src;
4552 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4553 tdata->validCipherOffsetInBits.len >> 3);
4555 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4556 + plaintext_pad_len;
4558 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4559 (tdata->validCipherOffsetInBits.len >> 3);
4561 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4563 reference_ciphertext,
4564 tdata->validCipherLenInBits.len,
4565 "KASUMI Ciphertext data not as expected");
4568 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4571 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4572 "KASUMI Generated auth tag not as expected");
4577 test_zuc_encryption(const struct wireless_test_data *tdata)
4579 struct crypto_testsuite_params *ts_params = &testsuite_params;
4580 struct crypto_unittest_params *ut_params = &unittest_params;
4583 uint8_t *plaintext, *ciphertext;
4584 unsigned plaintext_pad_len;
4585 unsigned plaintext_len;
4587 struct rte_cryptodev_sym_capability_idx cap_idx;
4589 /* Check if device supports ZUC EEA3 */
4590 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4591 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4593 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4597 /* Create ZUC session */
4598 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4599 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4600 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4601 tdata->key.data, tdata->key.len,
4602 tdata->cipher_iv.len);
4606 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4608 /* Clear mbuf payload */
4609 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4610 rte_pktmbuf_tailroom(ut_params->ibuf));
4612 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4613 /* Append data which is padded to a multiple */
4614 /* of the algorithms block size */
4615 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4616 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4618 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4620 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4622 /* Create ZUC operation */
4623 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4624 tdata->cipher_iv.len,
4625 tdata->plaintext.len,
4630 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4632 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4634 ut_params->obuf = ut_params->op->sym->m_dst;
4635 if (ut_params->obuf)
4636 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4638 ciphertext = plaintext;
4640 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4643 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4645 tdata->ciphertext.data,
4646 tdata->validCipherLenInBits.len,
4647 "ZUC Ciphertext data not as expected");
4652 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4654 struct crypto_testsuite_params *ts_params = &testsuite_params;
4655 struct crypto_unittest_params *ut_params = &unittest_params;
4659 unsigned int plaintext_pad_len;
4660 unsigned int plaintext_len;
4661 const uint8_t *ciphertext;
4662 uint8_t ciphertext_buffer[2048];
4663 struct rte_cryptodev_info dev_info;
4665 struct rte_cryptodev_sym_capability_idx cap_idx;
4667 /* Check if device supports ZUC EEA3 */
4668 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4669 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4671 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4675 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4677 uint64_t feat_flags = dev_info.feature_flags;
4679 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4680 printf("Device doesn't support in-place scatter-gather. "
4685 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4687 /* Append data which is padded to a multiple */
4688 /* of the algorithms block size */
4689 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4691 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4692 plaintext_pad_len, 10, 0);
4694 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4695 tdata->plaintext.data);
4697 /* Create ZUC session */
4698 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4699 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4700 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4701 tdata->key.data, tdata->key.len,
4702 tdata->cipher_iv.len);
4706 /* Clear mbuf payload */
4708 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4710 /* Create ZUC operation */
4711 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4712 tdata->cipher_iv.len, tdata->plaintext.len,
4717 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4719 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4721 ut_params->obuf = ut_params->op->sym->m_dst;
4722 if (ut_params->obuf)
4723 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4724 0, plaintext_len, ciphertext_buffer);
4726 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4727 0, plaintext_len, ciphertext_buffer);
4730 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4733 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4735 tdata->ciphertext.data,
4736 tdata->validCipherLenInBits.len,
4737 "ZUC Ciphertext data not as expected");
4743 test_zuc_authentication(const struct wireless_test_data *tdata)
4745 struct crypto_testsuite_params *ts_params = &testsuite_params;
4746 struct crypto_unittest_params *ut_params = &unittest_params;
4749 unsigned plaintext_pad_len;
4750 unsigned plaintext_len;
4753 struct rte_cryptodev_sym_capability_idx cap_idx;
4755 /* Check if device supports ZUC EIA3 */
4756 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4757 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4759 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4763 /* Create ZUC session */
4764 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4765 tdata->key.data, tdata->key.len,
4766 tdata->auth_iv.len, tdata->digest.len,
4767 RTE_CRYPTO_AUTH_OP_GENERATE,
4768 RTE_CRYPTO_AUTH_ZUC_EIA3);
4772 /* alloc mbuf and set payload */
4773 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4775 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4776 rte_pktmbuf_tailroom(ut_params->ibuf));
4778 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4779 /* Append data which is padded to a multiple of */
4780 /* the algorithms block size */
4781 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4782 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4784 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4786 /* Create ZUC operation */
4787 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4788 tdata->auth_iv.data, tdata->auth_iv.len,
4789 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4790 tdata->validAuthLenInBits.len,
4795 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4797 ut_params->obuf = ut_params->op->sym->m_src;
4798 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4799 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4800 + plaintext_pad_len;
4803 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4806 DIGEST_BYTE_LENGTH_KASUMI_F9,
4807 "ZUC Generated auth tag not as expected");
4813 test_kasumi_encryption_test_case_1(void)
4815 return test_kasumi_encryption(&kasumi_test_case_1);
4819 test_kasumi_encryption_test_case_1_sgl(void)
4821 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4825 test_kasumi_encryption_test_case_1_oop(void)
4827 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4831 test_kasumi_encryption_test_case_1_oop_sgl(void)
4833 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4837 test_kasumi_encryption_test_case_2(void)
4839 return test_kasumi_encryption(&kasumi_test_case_2);
4843 test_kasumi_encryption_test_case_3(void)
4845 return test_kasumi_encryption(&kasumi_test_case_3);
4849 test_kasumi_encryption_test_case_4(void)
4851 return test_kasumi_encryption(&kasumi_test_case_4);
4855 test_kasumi_encryption_test_case_5(void)
4857 return test_kasumi_encryption(&kasumi_test_case_5);
4861 test_kasumi_decryption_test_case_1(void)
4863 return test_kasumi_decryption(&kasumi_test_case_1);
4867 test_kasumi_decryption_test_case_1_oop(void)
4869 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4873 test_kasumi_decryption_test_case_2(void)
4875 return test_kasumi_decryption(&kasumi_test_case_2);
4879 test_kasumi_decryption_test_case_3(void)
4881 return test_kasumi_decryption(&kasumi_test_case_3);
4885 test_kasumi_decryption_test_case_4(void)
4887 return test_kasumi_decryption(&kasumi_test_case_4);
4891 test_kasumi_decryption_test_case_5(void)
4893 return test_kasumi_decryption(&kasumi_test_case_5);
4896 test_snow3g_encryption_test_case_1(void)
4898 return test_snow3g_encryption(&snow3g_test_case_1);
4902 test_snow3g_encryption_test_case_1_oop(void)
4904 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4908 test_snow3g_encryption_test_case_1_oop_sgl(void)
4910 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4915 test_snow3g_encryption_test_case_1_offset_oop(void)
4917 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4921 test_snow3g_encryption_test_case_2(void)
4923 return test_snow3g_encryption(&snow3g_test_case_2);
4927 test_snow3g_encryption_test_case_3(void)
4929 return test_snow3g_encryption(&snow3g_test_case_3);
4933 test_snow3g_encryption_test_case_4(void)
4935 return test_snow3g_encryption(&snow3g_test_case_4);
4939 test_snow3g_encryption_test_case_5(void)
4941 return test_snow3g_encryption(&snow3g_test_case_5);
4945 test_snow3g_decryption_test_case_1(void)
4947 return test_snow3g_decryption(&snow3g_test_case_1);
4951 test_snow3g_decryption_test_case_1_oop(void)
4953 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4957 test_snow3g_decryption_test_case_2(void)
4959 return test_snow3g_decryption(&snow3g_test_case_2);
4963 test_snow3g_decryption_test_case_3(void)
4965 return test_snow3g_decryption(&snow3g_test_case_3);
4969 test_snow3g_decryption_test_case_4(void)
4971 return test_snow3g_decryption(&snow3g_test_case_4);
4975 test_snow3g_decryption_test_case_5(void)
4977 return test_snow3g_decryption(&snow3g_test_case_5);
4981 * Function prepares snow3g_hash_test_data from snow3g_test_data.
4982 * Pattern digest from snow3g_test_data must be allocated as
4983 * 4 last bytes in plaintext.
4986 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
4987 struct snow3g_hash_test_data *output)
4989 if ((pattern != NULL) && (output != NULL)) {
4990 output->key.len = pattern->key.len;
4992 memcpy(output->key.data,
4993 pattern->key.data, pattern->key.len);
4995 output->auth_iv.len = pattern->auth_iv.len;
4997 memcpy(output->auth_iv.data,
4998 pattern->auth_iv.data, pattern->auth_iv.len);
5000 output->plaintext.len = pattern->plaintext.len;
5002 memcpy(output->plaintext.data,
5003 pattern->plaintext.data, pattern->plaintext.len >> 3);
5005 output->digest.len = pattern->digest.len;
5007 memcpy(output->digest.data,
5008 &pattern->plaintext.data[pattern->digest.offset_bytes],
5009 pattern->digest.len);
5011 output->validAuthLenInBits.len =
5012 pattern->validAuthLenInBits.len;
5017 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5020 test_snow3g_decryption_with_digest_test_case_1(void)
5022 struct snow3g_hash_test_data snow3g_hash_data;
5025 * Function prepare data for hash veryfication test case.
5026 * Digest is allocated in 4 last bytes in plaintext, pattern.
5028 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5030 return test_snow3g_decryption(&snow3g_test_case_7) &
5031 test_snow3g_authentication_verify(&snow3g_hash_data);
5035 test_snow3g_cipher_auth_test_case_1(void)
5037 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5041 test_snow3g_auth_cipher_test_case_1(void)
5043 return test_snow3g_auth_cipher(&snow3g_test_case_6);
5047 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5049 return test_snow3g_auth_cipher(&snow3g_test_case_7);
5053 test_kasumi_auth_cipher_test_case_1(void)
5055 return test_kasumi_auth_cipher(&kasumi_test_case_3);
5059 test_kasumi_cipher_auth_test_case_1(void)
5061 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5065 test_zuc_encryption_test_case_1(void)
5067 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5071 test_zuc_encryption_test_case_2(void)
5073 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5077 test_zuc_encryption_test_case_3(void)
5079 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5083 test_zuc_encryption_test_case_4(void)
5085 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5089 test_zuc_encryption_test_case_5(void)
5091 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5095 test_zuc_encryption_test_case_6_sgl(void)
5097 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5101 test_zuc_hash_generate_test_case_1(void)
5103 return test_zuc_authentication(&zuc_test_case_auth_1b);
5107 test_zuc_hash_generate_test_case_2(void)
5109 return test_zuc_authentication(&zuc_test_case_auth_90b);
5113 test_zuc_hash_generate_test_case_3(void)
5115 return test_zuc_authentication(&zuc_test_case_auth_577b);
5119 test_zuc_hash_generate_test_case_4(void)
5121 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5125 test_zuc_hash_generate_test_case_5(void)
5127 return test_zuc_authentication(&zuc_test_auth_5670b);
5131 test_zuc_hash_generate_test_case_6(void)
5133 return test_zuc_authentication(&zuc_test_case_auth_128b);
5137 test_zuc_hash_generate_test_case_7(void)
5139 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5143 test_zuc_hash_generate_test_case_8(void)
5145 return test_zuc_authentication(&zuc_test_case_auth_584b);
5149 test_zuc_cipher_auth_test_case_1(void)
5151 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5155 test_zuc_cipher_auth_test_case_2(void)
5157 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5161 test_3DES_chain_qat_all(void)
5163 struct crypto_testsuite_params *ts_params = &testsuite_params;
5166 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5167 ts_params->op_mpool,
5168 ts_params->session_mpool, ts_params->session_priv_mpool,
5169 ts_params->valid_devs[0],
5170 rte_cryptodev_driver_id_get(
5171 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5172 BLKCIPHER_3DES_CHAIN_TYPE);
5174 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5176 return TEST_SUCCESS;
5180 test_DES_cipheronly_qat_all(void)
5182 struct crypto_testsuite_params *ts_params = &testsuite_params;
5185 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5186 ts_params->op_mpool,
5187 ts_params->session_mpool, ts_params->session_priv_mpool,
5188 ts_params->valid_devs[0],
5189 rte_cryptodev_driver_id_get(
5190 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5191 BLKCIPHER_DES_CIPHERONLY_TYPE);
5193 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5195 return TEST_SUCCESS;
5199 test_DES_cipheronly_openssl_all(void)
5201 struct crypto_testsuite_params *ts_params = &testsuite_params;
5204 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5205 ts_params->op_mpool,
5206 ts_params->session_mpool, ts_params->session_priv_mpool,
5207 ts_params->valid_devs[0],
5208 rte_cryptodev_driver_id_get(
5209 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5210 BLKCIPHER_DES_CIPHERONLY_TYPE);
5212 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5214 return TEST_SUCCESS;
5218 test_DES_docsis_openssl_all(void)
5220 struct crypto_testsuite_params *ts_params = &testsuite_params;
5223 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5224 ts_params->op_mpool,
5225 ts_params->session_mpool, ts_params->session_priv_mpool,
5226 ts_params->valid_devs[0],
5227 rte_cryptodev_driver_id_get(
5228 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5229 BLKCIPHER_DES_DOCSIS_TYPE);
5231 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5233 return TEST_SUCCESS;
5237 test_DES_cipheronly_mb_all(void)
5239 struct crypto_testsuite_params *ts_params = &testsuite_params;
5242 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5243 ts_params->op_mpool,
5244 ts_params->session_mpool, ts_params->session_priv_mpool,
5245 ts_params->valid_devs[0],
5246 rte_cryptodev_driver_id_get(
5247 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5248 BLKCIPHER_DES_CIPHERONLY_TYPE);
5250 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5252 return TEST_SUCCESS;
5255 test_3DES_cipheronly_mb_all(void)
5257 struct crypto_testsuite_params *ts_params = &testsuite_params;
5260 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5261 ts_params->op_mpool,
5262 ts_params->session_mpool, ts_params->session_priv_mpool,
5263 ts_params->valid_devs[0],
5264 rte_cryptodev_driver_id_get(
5265 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5266 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5268 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5270 return TEST_SUCCESS;
5274 test_DES_docsis_mb_all(void)
5276 struct crypto_testsuite_params *ts_params = &testsuite_params;
5279 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5280 ts_params->op_mpool,
5281 ts_params->session_mpool, ts_params->session_priv_mpool,
5282 ts_params->valid_devs[0],
5283 rte_cryptodev_driver_id_get(
5284 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5285 BLKCIPHER_DES_DOCSIS_TYPE);
5287 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5289 return TEST_SUCCESS;
5293 test_3DES_chain_caam_jr_all(void)
5295 struct crypto_testsuite_params *ts_params = &testsuite_params;
5298 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5299 ts_params->op_mpool,
5300 ts_params->session_mpool, ts_params->session_priv_mpool,
5301 ts_params->valid_devs[0],
5302 rte_cryptodev_driver_id_get(
5303 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5304 BLKCIPHER_3DES_CHAIN_TYPE);
5306 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5308 return TEST_SUCCESS;
5312 test_3DES_cipheronly_caam_jr_all(void)
5314 struct crypto_testsuite_params *ts_params = &testsuite_params;
5317 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5318 ts_params->op_mpool,
5319 ts_params->session_mpool, ts_params->session_priv_mpool,
5320 ts_params->valid_devs[0],
5321 rte_cryptodev_driver_id_get(
5322 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5323 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5325 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5327 return TEST_SUCCESS;
5331 test_3DES_chain_dpaa_sec_all(void)
5333 struct crypto_testsuite_params *ts_params = &testsuite_params;
5336 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5337 ts_params->op_mpool,
5338 ts_params->session_mpool, ts_params->session_priv_mpool,
5339 ts_params->valid_devs[0],
5340 rte_cryptodev_driver_id_get(
5341 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5342 BLKCIPHER_3DES_CHAIN_TYPE);
5344 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5346 return TEST_SUCCESS;
5350 test_3DES_cipheronly_dpaa_sec_all(void)
5352 struct crypto_testsuite_params *ts_params = &testsuite_params;
5355 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5356 ts_params->op_mpool,
5357 ts_params->session_mpool, ts_params->session_priv_mpool,
5358 ts_params->valid_devs[0],
5359 rte_cryptodev_driver_id_get(
5360 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5361 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5363 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5365 return TEST_SUCCESS;
5369 test_3DES_chain_dpaa2_sec_all(void)
5371 struct crypto_testsuite_params *ts_params = &testsuite_params;
5374 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5375 ts_params->op_mpool,
5376 ts_params->session_mpool, ts_params->session_priv_mpool,
5377 ts_params->valid_devs[0],
5378 rte_cryptodev_driver_id_get(
5379 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5380 BLKCIPHER_3DES_CHAIN_TYPE);
5382 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5384 return TEST_SUCCESS;
5388 test_3DES_cipheronly_dpaa2_sec_all(void)
5390 struct crypto_testsuite_params *ts_params = &testsuite_params;
5393 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5394 ts_params->op_mpool,
5395 ts_params->session_mpool, ts_params->session_priv_mpool,
5396 ts_params->valid_devs[0],
5397 rte_cryptodev_driver_id_get(
5398 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5399 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5401 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5403 return TEST_SUCCESS;
5407 test_3DES_chain_ccp_all(void)
5409 struct crypto_testsuite_params *ts_params = &testsuite_params;
5412 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5413 ts_params->op_mpool,
5414 ts_params->session_mpool, ts_params->session_priv_mpool,
5415 ts_params->valid_devs[0],
5416 rte_cryptodev_driver_id_get(
5417 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5418 BLKCIPHER_3DES_CHAIN_TYPE);
5420 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5422 return TEST_SUCCESS;
5426 test_3DES_cipheronly_ccp_all(void)
5428 struct crypto_testsuite_params *ts_params = &testsuite_params;
5431 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5432 ts_params->op_mpool,
5433 ts_params->session_mpool, ts_params->session_priv_mpool,
5434 ts_params->valid_devs[0],
5435 rte_cryptodev_driver_id_get(
5436 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5437 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5439 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5441 return TEST_SUCCESS;
5445 test_3DES_cipheronly_qat_all(void)
5447 struct crypto_testsuite_params *ts_params = &testsuite_params;
5450 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5451 ts_params->op_mpool,
5452 ts_params->session_mpool, ts_params->session_priv_mpool,
5453 ts_params->valid_devs[0],
5454 rte_cryptodev_driver_id_get(
5455 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5456 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5458 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5460 return TEST_SUCCESS;
5464 test_3DES_chain_openssl_all(void)
5466 struct crypto_testsuite_params *ts_params = &testsuite_params;
5469 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5470 ts_params->op_mpool,
5471 ts_params->session_mpool, ts_params->session_priv_mpool,
5472 ts_params->valid_devs[0],
5473 rte_cryptodev_driver_id_get(
5474 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5475 BLKCIPHER_3DES_CHAIN_TYPE);
5477 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5479 return TEST_SUCCESS;
5483 test_3DES_cipheronly_openssl_all(void)
5485 struct crypto_testsuite_params *ts_params = &testsuite_params;
5488 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5489 ts_params->op_mpool,
5490 ts_params->session_mpool, ts_params->session_priv_mpool,
5491 ts_params->valid_devs[0],
5492 rte_cryptodev_driver_id_get(
5493 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5494 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5496 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5498 return TEST_SUCCESS;
5501 /* ***** AEAD algorithm Tests ***** */
5504 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5505 enum rte_crypto_aead_operation op,
5506 const uint8_t *key, const uint8_t key_len,
5507 const uint16_t aad_len, const uint8_t auth_len,
5510 uint8_t aead_key[key_len];
5512 struct crypto_testsuite_params *ts_params = &testsuite_params;
5513 struct crypto_unittest_params *ut_params = &unittest_params;
5515 memcpy(aead_key, key, key_len);
5517 /* Setup AEAD Parameters */
5518 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5519 ut_params->aead_xform.next = NULL;
5520 ut_params->aead_xform.aead.algo = algo;
5521 ut_params->aead_xform.aead.op = op;
5522 ut_params->aead_xform.aead.key.data = aead_key;
5523 ut_params->aead_xform.aead.key.length = key_len;
5524 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5525 ut_params->aead_xform.aead.iv.length = iv_len;
5526 ut_params->aead_xform.aead.digest_length = auth_len;
5527 ut_params->aead_xform.aead.aad_length = aad_len;
5529 debug_hexdump(stdout, "key:", key, key_len);
5531 /* Create Crypto session*/
5532 ut_params->sess = rte_cryptodev_sym_session_create(
5533 ts_params->session_mpool);
5535 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5536 &ut_params->aead_xform,
5537 ts_params->session_priv_mpool);
5539 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5545 create_aead_xform(struct rte_crypto_op *op,
5546 enum rte_crypto_aead_algorithm algo,
5547 enum rte_crypto_aead_operation aead_op,
5548 uint8_t *key, const uint8_t key_len,
5549 const uint8_t aad_len, const uint8_t auth_len,
5552 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5553 "failed to allocate space for crypto transform");
5555 struct rte_crypto_sym_op *sym_op = op->sym;
5557 /* Setup AEAD Parameters */
5558 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5559 sym_op->xform->next = NULL;
5560 sym_op->xform->aead.algo = algo;
5561 sym_op->xform->aead.op = aead_op;
5562 sym_op->xform->aead.key.data = key;
5563 sym_op->xform->aead.key.length = key_len;
5564 sym_op->xform->aead.iv.offset = IV_OFFSET;
5565 sym_op->xform->aead.iv.length = iv_len;
5566 sym_op->xform->aead.digest_length = auth_len;
5567 sym_op->xform->aead.aad_length = aad_len;
5569 debug_hexdump(stdout, "key:", key, key_len);
5575 create_aead_operation(enum rte_crypto_aead_operation op,
5576 const struct aead_test_data *tdata)
5578 struct crypto_testsuite_params *ts_params = &testsuite_params;
5579 struct crypto_unittest_params *ut_params = &unittest_params;
5581 uint8_t *plaintext, *ciphertext;
5582 unsigned int aad_pad_len, plaintext_pad_len;
5584 /* Generate Crypto op data structure */
5585 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5586 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5587 TEST_ASSERT_NOT_NULL(ut_params->op,
5588 "Failed to allocate symmetric crypto operation struct");
5590 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5592 /* Append aad data */
5593 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5594 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5595 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5597 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5598 "no room to append aad");
5600 sym_op->aead.aad.phys_addr =
5601 rte_pktmbuf_iova(ut_params->ibuf);
5602 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5603 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5604 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5607 /* Append IV at the end of the crypto operation*/
5608 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5609 uint8_t *, IV_OFFSET);
5611 /* Copy IV 1 byte after the IV pointer, according to the API */
5612 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5613 debug_hexdump(stdout, "iv:", iv_ptr,
5616 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5617 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5619 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5620 "no room to append aad");
5622 sym_op->aead.aad.phys_addr =
5623 rte_pktmbuf_iova(ut_params->ibuf);
5624 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5625 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5628 /* Append IV at the end of the crypto operation*/
5629 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5630 uint8_t *, IV_OFFSET);
5632 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5633 debug_hexdump(stdout, "iv:", iv_ptr,
5637 /* Append plaintext/ciphertext */
5638 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5639 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5640 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5642 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5644 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5645 debug_hexdump(stdout, "plaintext:", plaintext,
5646 tdata->plaintext.len);
5648 if (ut_params->obuf) {
5649 ciphertext = (uint8_t *)rte_pktmbuf_append(
5651 plaintext_pad_len + aad_pad_len);
5652 TEST_ASSERT_NOT_NULL(ciphertext,
5653 "no room to append ciphertext");
5655 memset(ciphertext + aad_pad_len, 0,
5656 tdata->ciphertext.len);
5659 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5660 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5662 TEST_ASSERT_NOT_NULL(ciphertext,
5663 "no room to append ciphertext");
5665 memcpy(ciphertext, tdata->ciphertext.data,
5666 tdata->ciphertext.len);
5667 debug_hexdump(stdout, "ciphertext:", ciphertext,
5668 tdata->ciphertext.len);
5670 if (ut_params->obuf) {
5671 plaintext = (uint8_t *)rte_pktmbuf_append(
5673 plaintext_pad_len + aad_pad_len);
5674 TEST_ASSERT_NOT_NULL(plaintext,
5675 "no room to append plaintext");
5677 memset(plaintext + aad_pad_len, 0,
5678 tdata->plaintext.len);
5682 /* Append digest data */
5683 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5684 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5685 ut_params->obuf ? ut_params->obuf :
5687 tdata->auth_tag.len);
5688 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5689 "no room to append digest");
5690 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5691 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5692 ut_params->obuf ? ut_params->obuf :
5697 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5698 ut_params->ibuf, tdata->auth_tag.len);
5699 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5700 "no room to append digest");
5701 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5703 plaintext_pad_len + aad_pad_len);
5705 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5706 tdata->auth_tag.len);
5707 debug_hexdump(stdout, "digest:",
5708 sym_op->aead.digest.data,
5709 tdata->auth_tag.len);
5712 sym_op->aead.data.length = tdata->plaintext.len;
5713 sym_op->aead.data.offset = aad_pad_len;
5719 test_authenticated_encryption(const struct aead_test_data *tdata)
5721 struct crypto_testsuite_params *ts_params = &testsuite_params;
5722 struct crypto_unittest_params *ut_params = &unittest_params;
5725 uint8_t *ciphertext, *auth_tag;
5726 uint16_t plaintext_pad_len;
5729 /* Create AEAD session */
5730 retval = create_aead_session(ts_params->valid_devs[0],
5732 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5733 tdata->key.data, tdata->key.len,
5734 tdata->aad.len, tdata->auth_tag.len,
5739 if (tdata->aad.len > MBUF_SIZE) {
5740 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5741 /* Populate full size of add data */
5742 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5743 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5745 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5747 /* clear mbuf payload */
5748 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5749 rte_pktmbuf_tailroom(ut_params->ibuf));
5751 /* Create AEAD operation */
5752 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5756 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5758 ut_params->op->sym->m_src = ut_params->ibuf;
5760 /* Process crypto operation */
5761 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5762 ut_params->op), "failed to process sym crypto op");
5764 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5765 "crypto op processing failed");
5767 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5769 if (ut_params->op->sym->m_dst) {
5770 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5772 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5773 uint8_t *, plaintext_pad_len);
5775 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5777 ut_params->op->sym->cipher.data.offset);
5778 auth_tag = ciphertext + plaintext_pad_len;
5781 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5782 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5785 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5787 tdata->ciphertext.data,
5788 tdata->ciphertext.len,
5789 "Ciphertext data not as expected");
5791 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5793 tdata->auth_tag.data,
5794 tdata->auth_tag.len,
5795 "Generated auth tag not as expected");
5802 test_AES_GCM_authenticated_encryption_test_case_1(void)
5804 return test_authenticated_encryption(&gcm_test_case_1);
5808 test_AES_GCM_authenticated_encryption_test_case_2(void)
5810 return test_authenticated_encryption(&gcm_test_case_2);
5814 test_AES_GCM_authenticated_encryption_test_case_3(void)
5816 return test_authenticated_encryption(&gcm_test_case_3);
5820 test_AES_GCM_authenticated_encryption_test_case_4(void)
5822 return test_authenticated_encryption(&gcm_test_case_4);
5826 test_AES_GCM_authenticated_encryption_test_case_5(void)
5828 return test_authenticated_encryption(&gcm_test_case_5);
5832 test_AES_GCM_authenticated_encryption_test_case_6(void)
5834 return test_authenticated_encryption(&gcm_test_case_6);
5838 test_AES_GCM_authenticated_encryption_test_case_7(void)
5840 return test_authenticated_encryption(&gcm_test_case_7);
5844 test_AES_GCM_auth_encryption_test_case_192_1(void)
5846 return test_authenticated_encryption(&gcm_test_case_192_1);
5850 test_AES_GCM_auth_encryption_test_case_192_2(void)
5852 return test_authenticated_encryption(&gcm_test_case_192_2);
5856 test_AES_GCM_auth_encryption_test_case_192_3(void)
5858 return test_authenticated_encryption(&gcm_test_case_192_3);
5862 test_AES_GCM_auth_encryption_test_case_192_4(void)
5864 return test_authenticated_encryption(&gcm_test_case_192_4);
5868 test_AES_GCM_auth_encryption_test_case_192_5(void)
5870 return test_authenticated_encryption(&gcm_test_case_192_5);
5874 test_AES_GCM_auth_encryption_test_case_192_6(void)
5876 return test_authenticated_encryption(&gcm_test_case_192_6);
5880 test_AES_GCM_auth_encryption_test_case_192_7(void)
5882 return test_authenticated_encryption(&gcm_test_case_192_7);
5886 test_AES_GCM_auth_encryption_test_case_256_1(void)
5888 return test_authenticated_encryption(&gcm_test_case_256_1);
5892 test_AES_GCM_auth_encryption_test_case_256_2(void)
5894 return test_authenticated_encryption(&gcm_test_case_256_2);
5898 test_AES_GCM_auth_encryption_test_case_256_3(void)
5900 return test_authenticated_encryption(&gcm_test_case_256_3);
5904 test_AES_GCM_auth_encryption_test_case_256_4(void)
5906 return test_authenticated_encryption(&gcm_test_case_256_4);
5910 test_AES_GCM_auth_encryption_test_case_256_5(void)
5912 return test_authenticated_encryption(&gcm_test_case_256_5);
5916 test_AES_GCM_auth_encryption_test_case_256_6(void)
5918 return test_authenticated_encryption(&gcm_test_case_256_6);
5922 test_AES_GCM_auth_encryption_test_case_256_7(void)
5924 return test_authenticated_encryption(&gcm_test_case_256_7);
5928 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5930 return test_authenticated_encryption(&gcm_test_case_aad_1);
5934 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5936 return test_authenticated_encryption(&gcm_test_case_aad_2);
5940 test_authenticated_decryption(const struct aead_test_data *tdata)
5942 struct crypto_testsuite_params *ts_params = &testsuite_params;
5943 struct crypto_unittest_params *ut_params = &unittest_params;
5949 /* Create AEAD session */
5950 retval = create_aead_session(ts_params->valid_devs[0],
5952 RTE_CRYPTO_AEAD_OP_DECRYPT,
5953 tdata->key.data, tdata->key.len,
5954 tdata->aad.len, tdata->auth_tag.len,
5959 /* alloc mbuf and set payload */
5960 if (tdata->aad.len > MBUF_SIZE) {
5961 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5962 /* Populate full size of add data */
5963 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5964 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5966 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5968 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5969 rte_pktmbuf_tailroom(ut_params->ibuf));
5971 /* Create AEAD operation */
5972 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5976 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5978 ut_params->op->sym->m_src = ut_params->ibuf;
5980 /* Process crypto operation */
5981 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5982 ut_params->op), "failed to process sym crypto op");
5984 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5985 "crypto op processing failed");
5987 if (ut_params->op->sym->m_dst)
5988 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5991 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5993 ut_params->op->sym->cipher.data.offset);
5995 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5998 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6000 tdata->plaintext.data,
6001 tdata->plaintext.len,
6002 "Plaintext data not as expected");
6004 TEST_ASSERT_EQUAL(ut_params->op->status,
6005 RTE_CRYPTO_OP_STATUS_SUCCESS,
6006 "Authentication failed");
6011 test_AES_GCM_authenticated_decryption_test_case_1(void)
6013 return test_authenticated_decryption(&gcm_test_case_1);
6017 test_AES_GCM_authenticated_decryption_test_case_2(void)
6019 return test_authenticated_decryption(&gcm_test_case_2);
6023 test_AES_GCM_authenticated_decryption_test_case_3(void)
6025 return test_authenticated_decryption(&gcm_test_case_3);
6029 test_AES_GCM_authenticated_decryption_test_case_4(void)
6031 return test_authenticated_decryption(&gcm_test_case_4);
6035 test_AES_GCM_authenticated_decryption_test_case_5(void)
6037 return test_authenticated_decryption(&gcm_test_case_5);
6041 test_AES_GCM_authenticated_decryption_test_case_6(void)
6043 return test_authenticated_decryption(&gcm_test_case_6);
6047 test_AES_GCM_authenticated_decryption_test_case_7(void)
6049 return test_authenticated_decryption(&gcm_test_case_7);
6053 test_AES_GCM_auth_decryption_test_case_192_1(void)
6055 return test_authenticated_decryption(&gcm_test_case_192_1);
6059 test_AES_GCM_auth_decryption_test_case_192_2(void)
6061 return test_authenticated_decryption(&gcm_test_case_192_2);
6065 test_AES_GCM_auth_decryption_test_case_192_3(void)
6067 return test_authenticated_decryption(&gcm_test_case_192_3);
6071 test_AES_GCM_auth_decryption_test_case_192_4(void)
6073 return test_authenticated_decryption(&gcm_test_case_192_4);
6077 test_AES_GCM_auth_decryption_test_case_192_5(void)
6079 return test_authenticated_decryption(&gcm_test_case_192_5);
6083 test_AES_GCM_auth_decryption_test_case_192_6(void)
6085 return test_authenticated_decryption(&gcm_test_case_192_6);
6089 test_AES_GCM_auth_decryption_test_case_192_7(void)
6091 return test_authenticated_decryption(&gcm_test_case_192_7);
6095 test_AES_GCM_auth_decryption_test_case_256_1(void)
6097 return test_authenticated_decryption(&gcm_test_case_256_1);
6101 test_AES_GCM_auth_decryption_test_case_256_2(void)
6103 return test_authenticated_decryption(&gcm_test_case_256_2);
6107 test_AES_GCM_auth_decryption_test_case_256_3(void)
6109 return test_authenticated_decryption(&gcm_test_case_256_3);
6113 test_AES_GCM_auth_decryption_test_case_256_4(void)
6115 return test_authenticated_decryption(&gcm_test_case_256_4);
6119 test_AES_GCM_auth_decryption_test_case_256_5(void)
6121 return test_authenticated_decryption(&gcm_test_case_256_5);
6125 test_AES_GCM_auth_decryption_test_case_256_6(void)
6127 return test_authenticated_decryption(&gcm_test_case_256_6);
6131 test_AES_GCM_auth_decryption_test_case_256_7(void)
6133 return test_authenticated_decryption(&gcm_test_case_256_7);
6137 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6139 return test_authenticated_decryption(&gcm_test_case_aad_1);
6143 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6145 return test_authenticated_decryption(&gcm_test_case_aad_2);
6149 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6151 struct crypto_testsuite_params *ts_params = &testsuite_params;
6152 struct crypto_unittest_params *ut_params = &unittest_params;
6155 uint8_t *ciphertext, *auth_tag;
6156 uint16_t plaintext_pad_len;
6158 /* Create AEAD session */
6159 retval = create_aead_session(ts_params->valid_devs[0],
6161 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6162 tdata->key.data, tdata->key.len,
6163 tdata->aad.len, tdata->auth_tag.len,
6168 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6169 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6171 /* clear mbuf payload */
6172 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6173 rte_pktmbuf_tailroom(ut_params->ibuf));
6174 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6175 rte_pktmbuf_tailroom(ut_params->obuf));
6177 /* Create AEAD operation */
6178 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6182 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6184 ut_params->op->sym->m_src = ut_params->ibuf;
6185 ut_params->op->sym->m_dst = ut_params->obuf;
6187 /* Process crypto operation */
6188 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6189 ut_params->op), "failed to process sym crypto op");
6191 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6192 "crypto op processing failed");
6194 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6196 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6197 ut_params->op->sym->cipher.data.offset);
6198 auth_tag = ciphertext + plaintext_pad_len;
6200 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6201 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6204 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6206 tdata->ciphertext.data,
6207 tdata->ciphertext.len,
6208 "Ciphertext data not as expected");
6210 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6212 tdata->auth_tag.data,
6213 tdata->auth_tag.len,
6214 "Generated auth tag not as expected");
6221 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6223 return test_authenticated_encryption_oop(&gcm_test_case_5);
6227 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6229 struct crypto_testsuite_params *ts_params = &testsuite_params;
6230 struct crypto_unittest_params *ut_params = &unittest_params;
6235 /* Create AEAD session */
6236 retval = create_aead_session(ts_params->valid_devs[0],
6238 RTE_CRYPTO_AEAD_OP_DECRYPT,
6239 tdata->key.data, tdata->key.len,
6240 tdata->aad.len, tdata->auth_tag.len,
6245 /* alloc mbuf and set payload */
6246 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6247 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6249 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6250 rte_pktmbuf_tailroom(ut_params->ibuf));
6251 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6252 rte_pktmbuf_tailroom(ut_params->obuf));
6254 /* Create AEAD operation */
6255 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6259 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6261 ut_params->op->sym->m_src = ut_params->ibuf;
6262 ut_params->op->sym->m_dst = ut_params->obuf;
6264 /* Process crypto operation */
6265 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6266 ut_params->op), "failed to process sym crypto op");
6268 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6269 "crypto op processing failed");
6271 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6272 ut_params->op->sym->cipher.data.offset);
6274 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6277 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6279 tdata->plaintext.data,
6280 tdata->plaintext.len,
6281 "Plaintext data not as expected");
6283 TEST_ASSERT_EQUAL(ut_params->op->status,
6284 RTE_CRYPTO_OP_STATUS_SUCCESS,
6285 "Authentication failed");
6290 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6292 return test_authenticated_decryption_oop(&gcm_test_case_5);
6296 test_authenticated_encryption_sessionless(
6297 const struct aead_test_data *tdata)
6299 struct crypto_testsuite_params *ts_params = &testsuite_params;
6300 struct crypto_unittest_params *ut_params = &unittest_params;
6303 uint8_t *ciphertext, *auth_tag;
6304 uint16_t plaintext_pad_len;
6305 uint8_t key[tdata->key.len + 1];
6307 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6309 /* clear mbuf payload */
6310 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6311 rte_pktmbuf_tailroom(ut_params->ibuf));
6313 /* Create AEAD operation */
6314 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6318 /* Create GCM xform */
6319 memcpy(key, tdata->key.data, tdata->key.len);
6320 retval = create_aead_xform(ut_params->op,
6322 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6323 key, tdata->key.len,
6324 tdata->aad.len, tdata->auth_tag.len,
6329 ut_params->op->sym->m_src = ut_params->ibuf;
6331 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6332 RTE_CRYPTO_OP_SESSIONLESS,
6333 "crypto op session type not sessionless");
6335 /* Process crypto operation */
6336 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6337 ut_params->op), "failed to process sym crypto op");
6339 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6341 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6342 "crypto op status not success");
6344 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6346 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6347 ut_params->op->sym->cipher.data.offset);
6348 auth_tag = ciphertext + plaintext_pad_len;
6350 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6351 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6354 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6356 tdata->ciphertext.data,
6357 tdata->ciphertext.len,
6358 "Ciphertext data not as expected");
6360 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6362 tdata->auth_tag.data,
6363 tdata->auth_tag.len,
6364 "Generated auth tag not as expected");
6371 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6373 return test_authenticated_encryption_sessionless(
6378 test_authenticated_decryption_sessionless(
6379 const struct aead_test_data *tdata)
6381 struct crypto_testsuite_params *ts_params = &testsuite_params;
6382 struct crypto_unittest_params *ut_params = &unittest_params;
6386 uint8_t key[tdata->key.len + 1];
6388 /* alloc mbuf and set payload */
6389 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6391 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6392 rte_pktmbuf_tailroom(ut_params->ibuf));
6394 /* Create AEAD operation */
6395 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6399 /* Create AEAD xform */
6400 memcpy(key, tdata->key.data, tdata->key.len);
6401 retval = create_aead_xform(ut_params->op,
6403 RTE_CRYPTO_AEAD_OP_DECRYPT,
6404 key, tdata->key.len,
6405 tdata->aad.len, tdata->auth_tag.len,
6410 ut_params->op->sym->m_src = ut_params->ibuf;
6412 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6413 RTE_CRYPTO_OP_SESSIONLESS,
6414 "crypto op session type not sessionless");
6416 /* Process crypto operation */
6417 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6418 ut_params->op), "failed to process sym crypto op");
6420 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6422 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6423 "crypto op status not success");
6425 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6426 ut_params->op->sym->cipher.data.offset);
6428 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6431 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6433 tdata->plaintext.data,
6434 tdata->plaintext.len,
6435 "Plaintext data not as expected");
6437 TEST_ASSERT_EQUAL(ut_params->op->status,
6438 RTE_CRYPTO_OP_STATUS_SUCCESS,
6439 "Authentication failed");
6444 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6446 return test_authenticated_decryption_sessionless(
6451 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6453 return test_authenticated_encryption(&ccm_test_case_128_1);
6457 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6459 return test_authenticated_encryption(&ccm_test_case_128_2);
6463 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6465 return test_authenticated_encryption(&ccm_test_case_128_3);
6469 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6471 return test_authenticated_decryption(&ccm_test_case_128_1);
6475 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6477 return test_authenticated_decryption(&ccm_test_case_128_2);
6481 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6483 return test_authenticated_decryption(&ccm_test_case_128_3);
6487 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6489 return test_authenticated_encryption(&ccm_test_case_192_1);
6493 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6495 return test_authenticated_encryption(&ccm_test_case_192_2);
6499 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6501 return test_authenticated_encryption(&ccm_test_case_192_3);
6505 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6507 return test_authenticated_decryption(&ccm_test_case_192_1);
6511 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6513 return test_authenticated_decryption(&ccm_test_case_192_2);
6517 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6519 return test_authenticated_decryption(&ccm_test_case_192_3);
6523 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6525 return test_authenticated_encryption(&ccm_test_case_256_1);
6529 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6531 return test_authenticated_encryption(&ccm_test_case_256_2);
6535 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6537 return test_authenticated_encryption(&ccm_test_case_256_3);
6541 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6543 return test_authenticated_decryption(&ccm_test_case_256_1);
6547 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6549 return test_authenticated_decryption(&ccm_test_case_256_2);
6553 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6555 return test_authenticated_decryption(&ccm_test_case_256_3);
6561 struct crypto_testsuite_params *ts_params = &testsuite_params;
6562 struct rte_cryptodev_stats stats;
6563 struct rte_cryptodev *dev;
6564 cryptodev_stats_get_t temp_pfn;
6566 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6567 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6568 &stats) == -ENODEV),
6569 "rte_cryptodev_stats_get invalid dev failed");
6570 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6571 "rte_cryptodev_stats_get invalid Param failed");
6572 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6573 temp_pfn = dev->dev_ops->stats_get;
6574 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6575 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6577 "rte_cryptodev_stats_get invalid Param failed");
6578 dev->dev_ops->stats_get = temp_pfn;
6580 /* Test expected values */
6582 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6584 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6586 "rte_cryptodev_stats_get failed");
6587 TEST_ASSERT((stats.enqueued_count == 1),
6588 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6589 TEST_ASSERT((stats.dequeued_count == 1),
6590 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6591 TEST_ASSERT((stats.enqueue_err_count == 0),
6592 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6593 TEST_ASSERT((stats.dequeue_err_count == 0),
6594 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6596 /* invalid device but should ignore and not reset device stats*/
6597 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6598 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6600 "rte_cryptodev_stats_get failed");
6601 TEST_ASSERT((stats.enqueued_count == 1),
6602 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6604 /* check that a valid reset clears stats */
6605 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6606 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6608 "rte_cryptodev_stats_get failed");
6609 TEST_ASSERT((stats.enqueued_count == 0),
6610 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6611 TEST_ASSERT((stats.dequeued_count == 0),
6612 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6614 return TEST_SUCCESS;
6617 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6618 struct crypto_unittest_params *ut_params,
6619 enum rte_crypto_auth_operation op,
6620 const struct HMAC_MD5_vector *test_case)
6624 memcpy(key, test_case->key.data, test_case->key.len);
6626 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6627 ut_params->auth_xform.next = NULL;
6628 ut_params->auth_xform.auth.op = op;
6630 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6632 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6633 ut_params->auth_xform.auth.key.length = test_case->key.len;
6634 ut_params->auth_xform.auth.key.data = key;
6636 ut_params->sess = rte_cryptodev_sym_session_create(
6637 ts_params->session_mpool);
6639 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6640 ut_params->sess, &ut_params->auth_xform,
6641 ts_params->session_priv_mpool);
6643 if (ut_params->sess == NULL)
6646 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6648 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6649 rte_pktmbuf_tailroom(ut_params->ibuf));
6654 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6655 const struct HMAC_MD5_vector *test_case,
6656 uint8_t **plaintext)
6658 uint16_t plaintext_pad_len;
6660 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6662 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6665 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6667 memcpy(*plaintext, test_case->plaintext.data,
6668 test_case->plaintext.len);
6670 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6671 ut_params->ibuf, MD5_DIGEST_LEN);
6672 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6673 "no room to append digest");
6674 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6675 ut_params->ibuf, plaintext_pad_len);
6677 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6678 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6679 test_case->auth_tag.len);
6682 sym_op->auth.data.offset = 0;
6683 sym_op->auth.data.length = test_case->plaintext.len;
6685 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6686 ut_params->op->sym->m_src = ut_params->ibuf;
6692 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6694 uint16_t plaintext_pad_len;
6695 uint8_t *plaintext, *auth_tag;
6697 struct crypto_testsuite_params *ts_params = &testsuite_params;
6698 struct crypto_unittest_params *ut_params = &unittest_params;
6700 if (MD5_HMAC_create_session(ts_params, ut_params,
6701 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6704 /* Generate Crypto op data structure */
6705 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6706 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6707 TEST_ASSERT_NOT_NULL(ut_params->op,
6708 "Failed to allocate symmetric crypto operation struct");
6710 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6713 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6716 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6717 ut_params->op), "failed to process sym crypto op");
6719 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6720 "crypto op processing failed");
6722 if (ut_params->op->sym->m_dst) {
6723 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6724 uint8_t *, plaintext_pad_len);
6726 auth_tag = plaintext + plaintext_pad_len;
6729 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6731 test_case->auth_tag.data,
6732 test_case->auth_tag.len,
6733 "HMAC_MD5 generated tag not as expected");
6735 return TEST_SUCCESS;
6739 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6743 struct crypto_testsuite_params *ts_params = &testsuite_params;
6744 struct crypto_unittest_params *ut_params = &unittest_params;
6746 if (MD5_HMAC_create_session(ts_params, ut_params,
6747 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6751 /* Generate Crypto op data structure */
6752 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6753 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6754 TEST_ASSERT_NOT_NULL(ut_params->op,
6755 "Failed to allocate symmetric crypto operation struct");
6757 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6760 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6761 ut_params->op), "failed to process sym crypto op");
6763 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6764 "HMAC_MD5 crypto op processing failed");
6766 return TEST_SUCCESS;
6770 test_MD5_HMAC_generate_case_1(void)
6772 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6776 test_MD5_HMAC_verify_case_1(void)
6778 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6782 test_MD5_HMAC_generate_case_2(void)
6784 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6788 test_MD5_HMAC_verify_case_2(void)
6790 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6794 test_multi_session(void)
6796 struct crypto_testsuite_params *ts_params = &testsuite_params;
6797 struct crypto_unittest_params *ut_params = &unittest_params;
6799 struct rte_cryptodev_info dev_info;
6800 struct rte_cryptodev_sym_session **sessions;
6804 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6805 aes_cbc_key, hmac_sha512_key);
6808 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6810 sessions = rte_malloc(NULL,
6811 (sizeof(struct rte_cryptodev_sym_session *) *
6812 MAX_NB_SESSIONS) + 1, 0);
6814 /* Create multiple crypto sessions*/
6815 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6817 sessions[i] = rte_cryptodev_sym_session_create(
6818 ts_params->session_mpool);
6820 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6821 sessions[i], &ut_params->auth_xform,
6822 ts_params->session_priv_mpool);
6823 TEST_ASSERT_NOT_NULL(sessions[i],
6824 "Session creation failed at session number %u",
6827 /* Attempt to send a request on each session */
6828 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6832 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6833 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6835 "Failed to perform decrypt on request number %u.", i);
6836 /* free crypto operation structure */
6838 rte_crypto_op_free(ut_params->op);
6841 * free mbuf - both obuf and ibuf are usually the same,
6842 * so check if they point at the same address is necessary,
6843 * to avoid freeing the mbuf twice.
6845 if (ut_params->obuf) {
6846 rte_pktmbuf_free(ut_params->obuf);
6847 if (ut_params->ibuf == ut_params->obuf)
6848 ut_params->ibuf = 0;
6849 ut_params->obuf = 0;
6851 if (ut_params->ibuf) {
6852 rte_pktmbuf_free(ut_params->ibuf);
6853 ut_params->ibuf = 0;
6857 /* Next session create should fail */
6858 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6859 sessions[i], &ut_params->auth_xform,
6860 ts_params->session_priv_mpool);
6861 TEST_ASSERT_NULL(sessions[i],
6862 "Session creation succeeded unexpectedly!");
6864 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6865 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6867 rte_cryptodev_sym_session_free(sessions[i]);
6872 return TEST_SUCCESS;
6875 struct multi_session_params {
6876 struct crypto_unittest_params ut_params;
6877 uint8_t *cipher_key;
6879 const uint8_t *cipher;
6880 const uint8_t *digest;
6884 #define MB_SESSION_NUMBER 3
6887 test_multi_session_random_usage(void)
6889 struct crypto_testsuite_params *ts_params = &testsuite_params;
6890 struct rte_cryptodev_info dev_info;
6891 struct rte_cryptodev_sym_session **sessions;
6893 struct multi_session_params ut_paramz[] = {
6896 .cipher_key = ms_aes_cbc_key0,
6897 .hmac_key = ms_hmac_key0,
6898 .cipher = ms_aes_cbc_cipher0,
6899 .digest = ms_hmac_digest0,
6900 .iv = ms_aes_cbc_iv0
6903 .cipher_key = ms_aes_cbc_key1,
6904 .hmac_key = ms_hmac_key1,
6905 .cipher = ms_aes_cbc_cipher1,
6906 .digest = ms_hmac_digest1,
6907 .iv = ms_aes_cbc_iv1
6910 .cipher_key = ms_aes_cbc_key2,
6911 .hmac_key = ms_hmac_key2,
6912 .cipher = ms_aes_cbc_cipher2,
6913 .digest = ms_hmac_digest2,
6914 .iv = ms_aes_cbc_iv2
6919 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6921 sessions = rte_malloc(NULL,
6922 (sizeof(struct rte_cryptodev_sym_session *)
6923 * MAX_NB_SESSIONS) + 1, 0);
6925 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6926 sessions[i] = rte_cryptodev_sym_session_create(
6927 ts_params->session_mpool);
6929 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6930 sizeof(struct crypto_unittest_params));
6932 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6933 &ut_paramz[i].ut_params,
6934 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6936 /* Create multiple crypto sessions*/
6937 rte_cryptodev_sym_session_init(
6938 ts_params->valid_devs[0],
6940 &ut_paramz[i].ut_params.auth_xform,
6941 ts_params->session_priv_mpool);
6943 TEST_ASSERT_NOT_NULL(sessions[i],
6944 "Session creation failed at session number %u",
6950 for (i = 0; i < 40000; i++) {
6952 j = rand() % MB_SESSION_NUMBER;
6954 TEST_ASSERT_SUCCESS(
6955 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6957 &ut_paramz[j].ut_params,
6958 ts_params, ut_paramz[j].cipher,
6959 ut_paramz[j].digest,
6961 "Failed to perform decrypt on request number %u.", i);
6963 if (ut_paramz[j].ut_params.op)
6964 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6967 * free mbuf - both obuf and ibuf are usually the same,
6968 * so check if they point at the same address is necessary,
6969 * to avoid freeing the mbuf twice.
6971 if (ut_paramz[j].ut_params.obuf) {
6972 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6973 if (ut_paramz[j].ut_params.ibuf
6974 == ut_paramz[j].ut_params.obuf)
6975 ut_paramz[j].ut_params.ibuf = 0;
6976 ut_paramz[j].ut_params.obuf = 0;
6978 if (ut_paramz[j].ut_params.ibuf) {
6979 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6980 ut_paramz[j].ut_params.ibuf = 0;
6984 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6985 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6987 rte_cryptodev_sym_session_free(sessions[i]);
6992 return TEST_SUCCESS;
6996 test_null_cipher_only_operation(void)
6998 struct crypto_testsuite_params *ts_params = &testsuite_params;
6999 struct crypto_unittest_params *ut_params = &unittest_params;
7001 /* Generate test mbuf data and space for digest */
7002 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7003 catch_22_quote, QUOTE_512_BYTES, 0);
7005 /* Setup Cipher Parameters */
7006 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7007 ut_params->cipher_xform.next = NULL;
7009 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7010 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7012 ut_params->sess = rte_cryptodev_sym_session_create(
7013 ts_params->session_mpool);
7015 /* Create Crypto session*/
7016 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7018 &ut_params->cipher_xform,
7019 ts_params->session_priv_mpool);
7020 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7022 /* Generate Crypto op data structure */
7023 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7024 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7025 TEST_ASSERT_NOT_NULL(ut_params->op,
7026 "Failed to allocate symmetric crypto operation struct");
7028 /* Set crypto operation data parameters */
7029 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7031 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7033 /* set crypto operation source mbuf */
7034 sym_op->m_src = ut_params->ibuf;
7036 sym_op->cipher.data.offset = 0;
7037 sym_op->cipher.data.length = QUOTE_512_BYTES;
7039 /* Process crypto operation */
7040 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7042 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7044 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7045 "crypto operation processing failed");
7048 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7049 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7052 "Ciphertext data not as expected");
7054 return TEST_SUCCESS;
7056 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
7057 0xab, 0xab, 0xab, 0xab,
7058 0xab, 0xab, 0xab, 0xab,
7059 0xab, 0xab, 0xab, 0xab};
7061 test_null_auth_only_operation(void)
7063 struct crypto_testsuite_params *ts_params = &testsuite_params;
7064 struct crypto_unittest_params *ut_params = &unittest_params;
7067 /* Generate test mbuf data and space for digest */
7068 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7069 catch_22_quote, QUOTE_512_BYTES, 0);
7071 /* create a pointer for digest, but don't expect anything to be written
7072 * here in a NULL auth algo so no mbuf append done.
7074 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7076 /* prefill the memory pointed to by digest */
7077 memcpy(digest, orig_data, sizeof(orig_data));
7079 /* Setup HMAC Parameters */
7080 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7081 ut_params->auth_xform.next = NULL;
7083 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7084 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7086 ut_params->sess = rte_cryptodev_sym_session_create(
7087 ts_params->session_mpool);
7089 /* Create Crypto session*/
7090 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7091 ut_params->sess, &ut_params->auth_xform,
7092 ts_params->session_priv_mpool);
7093 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7095 /* Generate Crypto op data structure */
7096 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7097 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7098 TEST_ASSERT_NOT_NULL(ut_params->op,
7099 "Failed to allocate symmetric crypto operation struct");
7101 /* Set crypto operation data parameters */
7102 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7104 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7106 sym_op->m_src = ut_params->ibuf;
7108 sym_op->auth.data.offset = 0;
7109 sym_op->auth.data.length = QUOTE_512_BYTES;
7110 sym_op->auth.digest.data = digest;
7111 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7114 /* Process crypto operation */
7115 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7117 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7119 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7120 "crypto operation processing failed");
7121 /* Make sure memory pointed to by digest hasn't been overwritten */
7122 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7126 "Memory at digest ptr overwritten unexpectedly");
7128 return TEST_SUCCESS;
7133 test_null_cipher_auth_operation(void)
7135 struct crypto_testsuite_params *ts_params = &testsuite_params;
7136 struct crypto_unittest_params *ut_params = &unittest_params;
7139 /* Generate test mbuf data and space for digest */
7140 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7141 catch_22_quote, QUOTE_512_BYTES, 0);
7143 /* create a pointer for digest, but don't expect anything to be written
7144 * here in a NULL auth algo so no mbuf append done.
7146 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7148 /* prefill the memory pointed to by digest */
7149 memcpy(digest, orig_data, sizeof(orig_data));
7151 /* Setup Cipher Parameters */
7152 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7153 ut_params->cipher_xform.next = &ut_params->auth_xform;
7155 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7156 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7158 /* Setup HMAC Parameters */
7159 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7160 ut_params->auth_xform.next = NULL;
7162 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7163 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7165 ut_params->sess = rte_cryptodev_sym_session_create(
7166 ts_params->session_mpool);
7168 /* Create Crypto session*/
7169 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7170 ut_params->sess, &ut_params->cipher_xform,
7171 ts_params->session_priv_mpool);
7172 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7174 /* Generate Crypto op data structure */
7175 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7176 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7177 TEST_ASSERT_NOT_NULL(ut_params->op,
7178 "Failed to allocate symmetric crypto operation struct");
7180 /* Set crypto operation data parameters */
7181 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7183 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7185 sym_op->m_src = ut_params->ibuf;
7187 sym_op->cipher.data.offset = 0;
7188 sym_op->cipher.data.length = QUOTE_512_BYTES;
7190 sym_op->auth.data.offset = 0;
7191 sym_op->auth.data.length = QUOTE_512_BYTES;
7192 sym_op->auth.digest.data = digest;
7193 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7196 /* Process crypto operation */
7197 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7199 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7201 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7202 "crypto operation processing failed");
7205 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7206 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7209 "Ciphertext data not as expected");
7210 /* Make sure memory pointed to by digest hasn't been overwritten */
7211 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7215 "Memory at digest ptr overwritten unexpectedly");
7217 return TEST_SUCCESS;
7221 test_null_auth_cipher_operation(void)
7223 struct crypto_testsuite_params *ts_params = &testsuite_params;
7224 struct crypto_unittest_params *ut_params = &unittest_params;
7227 /* Generate test mbuf data */
7228 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7229 catch_22_quote, QUOTE_512_BYTES, 0);
7231 /* create a pointer for digest, but don't expect anything to be written
7232 * here in a NULL auth algo so no mbuf append done.
7234 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7236 /* prefill the memory pointed to by digest */
7237 memcpy(digest, orig_data, sizeof(orig_data));
7239 /* Setup Cipher Parameters */
7240 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7241 ut_params->cipher_xform.next = NULL;
7243 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7244 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7246 /* Setup HMAC Parameters */
7247 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7248 ut_params->auth_xform.next = &ut_params->cipher_xform;
7250 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7251 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7253 ut_params->sess = rte_cryptodev_sym_session_create(
7254 ts_params->session_mpool);
7256 /* Create Crypto session*/
7257 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7258 ut_params->sess, &ut_params->cipher_xform,
7259 ts_params->session_priv_mpool);
7260 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7262 /* Generate Crypto op data structure */
7263 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7264 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7265 TEST_ASSERT_NOT_NULL(ut_params->op,
7266 "Failed to allocate symmetric crypto operation struct");
7268 /* Set crypto operation data parameters */
7269 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7271 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7273 sym_op->m_src = ut_params->ibuf;
7275 sym_op->cipher.data.offset = 0;
7276 sym_op->cipher.data.length = QUOTE_512_BYTES;
7278 sym_op->auth.data.offset = 0;
7279 sym_op->auth.data.length = QUOTE_512_BYTES;
7280 sym_op->auth.digest.data = digest;
7281 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7284 /* Process crypto operation */
7285 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7287 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7289 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7290 "crypto operation processing failed");
7293 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7294 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7297 "Ciphertext data not as expected");
7298 /* Make sure memory pointed to by digest hasn't been overwritten */
7299 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7303 "Memory at digest ptr overwritten unexpectedly");
7305 return TEST_SUCCESS;
7310 test_null_invalid_operation(void)
7312 struct crypto_testsuite_params *ts_params = &testsuite_params;
7313 struct crypto_unittest_params *ut_params = &unittest_params;
7316 /* Setup Cipher Parameters */
7317 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7318 ut_params->cipher_xform.next = NULL;
7320 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7321 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7323 ut_params->sess = rte_cryptodev_sym_session_create(
7324 ts_params->session_mpool);
7326 /* Create Crypto session*/
7327 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7328 ut_params->sess, &ut_params->cipher_xform,
7329 ts_params->session_priv_mpool);
7330 TEST_ASSERT(ret < 0,
7331 "Session creation succeeded unexpectedly");
7334 /* Setup HMAC Parameters */
7335 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7336 ut_params->auth_xform.next = NULL;
7338 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7339 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7341 ut_params->sess = rte_cryptodev_sym_session_create(
7342 ts_params->session_mpool);
7344 /* Create Crypto session*/
7345 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7346 ut_params->sess, &ut_params->auth_xform,
7347 ts_params->session_priv_mpool);
7348 TEST_ASSERT(ret < 0,
7349 "Session creation succeeded unexpectedly");
7351 return TEST_SUCCESS;
7355 #define NULL_BURST_LENGTH (32)
7358 test_null_burst_operation(void)
7360 struct crypto_testsuite_params *ts_params = &testsuite_params;
7361 struct crypto_unittest_params *ut_params = &unittest_params;
7363 unsigned i, burst_len = NULL_BURST_LENGTH;
7365 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7366 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7368 /* Setup Cipher Parameters */
7369 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7370 ut_params->cipher_xform.next = &ut_params->auth_xform;
7372 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7373 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7375 /* Setup HMAC Parameters */
7376 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7377 ut_params->auth_xform.next = NULL;
7379 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7380 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7382 ut_params->sess = rte_cryptodev_sym_session_create(
7383 ts_params->session_mpool);
7385 /* Create Crypto session*/
7386 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7387 ut_params->sess, &ut_params->cipher_xform,
7388 ts_params->session_priv_mpool);
7389 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7391 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7392 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7393 burst_len, "failed to generate burst of crypto ops");
7395 /* Generate an operation for each mbuf in burst */
7396 for (i = 0; i < burst_len; i++) {
7397 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7399 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7401 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7405 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7407 burst[i]->sym->m_src = m;
7410 /* Process crypto operation */
7411 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7412 0, burst, burst_len),
7414 "Error enqueuing burst");
7416 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7417 0, burst_dequeued, burst_len),
7419 "Error dequeuing burst");
7422 for (i = 0; i < burst_len; i++) {
7424 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7425 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7427 "data not as expected");
7429 rte_pktmbuf_free(burst[i]->sym->m_src);
7430 rte_crypto_op_free(burst[i]);
7433 return TEST_SUCCESS;
7437 generate_gmac_large_plaintext(uint8_t *data)
7441 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7442 memcpy(&data[i], &data[0], 32);
7446 create_gmac_operation(enum rte_crypto_auth_operation op,
7447 const struct gmac_test_data *tdata)
7449 struct crypto_testsuite_params *ts_params = &testsuite_params;
7450 struct crypto_unittest_params *ut_params = &unittest_params;
7451 struct rte_crypto_sym_op *sym_op;
7453 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7455 /* Generate Crypto op data structure */
7456 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7457 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7458 TEST_ASSERT_NOT_NULL(ut_params->op,
7459 "Failed to allocate symmetric crypto operation struct");
7461 sym_op = ut_params->op->sym;
7463 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7464 ut_params->ibuf, tdata->gmac_tag.len);
7465 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7466 "no room to append digest");
7468 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7469 ut_params->ibuf, plaintext_pad_len);
7471 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7472 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7473 tdata->gmac_tag.len);
7474 debug_hexdump(stdout, "digest:",
7475 sym_op->auth.digest.data,
7476 tdata->gmac_tag.len);
7479 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7480 uint8_t *, IV_OFFSET);
7482 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7484 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7486 sym_op->cipher.data.length = 0;
7487 sym_op->cipher.data.offset = 0;
7489 sym_op->auth.data.offset = 0;
7490 sym_op->auth.data.length = tdata->plaintext.len;
7495 static int create_gmac_session(uint8_t dev_id,
7496 const struct gmac_test_data *tdata,
7497 enum rte_crypto_auth_operation auth_op)
7499 uint8_t auth_key[tdata->key.len];
7501 struct crypto_testsuite_params *ts_params = &testsuite_params;
7502 struct crypto_unittest_params *ut_params = &unittest_params;
7504 memcpy(auth_key, tdata->key.data, tdata->key.len);
7506 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7507 ut_params->auth_xform.next = NULL;
7509 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7510 ut_params->auth_xform.auth.op = auth_op;
7511 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7512 ut_params->auth_xform.auth.key.length = tdata->key.len;
7513 ut_params->auth_xform.auth.key.data = auth_key;
7514 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7515 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7518 ut_params->sess = rte_cryptodev_sym_session_create(
7519 ts_params->session_mpool);
7521 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7522 &ut_params->auth_xform,
7523 ts_params->session_priv_mpool);
7525 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7531 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7533 struct crypto_testsuite_params *ts_params = &testsuite_params;
7534 struct crypto_unittest_params *ut_params = &unittest_params;
7538 uint8_t *auth_tag, *plaintext;
7539 uint16_t plaintext_pad_len;
7541 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7542 "No GMAC length in the source data");
7544 retval = create_gmac_session(ts_params->valid_devs[0],
7545 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7550 if (tdata->plaintext.len > MBUF_SIZE)
7551 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7553 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7554 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7555 "Failed to allocate input buffer in mempool");
7557 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7558 rte_pktmbuf_tailroom(ut_params->ibuf));
7560 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7562 * Runtime generate the large plain text instead of use hard code
7563 * plain text vector. It is done to avoid create huge source file
7564 * with the test vector.
7566 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7567 generate_gmac_large_plaintext(tdata->plaintext.data);
7569 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7571 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7573 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7574 debug_hexdump(stdout, "plaintext:", plaintext,
7575 tdata->plaintext.len);
7577 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7583 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7585 ut_params->op->sym->m_src = ut_params->ibuf;
7587 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7588 ut_params->op), "failed to process sym crypto op");
7590 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7591 "crypto op processing failed");
7593 if (ut_params->op->sym->m_dst) {
7594 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7595 uint8_t *, plaintext_pad_len);
7597 auth_tag = plaintext + plaintext_pad_len;
7600 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7602 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7604 tdata->gmac_tag.data,
7605 tdata->gmac_tag.len,
7606 "GMAC Generated auth tag not as expected");
7612 test_AES_GMAC_authentication_test_case_1(void)
7614 return test_AES_GMAC_authentication(&gmac_test_case_1);
7618 test_AES_GMAC_authentication_test_case_2(void)
7620 return test_AES_GMAC_authentication(&gmac_test_case_2);
7624 test_AES_GMAC_authentication_test_case_3(void)
7626 return test_AES_GMAC_authentication(&gmac_test_case_3);
7630 test_AES_GMAC_authentication_test_case_4(void)
7632 return test_AES_GMAC_authentication(&gmac_test_case_4);
7636 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7638 struct crypto_testsuite_params *ts_params = &testsuite_params;
7639 struct crypto_unittest_params *ut_params = &unittest_params;
7641 uint32_t plaintext_pad_len;
7644 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7645 "No GMAC length in the source data");
7647 retval = create_gmac_session(ts_params->valid_devs[0],
7648 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7653 if (tdata->plaintext.len > MBUF_SIZE)
7654 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7656 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7657 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7658 "Failed to allocate input buffer in mempool");
7660 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7661 rte_pktmbuf_tailroom(ut_params->ibuf));
7663 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7666 * Runtime generate the large plain text instead of use hard code
7667 * plain text vector. It is done to avoid create huge source file
7668 * with the test vector.
7670 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7671 generate_gmac_large_plaintext(tdata->plaintext.data);
7673 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7675 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7677 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7678 debug_hexdump(stdout, "plaintext:", plaintext,
7679 tdata->plaintext.len);
7681 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7687 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7689 ut_params->op->sym->m_src = ut_params->ibuf;
7691 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7692 ut_params->op), "failed to process sym crypto op");
7694 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7695 "crypto op processing failed");
7702 test_AES_GMAC_authentication_verify_test_case_1(void)
7704 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7708 test_AES_GMAC_authentication_verify_test_case_2(void)
7710 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7714 test_AES_GMAC_authentication_verify_test_case_3(void)
7716 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7720 test_AES_GMAC_authentication_verify_test_case_4(void)
7722 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7725 struct test_crypto_vector {
7726 enum rte_crypto_cipher_algorithm crypto_algo;
7739 const uint8_t *data;
7744 const uint8_t *data;
7748 enum rte_crypto_auth_algorithm auth_algo;
7756 const uint8_t *data;
7766 static const struct test_crypto_vector
7767 hmac_sha1_test_crypto_vector = {
7768 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7770 .data = plaintext_hash,
7775 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7776 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7777 0xDE, 0xF4, 0xDE, 0xAD
7783 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7784 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7785 0x3F, 0x91, 0x64, 0x59
7791 static const struct test_crypto_vector
7792 aes128_gmac_test_vector = {
7793 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7795 .data = plaintext_hash,
7800 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7801 0x08, 0x09, 0x0A, 0x0B
7807 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7808 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7814 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7815 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7821 static const struct test_crypto_vector
7822 aes128cbc_hmac_sha1_test_vector = {
7823 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7826 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7827 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7833 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7834 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7839 .data = plaintext_hash,
7843 .data = ciphertext512_aes128cbc,
7846 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7849 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7850 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7851 0xDE, 0xF4, 0xDE, 0xAD
7857 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7858 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7859 0x18, 0x8C, 0x1D, 0x32
7866 data_corruption(uint8_t *data)
7872 tag_corruption(uint8_t *data, unsigned int tag_offset)
7874 data[tag_offset] += 1;
7878 create_auth_session(struct crypto_unittest_params *ut_params,
7880 const struct test_crypto_vector *reference,
7881 enum rte_crypto_auth_operation auth_op)
7883 struct crypto_testsuite_params *ts_params = &testsuite_params;
7884 uint8_t auth_key[reference->auth_key.len + 1];
7886 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7888 /* Setup Authentication Parameters */
7889 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7890 ut_params->auth_xform.auth.op = auth_op;
7891 ut_params->auth_xform.next = NULL;
7892 ut_params->auth_xform.auth.algo = reference->auth_algo;
7893 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7894 ut_params->auth_xform.auth.key.data = auth_key;
7895 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7897 /* Create Crypto session*/
7898 ut_params->sess = rte_cryptodev_sym_session_create(
7899 ts_params->session_mpool);
7901 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7902 &ut_params->auth_xform,
7903 ts_params->session_priv_mpool);
7905 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7911 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7913 const struct test_crypto_vector *reference,
7914 enum rte_crypto_auth_operation auth_op,
7915 enum rte_crypto_cipher_operation cipher_op)
7917 struct crypto_testsuite_params *ts_params = &testsuite_params;
7918 uint8_t cipher_key[reference->cipher_key.len + 1];
7919 uint8_t auth_key[reference->auth_key.len + 1];
7921 memcpy(cipher_key, reference->cipher_key.data,
7922 reference->cipher_key.len);
7923 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7925 /* Setup Authentication Parameters */
7926 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7927 ut_params->auth_xform.auth.op = auth_op;
7928 ut_params->auth_xform.auth.algo = reference->auth_algo;
7929 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7930 ut_params->auth_xform.auth.key.data = auth_key;
7931 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7933 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7934 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7935 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7937 ut_params->auth_xform.next = &ut_params->cipher_xform;
7939 /* Setup Cipher Parameters */
7940 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7941 ut_params->cipher_xform.next = NULL;
7942 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7943 ut_params->cipher_xform.cipher.op = cipher_op;
7944 ut_params->cipher_xform.cipher.key.data = cipher_key;
7945 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7946 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7947 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7950 /* Create Crypto session*/
7951 ut_params->sess = rte_cryptodev_sym_session_create(
7952 ts_params->session_mpool);
7954 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7955 &ut_params->auth_xform,
7956 ts_params->session_priv_mpool);
7958 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7964 create_auth_operation(struct crypto_testsuite_params *ts_params,
7965 struct crypto_unittest_params *ut_params,
7966 const struct test_crypto_vector *reference,
7967 unsigned int auth_generate)
7969 /* Generate Crypto op data structure */
7970 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7971 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7972 TEST_ASSERT_NOT_NULL(ut_params->op,
7973 "Failed to allocate pktmbuf offload");
7975 /* Set crypto operation data parameters */
7976 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7978 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7980 /* set crypto operation source mbuf */
7981 sym_op->m_src = ut_params->ibuf;
7984 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7985 ut_params->ibuf, reference->digest.len);
7987 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7988 "no room to append auth tag");
7990 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7991 ut_params->ibuf, reference->plaintext.len);
7994 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7996 memcpy(sym_op->auth.digest.data,
7997 reference->digest.data,
7998 reference->digest.len);
8000 debug_hexdump(stdout, "digest:",
8001 sym_op->auth.digest.data,
8002 reference->digest.len);
8004 sym_op->auth.data.length = reference->plaintext.len;
8005 sym_op->auth.data.offset = 0;
8011 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
8012 struct crypto_unittest_params *ut_params,
8013 const struct test_crypto_vector *reference,
8014 unsigned int auth_generate)
8016 /* Generate Crypto op data structure */
8017 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8018 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8019 TEST_ASSERT_NOT_NULL(ut_params->op,
8020 "Failed to allocate pktmbuf offload");
8022 /* Set crypto operation data parameters */
8023 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8025 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8027 /* set crypto operation source mbuf */
8028 sym_op->m_src = ut_params->ibuf;
8031 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8032 ut_params->ibuf, reference->digest.len);
8034 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8035 "no room to append auth tag");
8037 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8038 ut_params->ibuf, reference->ciphertext.len);
8041 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8043 memcpy(sym_op->auth.digest.data,
8044 reference->digest.data,
8045 reference->digest.len);
8047 debug_hexdump(stdout, "digest:",
8048 sym_op->auth.digest.data,
8049 reference->digest.len);
8051 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8052 reference->iv.data, reference->iv.len);
8054 sym_op->cipher.data.length = 0;
8055 sym_op->cipher.data.offset = 0;
8057 sym_op->auth.data.length = reference->plaintext.len;
8058 sym_op->auth.data.offset = 0;
8064 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8065 struct crypto_unittest_params *ut_params,
8066 const struct test_crypto_vector *reference,
8067 unsigned int auth_generate)
8069 /* Generate Crypto op data structure */
8070 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8071 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8072 TEST_ASSERT_NOT_NULL(ut_params->op,
8073 "Failed to allocate pktmbuf offload");
8075 /* Set crypto operation data parameters */
8076 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8078 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8080 /* set crypto operation source mbuf */
8081 sym_op->m_src = ut_params->ibuf;
8084 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8085 ut_params->ibuf, reference->digest.len);
8087 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8088 "no room to append auth tag");
8090 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8091 ut_params->ibuf, reference->ciphertext.len);
8094 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8096 memcpy(sym_op->auth.digest.data,
8097 reference->digest.data,
8098 reference->digest.len);
8100 debug_hexdump(stdout, "digest:",
8101 sym_op->auth.digest.data,
8102 reference->digest.len);
8104 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8105 reference->iv.data, reference->iv.len);
8107 sym_op->cipher.data.length = reference->ciphertext.len;
8108 sym_op->cipher.data.offset = 0;
8110 sym_op->auth.data.length = reference->ciphertext.len;
8111 sym_op->auth.data.offset = 0;
8117 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8118 struct crypto_unittest_params *ut_params,
8119 const struct test_crypto_vector *reference)
8121 return create_auth_operation(ts_params, ut_params, reference, 0);
8125 create_auth_verify_GMAC_operation(
8126 struct crypto_testsuite_params *ts_params,
8127 struct crypto_unittest_params *ut_params,
8128 const struct test_crypto_vector *reference)
8130 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8134 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8135 struct crypto_unittest_params *ut_params,
8136 const struct test_crypto_vector *reference)
8138 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8142 test_authentication_verify_fail_when_data_corruption(
8143 struct crypto_testsuite_params *ts_params,
8144 struct crypto_unittest_params *ut_params,
8145 const struct test_crypto_vector *reference,
8146 unsigned int data_corrupted)
8152 /* Create session */
8153 retval = create_auth_session(ut_params,
8154 ts_params->valid_devs[0],
8156 RTE_CRYPTO_AUTH_OP_VERIFY);
8160 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8161 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8162 "Failed to allocate input buffer in mempool");
8164 /* clear mbuf payload */
8165 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8166 rte_pktmbuf_tailroom(ut_params->ibuf));
8168 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8169 reference->plaintext.len);
8170 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8171 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8173 debug_hexdump(stdout, "plaintext:", plaintext,
8174 reference->plaintext.len);
8176 /* Create operation */
8177 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8183 data_corruption(plaintext);
8185 tag_corruption(plaintext, reference->plaintext.len);
8187 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8189 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8190 TEST_ASSERT_EQUAL(ut_params->op->status,
8191 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8192 "authentication not failed");
8194 ut_params->obuf = ut_params->op->sym->m_src;
8195 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8201 test_authentication_verify_GMAC_fail_when_corruption(
8202 struct crypto_testsuite_params *ts_params,
8203 struct crypto_unittest_params *ut_params,
8204 const struct test_crypto_vector *reference,
8205 unsigned int data_corrupted)
8210 /* Create session */
8211 retval = create_auth_cipher_session(ut_params,
8212 ts_params->valid_devs[0],
8214 RTE_CRYPTO_AUTH_OP_VERIFY,
8215 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8219 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8220 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8221 "Failed to allocate input buffer in mempool");
8223 /* clear mbuf payload */
8224 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8225 rte_pktmbuf_tailroom(ut_params->ibuf));
8227 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8228 reference->plaintext.len);
8229 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8230 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8232 debug_hexdump(stdout, "plaintext:", plaintext,
8233 reference->plaintext.len);
8235 /* Create operation */
8236 retval = create_auth_verify_GMAC_operation(ts_params,
8244 data_corruption(plaintext);
8246 tag_corruption(plaintext, reference->aad.len);
8248 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8250 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8251 TEST_ASSERT_EQUAL(ut_params->op->status,
8252 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8253 "authentication not failed");
8255 ut_params->obuf = ut_params->op->sym->m_src;
8256 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8262 test_authenticated_decryption_fail_when_corruption(
8263 struct crypto_testsuite_params *ts_params,
8264 struct crypto_unittest_params *ut_params,
8265 const struct test_crypto_vector *reference,
8266 unsigned int data_corrupted)
8270 uint8_t *ciphertext;
8272 /* Create session */
8273 retval = create_auth_cipher_session(ut_params,
8274 ts_params->valid_devs[0],
8276 RTE_CRYPTO_AUTH_OP_VERIFY,
8277 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8281 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8282 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8283 "Failed to allocate input buffer in mempool");
8285 /* clear mbuf payload */
8286 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8287 rte_pktmbuf_tailroom(ut_params->ibuf));
8289 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8290 reference->ciphertext.len);
8291 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8292 memcpy(ciphertext, reference->ciphertext.data,
8293 reference->ciphertext.len);
8295 /* Create operation */
8296 retval = create_cipher_auth_verify_operation(ts_params,
8304 data_corruption(ciphertext);
8306 tag_corruption(ciphertext, reference->ciphertext.len);
8308 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8311 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8312 TEST_ASSERT_EQUAL(ut_params->op->status,
8313 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8314 "authentication not failed");
8316 ut_params->obuf = ut_params->op->sym->m_src;
8317 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8323 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8324 const struct aead_test_data *tdata,
8325 void *digest_mem, uint64_t digest_phys)
8327 struct crypto_testsuite_params *ts_params = &testsuite_params;
8328 struct crypto_unittest_params *ut_params = &unittest_params;
8330 const unsigned int auth_tag_len = tdata->auth_tag.len;
8331 const unsigned int iv_len = tdata->iv.len;
8332 unsigned int aad_len = tdata->aad.len;
8334 /* Generate Crypto op data structure */
8335 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8336 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8337 TEST_ASSERT_NOT_NULL(ut_params->op,
8338 "Failed to allocate symmetric crypto operation struct");
8340 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8342 sym_op->aead.digest.data = digest_mem;
8344 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8345 "no room to append digest");
8347 sym_op->aead.digest.phys_addr = digest_phys;
8349 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8350 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8352 debug_hexdump(stdout, "digest:",
8353 sym_op->aead.digest.data,
8357 /* Append aad data */
8358 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8359 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8360 uint8_t *, IV_OFFSET);
8362 /* Copy IV 1 byte after the IV pointer, according to the API */
8363 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8365 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8367 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8368 ut_params->ibuf, aad_len);
8369 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8370 "no room to prepend aad");
8371 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8374 memset(sym_op->aead.aad.data, 0, aad_len);
8375 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8376 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8378 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8379 debug_hexdump(stdout, "aad:",
8380 sym_op->aead.aad.data, aad_len);
8382 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8383 uint8_t *, IV_OFFSET);
8385 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8387 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8388 ut_params->ibuf, aad_len);
8389 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8390 "no room to prepend aad");
8391 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8394 memset(sym_op->aead.aad.data, 0, aad_len);
8395 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8397 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8398 debug_hexdump(stdout, "aad:",
8399 sym_op->aead.aad.data, aad_len);
8402 sym_op->aead.data.length = tdata->plaintext.len;
8403 sym_op->aead.data.offset = aad_len;
8408 #define SGL_MAX_NO 16
8411 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8412 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8414 struct crypto_testsuite_params *ts_params = &testsuite_params;
8415 struct crypto_unittest_params *ut_params = &unittest_params;
8416 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8419 int to_trn_tbl[SGL_MAX_NO];
8421 unsigned int trn_data = 0;
8422 uint8_t *plaintext, *ciphertext, *auth_tag;
8424 if (fragsz > tdata->plaintext.len)
8425 fragsz = tdata->plaintext.len;
8427 uint16_t plaintext_len = fragsz;
8428 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8430 if (fragsz_oop > tdata->plaintext.len)
8431 frag_size_oop = tdata->plaintext.len;
8434 void *digest_mem = NULL;
8436 uint32_t prepend_len = tdata->aad.len;
8438 if (tdata->plaintext.len % fragsz != 0) {
8439 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8442 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8447 * For out-op-place we need to alloc another mbuf
8450 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8451 rte_pktmbuf_append(ut_params->obuf,
8452 frag_size_oop + prepend_len);
8453 buf_oop = ut_params->obuf;
8456 /* Create AEAD session */
8457 retval = create_aead_session(ts_params->valid_devs[0],
8459 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8460 tdata->key.data, tdata->key.len,
8461 tdata->aad.len, tdata->auth_tag.len,
8466 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8468 /* clear mbuf payload */
8469 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8470 rte_pktmbuf_tailroom(ut_params->ibuf));
8472 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8475 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8477 trn_data += plaintext_len;
8479 buf = ut_params->ibuf;
8482 * Loop until no more fragments
8485 while (trn_data < tdata->plaintext.len) {
8487 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8488 (tdata->plaintext.len - trn_data) : fragsz;
8490 to_trn_tbl[ecx++] = to_trn;
8492 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8495 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8496 rte_pktmbuf_tailroom(buf));
8499 if (oop && !fragsz_oop) {
8500 buf_last_oop = buf_oop->next =
8501 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8502 buf_oop = buf_oop->next;
8503 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8504 0, rte_pktmbuf_tailroom(buf_oop));
8505 rte_pktmbuf_append(buf_oop, to_trn);
8508 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8511 memcpy(plaintext, tdata->plaintext.data + trn_data,
8514 if (trn_data == tdata->plaintext.len) {
8517 digest_mem = rte_pktmbuf_append(buf_oop,
8518 tdata->auth_tag.len);
8520 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8521 tdata->auth_tag.len);
8525 uint64_t digest_phys = 0;
8527 ut_params->ibuf->nb_segs = segs;
8530 if (fragsz_oop && oop) {
8534 if (frag_size_oop == tdata->plaintext.len) {
8535 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8536 tdata->auth_tag.len);
8538 digest_phys = rte_pktmbuf_iova_offset(
8540 tdata->plaintext.len + prepend_len);
8543 trn_data = frag_size_oop;
8544 while (trn_data < tdata->plaintext.len) {
8547 (tdata->plaintext.len - trn_data <
8549 (tdata->plaintext.len - trn_data) :
8552 to_trn_tbl[ecx++] = to_trn;
8554 buf_last_oop = buf_oop->next =
8555 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8556 buf_oop = buf_oop->next;
8557 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8558 0, rte_pktmbuf_tailroom(buf_oop));
8559 rte_pktmbuf_append(buf_oop, to_trn);
8563 if (trn_data == tdata->plaintext.len) {
8564 digest_mem = rte_pktmbuf_append(buf_oop,
8565 tdata->auth_tag.len);
8569 ut_params->obuf->nb_segs = segs;
8573 * Place digest at the end of the last buffer
8576 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8577 if (oop && buf_last_oop)
8578 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8580 if (!digest_mem && !oop) {
8581 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8582 + tdata->auth_tag.len);
8583 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8584 tdata->plaintext.len);
8587 /* Create AEAD operation */
8588 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8589 tdata, digest_mem, digest_phys);
8594 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8596 ut_params->op->sym->m_src = ut_params->ibuf;
8598 ut_params->op->sym->m_dst = ut_params->obuf;
8600 /* Process crypto operation */
8601 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8602 ut_params->op), "failed to process sym crypto op");
8604 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8605 "crypto op processing failed");
8608 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8609 uint8_t *, prepend_len);
8611 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8612 uint8_t *, prepend_len);
8616 fragsz = fragsz_oop;
8618 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8620 tdata->ciphertext.data,
8622 "Ciphertext data not as expected");
8624 buf = ut_params->op->sym->m_src->next;
8626 buf = ut_params->op->sym->m_dst->next;
8628 unsigned int off = fragsz;
8632 ciphertext = rte_pktmbuf_mtod(buf,
8635 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8637 tdata->ciphertext.data + off,
8639 "Ciphertext data not as expected");
8641 off += to_trn_tbl[ecx++];
8645 auth_tag = digest_mem;
8646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8648 tdata->auth_tag.data,
8649 tdata->auth_tag.len,
8650 "Generated auth tag not as expected");
8656 #define OUT_OF_PLACE 1
8659 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8661 return test_authenticated_encryption_SGL(
8662 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8666 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8668 return test_authenticated_encryption_SGL(
8669 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8673 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8675 return test_authenticated_encryption_SGL(
8676 &gcm_test_case_8, OUT_OF_PLACE, 400,
8677 gcm_test_case_8.plaintext.len);
8681 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8684 return test_authenticated_encryption_SGL(
8685 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8689 test_authentication_verify_fail_when_data_corrupted(
8690 struct crypto_testsuite_params *ts_params,
8691 struct crypto_unittest_params *ut_params,
8692 const struct test_crypto_vector *reference)
8694 return test_authentication_verify_fail_when_data_corruption(
8695 ts_params, ut_params, reference, 1);
8699 test_authentication_verify_fail_when_tag_corrupted(
8700 struct crypto_testsuite_params *ts_params,
8701 struct crypto_unittest_params *ut_params,
8702 const struct test_crypto_vector *reference)
8704 return test_authentication_verify_fail_when_data_corruption(
8705 ts_params, ut_params, reference, 0);
8709 test_authentication_verify_GMAC_fail_when_data_corrupted(
8710 struct crypto_testsuite_params *ts_params,
8711 struct crypto_unittest_params *ut_params,
8712 const struct test_crypto_vector *reference)
8714 return test_authentication_verify_GMAC_fail_when_corruption(
8715 ts_params, ut_params, reference, 1);
8719 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8720 struct crypto_testsuite_params *ts_params,
8721 struct crypto_unittest_params *ut_params,
8722 const struct test_crypto_vector *reference)
8724 return test_authentication_verify_GMAC_fail_when_corruption(
8725 ts_params, ut_params, reference, 0);
8729 test_authenticated_decryption_fail_when_data_corrupted(
8730 struct crypto_testsuite_params *ts_params,
8731 struct crypto_unittest_params *ut_params,
8732 const struct test_crypto_vector *reference)
8734 return test_authenticated_decryption_fail_when_corruption(
8735 ts_params, ut_params, reference, 1);
8739 test_authenticated_decryption_fail_when_tag_corrupted(
8740 struct crypto_testsuite_params *ts_params,
8741 struct crypto_unittest_params *ut_params,
8742 const struct test_crypto_vector *reference)
8744 return test_authenticated_decryption_fail_when_corruption(
8745 ts_params, ut_params, reference, 0);
8749 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8751 return test_authentication_verify_fail_when_data_corrupted(
8752 &testsuite_params, &unittest_params,
8753 &hmac_sha1_test_crypto_vector);
8757 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8759 return test_authentication_verify_fail_when_tag_corrupted(
8760 &testsuite_params, &unittest_params,
8761 &hmac_sha1_test_crypto_vector);
8765 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8767 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8768 &testsuite_params, &unittest_params,
8769 &aes128_gmac_test_vector);
8773 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8775 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8776 &testsuite_params, &unittest_params,
8777 &aes128_gmac_test_vector);
8781 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8783 return test_authenticated_decryption_fail_when_data_corrupted(
8786 &aes128cbc_hmac_sha1_test_vector);
8790 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8792 return test_authenticated_decryption_fail_when_tag_corrupted(
8795 &aes128cbc_hmac_sha1_test_vector);
8798 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8800 /* global AESNI slave IDs for the scheduler test */
8801 uint8_t aesni_ids[2];
8804 test_scheduler_attach_slave_op(void)
8806 struct crypto_testsuite_params *ts_params = &testsuite_params;
8807 uint8_t sched_id = ts_params->valid_devs[0];
8808 uint32_t nb_devs, i, nb_devs_attached = 0;
8812 /* create 2 AESNI_MB if necessary */
8813 nb_devs = rte_cryptodev_device_count_by_driver(
8814 rte_cryptodev_driver_id_get(
8815 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8817 for (i = nb_devs; i < 2; i++) {
8818 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8819 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8821 ret = rte_vdev_init(vdev_name, NULL);
8823 TEST_ASSERT(ret == 0,
8824 "Failed to create instance %u of"
8826 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8830 /* attach 2 AESNI_MB cdevs */
8831 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8833 struct rte_cryptodev_info info;
8834 unsigned int session_size;
8836 rte_cryptodev_info_get(i, &info);
8837 if (info.driver_id != rte_cryptodev_driver_id_get(
8838 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8841 session_size = rte_cryptodev_sym_get_private_session_size(i);
8843 * Create the session mempool again, since now there are new devices
8844 * to use the mempool.
8846 if (ts_params->session_mpool) {
8847 rte_mempool_free(ts_params->session_mpool);
8848 ts_params->session_mpool = NULL;
8850 if (ts_params->session_priv_mpool) {
8851 rte_mempool_free(ts_params->session_priv_mpool);
8852 ts_params->session_priv_mpool = NULL;
8855 if (info.sym.max_nb_sessions != 0 &&
8856 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8858 "Device does not support "
8859 "at least %u sessions\n",
8864 * Create mempool with maximum number of sessions,
8865 * to include the session headers
8867 if (ts_params->session_mpool == NULL) {
8868 ts_params->session_mpool =
8869 rte_cryptodev_sym_session_pool_create(
8871 MAX_NB_SESSIONS, 0, 0, 0,
8873 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8874 "session mempool allocation failed");
8878 * Create mempool with maximum number of sessions,
8879 * to include device specific session private data
8881 if (ts_params->session_priv_mpool == NULL) {
8882 ts_params->session_priv_mpool = rte_mempool_create(
8883 "test_sess_mp_priv",
8886 0, 0, NULL, NULL, NULL,
8887 NULL, SOCKET_ID_ANY,
8890 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
8891 "session mempool allocation failed");
8894 ts_params->qp_conf.mp_session = ts_params->session_mpool;
8895 ts_params->qp_conf.mp_session_private =
8896 ts_params->session_priv_mpool;
8898 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8901 TEST_ASSERT(ret == 0,
8902 "Failed to attach device %u of pmd : %s", i,
8903 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8905 aesni_ids[nb_devs_attached] = (uint8_t)i;
8914 test_scheduler_detach_slave_op(void)
8916 struct crypto_testsuite_params *ts_params = &testsuite_params;
8917 uint8_t sched_id = ts_params->valid_devs[0];
8921 for (i = 0; i < 2; i++) {
8922 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8924 TEST_ASSERT(ret == 0,
8925 "Failed to detach device %u", aesni_ids[i]);
8932 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8934 struct crypto_testsuite_params *ts_params = &testsuite_params;
8935 uint8_t sched_id = ts_params->valid_devs[0];
8937 return rte_cryptodev_scheduler_mode_set(sched_id,
8942 test_scheduler_mode_roundrobin_op(void)
8944 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8945 0, "Failed to set roundrobin mode");
8951 test_scheduler_mode_multicore_op(void)
8953 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8954 0, "Failed to set multicore mode");
8960 test_scheduler_mode_failover_op(void)
8962 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8963 0, "Failed to set failover mode");
8969 test_scheduler_mode_pkt_size_distr_op(void)
8971 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8972 0, "Failed to set pktsize mode");
8977 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8978 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8979 .setup = testsuite_setup,
8980 .teardown = testsuite_teardown,
8981 .unit_test_cases = {
8983 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8984 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_AES_chain_scheduler_all),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_AES_cipheronly_scheduler_all),
8989 TEST_CASE_ST(ut_setup, ut_teardown,
8990 test_authonly_scheduler_all),
8991 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8994 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8995 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 test_AES_chain_scheduler_all),
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 test_AES_cipheronly_scheduler_all),
9000 TEST_CASE_ST(ut_setup, ut_teardown,
9001 test_authonly_scheduler_all),
9002 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9005 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9006 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_chain_scheduler_all),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_AES_cipheronly_scheduler_all),
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_authonly_scheduler_all),
9013 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9016 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9017 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_AES_chain_scheduler_all),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_cipheronly_scheduler_all),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_authonly_scheduler_all),
9024 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9026 TEST_CASES_END() /**< NULL terminate unit test array */
9030 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
9032 static struct unit_test_suite cryptodev_qat_testsuite = {
9033 .suite_name = "Crypto QAT Unit Test Suite",
9034 .setup = testsuite_setup,
9035 .teardown = testsuite_teardown,
9036 .unit_test_cases = {
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_device_configure_invalid_dev_id),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_device_configure_invalid_queue_pair_ids),
9041 TEST_CASE_ST(ut_setup, ut_teardown,
9042 test_queue_pair_descriptor_setup),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_multi_session),
9046 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_cipheronly_qat_all),
9049 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_3DES_cipheronly_qat_all),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_DES_cipheronly_qat_all),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_docsis_qat_all),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_DES_docsis_qat_all),
9058 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
9059 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
9061 /** AES CCM Authenticated Encryption 128 bits key */
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_CCM_authenticated_encryption_test_case_128_1),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_CCM_authenticated_encryption_test_case_128_2),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_CCM_authenticated_encryption_test_case_128_3),
9069 /** AES CCM Authenticated Decryption 128 bits key*/
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_CCM_authenticated_decryption_test_case_128_1),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_CCM_authenticated_decryption_test_case_128_2),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_AES_CCM_authenticated_decryption_test_case_128_3),
9077 /** AES GCM Authenticated Encryption */
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_GCM_authenticated_encryption_test_case_1),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_GCM_authenticated_encryption_test_case_2),
9088 TEST_CASE_ST(ut_setup, ut_teardown,
9089 test_AES_GCM_authenticated_encryption_test_case_3),
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_AES_GCM_authenticated_encryption_test_case_4),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_AES_GCM_authenticated_encryption_test_case_5),
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_AES_GCM_authenticated_encryption_test_case_6),
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_authenticated_encryption_test_case_7),
9099 /** AES GCM Authenticated Decryption */
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GCM_authenticated_decryption_test_case_1),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GCM_authenticated_decryption_test_case_2),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_authenticated_decryption_test_case_3),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_GCM_authenticated_decryption_test_case_4),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_AES_GCM_authenticated_decryption_test_case_5),
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_AES_GCM_authenticated_decryption_test_case_6),
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_AES_GCM_authenticated_decryption_test_case_7),
9115 /** AES GCM Authenticated Encryption 192 bits key */
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_AES_GCM_auth_encryption_test_case_192_1),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_AES_GCM_auth_encryption_test_case_192_2),
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_AES_GCM_auth_encryption_test_case_192_3),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_AES_GCM_auth_encryption_test_case_192_4),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_AES_GCM_auth_encryption_test_case_192_5),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_AES_GCM_auth_encryption_test_case_192_6),
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_AES_GCM_auth_encryption_test_case_192_7),
9131 /** AES GCM Authenticated Decryption 192 bits key */
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_AES_GCM_auth_decryption_test_case_192_1),
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 test_AES_GCM_auth_decryption_test_case_192_2),
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_AES_GCM_auth_decryption_test_case_192_3),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_AES_GCM_auth_decryption_test_case_192_4),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_AES_GCM_auth_decryption_test_case_192_5),
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_AES_GCM_auth_decryption_test_case_192_6),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_AES_GCM_auth_decryption_test_case_192_7),
9147 /** AES GCM Authenticated Encryption 256 bits key */
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_AES_GCM_auth_encryption_test_case_256_1),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_AES_GCM_auth_encryption_test_case_256_2),
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_AES_GCM_auth_encryption_test_case_256_3),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_AES_GCM_auth_encryption_test_case_256_4),
9156 TEST_CASE_ST(ut_setup, ut_teardown,
9157 test_AES_GCM_auth_encryption_test_case_256_5),
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_AES_GCM_auth_encryption_test_case_256_6),
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_AES_GCM_auth_encryption_test_case_256_7),
9163 /** AES GMAC Authentication */
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_AES_GMAC_authentication_test_case_1),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_AES_GMAC_authentication_verify_test_case_1),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_AES_GMAC_authentication_test_case_2),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_AES_GMAC_authentication_verify_test_case_2),
9172 TEST_CASE_ST(ut_setup, ut_teardown,
9173 test_AES_GMAC_authentication_test_case_3),
9174 TEST_CASE_ST(ut_setup, ut_teardown,
9175 test_AES_GMAC_authentication_verify_test_case_3),
9177 /** SNOW 3G encrypt only (UEA2) */
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_snow3g_encryption_test_case_1),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_snow3g_encryption_test_case_2),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_snow3g_encryption_test_case_3),
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_snow3g_encryption_test_case_4),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_snow3g_encryption_test_case_5),
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_snow3g_encryption_test_case_1_oop),
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_snow3g_decryption_test_case_1_oop),
9194 /** SNOW 3G decrypt only (UEA2) */
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_snow3g_decryption_test_case_1),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_snow3g_decryption_test_case_2),
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 test_snow3g_decryption_test_case_3),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_snow3g_decryption_test_case_4),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_snow3g_decryption_test_case_5),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_snow3g_decryption_with_digest_test_case_1),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_snow3g_hash_generate_test_case_1),
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_snow3g_hash_generate_test_case_2),
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_snow3g_hash_generate_test_case_3),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 test_snow3g_hash_verify_test_case_1),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_snow3g_hash_verify_test_case_2),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 test_snow3g_hash_verify_test_case_3),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_snow3g_cipher_auth_test_case_1),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_snow3g_auth_cipher_test_case_1),
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 test_snow3g_auth_cipher_with_digest_test_case_1),
9226 /** ZUC encrypt only (EEA3) */
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_zuc_encryption_test_case_1),
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_zuc_encryption_test_case_2),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_zuc_encryption_test_case_3),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_zuc_encryption_test_case_4),
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_zuc_encryption_test_case_5),
9238 /** ZUC authenticate (EIA3) */
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_zuc_hash_generate_test_case_6),
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_zuc_hash_generate_test_case_7),
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 test_zuc_hash_generate_test_case_8),
9246 /** ZUC alg-chain (EEA3/EIA3) */
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_zuc_cipher_auth_test_case_1),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_zuc_cipher_auth_test_case_2),
9252 /** HMAC_MD5 Authentication */
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_MD5_HMAC_generate_case_1),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_MD5_HMAC_verify_case_1),
9257 TEST_CASE_ST(ut_setup, ut_teardown,
9258 test_MD5_HMAC_generate_case_2),
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_MD5_HMAC_verify_case_2),
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_null_auth_only_operation),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_null_cipher_only_operation),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_null_cipher_auth_operation),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_null_auth_cipher_operation),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_kasumi_hash_generate_test_case_1),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_kasumi_hash_generate_test_case_2),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_kasumi_hash_generate_test_case_3),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_kasumi_hash_generate_test_case_4),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_kasumi_hash_generate_test_case_5),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_kasumi_hash_generate_test_case_6),
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_kasumi_hash_verify_test_case_1),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_kasumi_hash_verify_test_case_2),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_kasumi_hash_verify_test_case_3),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_kasumi_hash_verify_test_case_4),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_kasumi_hash_verify_test_case_5),
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_kasumi_encryption_test_case_1),
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_kasumi_encryption_test_case_3),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_kasumi_auth_cipher_test_case_1),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_kasumi_cipher_auth_test_case_1),
9306 /** Negative tests */
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 authentication_verify_AES128_GMAC_fail_data_corrupt),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9320 TEST_CASES_END() /**< NULL terminate unit test array */
9324 static struct unit_test_suite cryptodev_virtio_testsuite = {
9325 .suite_name = "Crypto VIRTIO Unit Test Suite",
9326 .setup = testsuite_setup,
9327 .teardown = testsuite_teardown,
9328 .unit_test_cases = {
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_AES_cipheronly_virtio_all),
9332 TEST_CASES_END() /**< NULL terminate unit test array */
9336 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9337 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9338 .setup = testsuite_setup,
9339 .teardown = testsuite_teardown,
9340 .unit_test_cases = {
9341 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GCM_authenticated_encryption_test_case_1),
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_AES_GCM_authenticated_encryption_test_case_2),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GCM_authenticated_encryption_test_case_3),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_AES_GCM_authenticated_encryption_test_case_4),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GCM_authenticated_encryption_test_case_5),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_AES_GCM_authenticated_encryption_test_case_6),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_AES_GCM_authenticated_encryption_test_case_7),
9357 /** AES GCM Authenticated Decryption */
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_AES_GCM_authenticated_decryption_test_case_1),
9360 TEST_CASE_ST(ut_setup, ut_teardown,
9361 test_AES_GCM_authenticated_decryption_test_case_2),
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_GCM_authenticated_decryption_test_case_3),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_GCM_authenticated_decryption_test_case_4),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_GCM_authenticated_decryption_test_case_5),
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_AES_GCM_authenticated_decryption_test_case_6),
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_GCM_authenticated_decryption_test_case_7),
9373 /** AES GCM Authenticated Encryption 192 bits key */
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_AES_GCM_auth_encryption_test_case_192_1),
9376 TEST_CASE_ST(ut_setup, ut_teardown,
9377 test_AES_GCM_auth_encryption_test_case_192_2),
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_AES_GCM_auth_encryption_test_case_192_3),
9380 TEST_CASE_ST(ut_setup, ut_teardown,
9381 test_AES_GCM_auth_encryption_test_case_192_4),
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_AES_GCM_auth_encryption_test_case_192_5),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_AES_GCM_auth_encryption_test_case_192_6),
9386 TEST_CASE_ST(ut_setup, ut_teardown,
9387 test_AES_GCM_auth_encryption_test_case_192_7),
9389 /** AES GCM Authenticated Decryption 192 bits key */
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_AES_GCM_auth_decryption_test_case_192_1),
9392 TEST_CASE_ST(ut_setup, ut_teardown,
9393 test_AES_GCM_auth_decryption_test_case_192_2),
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_GCM_auth_decryption_test_case_192_3),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GCM_auth_decryption_test_case_192_4),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_GCM_auth_decryption_test_case_192_5),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_GCM_auth_decryption_test_case_192_6),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_AES_GCM_auth_decryption_test_case_192_7),
9405 /** AES GCM Authenticated Encryption 256 bits key */
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_auth_encryption_test_case_256_1),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_AES_GCM_auth_encryption_test_case_256_2),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_AES_GCM_auth_encryption_test_case_256_3),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_auth_encryption_test_case_256_4),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_auth_encryption_test_case_256_5),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_auth_encryption_test_case_256_6),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_AES_GCM_auth_encryption_test_case_256_7),
9421 /** AES GCM Authenticated Decryption 256 bits key */
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_auth_decryption_test_case_256_1),
9424 TEST_CASE_ST(ut_setup, ut_teardown,
9425 test_AES_GCM_auth_decryption_test_case_256_2),
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_auth_decryption_test_case_256_3),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_AES_GCM_auth_decryption_test_case_256_4),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_auth_decryption_test_case_256_5),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_auth_decryption_test_case_256_6),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_AES_GCM_auth_decryption_test_case_256_7),
9437 /** AES GCM Authenticated Encryption big aad size */
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_AES_GCM_auth_encryption_test_case_aad_1),
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_AES_GCM_auth_encryption_test_case_aad_2),
9443 /** AES GCM Authenticated Decryption big aad size */
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_AES_GCM_auth_decryption_test_case_aad_1),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_AES_GCM_auth_decryption_test_case_aad_2),
9449 /** Session-less tests */
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9455 /** AES GMAC Authentication */
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_AES_GMAC_authentication_test_case_1),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GMAC_authentication_verify_test_case_1),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_AES_GMAC_authentication_test_case_2),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GMAC_authentication_verify_test_case_2),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GMAC_authentication_test_case_3),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GMAC_authentication_verify_test_case_3),
9468 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
9470 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9471 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9472 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9473 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_DES_cipheronly_mb_all),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_DES_docsis_mb_all),
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_3DES_cipheronly_mb_all),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_CCM_authenticated_encryption_test_case_128_1),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_CCM_authenticated_decryption_test_case_128_1),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_AES_CCM_authenticated_encryption_test_case_128_2),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_AES_CCM_authenticated_decryption_test_case_128_2),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_AES_CCM_authenticated_encryption_test_case_128_3),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_AES_CCM_authenticated_decryption_test_case_128_3),
9493 TEST_CASES_END() /**< NULL terminate unit test array */
9497 static struct unit_test_suite cryptodev_openssl_testsuite = {
9498 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9499 .setup = testsuite_setup,
9500 .teardown = testsuite_teardown,
9501 .unit_test_cases = {
9502 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_multi_session_random_usage),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_AES_chain_openssl_all),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_AES_cipheronly_openssl_all),
9509 TEST_CASE_ST(ut_setup, ut_teardown,
9510 test_3DES_chain_openssl_all),
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_3DES_cipheronly_openssl_all),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_DES_cipheronly_openssl_all),
9515 TEST_CASE_ST(ut_setup, ut_teardown,
9516 test_DES_docsis_openssl_all),
9517 TEST_CASE_ST(ut_setup, ut_teardown,
9518 test_authonly_openssl_all),
9520 /** AES GCM Authenticated Encryption */
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_AES_GCM_authenticated_encryption_test_case_1),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_AES_GCM_authenticated_encryption_test_case_2),
9525 TEST_CASE_ST(ut_setup, ut_teardown,
9526 test_AES_GCM_authenticated_encryption_test_case_3),
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_AES_GCM_authenticated_encryption_test_case_4),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_AES_GCM_authenticated_encryption_test_case_5),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_AES_GCM_authenticated_encryption_test_case_6),
9533 TEST_CASE_ST(ut_setup, ut_teardown,
9534 test_AES_GCM_authenticated_encryption_test_case_7),
9536 /** AES GCM Authenticated Decryption */
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_AES_GCM_authenticated_decryption_test_case_1),
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_AES_GCM_authenticated_decryption_test_case_2),
9541 TEST_CASE_ST(ut_setup, ut_teardown,
9542 test_AES_GCM_authenticated_decryption_test_case_3),
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_AES_GCM_authenticated_decryption_test_case_4),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_AES_GCM_authenticated_decryption_test_case_5),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_AES_GCM_authenticated_decryption_test_case_6),
9549 TEST_CASE_ST(ut_setup, ut_teardown,
9550 test_AES_GCM_authenticated_decryption_test_case_7),
9553 /** AES GCM Authenticated Encryption 192 bits key */
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_AES_GCM_auth_encryption_test_case_192_1),
9556 TEST_CASE_ST(ut_setup, ut_teardown,
9557 test_AES_GCM_auth_encryption_test_case_192_2),
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_AES_GCM_auth_encryption_test_case_192_3),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_AES_GCM_auth_encryption_test_case_192_4),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_AES_GCM_auth_encryption_test_case_192_5),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_AES_GCM_auth_encryption_test_case_192_6),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_AES_GCM_auth_encryption_test_case_192_7),
9569 /** AES GCM Authenticated Decryption 192 bits key */
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 test_AES_GCM_auth_decryption_test_case_192_1),
9572 TEST_CASE_ST(ut_setup, ut_teardown,
9573 test_AES_GCM_auth_decryption_test_case_192_2),
9574 TEST_CASE_ST(ut_setup, ut_teardown,
9575 test_AES_GCM_auth_decryption_test_case_192_3),
9576 TEST_CASE_ST(ut_setup, ut_teardown,
9577 test_AES_GCM_auth_decryption_test_case_192_4),
9578 TEST_CASE_ST(ut_setup, ut_teardown,
9579 test_AES_GCM_auth_decryption_test_case_192_5),
9580 TEST_CASE_ST(ut_setup, ut_teardown,
9581 test_AES_GCM_auth_decryption_test_case_192_6),
9582 TEST_CASE_ST(ut_setup, ut_teardown,
9583 test_AES_GCM_auth_decryption_test_case_192_7),
9585 /** AES GCM Authenticated Encryption 256 bits key */
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_AES_GCM_auth_encryption_test_case_256_1),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_AES_GCM_auth_encryption_test_case_256_2),
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_AES_GCM_auth_encryption_test_case_256_3),
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_AES_GCM_auth_encryption_test_case_256_4),
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_AES_GCM_auth_encryption_test_case_256_5),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_GCM_auth_encryption_test_case_256_6),
9598 TEST_CASE_ST(ut_setup, ut_teardown,
9599 test_AES_GCM_auth_encryption_test_case_256_7),
9601 /** AES GCM Authenticated Decryption 256 bits key */
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_auth_decryption_test_case_256_1),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_GCM_auth_decryption_test_case_256_2),
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_auth_decryption_test_case_256_3),
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_GCM_auth_decryption_test_case_256_4),
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_auth_decryption_test_case_256_5),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_auth_decryption_test_case_256_6),
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_AES_GCM_auth_decryption_test_case_256_7),
9617 /** AES GMAC Authentication */
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GMAC_authentication_test_case_1),
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 test_AES_GMAC_authentication_verify_test_case_1),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GMAC_authentication_test_case_2),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_GMAC_authentication_verify_test_case_2),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GMAC_authentication_test_case_3),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GMAC_authentication_verify_test_case_3),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GMAC_authentication_test_case_4),
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_AES_GMAC_authentication_verify_test_case_4),
9635 /** AES CCM Authenticated Encryption 128 bits key */
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 test_AES_CCM_authenticated_encryption_test_case_128_1),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_CCM_authenticated_encryption_test_case_128_2),
9640 TEST_CASE_ST(ut_setup, ut_teardown,
9641 test_AES_CCM_authenticated_encryption_test_case_128_3),
9643 /** AES CCM Authenticated Decryption 128 bits key*/
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_CCM_authenticated_decryption_test_case_128_1),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_CCM_authenticated_decryption_test_case_128_2),
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_CCM_authenticated_decryption_test_case_128_3),
9651 /** AES CCM Authenticated Encryption 192 bits key */
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_CCM_authenticated_encryption_test_case_192_1),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_CCM_authenticated_encryption_test_case_192_2),
9656 TEST_CASE_ST(ut_setup, ut_teardown,
9657 test_AES_CCM_authenticated_encryption_test_case_192_3),
9659 /** AES CCM Authenticated Decryption 192 bits key*/
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_CCM_authenticated_decryption_test_case_192_1),
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_CCM_authenticated_decryption_test_case_192_2),
9664 TEST_CASE_ST(ut_setup, ut_teardown,
9665 test_AES_CCM_authenticated_decryption_test_case_192_3),
9667 /** AES CCM Authenticated Encryption 256 bits key */
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_CCM_authenticated_encryption_test_case_256_1),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_CCM_authenticated_encryption_test_case_256_2),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_CCM_authenticated_encryption_test_case_256_3),
9675 /** AES CCM Authenticated Decryption 256 bits key*/
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_CCM_authenticated_decryption_test_case_256_1),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_AES_CCM_authenticated_decryption_test_case_256_2),
9680 TEST_CASE_ST(ut_setup, ut_teardown,
9681 test_AES_CCM_authenticated_decryption_test_case_256_3),
9683 /** Scatter-Gather */
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9687 /** Negative tests */
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9690 TEST_CASE_ST(ut_setup, ut_teardown,
9691 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 authentication_verify_AES128_GMAC_fail_data_corrupt),
9694 TEST_CASE_ST(ut_setup, ut_teardown,
9695 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9701 TEST_CASES_END() /**< NULL terminate unit test array */
9705 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9706 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9707 .setup = testsuite_setup,
9708 .teardown = testsuite_teardown,
9709 .unit_test_cases = {
9710 /** AES GCM Authenticated Encryption */
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 test_AES_GCM_authenticated_encryption_test_case_1),
9713 TEST_CASE_ST(ut_setup, ut_teardown,
9714 test_AES_GCM_authenticated_encryption_test_case_2),
9715 TEST_CASE_ST(ut_setup, ut_teardown,
9716 test_AES_GCM_authenticated_encryption_test_case_3),
9717 TEST_CASE_ST(ut_setup, ut_teardown,
9718 test_AES_GCM_authenticated_encryption_test_case_4),
9719 TEST_CASE_ST(ut_setup, ut_teardown,
9720 test_AES_GCM_authenticated_encryption_test_case_5),
9721 TEST_CASE_ST(ut_setup, ut_teardown,
9722 test_AES_GCM_authenticated_encryption_test_case_6),
9723 TEST_CASE_ST(ut_setup, ut_teardown,
9724 test_AES_GCM_authenticated_encryption_test_case_7),
9726 /** AES GCM Authenticated Decryption */
9727 TEST_CASE_ST(ut_setup, ut_teardown,
9728 test_AES_GCM_authenticated_decryption_test_case_1),
9729 TEST_CASE_ST(ut_setup, ut_teardown,
9730 test_AES_GCM_authenticated_decryption_test_case_2),
9731 TEST_CASE_ST(ut_setup, ut_teardown,
9732 test_AES_GCM_authenticated_decryption_test_case_3),
9733 TEST_CASE_ST(ut_setup, ut_teardown,
9734 test_AES_GCM_authenticated_decryption_test_case_4),
9735 TEST_CASE_ST(ut_setup, ut_teardown,
9736 test_AES_GCM_authenticated_decryption_test_case_5),
9737 TEST_CASE_ST(ut_setup, ut_teardown,
9738 test_AES_GCM_authenticated_decryption_test_case_6),
9739 TEST_CASE_ST(ut_setup, ut_teardown,
9740 test_AES_GCM_authenticated_decryption_test_case_7),
9742 /** AES GCM Authenticated Encryption 192 bits key */
9743 TEST_CASE_ST(ut_setup, ut_teardown,
9744 test_AES_GCM_auth_encryption_test_case_192_1),
9745 TEST_CASE_ST(ut_setup, ut_teardown,
9746 test_AES_GCM_auth_encryption_test_case_192_2),
9747 TEST_CASE_ST(ut_setup, ut_teardown,
9748 test_AES_GCM_auth_encryption_test_case_192_3),
9749 TEST_CASE_ST(ut_setup, ut_teardown,
9750 test_AES_GCM_auth_encryption_test_case_192_4),
9751 TEST_CASE_ST(ut_setup, ut_teardown,
9752 test_AES_GCM_auth_encryption_test_case_192_5),
9753 TEST_CASE_ST(ut_setup, ut_teardown,
9754 test_AES_GCM_auth_encryption_test_case_192_6),
9755 TEST_CASE_ST(ut_setup, ut_teardown,
9756 test_AES_GCM_auth_encryption_test_case_192_7),
9758 /** AES GCM Authenticated Decryption 192 bits key */
9759 TEST_CASE_ST(ut_setup, ut_teardown,
9760 test_AES_GCM_auth_decryption_test_case_192_1),
9761 TEST_CASE_ST(ut_setup, ut_teardown,
9762 test_AES_GCM_auth_decryption_test_case_192_2),
9763 TEST_CASE_ST(ut_setup, ut_teardown,
9764 test_AES_GCM_auth_decryption_test_case_192_3),
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 test_AES_GCM_auth_decryption_test_case_192_4),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 test_AES_GCM_auth_decryption_test_case_192_5),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_AES_GCM_auth_decryption_test_case_192_6),
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_AES_GCM_auth_decryption_test_case_192_7),
9774 /** AES GCM Authenticated Encryption 256 bits key */
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_AES_GCM_auth_encryption_test_case_256_1),
9777 TEST_CASE_ST(ut_setup, ut_teardown,
9778 test_AES_GCM_auth_encryption_test_case_256_2),
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 test_AES_GCM_auth_encryption_test_case_256_3),
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 test_AES_GCM_auth_encryption_test_case_256_4),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_AES_GCM_auth_encryption_test_case_256_5),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_AES_GCM_auth_encryption_test_case_256_6),
9787 TEST_CASE_ST(ut_setup, ut_teardown,
9788 test_AES_GCM_auth_encryption_test_case_256_7),
9790 /** AES GCM Authenticated Decryption 256 bits key */
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_AES_GCM_auth_decryption_test_case_256_1),
9793 TEST_CASE_ST(ut_setup, ut_teardown,
9794 test_AES_GCM_auth_decryption_test_case_256_2),
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_AES_GCM_auth_decryption_test_case_256_3),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_AES_GCM_auth_decryption_test_case_256_4),
9799 TEST_CASE_ST(ut_setup, ut_teardown,
9800 test_AES_GCM_auth_decryption_test_case_256_5),
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_AES_GCM_auth_decryption_test_case_256_6),
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_AES_GCM_auth_decryption_test_case_256_7),
9806 /** AES GCM Authenticated Encryption big aad size */
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 test_AES_GCM_auth_encryption_test_case_aad_1),
9809 TEST_CASE_ST(ut_setup, ut_teardown,
9810 test_AES_GCM_auth_encryption_test_case_aad_2),
9812 /** AES GCM Authenticated Decryption big aad size */
9813 TEST_CASE_ST(ut_setup, ut_teardown,
9814 test_AES_GCM_auth_decryption_test_case_aad_1),
9815 TEST_CASE_ST(ut_setup, ut_teardown,
9816 test_AES_GCM_auth_decryption_test_case_aad_2),
9818 /** AES GMAC Authentication */
9819 TEST_CASE_ST(ut_setup, ut_teardown,
9820 test_AES_GMAC_authentication_test_case_1),
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_AES_GMAC_authentication_verify_test_case_1),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_AES_GMAC_authentication_test_case_3),
9825 TEST_CASE_ST(ut_setup, ut_teardown,
9826 test_AES_GMAC_authentication_verify_test_case_3),
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_AES_GMAC_authentication_test_case_4),
9829 TEST_CASE_ST(ut_setup, ut_teardown,
9830 test_AES_GMAC_authentication_verify_test_case_4),
9832 /** Negative tests */
9833 TEST_CASE_ST(ut_setup, ut_teardown,
9834 authentication_verify_AES128_GMAC_fail_data_corrupt),
9835 TEST_CASE_ST(ut_setup, ut_teardown,
9836 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9838 /** Out of place tests */
9839 TEST_CASE_ST(ut_setup, ut_teardown,
9840 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9841 TEST_CASE_ST(ut_setup, ut_teardown,
9842 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9844 /** Session-less tests */
9845 TEST_CASE_ST(ut_setup, ut_teardown,
9846 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9847 TEST_CASE_ST(ut_setup, ut_teardown,
9848 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9850 /** Scatter-Gather */
9851 TEST_CASE_ST(ut_setup, ut_teardown,
9852 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9854 TEST_CASES_END() /**< NULL terminate unit test array */
9858 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9859 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9860 .setup = testsuite_setup,
9861 .teardown = testsuite_teardown,
9862 .unit_test_cases = {
9863 /** KASUMI encrypt only (UEA1) */
9864 TEST_CASE_ST(ut_setup, ut_teardown,
9865 test_kasumi_encryption_test_case_1),
9866 TEST_CASE_ST(ut_setup, ut_teardown,
9867 test_kasumi_encryption_test_case_1_sgl),
9868 TEST_CASE_ST(ut_setup, ut_teardown,
9869 test_kasumi_encryption_test_case_2),
9870 TEST_CASE_ST(ut_setup, ut_teardown,
9871 test_kasumi_encryption_test_case_3),
9872 TEST_CASE_ST(ut_setup, ut_teardown,
9873 test_kasumi_encryption_test_case_4),
9874 TEST_CASE_ST(ut_setup, ut_teardown,
9875 test_kasumi_encryption_test_case_5),
9876 /** KASUMI decrypt only (UEA1) */
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 test_kasumi_decryption_test_case_1),
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 test_kasumi_decryption_test_case_2),
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 test_kasumi_decryption_test_case_3),
9883 TEST_CASE_ST(ut_setup, ut_teardown,
9884 test_kasumi_decryption_test_case_4),
9885 TEST_CASE_ST(ut_setup, ut_teardown,
9886 test_kasumi_decryption_test_case_5),
9888 TEST_CASE_ST(ut_setup, ut_teardown,
9889 test_kasumi_encryption_test_case_1_oop),
9890 TEST_CASE_ST(ut_setup, ut_teardown,
9891 test_kasumi_encryption_test_case_1_oop_sgl),
9894 TEST_CASE_ST(ut_setup, ut_teardown,
9895 test_kasumi_decryption_test_case_1_oop),
9897 /** KASUMI hash only (UIA1) */
9898 TEST_CASE_ST(ut_setup, ut_teardown,
9899 test_kasumi_hash_generate_test_case_1),
9900 TEST_CASE_ST(ut_setup, ut_teardown,
9901 test_kasumi_hash_generate_test_case_2),
9902 TEST_CASE_ST(ut_setup, ut_teardown,
9903 test_kasumi_hash_generate_test_case_3),
9904 TEST_CASE_ST(ut_setup, ut_teardown,
9905 test_kasumi_hash_generate_test_case_4),
9906 TEST_CASE_ST(ut_setup, ut_teardown,
9907 test_kasumi_hash_generate_test_case_5),
9908 TEST_CASE_ST(ut_setup, ut_teardown,
9909 test_kasumi_hash_generate_test_case_6),
9910 TEST_CASE_ST(ut_setup, ut_teardown,
9911 test_kasumi_hash_verify_test_case_1),
9912 TEST_CASE_ST(ut_setup, ut_teardown,
9913 test_kasumi_hash_verify_test_case_2),
9914 TEST_CASE_ST(ut_setup, ut_teardown,
9915 test_kasumi_hash_verify_test_case_3),
9916 TEST_CASE_ST(ut_setup, ut_teardown,
9917 test_kasumi_hash_verify_test_case_4),
9918 TEST_CASE_ST(ut_setup, ut_teardown,
9919 test_kasumi_hash_verify_test_case_5),
9920 TEST_CASE_ST(ut_setup, ut_teardown,
9921 test_kasumi_auth_cipher_test_case_1),
9922 TEST_CASE_ST(ut_setup, ut_teardown,
9923 test_kasumi_cipher_auth_test_case_1),
9924 TEST_CASES_END() /**< NULL terminate unit test array */
9927 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9928 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9929 .setup = testsuite_setup,
9930 .teardown = testsuite_teardown,
9931 .unit_test_cases = {
9932 /** SNOW 3G encrypt only (UEA2) */
9933 TEST_CASE_ST(ut_setup, ut_teardown,
9934 test_snow3g_encryption_test_case_1),
9935 TEST_CASE_ST(ut_setup, ut_teardown,
9936 test_snow3g_encryption_test_case_2),
9937 TEST_CASE_ST(ut_setup, ut_teardown,
9938 test_snow3g_encryption_test_case_3),
9939 TEST_CASE_ST(ut_setup, ut_teardown,
9940 test_snow3g_encryption_test_case_4),
9941 TEST_CASE_ST(ut_setup, ut_teardown,
9942 test_snow3g_encryption_test_case_5),
9943 TEST_CASE_ST(ut_setup, ut_teardown,
9944 test_snow3g_auth_cipher_with_digest_test_case_1),
9946 TEST_CASE_ST(ut_setup, ut_teardown,
9947 test_snow3g_encryption_test_case_1_oop),
9948 TEST_CASE_ST(ut_setup, ut_teardown,
9949 test_snow3g_encryption_test_case_1_oop_sgl),
9950 TEST_CASE_ST(ut_setup, ut_teardown,
9951 test_snow3g_decryption_test_case_1_oop),
9953 TEST_CASE_ST(ut_setup, ut_teardown,
9954 test_snow3g_encryption_test_case_1_offset_oop),
9956 /** SNOW 3G decrypt only (UEA2) */
9957 TEST_CASE_ST(ut_setup, ut_teardown,
9958 test_snow3g_decryption_test_case_1),
9959 TEST_CASE_ST(ut_setup, ut_teardown,
9960 test_snow3g_decryption_test_case_2),
9961 TEST_CASE_ST(ut_setup, ut_teardown,
9962 test_snow3g_decryption_test_case_3),
9963 TEST_CASE_ST(ut_setup, ut_teardown,
9964 test_snow3g_decryption_test_case_4),
9965 TEST_CASE_ST(ut_setup, ut_teardown,
9966 test_snow3g_decryption_test_case_5),
9967 TEST_CASE_ST(ut_setup, ut_teardown,
9968 test_snow3g_decryption_with_digest_test_case_1),
9969 TEST_CASE_ST(ut_setup, ut_teardown,
9970 test_snow3g_hash_generate_test_case_1),
9971 TEST_CASE_ST(ut_setup, ut_teardown,
9972 test_snow3g_hash_generate_test_case_2),
9973 TEST_CASE_ST(ut_setup, ut_teardown,
9974 test_snow3g_hash_generate_test_case_3),
9975 /* Tests with buffers which length is not byte-aligned */
9976 TEST_CASE_ST(ut_setup, ut_teardown,
9977 test_snow3g_hash_generate_test_case_4),
9978 TEST_CASE_ST(ut_setup, ut_teardown,
9979 test_snow3g_hash_generate_test_case_5),
9980 TEST_CASE_ST(ut_setup, ut_teardown,
9981 test_snow3g_hash_generate_test_case_6),
9982 TEST_CASE_ST(ut_setup, ut_teardown,
9983 test_snow3g_hash_verify_test_case_1),
9984 TEST_CASE_ST(ut_setup, ut_teardown,
9985 test_snow3g_hash_verify_test_case_2),
9986 TEST_CASE_ST(ut_setup, ut_teardown,
9987 test_snow3g_hash_verify_test_case_3),
9988 /* Tests with buffers which length is not byte-aligned */
9989 TEST_CASE_ST(ut_setup, ut_teardown,
9990 test_snow3g_hash_verify_test_case_4),
9991 TEST_CASE_ST(ut_setup, ut_teardown,
9992 test_snow3g_hash_verify_test_case_5),
9993 TEST_CASE_ST(ut_setup, ut_teardown,
9994 test_snow3g_hash_verify_test_case_6),
9995 TEST_CASE_ST(ut_setup, ut_teardown,
9996 test_snow3g_cipher_auth_test_case_1),
9997 TEST_CASE_ST(ut_setup, ut_teardown,
9998 test_snow3g_auth_cipher_test_case_1),
10000 TEST_CASES_END() /**< NULL terminate unit test array */
10004 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
10005 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
10006 .setup = testsuite_setup,
10007 .teardown = testsuite_teardown,
10008 .unit_test_cases = {
10009 /** ZUC encrypt only (EEA3) */
10010 TEST_CASE_ST(ut_setup, ut_teardown,
10011 test_zuc_encryption_test_case_1),
10012 TEST_CASE_ST(ut_setup, ut_teardown,
10013 test_zuc_encryption_test_case_2),
10014 TEST_CASE_ST(ut_setup, ut_teardown,
10015 test_zuc_encryption_test_case_3),
10016 TEST_CASE_ST(ut_setup, ut_teardown,
10017 test_zuc_encryption_test_case_4),
10018 TEST_CASE_ST(ut_setup, ut_teardown,
10019 test_zuc_encryption_test_case_5),
10020 TEST_CASE_ST(ut_setup, ut_teardown,
10021 test_zuc_hash_generate_test_case_1),
10022 TEST_CASE_ST(ut_setup, ut_teardown,
10023 test_zuc_hash_generate_test_case_2),
10024 TEST_CASE_ST(ut_setup, ut_teardown,
10025 test_zuc_hash_generate_test_case_3),
10026 TEST_CASE_ST(ut_setup, ut_teardown,
10027 test_zuc_hash_generate_test_case_4),
10028 TEST_CASE_ST(ut_setup, ut_teardown,
10029 test_zuc_hash_generate_test_case_5),
10030 TEST_CASE_ST(ut_setup, ut_teardown,
10031 test_zuc_encryption_test_case_6_sgl),
10032 TEST_CASES_END() /**< NULL terminate unit test array */
10036 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
10037 .suite_name = "Crypto CAAM JR Unit Test Suite",
10038 .setup = testsuite_setup,
10039 .teardown = testsuite_teardown,
10040 .unit_test_cases = {
10041 TEST_CASE_ST(ut_setup, ut_teardown,
10042 test_device_configure_invalid_dev_id),
10043 TEST_CASE_ST(ut_setup, ut_teardown,
10044 test_multi_session),
10046 TEST_CASE_ST(ut_setup, ut_teardown,
10047 test_AES_chain_caam_jr_all),
10048 TEST_CASE_ST(ut_setup, ut_teardown,
10049 test_3DES_chain_caam_jr_all),
10050 TEST_CASE_ST(ut_setup, ut_teardown,
10051 test_AES_cipheronly_caam_jr_all),
10052 TEST_CASE_ST(ut_setup, ut_teardown,
10053 test_3DES_cipheronly_caam_jr_all),
10054 TEST_CASE_ST(ut_setup, ut_teardown,
10055 test_authonly_caam_jr_all),
10057 TEST_CASES_END() /**< NULL terminate unit test array */
10061 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
10062 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
10063 .setup = testsuite_setup,
10064 .teardown = testsuite_teardown,
10065 .unit_test_cases = {
10066 TEST_CASE_ST(ut_setup, ut_teardown,
10067 test_device_configure_invalid_dev_id),
10068 TEST_CASE_ST(ut_setup, ut_teardown,
10069 test_multi_session),
10071 TEST_CASE_ST(ut_setup, ut_teardown,
10072 test_AES_chain_dpaa_sec_all),
10073 TEST_CASE_ST(ut_setup, ut_teardown,
10074 test_3DES_chain_dpaa_sec_all),
10075 TEST_CASE_ST(ut_setup, ut_teardown,
10076 test_AES_cipheronly_dpaa_sec_all),
10077 TEST_CASE_ST(ut_setup, ut_teardown,
10078 test_3DES_cipheronly_dpaa_sec_all),
10079 TEST_CASE_ST(ut_setup, ut_teardown,
10080 test_authonly_dpaa_sec_all),
10082 /** AES GCM Authenticated Encryption */
10083 TEST_CASE_ST(ut_setup, ut_teardown,
10084 test_AES_GCM_authenticated_encryption_test_case_1),
10085 TEST_CASE_ST(ut_setup, ut_teardown,
10086 test_AES_GCM_authenticated_encryption_test_case_2),
10087 TEST_CASE_ST(ut_setup, ut_teardown,
10088 test_AES_GCM_authenticated_encryption_test_case_3),
10089 TEST_CASE_ST(ut_setup, ut_teardown,
10090 test_AES_GCM_authenticated_encryption_test_case_4),
10091 TEST_CASE_ST(ut_setup, ut_teardown,
10092 test_AES_GCM_authenticated_encryption_test_case_5),
10093 TEST_CASE_ST(ut_setup, ut_teardown,
10094 test_AES_GCM_authenticated_encryption_test_case_6),
10095 TEST_CASE_ST(ut_setup, ut_teardown,
10096 test_AES_GCM_authenticated_encryption_test_case_7),
10098 /** AES GCM Authenticated Decryption */
10099 TEST_CASE_ST(ut_setup, ut_teardown,
10100 test_AES_GCM_authenticated_decryption_test_case_1),
10101 TEST_CASE_ST(ut_setup, ut_teardown,
10102 test_AES_GCM_authenticated_decryption_test_case_2),
10103 TEST_CASE_ST(ut_setup, ut_teardown,
10104 test_AES_GCM_authenticated_decryption_test_case_3),
10105 TEST_CASE_ST(ut_setup, ut_teardown,
10106 test_AES_GCM_authenticated_decryption_test_case_4),
10107 TEST_CASE_ST(ut_setup, ut_teardown,
10108 test_AES_GCM_authenticated_decryption_test_case_5),
10109 TEST_CASE_ST(ut_setup, ut_teardown,
10110 test_AES_GCM_authenticated_decryption_test_case_6),
10111 TEST_CASE_ST(ut_setup, ut_teardown,
10112 test_AES_GCM_authenticated_decryption_test_case_7),
10114 /** AES GCM Authenticated Encryption 256 bits key */
10115 TEST_CASE_ST(ut_setup, ut_teardown,
10116 test_AES_GCM_auth_encryption_test_case_256_1),
10117 TEST_CASE_ST(ut_setup, ut_teardown,
10118 test_AES_GCM_auth_encryption_test_case_256_2),
10119 TEST_CASE_ST(ut_setup, ut_teardown,
10120 test_AES_GCM_auth_encryption_test_case_256_3),
10121 TEST_CASE_ST(ut_setup, ut_teardown,
10122 test_AES_GCM_auth_encryption_test_case_256_4),
10123 TEST_CASE_ST(ut_setup, ut_teardown,
10124 test_AES_GCM_auth_encryption_test_case_256_5),
10125 TEST_CASE_ST(ut_setup, ut_teardown,
10126 test_AES_GCM_auth_encryption_test_case_256_6),
10127 TEST_CASE_ST(ut_setup, ut_teardown,
10128 test_AES_GCM_auth_encryption_test_case_256_7),
10130 /** AES GCM Authenticated Decryption 256 bits key */
10131 TEST_CASE_ST(ut_setup, ut_teardown,
10132 test_AES_GCM_auth_decryption_test_case_256_1),
10133 TEST_CASE_ST(ut_setup, ut_teardown,
10134 test_AES_GCM_auth_decryption_test_case_256_2),
10135 TEST_CASE_ST(ut_setup, ut_teardown,
10136 test_AES_GCM_auth_decryption_test_case_256_3),
10137 TEST_CASE_ST(ut_setup, ut_teardown,
10138 test_AES_GCM_auth_decryption_test_case_256_4),
10139 TEST_CASE_ST(ut_setup, ut_teardown,
10140 test_AES_GCM_auth_decryption_test_case_256_5),
10141 TEST_CASE_ST(ut_setup, ut_teardown,
10142 test_AES_GCM_auth_decryption_test_case_256_6),
10143 TEST_CASE_ST(ut_setup, ut_teardown,
10144 test_AES_GCM_auth_decryption_test_case_256_7),
10146 /** Out of place tests */
10147 TEST_CASE_ST(ut_setup, ut_teardown,
10148 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10149 TEST_CASE_ST(ut_setup, ut_teardown,
10150 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10152 /** Scatter-Gather */
10153 TEST_CASE_ST(ut_setup, ut_teardown,
10154 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10155 TEST_CASE_ST(ut_setup, ut_teardown,
10156 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10157 TEST_CASE_ST(ut_setup, ut_teardown,
10158 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10159 TEST_CASE_ST(ut_setup, ut_teardown,
10160 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10162 TEST_CASES_END() /**< NULL terminate unit test array */
10166 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10167 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10168 .setup = testsuite_setup,
10169 .teardown = testsuite_teardown,
10170 .unit_test_cases = {
10171 TEST_CASE_ST(ut_setup, ut_teardown,
10172 test_device_configure_invalid_dev_id),
10173 TEST_CASE_ST(ut_setup, ut_teardown,
10174 test_multi_session),
10176 TEST_CASE_ST(ut_setup, ut_teardown,
10177 test_AES_chain_dpaa2_sec_all),
10178 TEST_CASE_ST(ut_setup, ut_teardown,
10179 test_3DES_chain_dpaa2_sec_all),
10180 TEST_CASE_ST(ut_setup, ut_teardown,
10181 test_AES_cipheronly_dpaa2_sec_all),
10182 TEST_CASE_ST(ut_setup, ut_teardown,
10183 test_3DES_cipheronly_dpaa2_sec_all),
10184 TEST_CASE_ST(ut_setup, ut_teardown,
10185 test_authonly_dpaa2_sec_all),
10187 /** AES GCM Authenticated Encryption */
10188 TEST_CASE_ST(ut_setup, ut_teardown,
10189 test_AES_GCM_authenticated_encryption_test_case_1),
10190 TEST_CASE_ST(ut_setup, ut_teardown,
10191 test_AES_GCM_authenticated_encryption_test_case_2),
10192 TEST_CASE_ST(ut_setup, ut_teardown,
10193 test_AES_GCM_authenticated_encryption_test_case_3),
10194 TEST_CASE_ST(ut_setup, ut_teardown,
10195 test_AES_GCM_authenticated_encryption_test_case_4),
10196 TEST_CASE_ST(ut_setup, ut_teardown,
10197 test_AES_GCM_authenticated_encryption_test_case_5),
10198 TEST_CASE_ST(ut_setup, ut_teardown,
10199 test_AES_GCM_authenticated_encryption_test_case_6),
10200 TEST_CASE_ST(ut_setup, ut_teardown,
10201 test_AES_GCM_authenticated_encryption_test_case_7),
10203 /** AES GCM Authenticated Decryption */
10204 TEST_CASE_ST(ut_setup, ut_teardown,
10205 test_AES_GCM_authenticated_decryption_test_case_1),
10206 TEST_CASE_ST(ut_setup, ut_teardown,
10207 test_AES_GCM_authenticated_decryption_test_case_2),
10208 TEST_CASE_ST(ut_setup, ut_teardown,
10209 test_AES_GCM_authenticated_decryption_test_case_3),
10210 TEST_CASE_ST(ut_setup, ut_teardown,
10211 test_AES_GCM_authenticated_decryption_test_case_4),
10212 TEST_CASE_ST(ut_setup, ut_teardown,
10213 test_AES_GCM_authenticated_decryption_test_case_5),
10214 TEST_CASE_ST(ut_setup, ut_teardown,
10215 test_AES_GCM_authenticated_decryption_test_case_6),
10216 TEST_CASE_ST(ut_setup, ut_teardown,
10217 test_AES_GCM_authenticated_decryption_test_case_7),
10219 /** AES GCM Authenticated Encryption 192 bits key */
10220 TEST_CASE_ST(ut_setup, ut_teardown,
10221 test_AES_GCM_auth_encryption_test_case_192_1),
10222 TEST_CASE_ST(ut_setup, ut_teardown,
10223 test_AES_GCM_auth_encryption_test_case_192_2),
10224 TEST_CASE_ST(ut_setup, ut_teardown,
10225 test_AES_GCM_auth_encryption_test_case_192_3),
10226 TEST_CASE_ST(ut_setup, ut_teardown,
10227 test_AES_GCM_auth_encryption_test_case_192_4),
10228 TEST_CASE_ST(ut_setup, ut_teardown,
10229 test_AES_GCM_auth_encryption_test_case_192_5),
10230 TEST_CASE_ST(ut_setup, ut_teardown,
10231 test_AES_GCM_auth_encryption_test_case_192_6),
10232 TEST_CASE_ST(ut_setup, ut_teardown,
10233 test_AES_GCM_auth_encryption_test_case_192_7),
10235 /** AES GCM Authenticated Decryption 192 bits key */
10236 TEST_CASE_ST(ut_setup, ut_teardown,
10237 test_AES_GCM_auth_decryption_test_case_192_1),
10238 TEST_CASE_ST(ut_setup, ut_teardown,
10239 test_AES_GCM_auth_decryption_test_case_192_2),
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 test_AES_GCM_auth_decryption_test_case_192_3),
10242 TEST_CASE_ST(ut_setup, ut_teardown,
10243 test_AES_GCM_auth_decryption_test_case_192_4),
10244 TEST_CASE_ST(ut_setup, ut_teardown,
10245 test_AES_GCM_auth_decryption_test_case_192_5),
10246 TEST_CASE_ST(ut_setup, ut_teardown,
10247 test_AES_GCM_auth_decryption_test_case_192_6),
10248 TEST_CASE_ST(ut_setup, ut_teardown,
10249 test_AES_GCM_auth_decryption_test_case_192_7),
10251 /** AES GCM Authenticated Encryption 256 bits key */
10252 TEST_CASE_ST(ut_setup, ut_teardown,
10253 test_AES_GCM_auth_encryption_test_case_256_1),
10254 TEST_CASE_ST(ut_setup, ut_teardown,
10255 test_AES_GCM_auth_encryption_test_case_256_2),
10256 TEST_CASE_ST(ut_setup, ut_teardown,
10257 test_AES_GCM_auth_encryption_test_case_256_3),
10258 TEST_CASE_ST(ut_setup, ut_teardown,
10259 test_AES_GCM_auth_encryption_test_case_256_4),
10260 TEST_CASE_ST(ut_setup, ut_teardown,
10261 test_AES_GCM_auth_encryption_test_case_256_5),
10262 TEST_CASE_ST(ut_setup, ut_teardown,
10263 test_AES_GCM_auth_encryption_test_case_256_6),
10264 TEST_CASE_ST(ut_setup, ut_teardown,
10265 test_AES_GCM_auth_encryption_test_case_256_7),
10267 /** AES GCM Authenticated Decryption 256 bits key */
10268 TEST_CASE_ST(ut_setup, ut_teardown,
10269 test_AES_GCM_auth_decryption_test_case_256_1),
10270 TEST_CASE_ST(ut_setup, ut_teardown,
10271 test_AES_GCM_auth_decryption_test_case_256_2),
10272 TEST_CASE_ST(ut_setup, ut_teardown,
10273 test_AES_GCM_auth_decryption_test_case_256_3),
10274 TEST_CASE_ST(ut_setup, ut_teardown,
10275 test_AES_GCM_auth_decryption_test_case_256_4),
10276 TEST_CASE_ST(ut_setup, ut_teardown,
10277 test_AES_GCM_auth_decryption_test_case_256_5),
10278 TEST_CASE_ST(ut_setup, ut_teardown,
10279 test_AES_GCM_auth_decryption_test_case_256_6),
10280 TEST_CASE_ST(ut_setup, ut_teardown,
10281 test_AES_GCM_auth_decryption_test_case_256_7),
10283 /** Out of place tests */
10284 TEST_CASE_ST(ut_setup, ut_teardown,
10285 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10286 TEST_CASE_ST(ut_setup, ut_teardown,
10287 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10289 /** Scatter-Gather */
10290 TEST_CASE_ST(ut_setup, ut_teardown,
10291 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10292 TEST_CASE_ST(ut_setup, ut_teardown,
10293 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10294 TEST_CASE_ST(ut_setup, ut_teardown,
10295 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10296 TEST_CASE_ST(ut_setup, ut_teardown,
10297 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10299 TEST_CASES_END() /**< NULL terminate unit test array */
10303 static struct unit_test_suite cryptodev_null_testsuite = {
10304 .suite_name = "Crypto Device NULL Unit Test Suite",
10305 .setup = testsuite_setup,
10306 .teardown = testsuite_teardown,
10307 .unit_test_cases = {
10308 TEST_CASE_ST(ut_setup, ut_teardown,
10309 test_null_auth_only_operation),
10310 TEST_CASE_ST(ut_setup, ut_teardown,
10311 test_null_cipher_only_operation),
10312 TEST_CASE_ST(ut_setup, ut_teardown,
10313 test_null_cipher_auth_operation),
10314 TEST_CASE_ST(ut_setup, ut_teardown,
10315 test_null_auth_cipher_operation),
10316 TEST_CASE_ST(ut_setup, ut_teardown,
10317 test_null_invalid_operation),
10318 TEST_CASE_ST(ut_setup, ut_teardown,
10319 test_null_burst_operation),
10321 TEST_CASES_END() /**< NULL terminate unit test array */
10325 static struct unit_test_suite cryptodev_armv8_testsuite = {
10326 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10327 .setup = testsuite_setup,
10328 .teardown = testsuite_teardown,
10329 .unit_test_cases = {
10330 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10332 /** Negative tests */
10333 TEST_CASE_ST(ut_setup, ut_teardown,
10334 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10335 TEST_CASE_ST(ut_setup, ut_teardown,
10336 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10338 TEST_CASES_END() /**< NULL terminate unit test array */
10342 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10343 .suite_name = "Crypto Device Marvell Component Test Suite",
10344 .setup = testsuite_setup,
10345 .teardown = testsuite_teardown,
10346 .unit_test_cases = {
10347 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10348 TEST_CASE_ST(ut_setup, ut_teardown,
10349 test_multi_session_random_usage),
10350 TEST_CASE_ST(ut_setup, ut_teardown,
10351 test_AES_chain_mrvl_all),
10352 TEST_CASE_ST(ut_setup, ut_teardown,
10353 test_AES_cipheronly_mrvl_all),
10354 TEST_CASE_ST(ut_setup, ut_teardown,
10355 test_authonly_mrvl_all),
10356 TEST_CASE_ST(ut_setup, ut_teardown,
10357 test_3DES_chain_mrvl_all),
10358 TEST_CASE_ST(ut_setup, ut_teardown,
10359 test_3DES_cipheronly_mrvl_all),
10361 /** Negative tests */
10362 TEST_CASE_ST(ut_setup, ut_teardown,
10363 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10364 TEST_CASE_ST(ut_setup, ut_teardown,
10365 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10366 TEST_CASE_ST(ut_setup, ut_teardown,
10367 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10368 TEST_CASE_ST(ut_setup, ut_teardown,
10369 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10371 TEST_CASES_END() /**< NULL terminate unit test array */
10375 static struct unit_test_suite cryptodev_ccp_testsuite = {
10376 .suite_name = "Crypto Device CCP Unit Test Suite",
10377 .setup = testsuite_setup,
10378 .teardown = testsuite_teardown,
10379 .unit_test_cases = {
10380 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10381 TEST_CASE_ST(ut_setup, ut_teardown,
10382 test_multi_session_random_usage),
10383 TEST_CASE_ST(ut_setup, ut_teardown,
10384 test_AES_chain_ccp_all),
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 test_AES_cipheronly_ccp_all),
10387 TEST_CASE_ST(ut_setup, ut_teardown,
10388 test_3DES_chain_ccp_all),
10389 TEST_CASE_ST(ut_setup, ut_teardown,
10390 test_3DES_cipheronly_ccp_all),
10391 TEST_CASE_ST(ut_setup, ut_teardown,
10392 test_authonly_ccp_all),
10394 /** Negative tests */
10395 TEST_CASE_ST(ut_setup, ut_teardown,
10396 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10397 TEST_CASE_ST(ut_setup, ut_teardown,
10398 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10399 TEST_CASE_ST(ut_setup, ut_teardown,
10400 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10401 TEST_CASE_ST(ut_setup, ut_teardown,
10402 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10404 TEST_CASES_END() /**< NULL terminate unit test array */
10408 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10409 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10410 .setup = testsuite_setup,
10411 .teardown = testsuite_teardown,
10412 .unit_test_cases = {
10413 TEST_CASE_ST(ut_setup, ut_teardown,
10414 test_AES_chain_octeontx_all),
10415 TEST_CASE_ST(ut_setup, ut_teardown,
10416 test_AES_cipheronly_octeontx_all),
10417 TEST_CASE_ST(ut_setup, ut_teardown,
10418 test_3DES_chain_octeontx_all),
10419 TEST_CASE_ST(ut_setup, ut_teardown,
10420 test_3DES_cipheronly_octeontx_all),
10421 TEST_CASE_ST(ut_setup, ut_teardown,
10422 test_authonly_octeontx_all),
10424 /** AES GCM Authenticated Encryption */
10425 TEST_CASE_ST(ut_setup, ut_teardown,
10426 test_AES_GCM_authenticated_encryption_test_case_1),
10427 TEST_CASE_ST(ut_setup, ut_teardown,
10428 test_AES_GCM_authenticated_encryption_test_case_2),
10429 TEST_CASE_ST(ut_setup, ut_teardown,
10430 test_AES_GCM_authenticated_encryption_test_case_3),
10431 TEST_CASE_ST(ut_setup, ut_teardown,
10432 test_AES_GCM_authenticated_encryption_test_case_4),
10433 TEST_CASE_ST(ut_setup, ut_teardown,
10434 test_AES_GCM_authenticated_encryption_test_case_5),
10435 TEST_CASE_ST(ut_setup, ut_teardown,
10436 test_AES_GCM_authenticated_encryption_test_case_6),
10437 TEST_CASE_ST(ut_setup, ut_teardown,
10438 test_AES_GCM_authenticated_encryption_test_case_7),
10440 /** AES GCM Authenticated Decryption */
10441 TEST_CASE_ST(ut_setup, ut_teardown,
10442 test_AES_GCM_authenticated_decryption_test_case_1),
10443 TEST_CASE_ST(ut_setup, ut_teardown,
10444 test_AES_GCM_authenticated_decryption_test_case_2),
10445 TEST_CASE_ST(ut_setup, ut_teardown,
10446 test_AES_GCM_authenticated_decryption_test_case_3),
10447 TEST_CASE_ST(ut_setup, ut_teardown,
10448 test_AES_GCM_authenticated_decryption_test_case_4),
10449 TEST_CASE_ST(ut_setup, ut_teardown,
10450 test_AES_GCM_authenticated_decryption_test_case_5),
10451 TEST_CASE_ST(ut_setup, ut_teardown,
10452 test_AES_GCM_authenticated_decryption_test_case_6),
10453 TEST_CASE_ST(ut_setup, ut_teardown,
10454 test_AES_GCM_authenticated_decryption_test_case_7),
10455 /** AES GMAC Authentication */
10456 TEST_CASE_ST(ut_setup, ut_teardown,
10457 test_AES_GMAC_authentication_test_case_1),
10458 TEST_CASE_ST(ut_setup, ut_teardown,
10459 test_AES_GMAC_authentication_verify_test_case_1),
10460 TEST_CASE_ST(ut_setup, ut_teardown,
10461 test_AES_GMAC_authentication_test_case_2),
10462 TEST_CASE_ST(ut_setup, ut_teardown,
10463 test_AES_GMAC_authentication_verify_test_case_2),
10464 TEST_CASE_ST(ut_setup, ut_teardown,
10465 test_AES_GMAC_authentication_test_case_3),
10466 TEST_CASE_ST(ut_setup, ut_teardown,
10467 test_AES_GMAC_authentication_verify_test_case_3),
10469 /** SNOW 3G encrypt only (UEA2) */
10470 TEST_CASE_ST(ut_setup, ut_teardown,
10471 test_snow3g_encryption_test_case_1),
10472 TEST_CASE_ST(ut_setup, ut_teardown,
10473 test_snow3g_encryption_test_case_2),
10474 TEST_CASE_ST(ut_setup, ut_teardown,
10475 test_snow3g_encryption_test_case_3),
10476 TEST_CASE_ST(ut_setup, ut_teardown,
10477 test_snow3g_encryption_test_case_4),
10478 TEST_CASE_ST(ut_setup, ut_teardown,
10479 test_snow3g_encryption_test_case_5),
10481 TEST_CASE_ST(ut_setup, ut_teardown,
10482 test_snow3g_encryption_test_case_1_oop),
10483 TEST_CASE_ST(ut_setup, ut_teardown,
10484 test_snow3g_decryption_test_case_1_oop),
10485 TEST_CASE_ST(ut_setup, ut_teardown,
10486 test_snow3g_encryption_test_case_1_oop_sgl),
10488 /** SNOW 3G decrypt only (UEA2) */
10489 TEST_CASE_ST(ut_setup, ut_teardown,
10490 test_snow3g_decryption_test_case_1),
10491 TEST_CASE_ST(ut_setup, ut_teardown,
10492 test_snow3g_decryption_test_case_2),
10493 TEST_CASE_ST(ut_setup, ut_teardown,
10494 test_snow3g_decryption_test_case_3),
10495 TEST_CASE_ST(ut_setup, ut_teardown,
10496 test_snow3g_decryption_test_case_4),
10497 TEST_CASE_ST(ut_setup, ut_teardown,
10498 test_snow3g_decryption_test_case_5),
10500 TEST_CASE_ST(ut_setup, ut_teardown,
10501 test_snow3g_hash_generate_test_case_1),
10502 TEST_CASE_ST(ut_setup, ut_teardown,
10503 test_snow3g_hash_generate_test_case_2),
10504 TEST_CASE_ST(ut_setup, ut_teardown,
10505 test_snow3g_hash_generate_test_case_3),
10506 TEST_CASE_ST(ut_setup, ut_teardown,
10507 test_snow3g_hash_verify_test_case_1),
10508 TEST_CASE_ST(ut_setup, ut_teardown,
10509 test_snow3g_hash_verify_test_case_2),
10510 TEST_CASE_ST(ut_setup, ut_teardown,
10511 test_snow3g_hash_verify_test_case_3),
10513 /** ZUC encrypt only (EEA3) */
10514 TEST_CASE_ST(ut_setup, ut_teardown,
10515 test_zuc_encryption_test_case_1),
10516 TEST_CASE_ST(ut_setup, ut_teardown,
10517 test_zuc_encryption_test_case_2),
10518 TEST_CASE_ST(ut_setup, ut_teardown,
10519 test_zuc_encryption_test_case_3),
10520 TEST_CASE_ST(ut_setup, ut_teardown,
10521 test_zuc_encryption_test_case_4),
10522 TEST_CASE_ST(ut_setup, ut_teardown,
10523 test_zuc_encryption_test_case_5),
10524 TEST_CASE_ST(ut_setup, ut_teardown,
10525 test_zuc_hash_generate_test_case_1),
10526 TEST_CASE_ST(ut_setup, ut_teardown,
10527 test_zuc_hash_generate_test_case_2),
10528 TEST_CASE_ST(ut_setup, ut_teardown,
10529 test_zuc_hash_generate_test_case_3),
10530 TEST_CASE_ST(ut_setup, ut_teardown,
10531 test_zuc_hash_generate_test_case_4),
10532 TEST_CASE_ST(ut_setup, ut_teardown,
10533 test_zuc_hash_generate_test_case_5),
10534 TEST_CASE_ST(ut_setup, ut_teardown,
10535 test_zuc_encryption_test_case_6_sgl),
10537 /** KASUMI encrypt only (UEA1) */
10538 TEST_CASE_ST(ut_setup, ut_teardown,
10539 test_kasumi_encryption_test_case_1),
10540 TEST_CASE_ST(ut_setup, ut_teardown,
10541 test_kasumi_encryption_test_case_2),
10542 TEST_CASE_ST(ut_setup, ut_teardown,
10543 test_kasumi_encryption_test_case_3),
10544 TEST_CASE_ST(ut_setup, ut_teardown,
10545 test_kasumi_encryption_test_case_4),
10546 TEST_CASE_ST(ut_setup, ut_teardown,
10547 test_kasumi_encryption_test_case_5),
10548 TEST_CASE_ST(ut_setup, ut_teardown,
10549 test_kasumi_encryption_test_case_1_sgl),
10550 TEST_CASE_ST(ut_setup, ut_teardown,
10551 test_kasumi_encryption_test_case_1_oop_sgl),
10552 /** KASUMI decrypt only (UEA1) */
10553 TEST_CASE_ST(ut_setup, ut_teardown,
10554 test_kasumi_decryption_test_case_1),
10555 TEST_CASE_ST(ut_setup, ut_teardown,
10556 test_kasumi_decryption_test_case_2),
10557 TEST_CASE_ST(ut_setup, ut_teardown,
10558 test_kasumi_decryption_test_case_3),
10559 TEST_CASE_ST(ut_setup, ut_teardown,
10560 test_kasumi_decryption_test_case_4),
10561 TEST_CASE_ST(ut_setup, ut_teardown,
10562 test_kasumi_decryption_test_case_5),
10564 TEST_CASE_ST(ut_setup, ut_teardown,
10565 test_kasumi_encryption_test_case_1_oop),
10566 TEST_CASE_ST(ut_setup, ut_teardown,
10567 test_kasumi_decryption_test_case_1_oop),
10569 /** KASUMI hash only (UIA1) */
10570 TEST_CASE_ST(ut_setup, ut_teardown,
10571 test_kasumi_hash_generate_test_case_1),
10572 TEST_CASE_ST(ut_setup, ut_teardown,
10573 test_kasumi_hash_generate_test_case_2),
10574 TEST_CASE_ST(ut_setup, ut_teardown,
10575 test_kasumi_hash_generate_test_case_3),
10576 TEST_CASE_ST(ut_setup, ut_teardown,
10577 test_kasumi_hash_generate_test_case_4),
10578 TEST_CASE_ST(ut_setup, ut_teardown,
10579 test_kasumi_hash_generate_test_case_5),
10580 TEST_CASE_ST(ut_setup, ut_teardown,
10581 test_kasumi_hash_generate_test_case_6),
10582 TEST_CASE_ST(ut_setup, ut_teardown,
10583 test_kasumi_hash_verify_test_case_1),
10584 TEST_CASE_ST(ut_setup, ut_teardown,
10585 test_kasumi_hash_verify_test_case_2),
10586 TEST_CASE_ST(ut_setup, ut_teardown,
10587 test_kasumi_hash_verify_test_case_3),
10588 TEST_CASE_ST(ut_setup, ut_teardown,
10589 test_kasumi_hash_verify_test_case_4),
10590 TEST_CASE_ST(ut_setup, ut_teardown,
10591 test_kasumi_hash_verify_test_case_5),
10594 TEST_CASE_ST(ut_setup, ut_teardown,
10595 test_null_cipher_only_operation),
10596 TEST_CASE_ST(ut_setup, ut_teardown,
10597 test_null_auth_only_operation),
10598 TEST_CASE_ST(ut_setup, ut_teardown,
10599 test_null_cipher_auth_operation),
10600 TEST_CASE_ST(ut_setup, ut_teardown,
10601 test_null_auth_cipher_operation),
10603 /** Negative tests */
10604 TEST_CASE_ST(ut_setup, ut_teardown,
10605 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10606 TEST_CASE_ST(ut_setup, ut_teardown,
10607 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10608 TEST_CASE_ST(ut_setup, ut_teardown,
10609 authentication_verify_AES128_GMAC_fail_data_corrupt),
10610 TEST_CASE_ST(ut_setup, ut_teardown,
10611 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10612 TEST_CASE_ST(ut_setup, ut_teardown,
10613 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10614 TEST_CASE_ST(ut_setup, ut_teardown,
10615 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10616 TEST_CASES_END() /**< NULL terminate unit test array */
10621 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10623 gbl_driver_id = rte_cryptodev_driver_id_get(
10624 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10626 if (gbl_driver_id == -1) {
10627 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10628 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10629 "are enabled in config file to run this testsuite.\n");
10630 return TEST_SKIPPED;
10633 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10637 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10639 gbl_driver_id = rte_cryptodev_driver_id_get(
10640 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10642 if (gbl_driver_id == -1) {
10643 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10644 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10645 "in config file to run this testsuite.\n");
10646 return TEST_FAILED;
10649 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10653 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10655 gbl_driver_id = rte_cryptodev_driver_id_get(
10656 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10658 if (gbl_driver_id == -1) {
10659 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10660 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10661 "in config file to run this testsuite.\n");
10662 return TEST_SKIPPED;
10665 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10669 test_cryptodev_openssl(void)
10671 gbl_driver_id = rte_cryptodev_driver_id_get(
10672 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10674 if (gbl_driver_id == -1) {
10675 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10676 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10677 "in config file to run this testsuite.\n");
10678 return TEST_SKIPPED;
10681 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10685 test_cryptodev_aesni_gcm(void)
10687 gbl_driver_id = rte_cryptodev_driver_id_get(
10688 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10690 if (gbl_driver_id == -1) {
10691 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10692 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10693 "in config file to run this testsuite.\n");
10694 return TEST_SKIPPED;
10697 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10701 test_cryptodev_null(void)
10703 gbl_driver_id = rte_cryptodev_driver_id_get(
10704 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10706 if (gbl_driver_id == -1) {
10707 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10708 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10709 "in config file to run this testsuite.\n");
10710 return TEST_SKIPPED;
10713 return unit_test_suite_runner(&cryptodev_null_testsuite);
10717 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10719 gbl_driver_id = rte_cryptodev_driver_id_get(
10720 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10722 if (gbl_driver_id == -1) {
10723 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10724 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10725 "in config file to run this testsuite.\n");
10726 return TEST_SKIPPED;
10729 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10733 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10735 gbl_driver_id = rte_cryptodev_driver_id_get(
10736 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10738 if (gbl_driver_id == -1) {
10739 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10740 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10741 "in config file to run this testsuite.\n");
10742 return TEST_SKIPPED;
10745 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10749 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10751 gbl_driver_id = rte_cryptodev_driver_id_get(
10752 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10754 if (gbl_driver_id == -1) {
10755 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10756 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10757 "in config file to run this testsuite.\n");
10758 return TEST_SKIPPED;
10761 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10765 test_cryptodev_armv8(void)
10767 gbl_driver_id = rte_cryptodev_driver_id_get(
10768 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10770 if (gbl_driver_id == -1) {
10771 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10772 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10773 "in config file to run this testsuite.\n");
10774 return TEST_SKIPPED;
10777 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10781 test_cryptodev_mrvl(void)
10783 gbl_driver_id = rte_cryptodev_driver_id_get(
10784 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10786 if (gbl_driver_id == -1) {
10787 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10788 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10789 "in config file to run this testsuite.\n");
10790 return TEST_SKIPPED;
10793 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10796 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10799 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10801 gbl_driver_id = rte_cryptodev_driver_id_get(
10802 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10804 if (gbl_driver_id == -1) {
10805 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10806 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10807 "in config file to run this testsuite.\n");
10808 return TEST_SKIPPED;
10811 if (rte_cryptodev_driver_id_get(
10812 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10813 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10814 " enabled in config file to run this testsuite.\n");
10815 return TEST_SKIPPED;
10817 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10820 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10825 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10827 gbl_driver_id = rte_cryptodev_driver_id_get(
10828 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10830 if (gbl_driver_id == -1) {
10831 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10832 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10833 "in config file to run this testsuite.\n");
10834 return TEST_SKIPPED;
10837 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10841 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10843 gbl_driver_id = rte_cryptodev_driver_id_get(
10844 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10846 if (gbl_driver_id == -1) {
10847 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10848 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10849 "in config file to run this testsuite.\n");
10850 return TEST_SKIPPED;
10853 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10857 test_cryptodev_ccp(void)
10859 gbl_driver_id = rte_cryptodev_driver_id_get(
10860 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10862 if (gbl_driver_id == -1) {
10863 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10864 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10865 "in config file to run this testsuite.\n");
10866 return TEST_FAILED;
10869 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10873 test_cryptodev_octeontx(void)
10875 gbl_driver_id = rte_cryptodev_driver_id_get(
10876 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10877 if (gbl_driver_id == -1) {
10878 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10879 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10880 "enabled in config file to run this "
10882 return TEST_FAILED;
10884 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10888 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10890 gbl_driver_id = rte_cryptodev_driver_id_get(
10891 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10893 if (gbl_driver_id == -1) {
10894 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10895 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10896 "in config file to run this testsuite.\n");
10897 return TEST_FAILED;
10900 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10903 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10904 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10905 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10906 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10907 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10908 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10909 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10910 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10911 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10912 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10913 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10914 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10915 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10916 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10917 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10918 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);