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 = lcore_config[i].socket_id;
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(ERR, 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;
434 unsigned int session_size =
435 rte_cryptodev_sym_get_private_session_size(dev_id);
438 * Create mempool with maximum number of sessions * 2,
439 * to include the session headers
441 if (info.sym.max_nb_sessions != 0 &&
442 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
443 RTE_LOG(ERR, USER1, "Device does not support "
444 "at least %u sessions\n",
449 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
450 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
452 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
453 "session mempool allocation failed");
455 ts_params->session_priv_mpool = rte_mempool_create(
459 0, 0, NULL, NULL, NULL,
462 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
463 "session mempool allocation failed");
467 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
469 "Failed to configure cryptodev %u with %u qps",
470 dev_id, ts_params->conf.nb_queue_pairs);
472 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
473 ts_params->qp_conf.mp_session = ts_params->session_mpool;
474 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
476 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
477 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
478 dev_id, qp_id, &ts_params->qp_conf,
479 rte_cryptodev_socket_id(dev_id)),
480 "Failed to setup queue pair %u on cryptodev %u",
488 testsuite_teardown(void)
490 struct crypto_testsuite_params *ts_params = &testsuite_params;
492 if (ts_params->mbuf_pool != NULL) {
493 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
494 rte_mempool_avail_count(ts_params->mbuf_pool));
497 if (ts_params->op_mpool != NULL) {
498 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
499 rte_mempool_avail_count(ts_params->op_mpool));
502 /* Free session mempools */
503 if (ts_params->session_priv_mpool != NULL) {
504 rte_mempool_free(ts_params->session_priv_mpool);
505 ts_params->session_priv_mpool = NULL;
508 if (ts_params->session_mpool != NULL) {
509 rte_mempool_free(ts_params->session_mpool);
510 ts_params->session_mpool = NULL;
517 struct crypto_testsuite_params *ts_params = &testsuite_params;
518 struct crypto_unittest_params *ut_params = &unittest_params;
522 /* Clear unit test parameters before running test */
523 memset(ut_params, 0, sizeof(*ut_params));
525 /* Reconfigure device to default parameters */
526 ts_params->conf.socket_id = SOCKET_ID_ANY;
527 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
528 ts_params->qp_conf.mp_session = ts_params->session_mpool;
529 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
531 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
533 "Failed to configure cryptodev %u",
534 ts_params->valid_devs[0]);
536 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
537 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
538 ts_params->valid_devs[0], qp_id,
540 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
541 "Failed to setup queue pair %u on cryptodev %u",
542 qp_id, ts_params->valid_devs[0]);
546 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
548 /* Start the device */
549 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
550 "Failed to start cryptodev %u",
551 ts_params->valid_devs[0]);
559 struct crypto_testsuite_params *ts_params = &testsuite_params;
560 struct crypto_unittest_params *ut_params = &unittest_params;
561 struct rte_cryptodev_stats stats;
563 /* free crypto session structure */
564 if (ut_params->sess) {
565 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
567 rte_cryptodev_sym_session_free(ut_params->sess);
568 ut_params->sess = NULL;
571 /* free crypto operation structure */
573 rte_crypto_op_free(ut_params->op);
576 * free mbuf - both obuf and ibuf are usually the same,
577 * so check if they point at the same address is necessary,
578 * to avoid freeing the mbuf twice.
580 if (ut_params->obuf) {
581 rte_pktmbuf_free(ut_params->obuf);
582 if (ut_params->ibuf == ut_params->obuf)
586 if (ut_params->ibuf) {
587 rte_pktmbuf_free(ut_params->ibuf);
591 if (ts_params->mbuf_pool != NULL)
592 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
593 rte_mempool_avail_count(ts_params->mbuf_pool));
595 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
597 /* Stop the device */
598 rte_cryptodev_stop(ts_params->valid_devs[0]);
602 test_device_configure_invalid_dev_id(void)
604 struct crypto_testsuite_params *ts_params = &testsuite_params;
605 uint16_t dev_id, num_devs = 0;
607 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
608 "Need at least %d devices for test", 1);
610 /* valid dev_id values */
611 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
613 /* Stop the device in case it's started so it can be configured */
614 rte_cryptodev_stop(dev_id);
616 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
617 "Failed test for rte_cryptodev_configure: "
618 "invalid dev_num %u", dev_id);
620 /* invalid dev_id values */
623 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
624 "Failed test for rte_cryptodev_configure: "
625 "invalid dev_num %u", dev_id);
629 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
630 "Failed test for rte_cryptodev_configure:"
631 "invalid dev_num %u", dev_id);
637 test_device_configure_invalid_queue_pair_ids(void)
639 struct crypto_testsuite_params *ts_params = &testsuite_params;
640 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
642 /* Stop the device in case it's started so it can be configured */
643 rte_cryptodev_stop(ts_params->valid_devs[0]);
645 /* valid - one queue pairs */
646 ts_params->conf.nb_queue_pairs = 1;
648 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
650 "Failed to configure cryptodev: dev_id %u, qp_id %u",
651 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
654 /* valid - max value queue pairs */
655 ts_params->conf.nb_queue_pairs = orig_nb_qps;
657 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
659 "Failed to configure cryptodev: dev_id %u, qp_id %u",
660 ts_params->valid_devs[0],
661 ts_params->conf.nb_queue_pairs);
664 /* invalid - zero queue pairs */
665 ts_params->conf.nb_queue_pairs = 0;
667 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
669 "Failed test for rte_cryptodev_configure, dev_id %u,"
671 ts_params->valid_devs[0],
672 ts_params->conf.nb_queue_pairs);
675 /* invalid - max value supported by field queue pairs */
676 ts_params->conf.nb_queue_pairs = UINT16_MAX;
678 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
680 "Failed test for rte_cryptodev_configure, dev_id %u,"
682 ts_params->valid_devs[0],
683 ts_params->conf.nb_queue_pairs);
686 /* invalid - max value + 1 queue pairs */
687 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
689 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
691 "Failed test for rte_cryptodev_configure, dev_id %u,"
693 ts_params->valid_devs[0],
694 ts_params->conf.nb_queue_pairs);
696 /* revert to original testsuite value */
697 ts_params->conf.nb_queue_pairs = orig_nb_qps;
703 test_queue_pair_descriptor_setup(void)
705 struct crypto_testsuite_params *ts_params = &testsuite_params;
706 struct rte_cryptodev_info dev_info;
707 struct rte_cryptodev_qp_conf qp_conf = {
708 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
713 /* Stop the device in case it's started so it can be configured */
714 rte_cryptodev_stop(ts_params->valid_devs[0]);
717 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
719 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
721 "Failed to configure cryptodev %u",
722 ts_params->valid_devs[0]);
725 * Test various ring sizes on this device. memzones can't be
726 * freed so are re-used if ring is released and re-created.
728 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
729 qp_conf.mp_session = ts_params->session_mpool;
730 qp_conf.mp_session_private = ts_params->session_priv_mpool;
732 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
733 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
734 ts_params->valid_devs[0], qp_id, &qp_conf,
735 rte_cryptodev_socket_id(
736 ts_params->valid_devs[0])),
738 "rte_cryptodev_queue_pair_setup: num_inflights "
739 "%u on qp %u on cryptodev %u",
740 qp_conf.nb_descriptors, qp_id,
741 ts_params->valid_devs[0]);
744 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
746 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
747 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
748 ts_params->valid_devs[0], qp_id, &qp_conf,
749 rte_cryptodev_socket_id(
750 ts_params->valid_devs[0])),
752 " rte_cryptodev_queue_pair_setup: num_inflights"
753 " %u on qp %u on cryptodev %u",
754 qp_conf.nb_descriptors, qp_id,
755 ts_params->valid_devs[0]);
758 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
760 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
761 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
762 ts_params->valid_devs[0], qp_id, &qp_conf,
763 rte_cryptodev_socket_id(
764 ts_params->valid_devs[0])),
766 "rte_cryptodev_queue_pair_setup: num_inflights"
767 " %u on qp %u on cryptodev %u",
768 qp_conf.nb_descriptors, qp_id,
769 ts_params->valid_devs[0]);
772 /* invalid number of descriptors - max supported + 2 */
773 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
775 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
776 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
777 ts_params->valid_devs[0], qp_id, &qp_conf,
778 rte_cryptodev_socket_id(
779 ts_params->valid_devs[0])),
780 "Unexpectedly passed test for "
781 "rte_cryptodev_queue_pair_setup:"
782 "num_inflights %u on qp %u on cryptodev %u",
783 qp_conf.nb_descriptors, qp_id,
784 ts_params->valid_devs[0]);
787 /* invalid number of descriptors - max value of parameter */
788 qp_conf.nb_descriptors = UINT32_MAX-1;
790 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
791 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
792 ts_params->valid_devs[0], qp_id, &qp_conf,
793 rte_cryptodev_socket_id(
794 ts_params->valid_devs[0])),
795 "Unexpectedly passed test for "
796 "rte_cryptodev_queue_pair_setup:"
797 "num_inflights %u on qp %u on cryptodev %u",
798 qp_conf.nb_descriptors, qp_id,
799 ts_params->valid_devs[0]);
802 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
804 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
805 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
806 ts_params->valid_devs[0], qp_id, &qp_conf,
807 rte_cryptodev_socket_id(
808 ts_params->valid_devs[0])),
810 " rte_cryptodev_queue_pair_setup:"
811 "num_inflights %u on qp %u on cryptodev %u",
812 qp_conf.nb_descriptors, qp_id,
813 ts_params->valid_devs[0]);
816 /* invalid number of descriptors - max supported + 1 */
817 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
819 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
820 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
821 ts_params->valid_devs[0], qp_id, &qp_conf,
822 rte_cryptodev_socket_id(
823 ts_params->valid_devs[0])),
824 "Unexpectedly passed test for "
825 "rte_cryptodev_queue_pair_setup:"
826 "num_inflights %u on qp %u on cryptodev %u",
827 qp_conf.nb_descriptors, qp_id,
828 ts_params->valid_devs[0]);
831 /* test invalid queue pair id */
832 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
834 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
836 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
837 ts_params->valid_devs[0],
839 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
840 "Failed test for rte_cryptodev_queue_pair_setup:"
841 "invalid qp %u on cryptodev %u",
842 qp_id, ts_params->valid_devs[0]);
844 qp_id = 0xffff; /*invalid*/
846 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
847 ts_params->valid_devs[0],
849 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
850 "Failed test for rte_cryptodev_queue_pair_setup:"
851 "invalid qp %u on cryptodev %u",
852 qp_id, ts_params->valid_devs[0]);
857 /* ***** Plaintext data for tests ***** */
859 const char catch_22_quote_1[] =
860 "There was only one catch and that was Catch-22, which "
861 "specified that a concern for one's safety in the face of "
862 "dangers that were real and immediate was the process of a "
863 "rational mind. Orr was crazy and could be grounded. All he "
864 "had to do was ask; and as soon as he did, he would no longer "
865 "be crazy and would have to fly more missions. Orr would be "
866 "crazy to fly more missions and sane if he didn't, but if he "
867 "was sane he had to fly them. If he flew them he was crazy "
868 "and didn't have to; but if he didn't want to he was sane and "
869 "had to. Yossarian was moved very deeply by the absolute "
870 "simplicity of this clause of Catch-22 and let out a "
871 "respectful whistle. \"That's some catch, that Catch-22\", he "
872 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
874 const char catch_22_quote[] =
875 "What a lousy earth! He wondered how many people were "
876 "destitute that same night even in his own prosperous country, "
877 "how many homes were shanties, how many husbands were drunk "
878 "and wives socked, and how many children were bullied, abused, "
879 "or abandoned. How many families hungered for food they could "
880 "not afford to buy? How many hearts were broken? How many "
881 "suicides would take place that same night, how many people "
882 "would go insane? How many cockroaches and landlords would "
883 "triumph? How many winners were losers, successes failures, "
884 "and rich men poor men? How many wise guys were stupid? How "
885 "many happy endings were unhappy endings? How many honest men "
886 "were liars, brave men cowards, loyal men traitors, how many "
887 "sainted men were corrupt, how many people in positions of "
888 "trust had sold their souls to bodyguards, how many had never "
889 "had souls? How many straight-and-narrow paths were crooked "
890 "paths? How many best families were worst families and how "
891 "many good people were bad people? When you added them all up "
892 "and then subtracted, you might be left with only the children, "
893 "and perhaps with Albert Einstein and an old violinist or "
894 "sculptor somewhere.";
896 #define QUOTE_480_BYTES (480)
897 #define QUOTE_512_BYTES (512)
898 #define QUOTE_768_BYTES (768)
899 #define QUOTE_1024_BYTES (1024)
903 /* ***** SHA1 Hash Tests ***** */
905 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
907 static uint8_t hmac_sha1_key[] = {
908 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
909 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
910 0xDE, 0xF4, 0xDE, 0xAD };
912 /* ***** SHA224 Hash Tests ***** */
914 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
917 /* ***** AES-CBC Cipher Tests ***** */
919 #define CIPHER_KEY_LENGTH_AES_CBC (16)
920 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
922 static uint8_t aes_cbc_key[] = {
923 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
924 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
926 static uint8_t aes_cbc_iv[] = {
927 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
928 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
931 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
933 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
934 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
935 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
936 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
937 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
938 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
939 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
940 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
941 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
942 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
943 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
944 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
945 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
946 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
947 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
948 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
949 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
950 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
951 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
952 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
953 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
954 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
955 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
956 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
957 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
958 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
959 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
960 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
961 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
962 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
963 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
964 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
965 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
966 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
967 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
968 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
969 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
970 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
971 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
972 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
973 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
974 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
975 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
976 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
977 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
978 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
979 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
980 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
981 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
982 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
983 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
984 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
985 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
986 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
987 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
988 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
989 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
990 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
991 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
992 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
993 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
994 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
995 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
996 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
997 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1000 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1001 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1002 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1003 0x18, 0x8c, 0x1d, 0x32
1007 /* Multisession Vector context Test */
1008 /*Begin Session 0 */
1009 static uint8_t ms_aes_cbc_key0[] = {
1010 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1011 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1014 static uint8_t ms_aes_cbc_iv0[] = {
1015 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1016 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1019 static const uint8_t ms_aes_cbc_cipher0[] = {
1020 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1021 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1022 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1023 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1024 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1025 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1026 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1027 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1028 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1029 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1030 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1031 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1032 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1033 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1034 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1035 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1036 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1037 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1038 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1039 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1040 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1041 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1042 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1043 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1044 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1045 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1046 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1047 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1048 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1049 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1050 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1051 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1052 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1053 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1054 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1055 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1056 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1057 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1058 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1059 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1060 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1061 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1062 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1063 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1064 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1065 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1066 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1067 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1068 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1069 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1070 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1071 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1072 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1073 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1074 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1075 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1076 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1077 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1078 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1079 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1080 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1081 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1082 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1083 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1087 static uint8_t ms_hmac_key0[] = {
1088 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1089 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1090 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1091 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1092 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1093 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1094 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1095 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1098 static const uint8_t ms_hmac_digest0[] = {
1099 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1100 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1101 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1102 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1103 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1104 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1105 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1106 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1110 /* Begin session 1 */
1112 static uint8_t ms_aes_cbc_key1[] = {
1113 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1114 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1117 static uint8_t ms_aes_cbc_iv1[] = {
1118 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1119 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1122 static const uint8_t ms_aes_cbc_cipher1[] = {
1123 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1124 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1125 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1126 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1127 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1128 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1129 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1130 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1131 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1132 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1133 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1134 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1135 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1136 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1137 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1138 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1139 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1140 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1141 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1142 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1143 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1144 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1145 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1146 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1147 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1148 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1149 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1150 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1151 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1152 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1153 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1154 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1155 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1156 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1157 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1158 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1159 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1160 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1161 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1162 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1163 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1164 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1165 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1166 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1167 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1168 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1169 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1170 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1171 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1172 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1173 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1174 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1175 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1176 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1177 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1178 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1179 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1180 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1181 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1182 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1183 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1184 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1185 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1186 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1190 static uint8_t ms_hmac_key1[] = {
1191 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1192 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1193 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1194 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1195 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1196 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1197 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1198 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1201 static const uint8_t ms_hmac_digest1[] = {
1202 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1203 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1204 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1205 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1206 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1207 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1208 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1209 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1212 /* Begin Session 2 */
1213 static uint8_t ms_aes_cbc_key2[] = {
1214 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1215 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1218 static uint8_t ms_aes_cbc_iv2[] = {
1219 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1220 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1223 static const uint8_t ms_aes_cbc_cipher2[] = {
1224 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1225 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1226 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1227 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1228 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1229 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1230 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1231 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1232 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1233 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1234 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1235 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1236 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1237 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1238 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1239 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1240 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1241 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1242 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1243 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1244 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1245 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1246 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1247 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1248 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1249 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1250 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1251 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1252 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1253 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1254 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1255 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1256 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1257 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1258 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1259 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1260 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1261 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1262 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1263 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1264 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1265 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1266 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1267 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1268 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1269 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1270 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1271 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1272 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1273 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1274 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1275 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1276 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1277 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1278 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1279 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1280 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1281 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1282 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1283 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1284 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1285 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1286 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1287 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1290 static uint8_t ms_hmac_key2[] = {
1291 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1292 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1293 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1294 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1295 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1296 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1297 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1298 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1301 static const uint8_t ms_hmac_digest2[] = {
1302 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1303 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1304 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1305 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1306 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1307 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1308 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1309 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1316 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1318 struct crypto_testsuite_params *ts_params = &testsuite_params;
1319 struct crypto_unittest_params *ut_params = &unittest_params;
1321 /* Generate test mbuf data and space for digest */
1322 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1323 catch_22_quote, QUOTE_512_BYTES, 0);
1325 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1326 DIGEST_BYTE_LENGTH_SHA1);
1327 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1329 /* Setup Cipher Parameters */
1330 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1331 ut_params->cipher_xform.next = &ut_params->auth_xform;
1333 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1334 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1335 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1336 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1337 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1338 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1340 /* Setup HMAC Parameters */
1341 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1343 ut_params->auth_xform.next = NULL;
1345 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1346 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1347 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1348 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1349 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1351 ut_params->sess = rte_cryptodev_sym_session_create(
1352 ts_params->session_mpool);
1354 /* Create crypto session*/
1355 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1356 ut_params->sess, &ut_params->cipher_xform,
1357 ts_params->session_priv_mpool);
1358 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1360 /* Generate crypto op data structure */
1361 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1362 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1363 TEST_ASSERT_NOT_NULL(ut_params->op,
1364 "Failed to allocate symmetric crypto operation struct");
1366 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1368 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1370 /* set crypto operation source mbuf */
1371 sym_op->m_src = ut_params->ibuf;
1373 /* Set crypto operation authentication parameters */
1374 sym_op->auth.digest.data = ut_params->digest;
1375 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1376 ut_params->ibuf, QUOTE_512_BYTES);
1378 sym_op->auth.data.offset = 0;
1379 sym_op->auth.data.length = QUOTE_512_BYTES;
1381 /* Copy IV at the end of the crypto operation */
1382 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1383 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1385 /* Set crypto operation cipher parameters */
1386 sym_op->cipher.data.offset = 0;
1387 sym_op->cipher.data.length = QUOTE_512_BYTES;
1389 /* Process crypto operation */
1390 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1391 ut_params->op), "failed to process sym crypto op");
1393 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1394 "crypto op processing failed");
1397 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1400 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1401 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1403 "ciphertext data not as expected");
1405 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1407 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1408 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1409 gbl_driver_id == rte_cryptodev_driver_id_get(
1410 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1411 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1412 DIGEST_BYTE_LENGTH_SHA1,
1413 "Generated digest data not as expected");
1415 return TEST_SUCCESS;
1418 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1420 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1422 static uint8_t hmac_sha512_key[] = {
1423 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1424 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1425 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1426 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1427 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1428 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1429 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1430 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1432 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1433 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1434 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1435 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1436 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1437 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1438 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1439 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1440 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1445 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1446 struct crypto_unittest_params *ut_params,
1447 uint8_t *cipher_key,
1451 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1452 struct crypto_unittest_params *ut_params,
1453 struct crypto_testsuite_params *ts_params,
1454 const uint8_t *cipher,
1455 const uint8_t *digest,
1460 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1461 struct crypto_unittest_params *ut_params,
1462 uint8_t *cipher_key,
1466 /* Setup Cipher Parameters */
1467 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1468 ut_params->cipher_xform.next = NULL;
1470 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1471 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1472 ut_params->cipher_xform.cipher.key.data = cipher_key;
1473 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1474 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1475 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1477 /* Setup HMAC Parameters */
1478 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1479 ut_params->auth_xform.next = &ut_params->cipher_xform;
1481 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1482 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1483 ut_params->auth_xform.auth.key.data = hmac_key;
1484 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1485 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1487 return TEST_SUCCESS;
1492 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1493 struct crypto_unittest_params *ut_params,
1494 struct crypto_testsuite_params *ts_params,
1495 const uint8_t *cipher,
1496 const uint8_t *digest,
1499 /* Generate test mbuf data and digest */
1500 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1503 QUOTE_512_BYTES, 0);
1505 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1506 DIGEST_BYTE_LENGTH_SHA512);
1507 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1509 rte_memcpy(ut_params->digest,
1511 DIGEST_BYTE_LENGTH_SHA512);
1513 /* Generate Crypto op data structure */
1514 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1515 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1516 TEST_ASSERT_NOT_NULL(ut_params->op,
1517 "Failed to allocate symmetric crypto operation struct");
1519 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1521 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1523 /* set crypto operation source mbuf */
1524 sym_op->m_src = ut_params->ibuf;
1526 sym_op->auth.digest.data = ut_params->digest;
1527 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1528 ut_params->ibuf, QUOTE_512_BYTES);
1530 sym_op->auth.data.offset = 0;
1531 sym_op->auth.data.length = QUOTE_512_BYTES;
1533 /* Copy IV at the end of the crypto operation */
1534 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1535 iv, CIPHER_IV_LENGTH_AES_CBC);
1537 sym_op->cipher.data.offset = 0;
1538 sym_op->cipher.data.length = QUOTE_512_BYTES;
1540 /* Process crypto operation */
1541 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1542 ut_params->op), "failed to process sym crypto op");
1544 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1545 "crypto op processing failed");
1547 ut_params->obuf = ut_params->op->sym->m_src;
1550 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1551 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1554 "Plaintext data not as expected");
1557 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1558 "Digest verification failed");
1560 return TEST_SUCCESS;
1564 test_AES_cipheronly_mb_all(void)
1566 struct crypto_testsuite_params *ts_params = &testsuite_params;
1569 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1570 ts_params->op_mpool,
1571 ts_params->session_mpool, ts_params->session_priv_mpool,
1572 ts_params->valid_devs[0],
1573 rte_cryptodev_driver_id_get(
1574 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1575 BLKCIPHER_AES_CIPHERONLY_TYPE);
1577 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1579 return TEST_SUCCESS;
1583 test_AES_docsis_mb_all(void)
1585 struct crypto_testsuite_params *ts_params = &testsuite_params;
1588 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1589 ts_params->op_mpool,
1590 ts_params->session_mpool, ts_params->session_priv_mpool,
1591 ts_params->valid_devs[0],
1592 rte_cryptodev_driver_id_get(
1593 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1594 BLKCIPHER_AES_DOCSIS_TYPE);
1596 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1598 return TEST_SUCCESS;
1602 test_AES_docsis_qat_all(void)
1604 struct crypto_testsuite_params *ts_params = &testsuite_params;
1607 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1608 ts_params->op_mpool,
1609 ts_params->session_mpool, ts_params->session_priv_mpool,
1610 ts_params->valid_devs[0],
1611 rte_cryptodev_driver_id_get(
1612 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1613 BLKCIPHER_AES_DOCSIS_TYPE);
1615 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1617 return TEST_SUCCESS;
1621 test_DES_docsis_qat_all(void)
1623 struct crypto_testsuite_params *ts_params = &testsuite_params;
1626 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1627 ts_params->op_mpool,
1628 ts_params->session_mpool, ts_params->session_priv_mpool,
1629 ts_params->valid_devs[0],
1630 rte_cryptodev_driver_id_get(
1631 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1632 BLKCIPHER_DES_DOCSIS_TYPE);
1634 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1636 return TEST_SUCCESS;
1640 test_authonly_mb_all(void)
1642 struct crypto_testsuite_params *ts_params = &testsuite_params;
1645 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1646 ts_params->op_mpool,
1647 ts_params->session_mpool, ts_params->session_priv_mpool,
1648 ts_params->valid_devs[0],
1649 rte_cryptodev_driver_id_get(
1650 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1651 BLKCIPHER_AUTHONLY_TYPE);
1653 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1655 return TEST_SUCCESS;
1659 test_authonly_qat_all(void)
1661 struct crypto_testsuite_params *ts_params = &testsuite_params;
1664 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1665 ts_params->op_mpool,
1666 ts_params->session_mpool, ts_params->session_priv_mpool,
1667 ts_params->valid_devs[0],
1668 rte_cryptodev_driver_id_get(
1669 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1670 BLKCIPHER_AUTHONLY_TYPE);
1672 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1674 return TEST_SUCCESS;
1677 test_AES_chain_mb_all(void)
1679 struct crypto_testsuite_params *ts_params = &testsuite_params;
1682 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1683 ts_params->op_mpool,
1684 ts_params->session_mpool, ts_params->session_priv_mpool,
1685 ts_params->valid_devs[0],
1686 rte_cryptodev_driver_id_get(
1687 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1688 BLKCIPHER_AES_CHAIN_TYPE);
1690 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1692 return TEST_SUCCESS;
1695 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1698 test_AES_cipheronly_scheduler_all(void)
1700 struct crypto_testsuite_params *ts_params = &testsuite_params;
1703 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1704 ts_params->op_mpool,
1705 ts_params->session_mpool, ts_params->session_priv_mpool,
1706 ts_params->valid_devs[0],
1707 rte_cryptodev_driver_id_get(
1708 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1709 BLKCIPHER_AES_CIPHERONLY_TYPE);
1711 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1713 return TEST_SUCCESS;
1717 test_AES_chain_scheduler_all(void)
1719 struct crypto_testsuite_params *ts_params = &testsuite_params;
1722 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1723 ts_params->op_mpool,
1724 ts_params->session_mpool, ts_params->session_priv_mpool,
1725 ts_params->valid_devs[0],
1726 rte_cryptodev_driver_id_get(
1727 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1728 BLKCIPHER_AES_CHAIN_TYPE);
1730 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1732 return TEST_SUCCESS;
1736 test_authonly_scheduler_all(void)
1738 struct crypto_testsuite_params *ts_params = &testsuite_params;
1741 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1742 ts_params->op_mpool,
1743 ts_params->session_mpool, ts_params->session_priv_mpool,
1744 ts_params->valid_devs[0],
1745 rte_cryptodev_driver_id_get(
1746 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1747 BLKCIPHER_AUTHONLY_TYPE);
1749 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1751 return TEST_SUCCESS;
1754 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1757 test_AES_chain_openssl_all(void)
1759 struct crypto_testsuite_params *ts_params = &testsuite_params;
1762 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1763 ts_params->op_mpool,
1764 ts_params->session_mpool, ts_params->session_priv_mpool,
1765 ts_params->valid_devs[0],
1766 rte_cryptodev_driver_id_get(
1767 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1768 BLKCIPHER_AES_CHAIN_TYPE);
1770 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1772 return TEST_SUCCESS;
1776 test_AES_cipheronly_openssl_all(void)
1778 struct crypto_testsuite_params *ts_params = &testsuite_params;
1781 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1782 ts_params->op_mpool,
1783 ts_params->session_mpool, ts_params->session_priv_mpool,
1784 ts_params->valid_devs[0],
1785 rte_cryptodev_driver_id_get(
1786 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1787 BLKCIPHER_AES_CIPHERONLY_TYPE);
1789 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1791 return TEST_SUCCESS;
1795 test_AES_chain_ccp_all(void)
1797 struct crypto_testsuite_params *ts_params = &testsuite_params;
1800 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1801 ts_params->op_mpool,
1802 ts_params->session_mpool, ts_params->session_priv_mpool,
1803 ts_params->valid_devs[0],
1804 rte_cryptodev_driver_id_get(
1805 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1806 BLKCIPHER_AES_CHAIN_TYPE);
1808 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1810 return TEST_SUCCESS;
1814 test_AES_cipheronly_ccp_all(void)
1816 struct crypto_testsuite_params *ts_params = &testsuite_params;
1819 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1820 ts_params->op_mpool,
1821 ts_params->session_mpool, ts_params->session_priv_mpool,
1822 ts_params->valid_devs[0],
1823 rte_cryptodev_driver_id_get(
1824 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1825 BLKCIPHER_AES_CIPHERONLY_TYPE);
1827 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1829 return TEST_SUCCESS;
1833 test_AES_chain_qat_all(void)
1835 struct crypto_testsuite_params *ts_params = &testsuite_params;
1838 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1839 ts_params->op_mpool,
1840 ts_params->session_mpool, ts_params->session_priv_mpool,
1841 ts_params->valid_devs[0],
1842 rte_cryptodev_driver_id_get(
1843 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1844 BLKCIPHER_AES_CHAIN_TYPE);
1846 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1848 return TEST_SUCCESS;
1852 test_AES_cipheronly_qat_all(void)
1854 struct crypto_testsuite_params *ts_params = &testsuite_params;
1857 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1858 ts_params->op_mpool,
1859 ts_params->session_mpool, ts_params->session_priv_mpool,
1860 ts_params->valid_devs[0],
1861 rte_cryptodev_driver_id_get(
1862 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1863 BLKCIPHER_AES_CIPHERONLY_TYPE);
1865 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1867 return TEST_SUCCESS;
1871 test_AES_cipheronly_virtio_all(void)
1873 struct crypto_testsuite_params *ts_params = &testsuite_params;
1876 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1877 ts_params->op_mpool,
1878 ts_params->session_mpool, ts_params->session_priv_mpool,
1879 ts_params->valid_devs[0],
1880 rte_cryptodev_driver_id_get(
1881 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1882 BLKCIPHER_AES_CIPHERONLY_TYPE);
1884 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1886 return TEST_SUCCESS;
1890 test_AES_chain_caam_jr_all(void)
1892 struct crypto_testsuite_params *ts_params = &testsuite_params;
1895 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1896 ts_params->op_mpool,
1897 ts_params->session_mpool, ts_params->session_priv_mpool,
1898 ts_params->valid_devs[0],
1899 rte_cryptodev_driver_id_get(
1900 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1901 BLKCIPHER_AES_CHAIN_TYPE);
1903 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1905 return TEST_SUCCESS;
1909 test_AES_cipheronly_caam_jr_all(void)
1911 struct crypto_testsuite_params *ts_params = &testsuite_params;
1914 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1915 ts_params->op_mpool,
1916 ts_params->session_mpool, ts_params->session_priv_mpool,
1917 ts_params->valid_devs[0],
1918 rte_cryptodev_driver_id_get(
1919 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1920 BLKCIPHER_AES_CIPHERONLY_TYPE);
1922 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1924 return TEST_SUCCESS;
1928 test_authonly_caam_jr_all(void)
1930 struct crypto_testsuite_params *ts_params = &testsuite_params;
1933 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1934 ts_params->op_mpool,
1935 ts_params->session_mpool, ts_params->session_priv_mpool,
1936 ts_params->valid_devs[0],
1937 rte_cryptodev_driver_id_get(
1938 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1939 BLKCIPHER_AUTHONLY_TYPE);
1941 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1943 return TEST_SUCCESS;
1948 test_AES_chain_dpaa_sec_all(void)
1950 struct crypto_testsuite_params *ts_params = &testsuite_params;
1953 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1954 ts_params->op_mpool,
1955 ts_params->session_mpool, ts_params->session_priv_mpool,
1956 ts_params->valid_devs[0],
1957 rte_cryptodev_driver_id_get(
1958 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1959 BLKCIPHER_AES_CHAIN_TYPE);
1961 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1963 return TEST_SUCCESS;
1967 test_AES_cipheronly_dpaa_sec_all(void)
1969 struct crypto_testsuite_params *ts_params = &testsuite_params;
1972 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1973 ts_params->op_mpool,
1974 ts_params->session_mpool, ts_params->session_priv_mpool,
1975 ts_params->valid_devs[0],
1976 rte_cryptodev_driver_id_get(
1977 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1978 BLKCIPHER_AES_CIPHERONLY_TYPE);
1980 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1982 return TEST_SUCCESS;
1986 test_authonly_dpaa_sec_all(void)
1988 struct crypto_testsuite_params *ts_params = &testsuite_params;
1991 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1992 ts_params->op_mpool,
1993 ts_params->session_mpool, ts_params->session_priv_mpool,
1994 ts_params->valid_devs[0],
1995 rte_cryptodev_driver_id_get(
1996 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1997 BLKCIPHER_AUTHONLY_TYPE);
1999 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2001 return TEST_SUCCESS;
2005 test_AES_chain_dpaa2_sec_all(void)
2007 struct crypto_testsuite_params *ts_params = &testsuite_params;
2010 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2011 ts_params->op_mpool,
2012 ts_params->session_mpool, ts_params->session_priv_mpool,
2013 ts_params->valid_devs[0],
2014 rte_cryptodev_driver_id_get(
2015 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2016 BLKCIPHER_AES_CHAIN_TYPE);
2018 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2020 return TEST_SUCCESS;
2024 test_AES_cipheronly_dpaa2_sec_all(void)
2026 struct crypto_testsuite_params *ts_params = &testsuite_params;
2029 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2030 ts_params->op_mpool,
2031 ts_params->session_mpool, ts_params->session_priv_mpool,
2032 ts_params->valid_devs[0],
2033 rte_cryptodev_driver_id_get(
2034 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2035 BLKCIPHER_AES_CIPHERONLY_TYPE);
2037 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2039 return TEST_SUCCESS;
2043 test_authonly_dpaa2_sec_all(void)
2045 struct crypto_testsuite_params *ts_params = &testsuite_params;
2048 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2049 ts_params->op_mpool,
2050 ts_params->session_mpool, ts_params->session_priv_mpool,
2051 ts_params->valid_devs[0],
2052 rte_cryptodev_driver_id_get(
2053 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2054 BLKCIPHER_AUTHONLY_TYPE);
2056 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2058 return TEST_SUCCESS;
2062 test_authonly_openssl_all(void)
2064 struct crypto_testsuite_params *ts_params = &testsuite_params;
2067 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2068 ts_params->op_mpool,
2069 ts_params->session_mpool, ts_params->session_priv_mpool,
2070 ts_params->valid_devs[0],
2071 rte_cryptodev_driver_id_get(
2072 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2073 BLKCIPHER_AUTHONLY_TYPE);
2075 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2077 return TEST_SUCCESS;
2081 test_authonly_ccp_all(void)
2083 struct crypto_testsuite_params *ts_params = &testsuite_params;
2086 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2087 ts_params->op_mpool,
2088 ts_params->session_mpool, ts_params->session_priv_mpool,
2089 ts_params->valid_devs[0],
2090 rte_cryptodev_driver_id_get(
2091 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2092 BLKCIPHER_AUTHONLY_TYPE);
2094 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2096 return TEST_SUCCESS;
2100 test_AES_chain_armv8_all(void)
2102 struct crypto_testsuite_params *ts_params = &testsuite_params;
2105 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2106 ts_params->op_mpool,
2107 ts_params->session_mpool, ts_params->session_priv_mpool,
2108 ts_params->valid_devs[0],
2109 rte_cryptodev_driver_id_get(
2110 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2111 BLKCIPHER_AES_CHAIN_TYPE);
2113 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2115 return TEST_SUCCESS;
2119 test_AES_chain_mrvl_all(void)
2121 struct crypto_testsuite_params *ts_params = &testsuite_params;
2124 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2125 ts_params->op_mpool,
2126 ts_params->session_mpool, ts_params->session_priv_mpool,
2127 ts_params->valid_devs[0],
2128 rte_cryptodev_driver_id_get(
2129 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2130 BLKCIPHER_AES_CHAIN_TYPE);
2132 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2134 return TEST_SUCCESS;
2138 test_AES_cipheronly_mrvl_all(void)
2140 struct crypto_testsuite_params *ts_params = &testsuite_params;
2143 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2144 ts_params->op_mpool,
2145 ts_params->session_mpool, ts_params->session_priv_mpool,
2146 ts_params->valid_devs[0],
2147 rte_cryptodev_driver_id_get(
2148 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2149 BLKCIPHER_AES_CIPHERONLY_TYPE);
2151 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2153 return TEST_SUCCESS;
2157 test_authonly_mrvl_all(void)
2159 struct crypto_testsuite_params *ts_params = &testsuite_params;
2162 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2163 ts_params->op_mpool,
2164 ts_params->session_mpool, ts_params->session_priv_mpool,
2165 ts_params->valid_devs[0],
2166 rte_cryptodev_driver_id_get(
2167 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2168 BLKCIPHER_AUTHONLY_TYPE);
2170 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2172 return TEST_SUCCESS;
2176 test_3DES_chain_mrvl_all(void)
2178 struct crypto_testsuite_params *ts_params = &testsuite_params;
2181 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2182 ts_params->op_mpool,
2183 ts_params->session_mpool, ts_params->session_priv_mpool,
2184 ts_params->valid_devs[0],
2185 rte_cryptodev_driver_id_get(
2186 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2187 BLKCIPHER_3DES_CHAIN_TYPE);
2189 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2191 return TEST_SUCCESS;
2195 test_3DES_cipheronly_mrvl_all(void)
2197 struct crypto_testsuite_params *ts_params = &testsuite_params;
2200 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2201 ts_params->op_mpool,
2202 ts_params->session_mpool, ts_params->session_priv_mpool,
2203 ts_params->valid_devs[0],
2204 rte_cryptodev_driver_id_get(
2205 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2206 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2208 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2210 return TEST_SUCCESS;
2214 test_AES_chain_octeontx_all(void)
2216 struct crypto_testsuite_params *ts_params = &testsuite_params;
2219 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2220 ts_params->op_mpool, ts_params->session_mpool,
2221 ts_params->session_priv_mpool,
2222 ts_params->valid_devs[0],
2223 rte_cryptodev_driver_id_get(
2224 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2225 BLKCIPHER_AES_CHAIN_TYPE);
2227 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2229 return TEST_SUCCESS;
2233 test_AES_cipheronly_octeontx_all(void)
2235 struct crypto_testsuite_params *ts_params = &testsuite_params;
2238 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2239 ts_params->op_mpool, ts_params->session_mpool,
2240 ts_params->session_priv_mpool,
2241 ts_params->valid_devs[0],
2242 rte_cryptodev_driver_id_get(
2243 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2244 BLKCIPHER_AES_CIPHERONLY_TYPE);
2246 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2248 return TEST_SUCCESS;
2252 test_3DES_chain_octeontx_all(void)
2254 struct crypto_testsuite_params *ts_params = &testsuite_params;
2257 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2258 ts_params->op_mpool, ts_params->session_mpool,
2259 ts_params->session_priv_mpool,
2260 ts_params->valid_devs[0],
2261 rte_cryptodev_driver_id_get(
2262 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2263 BLKCIPHER_3DES_CHAIN_TYPE);
2265 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2267 return TEST_SUCCESS;
2271 test_3DES_cipheronly_octeontx_all(void)
2273 struct crypto_testsuite_params *ts_params = &testsuite_params;
2276 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2277 ts_params->op_mpool, ts_params->session_mpool,
2278 ts_params->session_priv_mpool,
2279 ts_params->valid_devs[0],
2280 rte_cryptodev_driver_id_get(
2281 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2282 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2284 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2286 return TEST_SUCCESS;
2290 test_authonly_octeontx_all(void)
2292 struct crypto_testsuite_params *ts_params = &testsuite_params;
2295 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2296 ts_params->op_mpool, ts_params->session_mpool,
2297 ts_params->session_priv_mpool,
2298 ts_params->valid_devs[0],
2299 rte_cryptodev_driver_id_get(
2300 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2301 BLKCIPHER_AUTHONLY_TYPE);
2303 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2305 return TEST_SUCCESS;
2308 /* ***** SNOW 3G Tests ***** */
2310 create_wireless_algo_hash_session(uint8_t dev_id,
2311 const uint8_t *key, const uint8_t key_len,
2312 const uint8_t iv_len, const uint8_t auth_len,
2313 enum rte_crypto_auth_operation op,
2314 enum rte_crypto_auth_algorithm algo)
2316 uint8_t hash_key[key_len];
2318 struct crypto_testsuite_params *ts_params = &testsuite_params;
2319 struct crypto_unittest_params *ut_params = &unittest_params;
2321 memcpy(hash_key, key, key_len);
2323 debug_hexdump(stdout, "key:", key, key_len);
2325 /* Setup Authentication Parameters */
2326 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2327 ut_params->auth_xform.next = NULL;
2329 ut_params->auth_xform.auth.op = op;
2330 ut_params->auth_xform.auth.algo = algo;
2331 ut_params->auth_xform.auth.key.length = key_len;
2332 ut_params->auth_xform.auth.key.data = hash_key;
2333 ut_params->auth_xform.auth.digest_length = auth_len;
2334 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2335 ut_params->auth_xform.auth.iv.length = iv_len;
2336 ut_params->sess = rte_cryptodev_sym_session_create(
2337 ts_params->session_mpool);
2339 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2340 &ut_params->auth_xform,
2341 ts_params->session_priv_mpool);
2342 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2347 create_wireless_algo_cipher_session(uint8_t dev_id,
2348 enum rte_crypto_cipher_operation op,
2349 enum rte_crypto_cipher_algorithm algo,
2350 const uint8_t *key, const uint8_t key_len,
2353 uint8_t cipher_key[key_len];
2355 struct crypto_testsuite_params *ts_params = &testsuite_params;
2356 struct crypto_unittest_params *ut_params = &unittest_params;
2358 memcpy(cipher_key, key, key_len);
2360 /* Setup Cipher Parameters */
2361 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2362 ut_params->cipher_xform.next = NULL;
2364 ut_params->cipher_xform.cipher.algo = algo;
2365 ut_params->cipher_xform.cipher.op = op;
2366 ut_params->cipher_xform.cipher.key.data = cipher_key;
2367 ut_params->cipher_xform.cipher.key.length = key_len;
2368 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2369 ut_params->cipher_xform.cipher.iv.length = iv_len;
2371 debug_hexdump(stdout, "key:", key, key_len);
2373 /* Create Crypto session */
2374 ut_params->sess = rte_cryptodev_sym_session_create(
2375 ts_params->session_mpool);
2377 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2378 &ut_params->cipher_xform,
2379 ts_params->session_priv_mpool);
2380 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2385 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2386 unsigned int cipher_len,
2387 unsigned int cipher_offset)
2389 struct crypto_testsuite_params *ts_params = &testsuite_params;
2390 struct crypto_unittest_params *ut_params = &unittest_params;
2392 /* Generate Crypto op data structure */
2393 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2394 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2395 TEST_ASSERT_NOT_NULL(ut_params->op,
2396 "Failed to allocate pktmbuf offload");
2398 /* Set crypto operation data parameters */
2399 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2401 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2403 /* set crypto operation source mbuf */
2404 sym_op->m_src = ut_params->ibuf;
2407 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2409 sym_op->cipher.data.length = cipher_len;
2410 sym_op->cipher.data.offset = cipher_offset;
2415 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2416 unsigned int cipher_len,
2417 unsigned int cipher_offset)
2419 struct crypto_testsuite_params *ts_params = &testsuite_params;
2420 struct crypto_unittest_params *ut_params = &unittest_params;
2422 /* Generate Crypto op data structure */
2423 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2424 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2425 TEST_ASSERT_NOT_NULL(ut_params->op,
2426 "Failed to allocate pktmbuf offload");
2428 /* Set crypto operation data parameters */
2429 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2431 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2433 /* set crypto operation source mbuf */
2434 sym_op->m_src = ut_params->ibuf;
2435 sym_op->m_dst = ut_params->obuf;
2438 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2440 sym_op->cipher.data.length = cipher_len;
2441 sym_op->cipher.data.offset = cipher_offset;
2446 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2447 enum rte_crypto_cipher_operation cipher_op,
2448 enum rte_crypto_auth_operation auth_op,
2449 enum rte_crypto_auth_algorithm auth_algo,
2450 enum rte_crypto_cipher_algorithm cipher_algo,
2451 const uint8_t *key, uint8_t key_len,
2452 uint8_t auth_iv_len, uint8_t auth_len,
2453 uint8_t cipher_iv_len)
2456 uint8_t cipher_auth_key[key_len];
2458 struct crypto_testsuite_params *ts_params = &testsuite_params;
2459 struct crypto_unittest_params *ut_params = &unittest_params;
2461 memcpy(cipher_auth_key, key, key_len);
2463 /* Setup Authentication Parameters */
2464 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2465 ut_params->auth_xform.next = NULL;
2467 ut_params->auth_xform.auth.op = auth_op;
2468 ut_params->auth_xform.auth.algo = auth_algo;
2469 ut_params->auth_xform.auth.key.length = key_len;
2470 /* Hash key = cipher key */
2471 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2472 ut_params->auth_xform.auth.digest_length = auth_len;
2473 /* Auth IV will be after cipher IV */
2474 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2475 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2477 /* Setup Cipher Parameters */
2478 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2479 ut_params->cipher_xform.next = &ut_params->auth_xform;
2481 ut_params->cipher_xform.cipher.algo = cipher_algo;
2482 ut_params->cipher_xform.cipher.op = cipher_op;
2483 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2484 ut_params->cipher_xform.cipher.key.length = key_len;
2485 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2486 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2488 debug_hexdump(stdout, "key:", key, key_len);
2490 /* Create Crypto session*/
2491 ut_params->sess = rte_cryptodev_sym_session_create(
2492 ts_params->session_mpool);
2494 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2495 &ut_params->cipher_xform,
2496 ts_params->session_priv_mpool);
2498 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2503 create_wireless_cipher_auth_session(uint8_t dev_id,
2504 enum rte_crypto_cipher_operation cipher_op,
2505 enum rte_crypto_auth_operation auth_op,
2506 enum rte_crypto_auth_algorithm auth_algo,
2507 enum rte_crypto_cipher_algorithm cipher_algo,
2508 const struct wireless_test_data *tdata)
2510 const uint8_t key_len = tdata->key.len;
2511 uint8_t cipher_auth_key[key_len];
2513 struct crypto_testsuite_params *ts_params = &testsuite_params;
2514 struct crypto_unittest_params *ut_params = &unittest_params;
2515 const uint8_t *key = tdata->key.data;
2516 const uint8_t auth_len = tdata->digest.len;
2517 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2518 uint8_t auth_iv_len = tdata->auth_iv.len;
2520 memcpy(cipher_auth_key, key, key_len);
2522 /* Setup Authentication Parameters */
2523 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2524 ut_params->auth_xform.next = NULL;
2526 ut_params->auth_xform.auth.op = auth_op;
2527 ut_params->auth_xform.auth.algo = auth_algo;
2528 ut_params->auth_xform.auth.key.length = key_len;
2529 /* Hash key = cipher key */
2530 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2531 ut_params->auth_xform.auth.digest_length = auth_len;
2532 /* Auth IV will be after cipher IV */
2533 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2534 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2536 /* Setup Cipher Parameters */
2537 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2538 ut_params->cipher_xform.next = &ut_params->auth_xform;
2540 ut_params->cipher_xform.cipher.algo = cipher_algo;
2541 ut_params->cipher_xform.cipher.op = cipher_op;
2542 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2543 ut_params->cipher_xform.cipher.key.length = key_len;
2544 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2545 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2548 debug_hexdump(stdout, "key:", key, key_len);
2550 /* Create Crypto session*/
2551 ut_params->sess = rte_cryptodev_sym_session_create(
2552 ts_params->session_mpool);
2554 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2555 &ut_params->cipher_xform,
2556 ts_params->session_priv_mpool);
2558 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2563 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2564 const struct wireless_test_data *tdata)
2566 return create_wireless_cipher_auth_session(dev_id,
2567 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2568 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2569 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2573 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2574 enum rte_crypto_cipher_operation cipher_op,
2575 enum rte_crypto_auth_operation auth_op,
2576 enum rte_crypto_auth_algorithm auth_algo,
2577 enum rte_crypto_cipher_algorithm cipher_algo,
2578 const uint8_t *key, const uint8_t key_len,
2579 uint8_t auth_iv_len, uint8_t auth_len,
2580 uint8_t cipher_iv_len)
2582 uint8_t auth_cipher_key[key_len];
2584 struct crypto_testsuite_params *ts_params = &testsuite_params;
2585 struct crypto_unittest_params *ut_params = &unittest_params;
2587 memcpy(auth_cipher_key, key, key_len);
2589 /* Setup Authentication Parameters */
2590 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2591 ut_params->auth_xform.auth.op = auth_op;
2592 ut_params->auth_xform.next = &ut_params->cipher_xform;
2593 ut_params->auth_xform.auth.algo = auth_algo;
2594 ut_params->auth_xform.auth.key.length = key_len;
2595 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2596 ut_params->auth_xform.auth.digest_length = auth_len;
2597 /* Auth IV will be after cipher IV */
2598 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2599 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2601 /* Setup Cipher Parameters */
2602 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2603 ut_params->cipher_xform.next = NULL;
2604 ut_params->cipher_xform.cipher.algo = cipher_algo;
2605 ut_params->cipher_xform.cipher.op = cipher_op;
2606 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2607 ut_params->cipher_xform.cipher.key.length = key_len;
2608 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2609 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2611 debug_hexdump(stdout, "key:", key, key_len);
2613 /* Create Crypto session*/
2614 ut_params->sess = rte_cryptodev_sym_session_create(
2615 ts_params->session_mpool);
2617 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2618 &ut_params->auth_xform,
2619 ts_params->session_priv_mpool);
2621 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2627 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2628 unsigned int auth_tag_len,
2629 const uint8_t *iv, unsigned int iv_len,
2630 unsigned int data_pad_len,
2631 enum rte_crypto_auth_operation op,
2632 unsigned int auth_len, unsigned int auth_offset)
2634 struct crypto_testsuite_params *ts_params = &testsuite_params;
2636 struct crypto_unittest_params *ut_params = &unittest_params;
2638 /* Generate Crypto op data structure */
2639 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2640 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2641 TEST_ASSERT_NOT_NULL(ut_params->op,
2642 "Failed to allocate pktmbuf offload");
2644 /* Set crypto operation data parameters */
2645 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2647 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2649 /* set crypto operation source mbuf */
2650 sym_op->m_src = ut_params->ibuf;
2653 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2656 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2657 ut_params->ibuf, auth_tag_len);
2659 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2660 "no room to append auth tag");
2661 ut_params->digest = sym_op->auth.digest.data;
2662 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2663 ut_params->ibuf, data_pad_len);
2664 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2665 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2667 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2669 debug_hexdump(stdout, "digest:",
2670 sym_op->auth.digest.data,
2673 sym_op->auth.data.length = auth_len;
2674 sym_op->auth.data.offset = auth_offset;
2680 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2681 enum rte_crypto_auth_operation op)
2683 struct crypto_testsuite_params *ts_params = &testsuite_params;
2684 struct crypto_unittest_params *ut_params = &unittest_params;
2686 const uint8_t *auth_tag = tdata->digest.data;
2687 const unsigned int auth_tag_len = tdata->digest.len;
2688 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2689 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2691 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2692 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2693 const uint8_t *auth_iv = tdata->auth_iv.data;
2694 const uint8_t auth_iv_len = tdata->auth_iv.len;
2695 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2696 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2698 /* Generate Crypto op data structure */
2699 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2700 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2701 TEST_ASSERT_NOT_NULL(ut_params->op,
2702 "Failed to allocate pktmbuf offload");
2703 /* Set crypto operation data parameters */
2704 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2706 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2708 /* set crypto operation source mbuf */
2709 sym_op->m_src = ut_params->ibuf;
2712 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2713 ut_params->ibuf, auth_tag_len);
2715 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2716 "no room to append auth tag");
2717 ut_params->digest = sym_op->auth.digest.data;
2718 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2719 ut_params->ibuf, data_pad_len);
2720 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2721 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2723 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2725 debug_hexdump(stdout, "digest:",
2726 sym_op->auth.digest.data,
2729 /* Copy cipher and auth IVs at the end of the crypto operation */
2730 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2732 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2733 iv_ptr += cipher_iv_len;
2734 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2736 sym_op->cipher.data.length = cipher_len;
2737 sym_op->cipher.data.offset = 0;
2738 sym_op->auth.data.length = auth_len;
2739 sym_op->auth.data.offset = 0;
2745 create_zuc_cipher_hash_generate_operation(
2746 const struct wireless_test_data *tdata)
2748 return create_wireless_cipher_hash_operation(tdata,
2749 RTE_CRYPTO_AUTH_OP_GENERATE);
2753 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2754 const unsigned auth_tag_len,
2755 const uint8_t *auth_iv, uint8_t auth_iv_len,
2756 unsigned data_pad_len,
2757 enum rte_crypto_auth_operation op,
2758 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2759 const unsigned cipher_len, const unsigned cipher_offset,
2760 const unsigned auth_len, const unsigned auth_offset)
2762 struct crypto_testsuite_params *ts_params = &testsuite_params;
2763 struct crypto_unittest_params *ut_params = &unittest_params;
2765 /* Generate Crypto op data structure */
2766 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2767 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2768 TEST_ASSERT_NOT_NULL(ut_params->op,
2769 "Failed to allocate pktmbuf offload");
2770 /* Set crypto operation data parameters */
2771 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2773 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2775 /* set crypto operation source mbuf */
2776 sym_op->m_src = ut_params->ibuf;
2779 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2780 ut_params->ibuf, auth_tag_len);
2782 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2783 "no room to append auth tag");
2784 ut_params->digest = sym_op->auth.digest.data;
2785 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2786 ut_params->ibuf, data_pad_len);
2787 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2788 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2790 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2792 debug_hexdump(stdout, "digest:",
2793 sym_op->auth.digest.data,
2796 /* Copy cipher and auth IVs at the end of the crypto operation */
2797 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2799 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2800 iv_ptr += cipher_iv_len;
2801 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2803 sym_op->cipher.data.length = cipher_len;
2804 sym_op->cipher.data.offset = cipher_offset;
2805 sym_op->auth.data.length = auth_len;
2806 sym_op->auth.data.offset = auth_offset;
2812 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2813 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2814 const uint8_t *auth_iv, uint8_t auth_iv_len,
2815 unsigned int data_pad_len,
2816 unsigned int cipher_len, unsigned int cipher_offset,
2817 unsigned int auth_len, unsigned int auth_offset)
2819 struct crypto_testsuite_params *ts_params = &testsuite_params;
2820 struct crypto_unittest_params *ut_params = &unittest_params;
2822 /* Generate Crypto op data structure */
2823 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2824 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2825 TEST_ASSERT_NOT_NULL(ut_params->op,
2826 "Failed to allocate pktmbuf offload");
2828 /* Set crypto operation data parameters */
2829 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2831 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2833 /* set crypto operation source mbuf */
2834 sym_op->m_src = ut_params->ibuf;
2837 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2838 ut_params->ibuf, auth_tag_len);
2840 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2841 "no room to append auth tag");
2843 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2844 ut_params->ibuf, data_pad_len);
2846 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2848 debug_hexdump(stdout, "digest:",
2849 sym_op->auth.digest.data,
2852 /* Copy cipher and auth IVs at the end of the crypto operation */
2853 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2855 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2856 iv_ptr += cipher_iv_len;
2857 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2859 sym_op->cipher.data.length = cipher_len;
2860 sym_op->cipher.data.offset = cipher_offset;
2862 sym_op->auth.data.length = auth_len;
2863 sym_op->auth.data.offset = auth_offset;
2869 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2871 struct crypto_testsuite_params *ts_params = &testsuite_params;
2872 struct crypto_unittest_params *ut_params = &unittest_params;
2875 unsigned plaintext_pad_len;
2876 unsigned plaintext_len;
2879 /* Create SNOW 3G session */
2880 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2881 tdata->key.data, tdata->key.len,
2882 tdata->auth_iv.len, tdata->digest.len,
2883 RTE_CRYPTO_AUTH_OP_GENERATE,
2884 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2888 /* alloc mbuf and set payload */
2889 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2891 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2892 rte_pktmbuf_tailroom(ut_params->ibuf));
2894 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2895 /* Append data which is padded to a multiple of */
2896 /* the algorithms block size */
2897 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2898 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2900 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2902 /* Create SNOW 3G operation */
2903 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2904 tdata->auth_iv.data, tdata->auth_iv.len,
2905 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2906 tdata->validAuthLenInBits.len,
2911 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2913 ut_params->obuf = ut_params->op->sym->m_src;
2914 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2915 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2916 + plaintext_pad_len;
2919 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2922 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2923 "SNOW 3G Generated auth tag not as expected");
2929 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2931 struct crypto_testsuite_params *ts_params = &testsuite_params;
2932 struct crypto_unittest_params *ut_params = &unittest_params;
2935 unsigned plaintext_pad_len;
2936 unsigned plaintext_len;
2939 /* Create SNOW 3G session */
2940 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2941 tdata->key.data, tdata->key.len,
2942 tdata->auth_iv.len, tdata->digest.len,
2943 RTE_CRYPTO_AUTH_OP_VERIFY,
2944 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2947 /* alloc mbuf and set payload */
2948 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2950 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2951 rte_pktmbuf_tailroom(ut_params->ibuf));
2953 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2954 /* Append data which is padded to a multiple of */
2955 /* the algorithms block size */
2956 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2957 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2959 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2961 /* Create SNOW 3G operation */
2962 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2964 tdata->auth_iv.data, tdata->auth_iv.len,
2966 RTE_CRYPTO_AUTH_OP_VERIFY,
2967 tdata->validAuthLenInBits.len,
2972 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2974 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2975 ut_params->obuf = ut_params->op->sym->m_src;
2976 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2977 + plaintext_pad_len;
2980 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2989 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2991 struct crypto_testsuite_params *ts_params = &testsuite_params;
2992 struct crypto_unittest_params *ut_params = &unittest_params;
2995 unsigned plaintext_pad_len;
2996 unsigned plaintext_len;
2999 /* Create KASUMI session */
3000 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3001 tdata->key.data, tdata->key.len,
3002 0, tdata->digest.len,
3003 RTE_CRYPTO_AUTH_OP_GENERATE,
3004 RTE_CRYPTO_AUTH_KASUMI_F9);
3008 /* alloc mbuf and set payload */
3009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3011 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3012 rte_pktmbuf_tailroom(ut_params->ibuf));
3014 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3015 /* Append data which is padded to a multiple of */
3016 /* the algorithms block size */
3017 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3018 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3020 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3022 /* Create KASUMI operation */
3023 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3025 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3026 tdata->plaintext.len,
3031 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3033 ut_params->obuf = ut_params->op->sym->m_src;
3034 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3035 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3036 + plaintext_pad_len;
3039 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3042 DIGEST_BYTE_LENGTH_KASUMI_F9,
3043 "KASUMI Generated auth tag not as expected");
3049 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3051 struct crypto_testsuite_params *ts_params = &testsuite_params;
3052 struct crypto_unittest_params *ut_params = &unittest_params;
3055 unsigned plaintext_pad_len;
3056 unsigned plaintext_len;
3059 /* Create KASUMI session */
3060 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3061 tdata->key.data, tdata->key.len,
3062 0, tdata->digest.len,
3063 RTE_CRYPTO_AUTH_OP_VERIFY,
3064 RTE_CRYPTO_AUTH_KASUMI_F9);
3067 /* alloc mbuf and set payload */
3068 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3070 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3071 rte_pktmbuf_tailroom(ut_params->ibuf));
3073 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3074 /* Append data which is padded to a multiple */
3075 /* of the algorithms block size */
3076 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3077 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3079 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3081 /* Create KASUMI operation */
3082 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3086 RTE_CRYPTO_AUTH_OP_VERIFY,
3087 tdata->plaintext.len,
3092 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3094 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3095 ut_params->obuf = ut_params->op->sym->m_src;
3096 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3097 + plaintext_pad_len;
3100 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3109 test_snow3g_hash_generate_test_case_1(void)
3111 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3115 test_snow3g_hash_generate_test_case_2(void)
3117 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3121 test_snow3g_hash_generate_test_case_3(void)
3123 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3127 test_snow3g_hash_generate_test_case_4(void)
3129 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3133 test_snow3g_hash_generate_test_case_5(void)
3135 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3139 test_snow3g_hash_generate_test_case_6(void)
3141 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3145 test_snow3g_hash_verify_test_case_1(void)
3147 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3152 test_snow3g_hash_verify_test_case_2(void)
3154 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3158 test_snow3g_hash_verify_test_case_3(void)
3160 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3164 test_snow3g_hash_verify_test_case_4(void)
3166 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3170 test_snow3g_hash_verify_test_case_5(void)
3172 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3176 test_snow3g_hash_verify_test_case_6(void)
3178 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3182 test_kasumi_hash_generate_test_case_1(void)
3184 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3188 test_kasumi_hash_generate_test_case_2(void)
3190 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3194 test_kasumi_hash_generate_test_case_3(void)
3196 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3200 test_kasumi_hash_generate_test_case_4(void)
3202 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3206 test_kasumi_hash_generate_test_case_5(void)
3208 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3212 test_kasumi_hash_generate_test_case_6(void)
3214 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3218 test_kasumi_hash_verify_test_case_1(void)
3220 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3224 test_kasumi_hash_verify_test_case_2(void)
3226 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3230 test_kasumi_hash_verify_test_case_3(void)
3232 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3236 test_kasumi_hash_verify_test_case_4(void)
3238 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3242 test_kasumi_hash_verify_test_case_5(void)
3244 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3248 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3250 struct crypto_testsuite_params *ts_params = &testsuite_params;
3251 struct crypto_unittest_params *ut_params = &unittest_params;
3254 uint8_t *plaintext, *ciphertext;
3255 unsigned plaintext_pad_len;
3256 unsigned plaintext_len;
3258 /* Create KASUMI session */
3259 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3260 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3261 RTE_CRYPTO_CIPHER_KASUMI_F8,
3262 tdata->key.data, tdata->key.len,
3263 tdata->cipher_iv.len);
3267 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3269 /* Clear mbuf payload */
3270 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3271 rte_pktmbuf_tailroom(ut_params->ibuf));
3273 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3274 /* Append data which is padded to a multiple */
3275 /* of the algorithms block size */
3276 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3277 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3279 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3281 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3283 /* Create KASUMI operation */
3284 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3285 tdata->cipher_iv.len,
3286 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3287 tdata->validCipherOffsetInBits.len);
3291 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3295 ut_params->obuf = ut_params->op->sym->m_dst;
3296 if (ut_params->obuf)
3297 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3299 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3301 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3303 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3304 (tdata->validCipherOffsetInBits.len >> 3);
3306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3308 reference_ciphertext,
3309 tdata->validCipherLenInBits.len,
3310 "KASUMI Ciphertext data not as expected");
3315 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3317 struct crypto_testsuite_params *ts_params = &testsuite_params;
3318 struct crypto_unittest_params *ut_params = &unittest_params;
3322 unsigned int plaintext_pad_len;
3323 unsigned int plaintext_len;
3325 uint8_t buffer[10000];
3326 const uint8_t *ciphertext;
3328 struct rte_cryptodev_info dev_info;
3330 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3332 uint64_t feat_flags = dev_info.feature_flags;
3334 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3335 printf("Device doesn't support in-place scatter-gather. "
3340 /* Create KASUMI session */
3341 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3342 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3343 RTE_CRYPTO_CIPHER_KASUMI_F8,
3344 tdata->key.data, tdata->key.len,
3345 tdata->cipher_iv.len);
3349 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3352 /* Append data which is padded to a multiple */
3353 /* of the algorithms block size */
3354 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3356 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3357 plaintext_pad_len, 10, 0);
3359 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3361 /* Create KASUMI operation */
3362 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3363 tdata->cipher_iv.len,
3364 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3365 tdata->validCipherOffsetInBits.len);
3369 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3371 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3373 ut_params->obuf = ut_params->op->sym->m_dst;
3375 if (ut_params->obuf)
3376 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3377 plaintext_len, buffer);
3379 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3380 tdata->validCipherOffsetInBits.len >> 3,
3381 plaintext_len, buffer);
3384 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3386 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3387 (tdata->validCipherOffsetInBits.len >> 3);
3389 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3391 reference_ciphertext,
3392 tdata->validCipherLenInBits.len,
3393 "KASUMI Ciphertext data not as expected");
3398 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3400 struct crypto_testsuite_params *ts_params = &testsuite_params;
3401 struct crypto_unittest_params *ut_params = &unittest_params;
3404 uint8_t *plaintext, *ciphertext;
3405 unsigned plaintext_pad_len;
3406 unsigned plaintext_len;
3408 /* Create KASUMI session */
3409 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3410 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3411 RTE_CRYPTO_CIPHER_KASUMI_F8,
3412 tdata->key.data, tdata->key.len,
3413 tdata->cipher_iv.len);
3417 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3418 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3420 /* Clear mbuf payload */
3421 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3422 rte_pktmbuf_tailroom(ut_params->ibuf));
3424 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3425 /* Append data which is padded to a multiple */
3426 /* of the algorithms block size */
3427 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3428 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3430 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3431 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3433 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3435 /* Create KASUMI operation */
3436 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3437 tdata->cipher_iv.len,
3438 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3439 tdata->validCipherOffsetInBits.len);
3443 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3445 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3447 ut_params->obuf = ut_params->op->sym->m_dst;
3448 if (ut_params->obuf)
3449 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3451 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3453 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3455 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3456 (tdata->validCipherOffsetInBits.len >> 3);
3458 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3460 reference_ciphertext,
3461 tdata->validCipherLenInBits.len,
3462 "KASUMI Ciphertext data not as expected");
3467 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3469 struct crypto_testsuite_params *ts_params = &testsuite_params;
3470 struct crypto_unittest_params *ut_params = &unittest_params;
3473 unsigned int plaintext_pad_len;
3474 unsigned int plaintext_len;
3476 const uint8_t *ciphertext;
3477 uint8_t buffer[2048];
3479 struct rte_cryptodev_info dev_info;
3481 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3483 uint64_t feat_flags = dev_info.feature_flags;
3484 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3485 printf("Device doesn't support out-of-place scatter-gather "
3486 "in both input and output mbufs. "
3491 /* Create KASUMI session */
3492 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3493 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3494 RTE_CRYPTO_CIPHER_KASUMI_F8,
3495 tdata->key.data, tdata->key.len,
3496 tdata->cipher_iv.len);
3500 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3501 /* Append data which is padded to a multiple */
3502 /* of the algorithms block size */
3503 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3505 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3506 plaintext_pad_len, 10, 0);
3507 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3508 plaintext_pad_len, 3, 0);
3510 /* Append data which is padded to a multiple */
3511 /* of the algorithms block size */
3512 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3514 /* Create KASUMI operation */
3515 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3516 tdata->cipher_iv.len,
3517 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3518 tdata->validCipherOffsetInBits.len);
3522 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3524 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3526 ut_params->obuf = ut_params->op->sym->m_dst;
3527 if (ut_params->obuf)
3528 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3529 plaintext_pad_len, buffer);
3531 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3532 tdata->validCipherOffsetInBits.len >> 3,
3533 plaintext_pad_len, buffer);
3535 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3536 (tdata->validCipherOffsetInBits.len >> 3);
3538 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3540 reference_ciphertext,
3541 tdata->validCipherLenInBits.len,
3542 "KASUMI Ciphertext data not as expected");
3548 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3550 struct crypto_testsuite_params *ts_params = &testsuite_params;
3551 struct crypto_unittest_params *ut_params = &unittest_params;
3554 uint8_t *ciphertext, *plaintext;
3555 unsigned ciphertext_pad_len;
3556 unsigned ciphertext_len;
3558 /* Create KASUMI session */
3559 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3560 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3561 RTE_CRYPTO_CIPHER_KASUMI_F8,
3562 tdata->key.data, tdata->key.len,
3563 tdata->cipher_iv.len);
3567 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3568 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3570 /* Clear mbuf payload */
3571 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3572 rte_pktmbuf_tailroom(ut_params->ibuf));
3574 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3575 /* Append data which is padded to a multiple */
3576 /* of the algorithms block size */
3577 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3578 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3579 ciphertext_pad_len);
3580 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3581 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3583 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3585 /* Create KASUMI operation */
3586 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3587 tdata->cipher_iv.len,
3588 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3589 tdata->validCipherOffsetInBits.len);
3593 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3595 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3597 ut_params->obuf = ut_params->op->sym->m_dst;
3598 if (ut_params->obuf)
3599 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3601 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3603 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3605 const uint8_t *reference_plaintext = tdata->plaintext.data +
3606 (tdata->validCipherOffsetInBits.len >> 3);
3608 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3610 reference_plaintext,
3611 tdata->validCipherLenInBits.len,
3612 "KASUMI Plaintext data not as expected");
3617 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3619 struct crypto_testsuite_params *ts_params = &testsuite_params;
3620 struct crypto_unittest_params *ut_params = &unittest_params;
3623 uint8_t *ciphertext, *plaintext;
3624 unsigned ciphertext_pad_len;
3625 unsigned ciphertext_len;
3627 /* Create KASUMI session */
3628 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3629 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3630 RTE_CRYPTO_CIPHER_KASUMI_F8,
3631 tdata->key.data, tdata->key.len,
3632 tdata->cipher_iv.len);
3636 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3638 /* Clear mbuf payload */
3639 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3640 rte_pktmbuf_tailroom(ut_params->ibuf));
3642 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3643 /* Append data which is padded to a multiple */
3644 /* of the algorithms block size */
3645 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3646 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3647 ciphertext_pad_len);
3648 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3650 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3652 /* Create KASUMI operation */
3653 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3654 tdata->cipher_iv.len,
3655 tdata->ciphertext.len,
3656 tdata->validCipherOffsetInBits.len);
3660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3662 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3664 ut_params->obuf = ut_params->op->sym->m_dst;
3665 if (ut_params->obuf)
3666 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3668 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3670 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3672 const uint8_t *reference_plaintext = tdata->plaintext.data +
3673 (tdata->validCipherOffsetInBits.len >> 3);
3675 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3677 reference_plaintext,
3678 tdata->validCipherLenInBits.len,
3679 "KASUMI Plaintext data not as expected");
3684 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3686 struct crypto_testsuite_params *ts_params = &testsuite_params;
3687 struct crypto_unittest_params *ut_params = &unittest_params;
3690 uint8_t *plaintext, *ciphertext;
3691 unsigned plaintext_pad_len;
3692 unsigned plaintext_len;
3694 /* Create SNOW 3G session */
3695 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3697 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3698 tdata->key.data, tdata->key.len,
3699 tdata->cipher_iv.len);
3703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3705 /* Clear mbuf payload */
3706 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3707 rte_pktmbuf_tailroom(ut_params->ibuf));
3709 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3710 /* Append data which is padded to a multiple of */
3711 /* the algorithms block size */
3712 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3713 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3715 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3717 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3719 /* Create SNOW 3G operation */
3720 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3721 tdata->cipher_iv.len,
3722 tdata->validCipherLenInBits.len,
3727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3729 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3731 ut_params->obuf = ut_params->op->sym->m_dst;
3732 if (ut_params->obuf)
3733 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3735 ciphertext = plaintext;
3737 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3740 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3742 tdata->ciphertext.data,
3743 tdata->validDataLenInBits.len,
3744 "SNOW 3G Ciphertext data not as expected");
3750 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3752 struct crypto_testsuite_params *ts_params = &testsuite_params;
3753 struct crypto_unittest_params *ut_params = &unittest_params;
3754 uint8_t *plaintext, *ciphertext;
3757 unsigned plaintext_pad_len;
3758 unsigned plaintext_len;
3760 /* Create SNOW 3G session */
3761 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3762 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3763 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3764 tdata->key.data, tdata->key.len,
3765 tdata->cipher_iv.len);
3769 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3770 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3772 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3773 "Failed to allocate input buffer in mempool");
3774 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3775 "Failed to allocate output buffer in mempool");
3777 /* Clear mbuf payload */
3778 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3779 rte_pktmbuf_tailroom(ut_params->ibuf));
3781 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3782 /* Append data which is padded to a multiple of */
3783 /* the algorithms block size */
3784 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3785 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3787 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3788 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3790 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3792 /* Create SNOW 3G operation */
3793 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3794 tdata->cipher_iv.len,
3795 tdata->validCipherLenInBits.len,
3800 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3802 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3804 ut_params->obuf = ut_params->op->sym->m_dst;
3805 if (ut_params->obuf)
3806 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3808 ciphertext = plaintext;
3810 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3813 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3815 tdata->ciphertext.data,
3816 tdata->validDataLenInBits.len,
3817 "SNOW 3G Ciphertext data not as expected");
3822 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3824 struct crypto_testsuite_params *ts_params = &testsuite_params;
3825 struct crypto_unittest_params *ut_params = &unittest_params;
3828 unsigned int plaintext_pad_len;
3829 unsigned int plaintext_len;
3830 uint8_t buffer[10000];
3831 const uint8_t *ciphertext;
3833 struct rte_cryptodev_info dev_info;
3835 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3837 uint64_t feat_flags = dev_info.feature_flags;
3839 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3840 printf("Device doesn't support out-of-place scatter-gather "
3841 "in both input and output mbufs. "
3846 /* Create SNOW 3G session */
3847 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3848 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3849 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3850 tdata->key.data, tdata->key.len,
3851 tdata->cipher_iv.len);
3855 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3856 /* Append data which is padded to a multiple of */
3857 /* the algorithms block size */
3858 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3860 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3861 plaintext_pad_len, 10, 0);
3862 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3863 plaintext_pad_len, 3, 0);
3865 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3866 "Failed to allocate input buffer in mempool");
3867 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3868 "Failed to allocate output buffer in mempool");
3870 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3872 /* Create SNOW 3G operation */
3873 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3874 tdata->cipher_iv.len,
3875 tdata->validCipherLenInBits.len,
3880 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3882 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3884 ut_params->obuf = ut_params->op->sym->m_dst;
3885 if (ut_params->obuf)
3886 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3887 plaintext_len, buffer);
3889 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3890 plaintext_len, buffer);
3892 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3895 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3897 tdata->ciphertext.data,
3898 tdata->validDataLenInBits.len,
3899 "SNOW 3G Ciphertext data not as expected");
3904 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3906 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3908 uint8_t curr_byte, prev_byte;
3909 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3910 uint8_t lower_byte_mask = (1 << offset) - 1;
3913 prev_byte = buffer[0];
3914 buffer[0] >>= offset;
3916 for (i = 1; i < length_in_bytes; i++) {
3917 curr_byte = buffer[i];
3918 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3919 (curr_byte >> offset);
3920 prev_byte = curr_byte;
3925 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3927 struct crypto_testsuite_params *ts_params = &testsuite_params;
3928 struct crypto_unittest_params *ut_params = &unittest_params;
3929 uint8_t *plaintext, *ciphertext;
3931 uint32_t plaintext_len;
3932 uint32_t plaintext_pad_len;
3933 uint8_t extra_offset = 4;
3934 uint8_t *expected_ciphertext_shifted;
3936 /* Create SNOW 3G session */
3937 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3938 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3939 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3940 tdata->key.data, tdata->key.len,
3941 tdata->cipher_iv.len);
3945 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3946 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3948 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3949 "Failed to allocate input buffer in mempool");
3950 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3951 "Failed to allocate output buffer in mempool");
3953 /* Clear mbuf payload */
3954 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3955 rte_pktmbuf_tailroom(ut_params->ibuf));
3957 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3959 * Append data which is padded to a
3960 * multiple of the algorithms block size
3962 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3964 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3967 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3969 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3970 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3972 #ifdef RTE_APP_TEST_DEBUG
3973 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3975 /* Create SNOW 3G operation */
3976 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3977 tdata->cipher_iv.len,
3978 tdata->validCipherLenInBits.len,
3983 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3985 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3987 ut_params->obuf = ut_params->op->sym->m_dst;
3988 if (ut_params->obuf)
3989 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3991 ciphertext = plaintext;
3993 #ifdef RTE_APP_TEST_DEBUG
3994 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3997 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3999 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4000 "failed to reserve memory for ciphertext shifted\n");
4002 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4003 ceil_byte_length(tdata->ciphertext.len));
4004 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4007 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4009 expected_ciphertext_shifted,
4010 tdata->validDataLenInBits.len,
4012 "SNOW 3G Ciphertext data not as expected");
4016 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4018 struct crypto_testsuite_params *ts_params = &testsuite_params;
4019 struct crypto_unittest_params *ut_params = &unittest_params;
4023 uint8_t *plaintext, *ciphertext;
4024 unsigned ciphertext_pad_len;
4025 unsigned ciphertext_len;
4027 /* Create SNOW 3G session */
4028 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4029 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4030 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4031 tdata->key.data, tdata->key.len,
4032 tdata->cipher_iv.len);
4036 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4038 /* Clear mbuf payload */
4039 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4040 rte_pktmbuf_tailroom(ut_params->ibuf));
4042 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4043 /* Append data which is padded to a multiple of */
4044 /* the algorithms block size */
4045 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4046 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4047 ciphertext_pad_len);
4048 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4050 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4052 /* Create SNOW 3G operation */
4053 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4054 tdata->cipher_iv.len,
4055 tdata->validCipherLenInBits.len,
4060 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4062 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4063 ut_params->obuf = ut_params->op->sym->m_dst;
4064 if (ut_params->obuf)
4065 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4067 plaintext = ciphertext;
4069 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4072 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4073 tdata->plaintext.data,
4074 tdata->validDataLenInBits.len,
4075 "SNOW 3G Plaintext data not as expected");
4079 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4081 struct crypto_testsuite_params *ts_params = &testsuite_params;
4082 struct crypto_unittest_params *ut_params = &unittest_params;
4086 uint8_t *plaintext, *ciphertext;
4087 unsigned ciphertext_pad_len;
4088 unsigned ciphertext_len;
4090 /* Create SNOW 3G session */
4091 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4092 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4093 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4094 tdata->key.data, tdata->key.len,
4095 tdata->cipher_iv.len);
4099 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4100 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4102 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4103 "Failed to allocate input buffer");
4104 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4105 "Failed to allocate output buffer");
4107 /* Clear mbuf payload */
4108 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4109 rte_pktmbuf_tailroom(ut_params->ibuf));
4111 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4112 rte_pktmbuf_tailroom(ut_params->obuf));
4114 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4115 /* Append data which is padded to a multiple of */
4116 /* the algorithms block size */
4117 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4118 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4119 ciphertext_pad_len);
4120 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4121 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4123 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4125 /* Create SNOW 3G operation */
4126 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4127 tdata->cipher_iv.len,
4128 tdata->validCipherLenInBits.len,
4133 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4135 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4136 ut_params->obuf = ut_params->op->sym->m_dst;
4137 if (ut_params->obuf)
4138 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4140 plaintext = ciphertext;
4142 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4145 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4146 tdata->plaintext.data,
4147 tdata->validDataLenInBits.len,
4148 "SNOW 3G Plaintext data not as expected");
4153 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4155 struct crypto_testsuite_params *ts_params = &testsuite_params;
4156 struct crypto_unittest_params *ut_params = &unittest_params;
4160 uint8_t *plaintext, *ciphertext;
4161 unsigned int plaintext_pad_len;
4162 unsigned int plaintext_len;
4164 struct rte_cryptodev_sym_capability_idx cap_idx;
4166 /* Check if device supports ZUC EEA3 */
4167 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4168 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4170 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4174 /* Check if device supports ZUC EIA3 */
4175 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4176 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4178 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4182 /* Create ZUC session */
4183 retval = create_zuc_cipher_auth_encrypt_generate_session(
4184 ts_params->valid_devs[0],
4188 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4190 /* clear mbuf payload */
4191 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4192 rte_pktmbuf_tailroom(ut_params->ibuf));
4194 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4195 /* Append data which is padded to a multiple of */
4196 /* the algorithms block size */
4197 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4198 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4200 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4202 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4204 /* Create ZUC operation */
4205 retval = create_zuc_cipher_hash_generate_operation(tdata);
4209 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4211 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4212 ut_params->obuf = ut_params->op->sym->m_src;
4213 if (ut_params->obuf)
4214 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4216 ciphertext = plaintext;
4218 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4220 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4222 tdata->ciphertext.data,
4223 tdata->validDataLenInBits.len,
4224 "ZUC Ciphertext data not as expected");
4226 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4227 + plaintext_pad_len;
4230 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4234 "ZUC Generated auth tag not as expected");
4239 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4241 struct crypto_testsuite_params *ts_params = &testsuite_params;
4242 struct crypto_unittest_params *ut_params = &unittest_params;
4246 uint8_t *plaintext, *ciphertext;
4247 unsigned plaintext_pad_len;
4248 unsigned plaintext_len;
4250 /* Create SNOW 3G session */
4251 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4252 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4253 RTE_CRYPTO_AUTH_OP_GENERATE,
4254 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4255 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4256 tdata->key.data, tdata->key.len,
4257 tdata->auth_iv.len, tdata->digest.len,
4258 tdata->cipher_iv.len);
4261 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4263 /* clear mbuf payload */
4264 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4265 rte_pktmbuf_tailroom(ut_params->ibuf));
4267 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4268 /* Append data which is padded to a multiple of */
4269 /* the algorithms block size */
4270 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4271 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4273 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4275 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4277 /* Create SNOW 3G operation */
4278 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4279 tdata->digest.len, tdata->auth_iv.data,
4281 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4282 tdata->cipher_iv.data, tdata->cipher_iv.len,
4283 tdata->validCipherLenInBits.len,
4285 tdata->validAuthLenInBits.len,
4291 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4294 ut_params->obuf = ut_params->op->sym->m_src;
4295 if (ut_params->obuf)
4296 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4298 ciphertext = plaintext;
4300 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4302 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4304 tdata->ciphertext.data,
4305 tdata->validDataLenInBits.len,
4306 "SNOW 3G Ciphertext data not as expected");
4308 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4309 + plaintext_pad_len;
4312 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4315 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4316 "SNOW 3G Generated auth tag not as expected");
4320 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4322 struct crypto_testsuite_params *ts_params = &testsuite_params;
4323 struct crypto_unittest_params *ut_params = &unittest_params;
4327 uint8_t *plaintext, *ciphertext;
4328 unsigned plaintext_pad_len;
4329 unsigned plaintext_len;
4331 /* Create SNOW 3G session */
4332 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4333 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4334 RTE_CRYPTO_AUTH_OP_GENERATE,
4335 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4336 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4337 tdata->key.data, tdata->key.len,
4338 tdata->auth_iv.len, tdata->digest.len,
4339 tdata->cipher_iv.len);
4343 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4345 /* clear mbuf payload */
4346 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4347 rte_pktmbuf_tailroom(ut_params->ibuf));
4349 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4350 /* Append data which is padded to a multiple of */
4351 /* the algorithms block size */
4352 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4353 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4355 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4357 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4359 /* Create SNOW 3G operation */
4360 retval = create_wireless_algo_auth_cipher_operation(
4362 tdata->cipher_iv.data, tdata->cipher_iv.len,
4363 tdata->auth_iv.data, tdata->auth_iv.len,
4365 tdata->validCipherLenInBits.len,
4367 tdata->validAuthLenInBits.len,
4373 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4375 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4376 ut_params->obuf = ut_params->op->sym->m_src;
4377 if (ut_params->obuf)
4378 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4380 ciphertext = plaintext;
4382 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4383 + plaintext_pad_len;
4384 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4389 tdata->ciphertext.data,
4390 tdata->validDataLenInBits.len,
4391 "SNOW 3G Ciphertext data not as expected");
4394 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4397 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4398 "SNOW 3G Generated auth tag not as expected");
4403 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4405 struct crypto_testsuite_params *ts_params = &testsuite_params;
4406 struct crypto_unittest_params *ut_params = &unittest_params;
4410 uint8_t *plaintext, *ciphertext;
4411 unsigned plaintext_pad_len;
4412 unsigned plaintext_len;
4414 /* Create KASUMI session */
4415 retval = create_wireless_algo_auth_cipher_session(
4416 ts_params->valid_devs[0],
4417 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4418 RTE_CRYPTO_AUTH_OP_GENERATE,
4419 RTE_CRYPTO_AUTH_KASUMI_F9,
4420 RTE_CRYPTO_CIPHER_KASUMI_F8,
4421 tdata->key.data, tdata->key.len,
4422 0, tdata->digest.len,
4423 tdata->cipher_iv.len);
4426 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4428 /* clear mbuf payload */
4429 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4430 rte_pktmbuf_tailroom(ut_params->ibuf));
4432 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4433 /* Append data which is padded to a multiple of */
4434 /* the algorithms block size */
4435 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4436 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4438 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4440 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4442 /* Create KASUMI operation */
4443 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4444 tdata->cipher_iv.data, tdata->cipher_iv.len,
4447 tdata->validCipherLenInBits.len,
4448 tdata->validCipherOffsetInBits.len,
4449 tdata->validAuthLenInBits.len,
4456 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4458 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4459 if (ut_params->op->sym->m_dst)
4460 ut_params->obuf = ut_params->op->sym->m_dst;
4462 ut_params->obuf = ut_params->op->sym->m_src;
4464 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4465 tdata->validCipherOffsetInBits.len >> 3);
4467 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4468 (tdata->validCipherOffsetInBits.len >> 3);
4470 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4472 reference_ciphertext,
4473 tdata->validCipherLenInBits.len,
4474 "KASUMI Ciphertext data not as expected");
4475 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4476 + plaintext_pad_len;
4479 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4482 DIGEST_BYTE_LENGTH_KASUMI_F9,
4483 "KASUMI Generated auth tag not as expected");
4488 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4490 struct crypto_testsuite_params *ts_params = &testsuite_params;
4491 struct crypto_unittest_params *ut_params = &unittest_params;
4495 uint8_t *plaintext, *ciphertext;
4496 unsigned plaintext_pad_len;
4497 unsigned plaintext_len;
4499 /* Create KASUMI session */
4500 retval = create_wireless_algo_cipher_auth_session(
4501 ts_params->valid_devs[0],
4502 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4503 RTE_CRYPTO_AUTH_OP_GENERATE,
4504 RTE_CRYPTO_AUTH_KASUMI_F9,
4505 RTE_CRYPTO_CIPHER_KASUMI_F8,
4506 tdata->key.data, tdata->key.len,
4507 0, tdata->digest.len,
4508 tdata->cipher_iv.len);
4512 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4514 /* clear mbuf payload */
4515 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4516 rte_pktmbuf_tailroom(ut_params->ibuf));
4518 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4519 /* Append data which is padded to a multiple of */
4520 /* the algorithms block size */
4521 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4522 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4524 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4526 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4528 /* Create KASUMI operation */
4529 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4530 tdata->digest.len, NULL, 0,
4531 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4532 tdata->cipher_iv.data, tdata->cipher_iv.len,
4533 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4534 tdata->validCipherOffsetInBits.len,
4535 tdata->validAuthLenInBits.len,
4541 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4543 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4545 if (ut_params->op->sym->m_dst)
4546 ut_params->obuf = ut_params->op->sym->m_dst;
4548 ut_params->obuf = ut_params->op->sym->m_src;
4550 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4551 tdata->validCipherOffsetInBits.len >> 3);
4553 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4554 + plaintext_pad_len;
4556 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4557 (tdata->validCipherOffsetInBits.len >> 3);
4559 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4561 reference_ciphertext,
4562 tdata->validCipherLenInBits.len,
4563 "KASUMI Ciphertext data not as expected");
4566 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4569 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4570 "KASUMI Generated auth tag not as expected");
4575 test_zuc_encryption(const struct wireless_test_data *tdata)
4577 struct crypto_testsuite_params *ts_params = &testsuite_params;
4578 struct crypto_unittest_params *ut_params = &unittest_params;
4581 uint8_t *plaintext, *ciphertext;
4582 unsigned plaintext_pad_len;
4583 unsigned plaintext_len;
4585 struct rte_cryptodev_sym_capability_idx cap_idx;
4587 /* Check if device supports ZUC EEA3 */
4588 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4589 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4591 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4595 /* Create ZUC session */
4596 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4597 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4598 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4599 tdata->key.data, tdata->key.len,
4600 tdata->cipher_iv.len);
4604 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4606 /* Clear mbuf payload */
4607 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4608 rte_pktmbuf_tailroom(ut_params->ibuf));
4610 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4611 /* Append data which is padded to a multiple */
4612 /* of the algorithms block size */
4613 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4614 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4616 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4618 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4620 /* Create ZUC operation */
4621 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4622 tdata->cipher_iv.len,
4623 tdata->plaintext.len,
4628 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4630 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4632 ut_params->obuf = ut_params->op->sym->m_dst;
4633 if (ut_params->obuf)
4634 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4636 ciphertext = plaintext;
4638 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4641 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4643 tdata->ciphertext.data,
4644 tdata->validCipherLenInBits.len,
4645 "ZUC Ciphertext data not as expected");
4650 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4652 struct crypto_testsuite_params *ts_params = &testsuite_params;
4653 struct crypto_unittest_params *ut_params = &unittest_params;
4657 unsigned int plaintext_pad_len;
4658 unsigned int plaintext_len;
4659 const uint8_t *ciphertext;
4660 uint8_t ciphertext_buffer[2048];
4661 struct rte_cryptodev_info dev_info;
4663 struct rte_cryptodev_sym_capability_idx cap_idx;
4665 /* Check if device supports ZUC EEA3 */
4666 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4667 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4669 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4673 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4675 uint64_t feat_flags = dev_info.feature_flags;
4677 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4678 printf("Device doesn't support in-place scatter-gather. "
4683 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4685 /* Append data which is padded to a multiple */
4686 /* of the algorithms block size */
4687 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4689 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4690 plaintext_pad_len, 10, 0);
4692 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4693 tdata->plaintext.data);
4695 /* Create ZUC session */
4696 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4697 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4698 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4699 tdata->key.data, tdata->key.len,
4700 tdata->cipher_iv.len);
4704 /* Clear mbuf payload */
4706 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4708 /* Create ZUC operation */
4709 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4710 tdata->cipher_iv.len, tdata->plaintext.len,
4715 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4717 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4719 ut_params->obuf = ut_params->op->sym->m_dst;
4720 if (ut_params->obuf)
4721 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4722 0, plaintext_len, ciphertext_buffer);
4724 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4725 0, plaintext_len, ciphertext_buffer);
4728 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4731 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4733 tdata->ciphertext.data,
4734 tdata->validCipherLenInBits.len,
4735 "ZUC Ciphertext data not as expected");
4741 test_zuc_authentication(const struct wireless_test_data *tdata)
4743 struct crypto_testsuite_params *ts_params = &testsuite_params;
4744 struct crypto_unittest_params *ut_params = &unittest_params;
4747 unsigned plaintext_pad_len;
4748 unsigned plaintext_len;
4751 struct rte_cryptodev_sym_capability_idx cap_idx;
4753 /* Check if device supports ZUC EIA3 */
4754 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4755 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4757 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4761 /* Create ZUC session */
4762 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4763 tdata->key.data, tdata->key.len,
4764 tdata->auth_iv.len, tdata->digest.len,
4765 RTE_CRYPTO_AUTH_OP_GENERATE,
4766 RTE_CRYPTO_AUTH_ZUC_EIA3);
4770 /* alloc mbuf and set payload */
4771 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4773 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4774 rte_pktmbuf_tailroom(ut_params->ibuf));
4776 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4777 /* Append data which is padded to a multiple of */
4778 /* the algorithms block size */
4779 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4780 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4782 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4784 /* Create ZUC operation */
4785 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4786 tdata->auth_iv.data, tdata->auth_iv.len,
4787 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4788 tdata->validAuthLenInBits.len,
4793 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4795 ut_params->obuf = ut_params->op->sym->m_src;
4796 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4797 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4798 + plaintext_pad_len;
4801 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4804 DIGEST_BYTE_LENGTH_KASUMI_F9,
4805 "ZUC Generated auth tag not as expected");
4811 test_kasumi_encryption_test_case_1(void)
4813 return test_kasumi_encryption(&kasumi_test_case_1);
4817 test_kasumi_encryption_test_case_1_sgl(void)
4819 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4823 test_kasumi_encryption_test_case_1_oop(void)
4825 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4829 test_kasumi_encryption_test_case_1_oop_sgl(void)
4831 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4835 test_kasumi_encryption_test_case_2(void)
4837 return test_kasumi_encryption(&kasumi_test_case_2);
4841 test_kasumi_encryption_test_case_3(void)
4843 return test_kasumi_encryption(&kasumi_test_case_3);
4847 test_kasumi_encryption_test_case_4(void)
4849 return test_kasumi_encryption(&kasumi_test_case_4);
4853 test_kasumi_encryption_test_case_5(void)
4855 return test_kasumi_encryption(&kasumi_test_case_5);
4859 test_kasumi_decryption_test_case_1(void)
4861 return test_kasumi_decryption(&kasumi_test_case_1);
4865 test_kasumi_decryption_test_case_1_oop(void)
4867 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4871 test_kasumi_decryption_test_case_2(void)
4873 return test_kasumi_decryption(&kasumi_test_case_2);
4877 test_kasumi_decryption_test_case_3(void)
4879 return test_kasumi_decryption(&kasumi_test_case_3);
4883 test_kasumi_decryption_test_case_4(void)
4885 return test_kasumi_decryption(&kasumi_test_case_4);
4889 test_kasumi_decryption_test_case_5(void)
4891 return test_kasumi_decryption(&kasumi_test_case_5);
4894 test_snow3g_encryption_test_case_1(void)
4896 return test_snow3g_encryption(&snow3g_test_case_1);
4900 test_snow3g_encryption_test_case_1_oop(void)
4902 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4906 test_snow3g_encryption_test_case_1_oop_sgl(void)
4908 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4913 test_snow3g_encryption_test_case_1_offset_oop(void)
4915 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4919 test_snow3g_encryption_test_case_2(void)
4921 return test_snow3g_encryption(&snow3g_test_case_2);
4925 test_snow3g_encryption_test_case_3(void)
4927 return test_snow3g_encryption(&snow3g_test_case_3);
4931 test_snow3g_encryption_test_case_4(void)
4933 return test_snow3g_encryption(&snow3g_test_case_4);
4937 test_snow3g_encryption_test_case_5(void)
4939 return test_snow3g_encryption(&snow3g_test_case_5);
4943 test_snow3g_decryption_test_case_1(void)
4945 return test_snow3g_decryption(&snow3g_test_case_1);
4949 test_snow3g_decryption_test_case_1_oop(void)
4951 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4955 test_snow3g_decryption_test_case_2(void)
4957 return test_snow3g_decryption(&snow3g_test_case_2);
4961 test_snow3g_decryption_test_case_3(void)
4963 return test_snow3g_decryption(&snow3g_test_case_3);
4967 test_snow3g_decryption_test_case_4(void)
4969 return test_snow3g_decryption(&snow3g_test_case_4);
4973 test_snow3g_decryption_test_case_5(void)
4975 return test_snow3g_decryption(&snow3g_test_case_5);
4978 test_snow3g_cipher_auth_test_case_1(void)
4980 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4984 test_snow3g_auth_cipher_test_case_1(void)
4986 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4990 test_kasumi_auth_cipher_test_case_1(void)
4992 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4996 test_kasumi_cipher_auth_test_case_1(void)
4998 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5002 test_zuc_encryption_test_case_1(void)
5004 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5008 test_zuc_encryption_test_case_2(void)
5010 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5014 test_zuc_encryption_test_case_3(void)
5016 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5020 test_zuc_encryption_test_case_4(void)
5022 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5026 test_zuc_encryption_test_case_5(void)
5028 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5032 test_zuc_encryption_test_case_6_sgl(void)
5034 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5038 test_zuc_hash_generate_test_case_1(void)
5040 return test_zuc_authentication(&zuc_test_case_auth_1b);
5044 test_zuc_hash_generate_test_case_2(void)
5046 return test_zuc_authentication(&zuc_test_case_auth_90b);
5050 test_zuc_hash_generate_test_case_3(void)
5052 return test_zuc_authentication(&zuc_test_case_auth_577b);
5056 test_zuc_hash_generate_test_case_4(void)
5058 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5062 test_zuc_hash_generate_test_case_5(void)
5064 return test_zuc_authentication(&zuc_test_auth_5670b);
5068 test_zuc_hash_generate_test_case_6(void)
5070 return test_zuc_authentication(&zuc_test_case_auth_128b);
5074 test_zuc_hash_generate_test_case_7(void)
5076 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5080 test_zuc_hash_generate_test_case_8(void)
5082 return test_zuc_authentication(&zuc_test_case_auth_584b);
5086 test_zuc_cipher_auth_test_case_1(void)
5088 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5092 test_zuc_cipher_auth_test_case_2(void)
5094 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5098 test_3DES_chain_qat_all(void)
5100 struct crypto_testsuite_params *ts_params = &testsuite_params;
5103 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5104 ts_params->op_mpool,
5105 ts_params->session_mpool, ts_params->session_priv_mpool,
5106 ts_params->valid_devs[0],
5107 rte_cryptodev_driver_id_get(
5108 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5109 BLKCIPHER_3DES_CHAIN_TYPE);
5111 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5113 return TEST_SUCCESS;
5117 test_DES_cipheronly_qat_all(void)
5119 struct crypto_testsuite_params *ts_params = &testsuite_params;
5122 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5123 ts_params->op_mpool,
5124 ts_params->session_mpool, ts_params->session_priv_mpool,
5125 ts_params->valid_devs[0],
5126 rte_cryptodev_driver_id_get(
5127 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5128 BLKCIPHER_DES_CIPHERONLY_TYPE);
5130 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5132 return TEST_SUCCESS;
5136 test_DES_cipheronly_openssl_all(void)
5138 struct crypto_testsuite_params *ts_params = &testsuite_params;
5141 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5142 ts_params->op_mpool,
5143 ts_params->session_mpool, ts_params->session_priv_mpool,
5144 ts_params->valid_devs[0],
5145 rte_cryptodev_driver_id_get(
5146 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5147 BLKCIPHER_DES_CIPHERONLY_TYPE);
5149 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5151 return TEST_SUCCESS;
5155 test_DES_docsis_openssl_all(void)
5157 struct crypto_testsuite_params *ts_params = &testsuite_params;
5160 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5161 ts_params->op_mpool,
5162 ts_params->session_mpool, ts_params->session_priv_mpool,
5163 ts_params->valid_devs[0],
5164 rte_cryptodev_driver_id_get(
5165 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5166 BLKCIPHER_DES_DOCSIS_TYPE);
5168 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5170 return TEST_SUCCESS;
5174 test_DES_cipheronly_mb_all(void)
5176 struct crypto_testsuite_params *ts_params = &testsuite_params;
5179 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5180 ts_params->op_mpool,
5181 ts_params->session_mpool, ts_params->session_priv_mpool,
5182 ts_params->valid_devs[0],
5183 rte_cryptodev_driver_id_get(
5184 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5185 BLKCIPHER_DES_CIPHERONLY_TYPE);
5187 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5189 return TEST_SUCCESS;
5192 test_3DES_cipheronly_mb_all(void)
5194 struct crypto_testsuite_params *ts_params = &testsuite_params;
5197 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5198 ts_params->op_mpool,
5199 ts_params->session_mpool, ts_params->session_priv_mpool,
5200 ts_params->valid_devs[0],
5201 rte_cryptodev_driver_id_get(
5202 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5203 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5205 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5207 return TEST_SUCCESS;
5211 test_DES_docsis_mb_all(void)
5213 struct crypto_testsuite_params *ts_params = &testsuite_params;
5216 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5217 ts_params->op_mpool,
5218 ts_params->session_mpool, ts_params->session_priv_mpool,
5219 ts_params->valid_devs[0],
5220 rte_cryptodev_driver_id_get(
5221 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5222 BLKCIPHER_DES_DOCSIS_TYPE);
5224 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5226 return TEST_SUCCESS;
5230 test_3DES_chain_caam_jr_all(void)
5232 struct crypto_testsuite_params *ts_params = &testsuite_params;
5235 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5236 ts_params->op_mpool,
5237 ts_params->session_mpool, ts_params->session_priv_mpool,
5238 ts_params->valid_devs[0],
5239 rte_cryptodev_driver_id_get(
5240 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5241 BLKCIPHER_3DES_CHAIN_TYPE);
5243 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5245 return TEST_SUCCESS;
5249 test_3DES_cipheronly_caam_jr_all(void)
5251 struct crypto_testsuite_params *ts_params = &testsuite_params;
5254 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5255 ts_params->op_mpool,
5256 ts_params->session_mpool, ts_params->session_priv_mpool,
5257 ts_params->valid_devs[0],
5258 rte_cryptodev_driver_id_get(
5259 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5260 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5262 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5264 return TEST_SUCCESS;
5268 test_3DES_chain_dpaa_sec_all(void)
5270 struct crypto_testsuite_params *ts_params = &testsuite_params;
5273 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5274 ts_params->op_mpool,
5275 ts_params->session_mpool, ts_params->session_priv_mpool,
5276 ts_params->valid_devs[0],
5277 rte_cryptodev_driver_id_get(
5278 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5279 BLKCIPHER_3DES_CHAIN_TYPE);
5281 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5283 return TEST_SUCCESS;
5287 test_3DES_cipheronly_dpaa_sec_all(void)
5289 struct crypto_testsuite_params *ts_params = &testsuite_params;
5292 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5293 ts_params->op_mpool,
5294 ts_params->session_mpool, ts_params->session_priv_mpool,
5295 ts_params->valid_devs[0],
5296 rte_cryptodev_driver_id_get(
5297 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5298 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5300 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5302 return TEST_SUCCESS;
5306 test_3DES_chain_dpaa2_sec_all(void)
5308 struct crypto_testsuite_params *ts_params = &testsuite_params;
5311 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5312 ts_params->op_mpool,
5313 ts_params->session_mpool, ts_params->session_priv_mpool,
5314 ts_params->valid_devs[0],
5315 rte_cryptodev_driver_id_get(
5316 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5317 BLKCIPHER_3DES_CHAIN_TYPE);
5319 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5321 return TEST_SUCCESS;
5325 test_3DES_cipheronly_dpaa2_sec_all(void)
5327 struct crypto_testsuite_params *ts_params = &testsuite_params;
5330 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5331 ts_params->op_mpool,
5332 ts_params->session_mpool, ts_params->session_priv_mpool,
5333 ts_params->valid_devs[0],
5334 rte_cryptodev_driver_id_get(
5335 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5336 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5338 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5340 return TEST_SUCCESS;
5344 test_3DES_chain_ccp_all(void)
5346 struct crypto_testsuite_params *ts_params = &testsuite_params;
5349 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5350 ts_params->op_mpool,
5351 ts_params->session_mpool, ts_params->session_priv_mpool,
5352 ts_params->valid_devs[0],
5353 rte_cryptodev_driver_id_get(
5354 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5355 BLKCIPHER_3DES_CHAIN_TYPE);
5357 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5359 return TEST_SUCCESS;
5363 test_3DES_cipheronly_ccp_all(void)
5365 struct crypto_testsuite_params *ts_params = &testsuite_params;
5368 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5369 ts_params->op_mpool,
5370 ts_params->session_mpool, ts_params->session_priv_mpool,
5371 ts_params->valid_devs[0],
5372 rte_cryptodev_driver_id_get(
5373 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5374 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5376 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5378 return TEST_SUCCESS;
5382 test_3DES_cipheronly_qat_all(void)
5384 struct crypto_testsuite_params *ts_params = &testsuite_params;
5387 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5388 ts_params->op_mpool,
5389 ts_params->session_mpool, ts_params->session_priv_mpool,
5390 ts_params->valid_devs[0],
5391 rte_cryptodev_driver_id_get(
5392 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5393 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5395 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5397 return TEST_SUCCESS;
5401 test_3DES_chain_openssl_all(void)
5403 struct crypto_testsuite_params *ts_params = &testsuite_params;
5406 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5407 ts_params->op_mpool,
5408 ts_params->session_mpool, ts_params->session_priv_mpool,
5409 ts_params->valid_devs[0],
5410 rte_cryptodev_driver_id_get(
5411 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5412 BLKCIPHER_3DES_CHAIN_TYPE);
5414 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5416 return TEST_SUCCESS;
5420 test_3DES_cipheronly_openssl_all(void)
5422 struct crypto_testsuite_params *ts_params = &testsuite_params;
5425 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5426 ts_params->op_mpool,
5427 ts_params->session_mpool, ts_params->session_priv_mpool,
5428 ts_params->valid_devs[0],
5429 rte_cryptodev_driver_id_get(
5430 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5431 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5433 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5435 return TEST_SUCCESS;
5438 /* ***** AEAD algorithm Tests ***** */
5441 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5442 enum rte_crypto_aead_operation op,
5443 const uint8_t *key, const uint8_t key_len,
5444 const uint16_t aad_len, const uint8_t auth_len,
5447 uint8_t aead_key[key_len];
5449 struct crypto_testsuite_params *ts_params = &testsuite_params;
5450 struct crypto_unittest_params *ut_params = &unittest_params;
5452 memcpy(aead_key, key, key_len);
5454 /* Setup AEAD Parameters */
5455 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5456 ut_params->aead_xform.next = NULL;
5457 ut_params->aead_xform.aead.algo = algo;
5458 ut_params->aead_xform.aead.op = op;
5459 ut_params->aead_xform.aead.key.data = aead_key;
5460 ut_params->aead_xform.aead.key.length = key_len;
5461 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5462 ut_params->aead_xform.aead.iv.length = iv_len;
5463 ut_params->aead_xform.aead.digest_length = auth_len;
5464 ut_params->aead_xform.aead.aad_length = aad_len;
5466 debug_hexdump(stdout, "key:", key, key_len);
5468 /* Create Crypto session*/
5469 ut_params->sess = rte_cryptodev_sym_session_create(
5470 ts_params->session_mpool);
5472 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5473 &ut_params->aead_xform,
5474 ts_params->session_priv_mpool);
5476 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5482 create_aead_xform(struct rte_crypto_op *op,
5483 enum rte_crypto_aead_algorithm algo,
5484 enum rte_crypto_aead_operation aead_op,
5485 uint8_t *key, const uint8_t key_len,
5486 const uint8_t aad_len, const uint8_t auth_len,
5489 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5490 "failed to allocate space for crypto transform");
5492 struct rte_crypto_sym_op *sym_op = op->sym;
5494 /* Setup AEAD Parameters */
5495 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5496 sym_op->xform->next = NULL;
5497 sym_op->xform->aead.algo = algo;
5498 sym_op->xform->aead.op = aead_op;
5499 sym_op->xform->aead.key.data = key;
5500 sym_op->xform->aead.key.length = key_len;
5501 sym_op->xform->aead.iv.offset = IV_OFFSET;
5502 sym_op->xform->aead.iv.length = iv_len;
5503 sym_op->xform->aead.digest_length = auth_len;
5504 sym_op->xform->aead.aad_length = aad_len;
5506 debug_hexdump(stdout, "key:", key, key_len);
5512 create_aead_operation(enum rte_crypto_aead_operation op,
5513 const struct aead_test_data *tdata)
5515 struct crypto_testsuite_params *ts_params = &testsuite_params;
5516 struct crypto_unittest_params *ut_params = &unittest_params;
5518 uint8_t *plaintext, *ciphertext;
5519 unsigned int aad_pad_len, plaintext_pad_len;
5521 /* Generate Crypto op data structure */
5522 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5523 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5524 TEST_ASSERT_NOT_NULL(ut_params->op,
5525 "Failed to allocate symmetric crypto operation struct");
5527 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5529 /* Append aad data */
5530 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5531 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5532 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5534 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5535 "no room to append aad");
5537 sym_op->aead.aad.phys_addr =
5538 rte_pktmbuf_iova(ut_params->ibuf);
5539 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5540 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5541 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5544 /* Append IV at the end of the crypto operation*/
5545 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5546 uint8_t *, IV_OFFSET);
5548 /* Copy IV 1 byte after the IV pointer, according to the API */
5549 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5550 debug_hexdump(stdout, "iv:", iv_ptr,
5553 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5554 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5556 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5557 "no room to append aad");
5559 sym_op->aead.aad.phys_addr =
5560 rte_pktmbuf_iova(ut_params->ibuf);
5561 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5562 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5565 /* Append IV at the end of the crypto operation*/
5566 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5567 uint8_t *, IV_OFFSET);
5569 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5570 debug_hexdump(stdout, "iv:", iv_ptr,
5574 /* Append plaintext/ciphertext */
5575 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5576 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5577 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5579 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5581 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5582 debug_hexdump(stdout, "plaintext:", plaintext,
5583 tdata->plaintext.len);
5585 if (ut_params->obuf) {
5586 ciphertext = (uint8_t *)rte_pktmbuf_append(
5588 plaintext_pad_len + aad_pad_len);
5589 TEST_ASSERT_NOT_NULL(ciphertext,
5590 "no room to append ciphertext");
5592 memset(ciphertext + aad_pad_len, 0,
5593 tdata->ciphertext.len);
5596 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5597 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5599 TEST_ASSERT_NOT_NULL(ciphertext,
5600 "no room to append ciphertext");
5602 memcpy(ciphertext, tdata->ciphertext.data,
5603 tdata->ciphertext.len);
5604 debug_hexdump(stdout, "ciphertext:", ciphertext,
5605 tdata->ciphertext.len);
5607 if (ut_params->obuf) {
5608 plaintext = (uint8_t *)rte_pktmbuf_append(
5610 plaintext_pad_len + aad_pad_len);
5611 TEST_ASSERT_NOT_NULL(plaintext,
5612 "no room to append plaintext");
5614 memset(plaintext + aad_pad_len, 0,
5615 tdata->plaintext.len);
5619 /* Append digest data */
5620 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5621 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5622 ut_params->obuf ? ut_params->obuf :
5624 tdata->auth_tag.len);
5625 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5626 "no room to append digest");
5627 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5628 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5629 ut_params->obuf ? ut_params->obuf :
5634 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5635 ut_params->ibuf, tdata->auth_tag.len);
5636 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5637 "no room to append digest");
5638 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5640 plaintext_pad_len + aad_pad_len);
5642 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5643 tdata->auth_tag.len);
5644 debug_hexdump(stdout, "digest:",
5645 sym_op->aead.digest.data,
5646 tdata->auth_tag.len);
5649 sym_op->aead.data.length = tdata->plaintext.len;
5650 sym_op->aead.data.offset = aad_pad_len;
5656 test_authenticated_encryption(const struct aead_test_data *tdata)
5658 struct crypto_testsuite_params *ts_params = &testsuite_params;
5659 struct crypto_unittest_params *ut_params = &unittest_params;
5662 uint8_t *ciphertext, *auth_tag;
5663 uint16_t plaintext_pad_len;
5666 /* Create AEAD session */
5667 retval = create_aead_session(ts_params->valid_devs[0],
5669 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5670 tdata->key.data, tdata->key.len,
5671 tdata->aad.len, tdata->auth_tag.len,
5676 if (tdata->aad.len > MBUF_SIZE) {
5677 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5678 /* Populate full size of add data */
5679 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5680 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5682 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5684 /* clear mbuf payload */
5685 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5686 rte_pktmbuf_tailroom(ut_params->ibuf));
5688 /* Create AEAD operation */
5689 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5693 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5695 ut_params->op->sym->m_src = ut_params->ibuf;
5697 /* Process crypto operation */
5698 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5699 ut_params->op), "failed to process sym crypto op");
5701 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5702 "crypto op processing failed");
5704 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5706 if (ut_params->op->sym->m_dst) {
5707 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5709 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5710 uint8_t *, plaintext_pad_len);
5712 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5714 ut_params->op->sym->cipher.data.offset);
5715 auth_tag = ciphertext + plaintext_pad_len;
5718 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5719 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5722 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5724 tdata->ciphertext.data,
5725 tdata->ciphertext.len,
5726 "Ciphertext data not as expected");
5728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5730 tdata->auth_tag.data,
5731 tdata->auth_tag.len,
5732 "Generated auth tag not as expected");
5739 test_AES_GCM_authenticated_encryption_test_case_1(void)
5741 return test_authenticated_encryption(&gcm_test_case_1);
5745 test_AES_GCM_authenticated_encryption_test_case_2(void)
5747 return test_authenticated_encryption(&gcm_test_case_2);
5751 test_AES_GCM_authenticated_encryption_test_case_3(void)
5753 return test_authenticated_encryption(&gcm_test_case_3);
5757 test_AES_GCM_authenticated_encryption_test_case_4(void)
5759 return test_authenticated_encryption(&gcm_test_case_4);
5763 test_AES_GCM_authenticated_encryption_test_case_5(void)
5765 return test_authenticated_encryption(&gcm_test_case_5);
5769 test_AES_GCM_authenticated_encryption_test_case_6(void)
5771 return test_authenticated_encryption(&gcm_test_case_6);
5775 test_AES_GCM_authenticated_encryption_test_case_7(void)
5777 return test_authenticated_encryption(&gcm_test_case_7);
5781 test_AES_GCM_auth_encryption_test_case_192_1(void)
5783 return test_authenticated_encryption(&gcm_test_case_192_1);
5787 test_AES_GCM_auth_encryption_test_case_192_2(void)
5789 return test_authenticated_encryption(&gcm_test_case_192_2);
5793 test_AES_GCM_auth_encryption_test_case_192_3(void)
5795 return test_authenticated_encryption(&gcm_test_case_192_3);
5799 test_AES_GCM_auth_encryption_test_case_192_4(void)
5801 return test_authenticated_encryption(&gcm_test_case_192_4);
5805 test_AES_GCM_auth_encryption_test_case_192_5(void)
5807 return test_authenticated_encryption(&gcm_test_case_192_5);
5811 test_AES_GCM_auth_encryption_test_case_192_6(void)
5813 return test_authenticated_encryption(&gcm_test_case_192_6);
5817 test_AES_GCM_auth_encryption_test_case_192_7(void)
5819 return test_authenticated_encryption(&gcm_test_case_192_7);
5823 test_AES_GCM_auth_encryption_test_case_256_1(void)
5825 return test_authenticated_encryption(&gcm_test_case_256_1);
5829 test_AES_GCM_auth_encryption_test_case_256_2(void)
5831 return test_authenticated_encryption(&gcm_test_case_256_2);
5835 test_AES_GCM_auth_encryption_test_case_256_3(void)
5837 return test_authenticated_encryption(&gcm_test_case_256_3);
5841 test_AES_GCM_auth_encryption_test_case_256_4(void)
5843 return test_authenticated_encryption(&gcm_test_case_256_4);
5847 test_AES_GCM_auth_encryption_test_case_256_5(void)
5849 return test_authenticated_encryption(&gcm_test_case_256_5);
5853 test_AES_GCM_auth_encryption_test_case_256_6(void)
5855 return test_authenticated_encryption(&gcm_test_case_256_6);
5859 test_AES_GCM_auth_encryption_test_case_256_7(void)
5861 return test_authenticated_encryption(&gcm_test_case_256_7);
5865 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5867 return test_authenticated_encryption(&gcm_test_case_aad_1);
5871 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5873 return test_authenticated_encryption(&gcm_test_case_aad_2);
5877 test_authenticated_decryption(const struct aead_test_data *tdata)
5879 struct crypto_testsuite_params *ts_params = &testsuite_params;
5880 struct crypto_unittest_params *ut_params = &unittest_params;
5886 /* Create AEAD session */
5887 retval = create_aead_session(ts_params->valid_devs[0],
5889 RTE_CRYPTO_AEAD_OP_DECRYPT,
5890 tdata->key.data, tdata->key.len,
5891 tdata->aad.len, tdata->auth_tag.len,
5896 /* alloc mbuf and set payload */
5897 if (tdata->aad.len > MBUF_SIZE) {
5898 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5899 /* Populate full size of add data */
5900 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5901 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5903 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5905 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5906 rte_pktmbuf_tailroom(ut_params->ibuf));
5908 /* Create AEAD operation */
5909 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5913 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5915 ut_params->op->sym->m_src = ut_params->ibuf;
5917 /* Process crypto operation */
5918 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5919 ut_params->op), "failed to process sym crypto op");
5921 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5922 "crypto op processing failed");
5924 if (ut_params->op->sym->m_dst)
5925 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5928 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5930 ut_params->op->sym->cipher.data.offset);
5932 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5935 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5937 tdata->plaintext.data,
5938 tdata->plaintext.len,
5939 "Plaintext data not as expected");
5941 TEST_ASSERT_EQUAL(ut_params->op->status,
5942 RTE_CRYPTO_OP_STATUS_SUCCESS,
5943 "Authentication failed");
5948 test_AES_GCM_authenticated_decryption_test_case_1(void)
5950 return test_authenticated_decryption(&gcm_test_case_1);
5954 test_AES_GCM_authenticated_decryption_test_case_2(void)
5956 return test_authenticated_decryption(&gcm_test_case_2);
5960 test_AES_GCM_authenticated_decryption_test_case_3(void)
5962 return test_authenticated_decryption(&gcm_test_case_3);
5966 test_AES_GCM_authenticated_decryption_test_case_4(void)
5968 return test_authenticated_decryption(&gcm_test_case_4);
5972 test_AES_GCM_authenticated_decryption_test_case_5(void)
5974 return test_authenticated_decryption(&gcm_test_case_5);
5978 test_AES_GCM_authenticated_decryption_test_case_6(void)
5980 return test_authenticated_decryption(&gcm_test_case_6);
5984 test_AES_GCM_authenticated_decryption_test_case_7(void)
5986 return test_authenticated_decryption(&gcm_test_case_7);
5990 test_AES_GCM_auth_decryption_test_case_192_1(void)
5992 return test_authenticated_decryption(&gcm_test_case_192_1);
5996 test_AES_GCM_auth_decryption_test_case_192_2(void)
5998 return test_authenticated_decryption(&gcm_test_case_192_2);
6002 test_AES_GCM_auth_decryption_test_case_192_3(void)
6004 return test_authenticated_decryption(&gcm_test_case_192_3);
6008 test_AES_GCM_auth_decryption_test_case_192_4(void)
6010 return test_authenticated_decryption(&gcm_test_case_192_4);
6014 test_AES_GCM_auth_decryption_test_case_192_5(void)
6016 return test_authenticated_decryption(&gcm_test_case_192_5);
6020 test_AES_GCM_auth_decryption_test_case_192_6(void)
6022 return test_authenticated_decryption(&gcm_test_case_192_6);
6026 test_AES_GCM_auth_decryption_test_case_192_7(void)
6028 return test_authenticated_decryption(&gcm_test_case_192_7);
6032 test_AES_GCM_auth_decryption_test_case_256_1(void)
6034 return test_authenticated_decryption(&gcm_test_case_256_1);
6038 test_AES_GCM_auth_decryption_test_case_256_2(void)
6040 return test_authenticated_decryption(&gcm_test_case_256_2);
6044 test_AES_GCM_auth_decryption_test_case_256_3(void)
6046 return test_authenticated_decryption(&gcm_test_case_256_3);
6050 test_AES_GCM_auth_decryption_test_case_256_4(void)
6052 return test_authenticated_decryption(&gcm_test_case_256_4);
6056 test_AES_GCM_auth_decryption_test_case_256_5(void)
6058 return test_authenticated_decryption(&gcm_test_case_256_5);
6062 test_AES_GCM_auth_decryption_test_case_256_6(void)
6064 return test_authenticated_decryption(&gcm_test_case_256_6);
6068 test_AES_GCM_auth_decryption_test_case_256_7(void)
6070 return test_authenticated_decryption(&gcm_test_case_256_7);
6074 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6076 return test_authenticated_decryption(&gcm_test_case_aad_1);
6080 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6082 return test_authenticated_decryption(&gcm_test_case_aad_2);
6086 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6088 struct crypto_testsuite_params *ts_params = &testsuite_params;
6089 struct crypto_unittest_params *ut_params = &unittest_params;
6092 uint8_t *ciphertext, *auth_tag;
6093 uint16_t plaintext_pad_len;
6095 /* Create AEAD session */
6096 retval = create_aead_session(ts_params->valid_devs[0],
6098 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6099 tdata->key.data, tdata->key.len,
6100 tdata->aad.len, tdata->auth_tag.len,
6105 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6106 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6108 /* clear mbuf payload */
6109 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6110 rte_pktmbuf_tailroom(ut_params->ibuf));
6111 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6112 rte_pktmbuf_tailroom(ut_params->obuf));
6114 /* Create AEAD operation */
6115 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6119 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6121 ut_params->op->sym->m_src = ut_params->ibuf;
6122 ut_params->op->sym->m_dst = ut_params->obuf;
6124 /* Process crypto operation */
6125 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6126 ut_params->op), "failed to process sym crypto op");
6128 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6129 "crypto op processing failed");
6131 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6133 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6134 ut_params->op->sym->cipher.data.offset);
6135 auth_tag = ciphertext + plaintext_pad_len;
6137 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6138 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6141 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6143 tdata->ciphertext.data,
6144 tdata->ciphertext.len,
6145 "Ciphertext data not as expected");
6147 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6149 tdata->auth_tag.data,
6150 tdata->auth_tag.len,
6151 "Generated auth tag not as expected");
6158 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6160 return test_authenticated_encryption_oop(&gcm_test_case_5);
6164 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6166 struct crypto_testsuite_params *ts_params = &testsuite_params;
6167 struct crypto_unittest_params *ut_params = &unittest_params;
6172 /* Create AEAD session */
6173 retval = create_aead_session(ts_params->valid_devs[0],
6175 RTE_CRYPTO_AEAD_OP_DECRYPT,
6176 tdata->key.data, tdata->key.len,
6177 tdata->aad.len, tdata->auth_tag.len,
6182 /* alloc mbuf and set payload */
6183 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6184 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6186 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6187 rte_pktmbuf_tailroom(ut_params->ibuf));
6188 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6189 rte_pktmbuf_tailroom(ut_params->obuf));
6191 /* Create AEAD operation */
6192 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6196 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6198 ut_params->op->sym->m_src = ut_params->ibuf;
6199 ut_params->op->sym->m_dst = ut_params->obuf;
6201 /* Process crypto operation */
6202 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6203 ut_params->op), "failed to process sym crypto op");
6205 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6206 "crypto op processing failed");
6208 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6209 ut_params->op->sym->cipher.data.offset);
6211 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6214 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6216 tdata->plaintext.data,
6217 tdata->plaintext.len,
6218 "Plaintext data not as expected");
6220 TEST_ASSERT_EQUAL(ut_params->op->status,
6221 RTE_CRYPTO_OP_STATUS_SUCCESS,
6222 "Authentication failed");
6227 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6229 return test_authenticated_decryption_oop(&gcm_test_case_5);
6233 test_authenticated_encryption_sessionless(
6234 const struct aead_test_data *tdata)
6236 struct crypto_testsuite_params *ts_params = &testsuite_params;
6237 struct crypto_unittest_params *ut_params = &unittest_params;
6240 uint8_t *ciphertext, *auth_tag;
6241 uint16_t plaintext_pad_len;
6242 uint8_t key[tdata->key.len + 1];
6244 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6246 /* clear mbuf payload */
6247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6248 rte_pktmbuf_tailroom(ut_params->ibuf));
6250 /* Create AEAD operation */
6251 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6255 /* Create GCM xform */
6256 memcpy(key, tdata->key.data, tdata->key.len);
6257 retval = create_aead_xform(ut_params->op,
6259 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6260 key, tdata->key.len,
6261 tdata->aad.len, tdata->auth_tag.len,
6266 ut_params->op->sym->m_src = ut_params->ibuf;
6268 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6269 RTE_CRYPTO_OP_SESSIONLESS,
6270 "crypto op session type not sessionless");
6272 /* Process crypto operation */
6273 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6274 ut_params->op), "failed to process sym crypto op");
6276 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6278 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6279 "crypto op status not success");
6281 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6283 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6284 ut_params->op->sym->cipher.data.offset);
6285 auth_tag = ciphertext + plaintext_pad_len;
6287 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6288 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6291 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6293 tdata->ciphertext.data,
6294 tdata->ciphertext.len,
6295 "Ciphertext data not as expected");
6297 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6299 tdata->auth_tag.data,
6300 tdata->auth_tag.len,
6301 "Generated auth tag not as expected");
6308 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6310 return test_authenticated_encryption_sessionless(
6315 test_authenticated_decryption_sessionless(
6316 const struct aead_test_data *tdata)
6318 struct crypto_testsuite_params *ts_params = &testsuite_params;
6319 struct crypto_unittest_params *ut_params = &unittest_params;
6323 uint8_t key[tdata->key.len + 1];
6325 /* alloc mbuf and set payload */
6326 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6328 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6329 rte_pktmbuf_tailroom(ut_params->ibuf));
6331 /* Create AEAD operation */
6332 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6336 /* Create AEAD xform */
6337 memcpy(key, tdata->key.data, tdata->key.len);
6338 retval = create_aead_xform(ut_params->op,
6340 RTE_CRYPTO_AEAD_OP_DECRYPT,
6341 key, tdata->key.len,
6342 tdata->aad.len, tdata->auth_tag.len,
6347 ut_params->op->sym->m_src = ut_params->ibuf;
6349 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6350 RTE_CRYPTO_OP_SESSIONLESS,
6351 "crypto op session type not sessionless");
6353 /* Process crypto operation */
6354 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6355 ut_params->op), "failed to process sym crypto op");
6357 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6359 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6360 "crypto op status not success");
6362 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6363 ut_params->op->sym->cipher.data.offset);
6365 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6368 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6370 tdata->plaintext.data,
6371 tdata->plaintext.len,
6372 "Plaintext data not as expected");
6374 TEST_ASSERT_EQUAL(ut_params->op->status,
6375 RTE_CRYPTO_OP_STATUS_SUCCESS,
6376 "Authentication failed");
6381 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6383 return test_authenticated_decryption_sessionless(
6388 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6390 return test_authenticated_encryption(&ccm_test_case_128_1);
6394 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6396 return test_authenticated_encryption(&ccm_test_case_128_2);
6400 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6402 return test_authenticated_encryption(&ccm_test_case_128_3);
6406 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6408 return test_authenticated_decryption(&ccm_test_case_128_1);
6412 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6414 return test_authenticated_decryption(&ccm_test_case_128_2);
6418 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6420 return test_authenticated_decryption(&ccm_test_case_128_3);
6424 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6426 return test_authenticated_encryption(&ccm_test_case_192_1);
6430 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6432 return test_authenticated_encryption(&ccm_test_case_192_2);
6436 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6438 return test_authenticated_encryption(&ccm_test_case_192_3);
6442 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6444 return test_authenticated_decryption(&ccm_test_case_192_1);
6448 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6450 return test_authenticated_decryption(&ccm_test_case_192_2);
6454 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6456 return test_authenticated_decryption(&ccm_test_case_192_3);
6460 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6462 return test_authenticated_encryption(&ccm_test_case_256_1);
6466 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6468 return test_authenticated_encryption(&ccm_test_case_256_2);
6472 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6474 return test_authenticated_encryption(&ccm_test_case_256_3);
6478 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6480 return test_authenticated_decryption(&ccm_test_case_256_1);
6484 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6486 return test_authenticated_decryption(&ccm_test_case_256_2);
6490 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6492 return test_authenticated_decryption(&ccm_test_case_256_3);
6498 struct crypto_testsuite_params *ts_params = &testsuite_params;
6499 struct rte_cryptodev_stats stats;
6500 struct rte_cryptodev *dev;
6501 cryptodev_stats_get_t temp_pfn;
6503 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6504 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6505 &stats) == -ENODEV),
6506 "rte_cryptodev_stats_get invalid dev failed");
6507 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6508 "rte_cryptodev_stats_get invalid Param failed");
6509 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6510 temp_pfn = dev->dev_ops->stats_get;
6511 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6512 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6514 "rte_cryptodev_stats_get invalid Param failed");
6515 dev->dev_ops->stats_get = temp_pfn;
6517 /* Test expected values */
6519 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6521 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6523 "rte_cryptodev_stats_get failed");
6524 TEST_ASSERT((stats.enqueued_count == 1),
6525 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6526 TEST_ASSERT((stats.dequeued_count == 1),
6527 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6528 TEST_ASSERT((stats.enqueue_err_count == 0),
6529 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6530 TEST_ASSERT((stats.dequeue_err_count == 0),
6531 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6533 /* invalid device but should ignore and not reset device stats*/
6534 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6535 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6537 "rte_cryptodev_stats_get failed");
6538 TEST_ASSERT((stats.enqueued_count == 1),
6539 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6541 /* check that a valid reset clears stats */
6542 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6543 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6545 "rte_cryptodev_stats_get failed");
6546 TEST_ASSERT((stats.enqueued_count == 0),
6547 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6548 TEST_ASSERT((stats.dequeued_count == 0),
6549 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6551 return TEST_SUCCESS;
6554 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6555 struct crypto_unittest_params *ut_params,
6556 enum rte_crypto_auth_operation op,
6557 const struct HMAC_MD5_vector *test_case)
6561 memcpy(key, test_case->key.data, test_case->key.len);
6563 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6564 ut_params->auth_xform.next = NULL;
6565 ut_params->auth_xform.auth.op = op;
6567 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6569 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6570 ut_params->auth_xform.auth.key.length = test_case->key.len;
6571 ut_params->auth_xform.auth.key.data = key;
6573 ut_params->sess = rte_cryptodev_sym_session_create(
6574 ts_params->session_mpool);
6576 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6577 ut_params->sess, &ut_params->auth_xform,
6578 ts_params->session_priv_mpool);
6580 if (ut_params->sess == NULL)
6583 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6585 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6586 rte_pktmbuf_tailroom(ut_params->ibuf));
6591 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6592 const struct HMAC_MD5_vector *test_case,
6593 uint8_t **plaintext)
6595 uint16_t plaintext_pad_len;
6597 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6599 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6602 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6604 memcpy(*plaintext, test_case->plaintext.data,
6605 test_case->plaintext.len);
6607 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6608 ut_params->ibuf, MD5_DIGEST_LEN);
6609 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6610 "no room to append digest");
6611 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6612 ut_params->ibuf, plaintext_pad_len);
6614 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6615 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6616 test_case->auth_tag.len);
6619 sym_op->auth.data.offset = 0;
6620 sym_op->auth.data.length = test_case->plaintext.len;
6622 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6623 ut_params->op->sym->m_src = ut_params->ibuf;
6629 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6631 uint16_t plaintext_pad_len;
6632 uint8_t *plaintext, *auth_tag;
6634 struct crypto_testsuite_params *ts_params = &testsuite_params;
6635 struct crypto_unittest_params *ut_params = &unittest_params;
6637 if (MD5_HMAC_create_session(ts_params, ut_params,
6638 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6641 /* Generate Crypto op data structure */
6642 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6643 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6644 TEST_ASSERT_NOT_NULL(ut_params->op,
6645 "Failed to allocate symmetric crypto operation struct");
6647 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6650 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6653 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6654 ut_params->op), "failed to process sym crypto op");
6656 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6657 "crypto op processing failed");
6659 if (ut_params->op->sym->m_dst) {
6660 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6661 uint8_t *, plaintext_pad_len);
6663 auth_tag = plaintext + plaintext_pad_len;
6666 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6668 test_case->auth_tag.data,
6669 test_case->auth_tag.len,
6670 "HMAC_MD5 generated tag not as expected");
6672 return TEST_SUCCESS;
6676 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6680 struct crypto_testsuite_params *ts_params = &testsuite_params;
6681 struct crypto_unittest_params *ut_params = &unittest_params;
6683 if (MD5_HMAC_create_session(ts_params, ut_params,
6684 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6688 /* Generate Crypto op data structure */
6689 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6690 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6691 TEST_ASSERT_NOT_NULL(ut_params->op,
6692 "Failed to allocate symmetric crypto operation struct");
6694 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6697 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6698 ut_params->op), "failed to process sym crypto op");
6700 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6701 "HMAC_MD5 crypto op processing failed");
6703 return TEST_SUCCESS;
6707 test_MD5_HMAC_generate_case_1(void)
6709 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6713 test_MD5_HMAC_verify_case_1(void)
6715 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6719 test_MD5_HMAC_generate_case_2(void)
6721 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6725 test_MD5_HMAC_verify_case_2(void)
6727 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6731 test_multi_session(void)
6733 struct crypto_testsuite_params *ts_params = &testsuite_params;
6734 struct crypto_unittest_params *ut_params = &unittest_params;
6736 struct rte_cryptodev_info dev_info;
6737 struct rte_cryptodev_sym_session **sessions;
6741 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6742 aes_cbc_key, hmac_sha512_key);
6745 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6747 sessions = rte_malloc(NULL,
6748 (sizeof(struct rte_cryptodev_sym_session *) *
6749 MAX_NB_SESSIONS) + 1, 0);
6751 /* Create multiple crypto sessions*/
6752 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6754 sessions[i] = rte_cryptodev_sym_session_create(
6755 ts_params->session_mpool);
6757 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6758 sessions[i], &ut_params->auth_xform,
6759 ts_params->session_priv_mpool);
6760 TEST_ASSERT_NOT_NULL(sessions[i],
6761 "Session creation failed at session number %u",
6764 /* Attempt to send a request on each session */
6765 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6769 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6770 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6772 "Failed to perform decrypt on request number %u.", i);
6773 /* free crypto operation structure */
6775 rte_crypto_op_free(ut_params->op);
6778 * free mbuf - both obuf and ibuf are usually the same,
6779 * so check if they point at the same address is necessary,
6780 * to avoid freeing the mbuf twice.
6782 if (ut_params->obuf) {
6783 rte_pktmbuf_free(ut_params->obuf);
6784 if (ut_params->ibuf == ut_params->obuf)
6785 ut_params->ibuf = 0;
6786 ut_params->obuf = 0;
6788 if (ut_params->ibuf) {
6789 rte_pktmbuf_free(ut_params->ibuf);
6790 ut_params->ibuf = 0;
6794 /* Next session create should fail */
6795 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6796 sessions[i], &ut_params->auth_xform,
6797 ts_params->session_priv_mpool);
6798 TEST_ASSERT_NULL(sessions[i],
6799 "Session creation succeeded unexpectedly!");
6801 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6802 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6804 rte_cryptodev_sym_session_free(sessions[i]);
6809 return TEST_SUCCESS;
6812 struct multi_session_params {
6813 struct crypto_unittest_params ut_params;
6814 uint8_t *cipher_key;
6816 const uint8_t *cipher;
6817 const uint8_t *digest;
6821 #define MB_SESSION_NUMBER 3
6824 test_multi_session_random_usage(void)
6826 struct crypto_testsuite_params *ts_params = &testsuite_params;
6827 struct rte_cryptodev_info dev_info;
6828 struct rte_cryptodev_sym_session **sessions;
6830 struct multi_session_params ut_paramz[] = {
6833 .cipher_key = ms_aes_cbc_key0,
6834 .hmac_key = ms_hmac_key0,
6835 .cipher = ms_aes_cbc_cipher0,
6836 .digest = ms_hmac_digest0,
6837 .iv = ms_aes_cbc_iv0
6840 .cipher_key = ms_aes_cbc_key1,
6841 .hmac_key = ms_hmac_key1,
6842 .cipher = ms_aes_cbc_cipher1,
6843 .digest = ms_hmac_digest1,
6844 .iv = ms_aes_cbc_iv1
6847 .cipher_key = ms_aes_cbc_key2,
6848 .hmac_key = ms_hmac_key2,
6849 .cipher = ms_aes_cbc_cipher2,
6850 .digest = ms_hmac_digest2,
6851 .iv = ms_aes_cbc_iv2
6856 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6858 sessions = rte_malloc(NULL,
6859 (sizeof(struct rte_cryptodev_sym_session *)
6860 * MAX_NB_SESSIONS) + 1, 0);
6862 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6863 sessions[i] = rte_cryptodev_sym_session_create(
6864 ts_params->session_mpool);
6866 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6867 sizeof(struct crypto_unittest_params));
6869 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6870 &ut_paramz[i].ut_params,
6871 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6873 /* Create multiple crypto sessions*/
6874 rte_cryptodev_sym_session_init(
6875 ts_params->valid_devs[0],
6877 &ut_paramz[i].ut_params.auth_xform,
6878 ts_params->session_priv_mpool);
6880 TEST_ASSERT_NOT_NULL(sessions[i],
6881 "Session creation failed at session number %u",
6887 for (i = 0; i < 40000; i++) {
6889 j = rand() % MB_SESSION_NUMBER;
6891 TEST_ASSERT_SUCCESS(
6892 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6894 &ut_paramz[j].ut_params,
6895 ts_params, ut_paramz[j].cipher,
6896 ut_paramz[j].digest,
6898 "Failed to perform decrypt on request number %u.", i);
6900 if (ut_paramz[j].ut_params.op)
6901 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6904 * free mbuf - both obuf and ibuf are usually the same,
6905 * so check if they point at the same address is necessary,
6906 * to avoid freeing the mbuf twice.
6908 if (ut_paramz[j].ut_params.obuf) {
6909 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6910 if (ut_paramz[j].ut_params.ibuf
6911 == ut_paramz[j].ut_params.obuf)
6912 ut_paramz[j].ut_params.ibuf = 0;
6913 ut_paramz[j].ut_params.obuf = 0;
6915 if (ut_paramz[j].ut_params.ibuf) {
6916 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6917 ut_paramz[j].ut_params.ibuf = 0;
6921 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6922 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6924 rte_cryptodev_sym_session_free(sessions[i]);
6929 return TEST_SUCCESS;
6933 test_null_cipher_only_operation(void)
6935 struct crypto_testsuite_params *ts_params = &testsuite_params;
6936 struct crypto_unittest_params *ut_params = &unittest_params;
6938 /* Generate test mbuf data and space for digest */
6939 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6940 catch_22_quote, QUOTE_512_BYTES, 0);
6942 /* Setup Cipher Parameters */
6943 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6944 ut_params->cipher_xform.next = NULL;
6946 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6947 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6949 ut_params->sess = rte_cryptodev_sym_session_create(
6950 ts_params->session_mpool);
6952 /* Create Crypto session*/
6953 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6955 &ut_params->cipher_xform,
6956 ts_params->session_priv_mpool);
6957 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6959 /* Generate Crypto op data structure */
6960 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6961 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6962 TEST_ASSERT_NOT_NULL(ut_params->op,
6963 "Failed to allocate symmetric crypto operation struct");
6965 /* Set crypto operation data parameters */
6966 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6968 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6970 /* set crypto operation source mbuf */
6971 sym_op->m_src = ut_params->ibuf;
6973 sym_op->cipher.data.offset = 0;
6974 sym_op->cipher.data.length = QUOTE_512_BYTES;
6976 /* Process crypto operation */
6977 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6979 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6981 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6982 "crypto operation processing failed");
6985 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6986 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6989 "Ciphertext data not as expected");
6991 return TEST_SUCCESS;
6993 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6994 0xab, 0xab, 0xab, 0xab,
6995 0xab, 0xab, 0xab, 0xab,
6996 0xab, 0xab, 0xab, 0xab};
6998 test_null_auth_only_operation(void)
7000 struct crypto_testsuite_params *ts_params = &testsuite_params;
7001 struct crypto_unittest_params *ut_params = &unittest_params;
7004 /* Generate test mbuf data and space for digest */
7005 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7006 catch_22_quote, QUOTE_512_BYTES, 0);
7008 /* create a pointer for digest, but don't expect anything to be written
7009 * here in a NULL auth algo so no mbuf append done.
7011 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7013 /* prefill the memory pointed to by digest */
7014 memcpy(digest, orig_data, sizeof(orig_data));
7016 /* Setup HMAC Parameters */
7017 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7018 ut_params->auth_xform.next = NULL;
7020 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7021 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7023 ut_params->sess = rte_cryptodev_sym_session_create(
7024 ts_params->session_mpool);
7026 /* Create Crypto session*/
7027 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7028 ut_params->sess, &ut_params->auth_xform,
7029 ts_params->session_priv_mpool);
7030 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7032 /* Generate Crypto op data structure */
7033 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7034 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7035 TEST_ASSERT_NOT_NULL(ut_params->op,
7036 "Failed to allocate symmetric crypto operation struct");
7038 /* Set crypto operation data parameters */
7039 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7041 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7043 sym_op->m_src = ut_params->ibuf;
7045 sym_op->auth.data.offset = 0;
7046 sym_op->auth.data.length = QUOTE_512_BYTES;
7047 sym_op->auth.digest.data = digest;
7048 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7051 /* Process crypto operation */
7052 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7054 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7056 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7057 "crypto operation processing failed");
7058 /* Make sure memory pointed to by digest hasn't been overwritten */
7059 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7063 "Memory at digest ptr overwritten unexpectedly");
7065 return TEST_SUCCESS;
7070 test_null_cipher_auth_operation(void)
7072 struct crypto_testsuite_params *ts_params = &testsuite_params;
7073 struct crypto_unittest_params *ut_params = &unittest_params;
7076 /* Generate test mbuf data and space for digest */
7077 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7078 catch_22_quote, QUOTE_512_BYTES, 0);
7080 /* create a pointer for digest, but don't expect anything to be written
7081 * here in a NULL auth algo so no mbuf append done.
7083 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7085 /* prefill the memory pointed to by digest */
7086 memcpy(digest, orig_data, sizeof(orig_data));
7088 /* Setup Cipher Parameters */
7089 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7090 ut_params->cipher_xform.next = &ut_params->auth_xform;
7092 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7093 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7095 /* Setup HMAC Parameters */
7096 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7097 ut_params->auth_xform.next = NULL;
7099 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7100 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7102 ut_params->sess = rte_cryptodev_sym_session_create(
7103 ts_params->session_mpool);
7105 /* Create Crypto session*/
7106 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7107 ut_params->sess, &ut_params->cipher_xform,
7108 ts_params->session_priv_mpool);
7109 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7111 /* Generate Crypto op data structure */
7112 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7113 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7114 TEST_ASSERT_NOT_NULL(ut_params->op,
7115 "Failed to allocate symmetric crypto operation struct");
7117 /* Set crypto operation data parameters */
7118 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7120 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7122 sym_op->m_src = ut_params->ibuf;
7124 sym_op->cipher.data.offset = 0;
7125 sym_op->cipher.data.length = QUOTE_512_BYTES;
7127 sym_op->auth.data.offset = 0;
7128 sym_op->auth.data.length = QUOTE_512_BYTES;
7129 sym_op->auth.digest.data = digest;
7130 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7133 /* Process crypto operation */
7134 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7136 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7138 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7139 "crypto operation processing failed");
7142 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7143 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7146 "Ciphertext data not as expected");
7147 /* Make sure memory pointed to by digest hasn't been overwritten */
7148 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7152 "Memory at digest ptr overwritten unexpectedly");
7154 return TEST_SUCCESS;
7158 test_null_auth_cipher_operation(void)
7160 struct crypto_testsuite_params *ts_params = &testsuite_params;
7161 struct crypto_unittest_params *ut_params = &unittest_params;
7164 /* Generate test mbuf data */
7165 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7166 catch_22_quote, QUOTE_512_BYTES, 0);
7168 /* create a pointer for digest, but don't expect anything to be written
7169 * here in a NULL auth algo so no mbuf append done.
7171 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7173 /* prefill the memory pointed to by digest */
7174 memcpy(digest, orig_data, sizeof(orig_data));
7176 /* Setup Cipher Parameters */
7177 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7178 ut_params->cipher_xform.next = NULL;
7180 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7181 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7183 /* Setup HMAC Parameters */
7184 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7185 ut_params->auth_xform.next = &ut_params->cipher_xform;
7187 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7188 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7190 ut_params->sess = rte_cryptodev_sym_session_create(
7191 ts_params->session_mpool);
7193 /* Create Crypto session*/
7194 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7195 ut_params->sess, &ut_params->cipher_xform,
7196 ts_params->session_priv_mpool);
7197 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7199 /* Generate Crypto op data structure */
7200 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7201 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7202 TEST_ASSERT_NOT_NULL(ut_params->op,
7203 "Failed to allocate symmetric crypto operation struct");
7205 /* Set crypto operation data parameters */
7206 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7208 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7210 sym_op->m_src = ut_params->ibuf;
7212 sym_op->cipher.data.offset = 0;
7213 sym_op->cipher.data.length = QUOTE_512_BYTES;
7215 sym_op->auth.data.offset = 0;
7216 sym_op->auth.data.length = QUOTE_512_BYTES;
7217 sym_op->auth.digest.data = digest;
7218 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7221 /* Process crypto operation */
7222 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7224 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7226 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7227 "crypto operation processing failed");
7230 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7231 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7234 "Ciphertext data not as expected");
7235 /* Make sure memory pointed to by digest hasn't been overwritten */
7236 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7240 "Memory at digest ptr overwritten unexpectedly");
7242 return TEST_SUCCESS;
7247 test_null_invalid_operation(void)
7249 struct crypto_testsuite_params *ts_params = &testsuite_params;
7250 struct crypto_unittest_params *ut_params = &unittest_params;
7253 /* Setup Cipher Parameters */
7254 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7255 ut_params->cipher_xform.next = NULL;
7257 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7258 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7260 ut_params->sess = rte_cryptodev_sym_session_create(
7261 ts_params->session_mpool);
7263 /* Create Crypto session*/
7264 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7265 ut_params->sess, &ut_params->cipher_xform,
7266 ts_params->session_priv_mpool);
7267 TEST_ASSERT(ret < 0,
7268 "Session creation succeeded unexpectedly");
7271 /* Setup HMAC Parameters */
7272 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7273 ut_params->auth_xform.next = NULL;
7275 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7276 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7278 ut_params->sess = rte_cryptodev_sym_session_create(
7279 ts_params->session_mpool);
7281 /* Create Crypto session*/
7282 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7283 ut_params->sess, &ut_params->auth_xform,
7284 ts_params->session_priv_mpool);
7285 TEST_ASSERT(ret < 0,
7286 "Session creation succeeded unexpectedly");
7288 return TEST_SUCCESS;
7292 #define NULL_BURST_LENGTH (32)
7295 test_null_burst_operation(void)
7297 struct crypto_testsuite_params *ts_params = &testsuite_params;
7298 struct crypto_unittest_params *ut_params = &unittest_params;
7300 unsigned i, burst_len = NULL_BURST_LENGTH;
7302 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7303 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7305 /* Setup Cipher Parameters */
7306 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7307 ut_params->cipher_xform.next = &ut_params->auth_xform;
7309 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7310 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7312 /* Setup HMAC Parameters */
7313 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7314 ut_params->auth_xform.next = NULL;
7316 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7317 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7319 ut_params->sess = rte_cryptodev_sym_session_create(
7320 ts_params->session_mpool);
7322 /* Create Crypto session*/
7323 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7324 ut_params->sess, &ut_params->cipher_xform,
7325 ts_params->session_priv_mpool);
7326 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7328 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7329 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7330 burst_len, "failed to generate burst of crypto ops");
7332 /* Generate an operation for each mbuf in burst */
7333 for (i = 0; i < burst_len; i++) {
7334 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7336 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7338 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7342 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7344 burst[i]->sym->m_src = m;
7347 /* Process crypto operation */
7348 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7349 0, burst, burst_len),
7351 "Error enqueuing burst");
7353 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7354 0, burst_dequeued, burst_len),
7356 "Error dequeuing burst");
7359 for (i = 0; i < burst_len; i++) {
7361 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7362 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7364 "data not as expected");
7366 rte_pktmbuf_free(burst[i]->sym->m_src);
7367 rte_crypto_op_free(burst[i]);
7370 return TEST_SUCCESS;
7374 generate_gmac_large_plaintext(uint8_t *data)
7378 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7379 memcpy(&data[i], &data[0], 32);
7383 create_gmac_operation(enum rte_crypto_auth_operation op,
7384 const struct gmac_test_data *tdata)
7386 struct crypto_testsuite_params *ts_params = &testsuite_params;
7387 struct crypto_unittest_params *ut_params = &unittest_params;
7388 struct rte_crypto_sym_op *sym_op;
7390 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7392 /* Generate Crypto op data structure */
7393 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7394 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7395 TEST_ASSERT_NOT_NULL(ut_params->op,
7396 "Failed to allocate symmetric crypto operation struct");
7398 sym_op = ut_params->op->sym;
7400 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7401 ut_params->ibuf, tdata->gmac_tag.len);
7402 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7403 "no room to append digest");
7405 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7406 ut_params->ibuf, plaintext_pad_len);
7408 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7409 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7410 tdata->gmac_tag.len);
7411 debug_hexdump(stdout, "digest:",
7412 sym_op->auth.digest.data,
7413 tdata->gmac_tag.len);
7416 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7417 uint8_t *, IV_OFFSET);
7419 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7421 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7423 sym_op->cipher.data.length = 0;
7424 sym_op->cipher.data.offset = 0;
7426 sym_op->auth.data.offset = 0;
7427 sym_op->auth.data.length = tdata->plaintext.len;
7432 static int create_gmac_session(uint8_t dev_id,
7433 const struct gmac_test_data *tdata,
7434 enum rte_crypto_auth_operation auth_op)
7436 uint8_t auth_key[tdata->key.len];
7438 struct crypto_testsuite_params *ts_params = &testsuite_params;
7439 struct crypto_unittest_params *ut_params = &unittest_params;
7441 memcpy(auth_key, tdata->key.data, tdata->key.len);
7443 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7444 ut_params->auth_xform.next = NULL;
7446 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7447 ut_params->auth_xform.auth.op = auth_op;
7448 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7449 ut_params->auth_xform.auth.key.length = tdata->key.len;
7450 ut_params->auth_xform.auth.key.data = auth_key;
7451 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7452 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7455 ut_params->sess = rte_cryptodev_sym_session_create(
7456 ts_params->session_mpool);
7458 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7459 &ut_params->auth_xform,
7460 ts_params->session_priv_mpool);
7462 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7468 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7470 struct crypto_testsuite_params *ts_params = &testsuite_params;
7471 struct crypto_unittest_params *ut_params = &unittest_params;
7475 uint8_t *auth_tag, *plaintext;
7476 uint16_t plaintext_pad_len;
7478 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7479 "No GMAC length in the source data");
7481 retval = create_gmac_session(ts_params->valid_devs[0],
7482 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7487 if (tdata->plaintext.len > MBUF_SIZE)
7488 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7490 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7491 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7492 "Failed to allocate input buffer in mempool");
7494 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7495 rte_pktmbuf_tailroom(ut_params->ibuf));
7497 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7499 * Runtime generate the large plain text instead of use hard code
7500 * plain text vector. It is done to avoid create huge source file
7501 * with the test vector.
7503 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7504 generate_gmac_large_plaintext(tdata->plaintext.data);
7506 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7508 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7510 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7511 debug_hexdump(stdout, "plaintext:", plaintext,
7512 tdata->plaintext.len);
7514 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7520 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7522 ut_params->op->sym->m_src = ut_params->ibuf;
7524 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7525 ut_params->op), "failed to process sym crypto op");
7527 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7528 "crypto op processing failed");
7530 if (ut_params->op->sym->m_dst) {
7531 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7532 uint8_t *, plaintext_pad_len);
7534 auth_tag = plaintext + plaintext_pad_len;
7537 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7539 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7541 tdata->gmac_tag.data,
7542 tdata->gmac_tag.len,
7543 "GMAC Generated auth tag not as expected");
7549 test_AES_GMAC_authentication_test_case_1(void)
7551 return test_AES_GMAC_authentication(&gmac_test_case_1);
7555 test_AES_GMAC_authentication_test_case_2(void)
7557 return test_AES_GMAC_authentication(&gmac_test_case_2);
7561 test_AES_GMAC_authentication_test_case_3(void)
7563 return test_AES_GMAC_authentication(&gmac_test_case_3);
7567 test_AES_GMAC_authentication_test_case_4(void)
7569 return test_AES_GMAC_authentication(&gmac_test_case_4);
7573 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7575 struct crypto_testsuite_params *ts_params = &testsuite_params;
7576 struct crypto_unittest_params *ut_params = &unittest_params;
7578 uint32_t plaintext_pad_len;
7581 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7582 "No GMAC length in the source data");
7584 retval = create_gmac_session(ts_params->valid_devs[0],
7585 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7590 if (tdata->plaintext.len > MBUF_SIZE)
7591 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7593 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7594 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7595 "Failed to allocate input buffer in mempool");
7597 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7598 rte_pktmbuf_tailroom(ut_params->ibuf));
7600 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7603 * Runtime generate the large plain text instead of use hard code
7604 * plain text vector. It is done to avoid create huge source file
7605 * with the test vector.
7607 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7608 generate_gmac_large_plaintext(tdata->plaintext.data);
7610 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7612 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7614 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7615 debug_hexdump(stdout, "plaintext:", plaintext,
7616 tdata->plaintext.len);
7618 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7624 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7626 ut_params->op->sym->m_src = ut_params->ibuf;
7628 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7629 ut_params->op), "failed to process sym crypto op");
7631 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7632 "crypto op processing failed");
7639 test_AES_GMAC_authentication_verify_test_case_1(void)
7641 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7645 test_AES_GMAC_authentication_verify_test_case_2(void)
7647 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7651 test_AES_GMAC_authentication_verify_test_case_3(void)
7653 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7657 test_AES_GMAC_authentication_verify_test_case_4(void)
7659 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7662 struct test_crypto_vector {
7663 enum rte_crypto_cipher_algorithm crypto_algo;
7676 const uint8_t *data;
7681 const uint8_t *data;
7685 enum rte_crypto_auth_algorithm auth_algo;
7693 const uint8_t *data;
7703 static const struct test_crypto_vector
7704 hmac_sha1_test_crypto_vector = {
7705 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7707 .data = plaintext_hash,
7712 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7713 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7714 0xDE, 0xF4, 0xDE, 0xAD
7720 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7721 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7722 0x3F, 0x91, 0x64, 0x59
7728 static const struct test_crypto_vector
7729 aes128_gmac_test_vector = {
7730 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7732 .data = plaintext_hash,
7737 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7738 0x08, 0x09, 0x0A, 0x0B
7744 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7745 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7751 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7752 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7758 static const struct test_crypto_vector
7759 aes128cbc_hmac_sha1_test_vector = {
7760 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7763 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7764 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7770 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7771 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7776 .data = plaintext_hash,
7780 .data = ciphertext512_aes128cbc,
7783 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7786 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7787 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7788 0xDE, 0xF4, 0xDE, 0xAD
7794 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7795 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7796 0x18, 0x8C, 0x1D, 0x32
7803 data_corruption(uint8_t *data)
7809 tag_corruption(uint8_t *data, unsigned int tag_offset)
7811 data[tag_offset] += 1;
7815 create_auth_session(struct crypto_unittest_params *ut_params,
7817 const struct test_crypto_vector *reference,
7818 enum rte_crypto_auth_operation auth_op)
7820 struct crypto_testsuite_params *ts_params = &testsuite_params;
7821 uint8_t auth_key[reference->auth_key.len + 1];
7823 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7825 /* Setup Authentication Parameters */
7826 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7827 ut_params->auth_xform.auth.op = auth_op;
7828 ut_params->auth_xform.next = NULL;
7829 ut_params->auth_xform.auth.algo = reference->auth_algo;
7830 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7831 ut_params->auth_xform.auth.key.data = auth_key;
7832 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7834 /* Create Crypto session*/
7835 ut_params->sess = rte_cryptodev_sym_session_create(
7836 ts_params->session_mpool);
7838 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7839 &ut_params->auth_xform,
7840 ts_params->session_priv_mpool);
7842 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7848 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7850 const struct test_crypto_vector *reference,
7851 enum rte_crypto_auth_operation auth_op,
7852 enum rte_crypto_cipher_operation cipher_op)
7854 struct crypto_testsuite_params *ts_params = &testsuite_params;
7855 uint8_t cipher_key[reference->cipher_key.len + 1];
7856 uint8_t auth_key[reference->auth_key.len + 1];
7858 memcpy(cipher_key, reference->cipher_key.data,
7859 reference->cipher_key.len);
7860 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7862 /* Setup Authentication Parameters */
7863 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7864 ut_params->auth_xform.auth.op = auth_op;
7865 ut_params->auth_xform.auth.algo = reference->auth_algo;
7866 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7867 ut_params->auth_xform.auth.key.data = auth_key;
7868 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7870 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7871 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7872 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7874 ut_params->auth_xform.next = &ut_params->cipher_xform;
7876 /* Setup Cipher Parameters */
7877 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7878 ut_params->cipher_xform.next = NULL;
7879 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7880 ut_params->cipher_xform.cipher.op = cipher_op;
7881 ut_params->cipher_xform.cipher.key.data = cipher_key;
7882 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7883 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7884 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7887 /* Create Crypto session*/
7888 ut_params->sess = rte_cryptodev_sym_session_create(
7889 ts_params->session_mpool);
7891 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7892 &ut_params->auth_xform,
7893 ts_params->session_priv_mpool);
7895 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7901 create_auth_operation(struct crypto_testsuite_params *ts_params,
7902 struct crypto_unittest_params *ut_params,
7903 const struct test_crypto_vector *reference,
7904 unsigned int auth_generate)
7906 /* Generate Crypto op data structure */
7907 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7908 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7909 TEST_ASSERT_NOT_NULL(ut_params->op,
7910 "Failed to allocate pktmbuf offload");
7912 /* Set crypto operation data parameters */
7913 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7915 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7917 /* set crypto operation source mbuf */
7918 sym_op->m_src = ut_params->ibuf;
7921 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7922 ut_params->ibuf, reference->digest.len);
7924 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7925 "no room to append auth tag");
7927 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7928 ut_params->ibuf, reference->plaintext.len);
7931 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7933 memcpy(sym_op->auth.digest.data,
7934 reference->digest.data,
7935 reference->digest.len);
7937 debug_hexdump(stdout, "digest:",
7938 sym_op->auth.digest.data,
7939 reference->digest.len);
7941 sym_op->auth.data.length = reference->plaintext.len;
7942 sym_op->auth.data.offset = 0;
7948 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7949 struct crypto_unittest_params *ut_params,
7950 const struct test_crypto_vector *reference,
7951 unsigned int auth_generate)
7953 /* Generate Crypto op data structure */
7954 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7955 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7956 TEST_ASSERT_NOT_NULL(ut_params->op,
7957 "Failed to allocate pktmbuf offload");
7959 /* Set crypto operation data parameters */
7960 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7962 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7964 /* set crypto operation source mbuf */
7965 sym_op->m_src = ut_params->ibuf;
7968 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7969 ut_params->ibuf, reference->digest.len);
7971 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7972 "no room to append auth tag");
7974 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7975 ut_params->ibuf, reference->ciphertext.len);
7978 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7980 memcpy(sym_op->auth.digest.data,
7981 reference->digest.data,
7982 reference->digest.len);
7984 debug_hexdump(stdout, "digest:",
7985 sym_op->auth.digest.data,
7986 reference->digest.len);
7988 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7989 reference->iv.data, reference->iv.len);
7991 sym_op->cipher.data.length = 0;
7992 sym_op->cipher.data.offset = 0;
7994 sym_op->auth.data.length = reference->plaintext.len;
7995 sym_op->auth.data.offset = 0;
8001 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8002 struct crypto_unittest_params *ut_params,
8003 const struct test_crypto_vector *reference,
8004 unsigned int auth_generate)
8006 /* Generate Crypto op data structure */
8007 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8008 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8009 TEST_ASSERT_NOT_NULL(ut_params->op,
8010 "Failed to allocate pktmbuf offload");
8012 /* Set crypto operation data parameters */
8013 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8015 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8017 /* set crypto operation source mbuf */
8018 sym_op->m_src = ut_params->ibuf;
8021 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8022 ut_params->ibuf, reference->digest.len);
8024 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8025 "no room to append auth tag");
8027 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8028 ut_params->ibuf, reference->ciphertext.len);
8031 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8033 memcpy(sym_op->auth.digest.data,
8034 reference->digest.data,
8035 reference->digest.len);
8037 debug_hexdump(stdout, "digest:",
8038 sym_op->auth.digest.data,
8039 reference->digest.len);
8041 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8042 reference->iv.data, reference->iv.len);
8044 sym_op->cipher.data.length = reference->ciphertext.len;
8045 sym_op->cipher.data.offset = 0;
8047 sym_op->auth.data.length = reference->ciphertext.len;
8048 sym_op->auth.data.offset = 0;
8054 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8055 struct crypto_unittest_params *ut_params,
8056 const struct test_crypto_vector *reference)
8058 return create_auth_operation(ts_params, ut_params, reference, 0);
8062 create_auth_verify_GMAC_operation(
8063 struct crypto_testsuite_params *ts_params,
8064 struct crypto_unittest_params *ut_params,
8065 const struct test_crypto_vector *reference)
8067 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8071 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8072 struct crypto_unittest_params *ut_params,
8073 const struct test_crypto_vector *reference)
8075 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8079 test_authentication_verify_fail_when_data_corruption(
8080 struct crypto_testsuite_params *ts_params,
8081 struct crypto_unittest_params *ut_params,
8082 const struct test_crypto_vector *reference,
8083 unsigned int data_corrupted)
8089 /* Create session */
8090 retval = create_auth_session(ut_params,
8091 ts_params->valid_devs[0],
8093 RTE_CRYPTO_AUTH_OP_VERIFY);
8097 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8098 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8099 "Failed to allocate input buffer in mempool");
8101 /* clear mbuf payload */
8102 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8103 rte_pktmbuf_tailroom(ut_params->ibuf));
8105 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8106 reference->plaintext.len);
8107 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8108 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8110 debug_hexdump(stdout, "plaintext:", plaintext,
8111 reference->plaintext.len);
8113 /* Create operation */
8114 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8120 data_corruption(plaintext);
8122 tag_corruption(plaintext, reference->plaintext.len);
8124 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8126 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8127 TEST_ASSERT_EQUAL(ut_params->op->status,
8128 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8129 "authentication not failed");
8131 ut_params->obuf = ut_params->op->sym->m_src;
8132 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8138 test_authentication_verify_GMAC_fail_when_corruption(
8139 struct crypto_testsuite_params *ts_params,
8140 struct crypto_unittest_params *ut_params,
8141 const struct test_crypto_vector *reference,
8142 unsigned int data_corrupted)
8147 /* Create session */
8148 retval = create_auth_cipher_session(ut_params,
8149 ts_params->valid_devs[0],
8151 RTE_CRYPTO_AUTH_OP_VERIFY,
8152 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8156 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8157 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8158 "Failed to allocate input buffer in mempool");
8160 /* clear mbuf payload */
8161 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8162 rte_pktmbuf_tailroom(ut_params->ibuf));
8164 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8165 reference->plaintext.len);
8166 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8167 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8169 debug_hexdump(stdout, "plaintext:", plaintext,
8170 reference->plaintext.len);
8172 /* Create operation */
8173 retval = create_auth_verify_GMAC_operation(ts_params,
8181 data_corruption(plaintext);
8183 tag_corruption(plaintext, reference->aad.len);
8185 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8187 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8188 TEST_ASSERT_EQUAL(ut_params->op->status,
8189 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8190 "authentication not failed");
8192 ut_params->obuf = ut_params->op->sym->m_src;
8193 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8199 test_authenticated_decryption_fail_when_corruption(
8200 struct crypto_testsuite_params *ts_params,
8201 struct crypto_unittest_params *ut_params,
8202 const struct test_crypto_vector *reference,
8203 unsigned int data_corrupted)
8207 uint8_t *ciphertext;
8209 /* Create session */
8210 retval = create_auth_cipher_session(ut_params,
8211 ts_params->valid_devs[0],
8213 RTE_CRYPTO_AUTH_OP_VERIFY,
8214 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8218 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8219 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8220 "Failed to allocate input buffer in mempool");
8222 /* clear mbuf payload */
8223 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8224 rte_pktmbuf_tailroom(ut_params->ibuf));
8226 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8227 reference->ciphertext.len);
8228 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8229 memcpy(ciphertext, reference->ciphertext.data,
8230 reference->ciphertext.len);
8232 /* Create operation */
8233 retval = create_cipher_auth_verify_operation(ts_params,
8241 data_corruption(ciphertext);
8243 tag_corruption(ciphertext, reference->ciphertext.len);
8245 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8248 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8249 TEST_ASSERT_EQUAL(ut_params->op->status,
8250 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8251 "authentication not failed");
8253 ut_params->obuf = ut_params->op->sym->m_src;
8254 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8260 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8261 const struct aead_test_data *tdata,
8262 void *digest_mem, uint64_t digest_phys)
8264 struct crypto_testsuite_params *ts_params = &testsuite_params;
8265 struct crypto_unittest_params *ut_params = &unittest_params;
8267 const unsigned int auth_tag_len = tdata->auth_tag.len;
8268 const unsigned int iv_len = tdata->iv.len;
8269 unsigned int aad_len = tdata->aad.len;
8271 /* Generate Crypto op data structure */
8272 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8273 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8274 TEST_ASSERT_NOT_NULL(ut_params->op,
8275 "Failed to allocate symmetric crypto operation struct");
8277 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8279 sym_op->aead.digest.data = digest_mem;
8281 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8282 "no room to append digest");
8284 sym_op->aead.digest.phys_addr = digest_phys;
8286 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8287 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8289 debug_hexdump(stdout, "digest:",
8290 sym_op->aead.digest.data,
8294 /* Append aad data */
8295 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8296 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8297 uint8_t *, IV_OFFSET);
8299 /* Copy IV 1 byte after the IV pointer, according to the API */
8300 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8302 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8304 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8305 ut_params->ibuf, aad_len);
8306 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8307 "no room to prepend aad");
8308 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8311 memset(sym_op->aead.aad.data, 0, aad_len);
8312 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8313 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8315 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8316 debug_hexdump(stdout, "aad:",
8317 sym_op->aead.aad.data, aad_len);
8319 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8320 uint8_t *, IV_OFFSET);
8322 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8324 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8325 ut_params->ibuf, aad_len);
8326 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8327 "no room to prepend aad");
8328 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8331 memset(sym_op->aead.aad.data, 0, aad_len);
8332 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8334 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8335 debug_hexdump(stdout, "aad:",
8336 sym_op->aead.aad.data, aad_len);
8339 sym_op->aead.data.length = tdata->plaintext.len;
8340 sym_op->aead.data.offset = aad_len;
8345 #define SGL_MAX_NO 16
8348 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8349 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8351 struct crypto_testsuite_params *ts_params = &testsuite_params;
8352 struct crypto_unittest_params *ut_params = &unittest_params;
8353 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8356 int to_trn_tbl[SGL_MAX_NO];
8358 unsigned int trn_data = 0;
8359 uint8_t *plaintext, *ciphertext, *auth_tag;
8361 if (fragsz > tdata->plaintext.len)
8362 fragsz = tdata->plaintext.len;
8364 uint16_t plaintext_len = fragsz;
8365 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8367 if (fragsz_oop > tdata->plaintext.len)
8368 frag_size_oop = tdata->plaintext.len;
8371 void *digest_mem = NULL;
8373 uint32_t prepend_len = tdata->aad.len;
8375 if (tdata->plaintext.len % fragsz != 0) {
8376 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8379 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8384 * For out-op-place we need to alloc another mbuf
8387 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8388 rte_pktmbuf_append(ut_params->obuf,
8389 frag_size_oop + prepend_len);
8390 buf_oop = ut_params->obuf;
8393 /* Create AEAD session */
8394 retval = create_aead_session(ts_params->valid_devs[0],
8396 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8397 tdata->key.data, tdata->key.len,
8398 tdata->aad.len, tdata->auth_tag.len,
8403 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8405 /* clear mbuf payload */
8406 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8407 rte_pktmbuf_tailroom(ut_params->ibuf));
8409 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8412 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8414 trn_data += plaintext_len;
8416 buf = ut_params->ibuf;
8419 * Loop until no more fragments
8422 while (trn_data < tdata->plaintext.len) {
8424 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8425 (tdata->plaintext.len - trn_data) : fragsz;
8427 to_trn_tbl[ecx++] = to_trn;
8429 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8432 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8433 rte_pktmbuf_tailroom(buf));
8436 if (oop && !fragsz_oop) {
8437 buf_last_oop = buf_oop->next =
8438 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8439 buf_oop = buf_oop->next;
8440 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8441 0, rte_pktmbuf_tailroom(buf_oop));
8442 rte_pktmbuf_append(buf_oop, to_trn);
8445 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8448 memcpy(plaintext, tdata->plaintext.data + trn_data,
8451 if (trn_data == tdata->plaintext.len) {
8454 digest_mem = rte_pktmbuf_append(buf_oop,
8455 tdata->auth_tag.len);
8457 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8458 tdata->auth_tag.len);
8462 uint64_t digest_phys = 0;
8464 ut_params->ibuf->nb_segs = segs;
8467 if (fragsz_oop && oop) {
8471 if (frag_size_oop == tdata->plaintext.len) {
8472 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8473 tdata->auth_tag.len);
8475 digest_phys = rte_pktmbuf_iova_offset(
8477 tdata->plaintext.len + prepend_len);
8480 trn_data = frag_size_oop;
8481 while (trn_data < tdata->plaintext.len) {
8484 (tdata->plaintext.len - trn_data <
8486 (tdata->plaintext.len - trn_data) :
8489 to_trn_tbl[ecx++] = to_trn;
8491 buf_last_oop = buf_oop->next =
8492 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8493 buf_oop = buf_oop->next;
8494 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8495 0, rte_pktmbuf_tailroom(buf_oop));
8496 rte_pktmbuf_append(buf_oop, to_trn);
8500 if (trn_data == tdata->plaintext.len) {
8501 digest_mem = rte_pktmbuf_append(buf_oop,
8502 tdata->auth_tag.len);
8506 ut_params->obuf->nb_segs = segs;
8510 * Place digest at the end of the last buffer
8513 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8514 if (oop && buf_last_oop)
8515 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8517 if (!digest_mem && !oop) {
8518 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8519 + tdata->auth_tag.len);
8520 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8521 tdata->plaintext.len);
8524 /* Create AEAD operation */
8525 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8526 tdata, digest_mem, digest_phys);
8531 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8533 ut_params->op->sym->m_src = ut_params->ibuf;
8535 ut_params->op->sym->m_dst = ut_params->obuf;
8537 /* Process crypto operation */
8538 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8539 ut_params->op), "failed to process sym crypto op");
8541 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8542 "crypto op processing failed");
8545 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8546 uint8_t *, prepend_len);
8548 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8549 uint8_t *, prepend_len);
8553 fragsz = fragsz_oop;
8555 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8557 tdata->ciphertext.data,
8559 "Ciphertext data not as expected");
8561 buf = ut_params->op->sym->m_src->next;
8563 buf = ut_params->op->sym->m_dst->next;
8565 unsigned int off = fragsz;
8569 ciphertext = rte_pktmbuf_mtod(buf,
8572 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8574 tdata->ciphertext.data + off,
8576 "Ciphertext data not as expected");
8578 off += to_trn_tbl[ecx++];
8582 auth_tag = digest_mem;
8583 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8585 tdata->auth_tag.data,
8586 tdata->auth_tag.len,
8587 "Generated auth tag not as expected");
8593 #define OUT_OF_PLACE 1
8596 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8598 return test_authenticated_encryption_SGL(
8599 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8603 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8605 return test_authenticated_encryption_SGL(
8606 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8610 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8612 return test_authenticated_encryption_SGL(
8613 &gcm_test_case_8, OUT_OF_PLACE, 400,
8614 gcm_test_case_8.plaintext.len);
8618 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8621 return test_authenticated_encryption_SGL(
8622 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8626 test_authentication_verify_fail_when_data_corrupted(
8627 struct crypto_testsuite_params *ts_params,
8628 struct crypto_unittest_params *ut_params,
8629 const struct test_crypto_vector *reference)
8631 return test_authentication_verify_fail_when_data_corruption(
8632 ts_params, ut_params, reference, 1);
8636 test_authentication_verify_fail_when_tag_corrupted(
8637 struct crypto_testsuite_params *ts_params,
8638 struct crypto_unittest_params *ut_params,
8639 const struct test_crypto_vector *reference)
8641 return test_authentication_verify_fail_when_data_corruption(
8642 ts_params, ut_params, reference, 0);
8646 test_authentication_verify_GMAC_fail_when_data_corrupted(
8647 struct crypto_testsuite_params *ts_params,
8648 struct crypto_unittest_params *ut_params,
8649 const struct test_crypto_vector *reference)
8651 return test_authentication_verify_GMAC_fail_when_corruption(
8652 ts_params, ut_params, reference, 1);
8656 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8657 struct crypto_testsuite_params *ts_params,
8658 struct crypto_unittest_params *ut_params,
8659 const struct test_crypto_vector *reference)
8661 return test_authentication_verify_GMAC_fail_when_corruption(
8662 ts_params, ut_params, reference, 0);
8666 test_authenticated_decryption_fail_when_data_corrupted(
8667 struct crypto_testsuite_params *ts_params,
8668 struct crypto_unittest_params *ut_params,
8669 const struct test_crypto_vector *reference)
8671 return test_authenticated_decryption_fail_when_corruption(
8672 ts_params, ut_params, reference, 1);
8676 test_authenticated_decryption_fail_when_tag_corrupted(
8677 struct crypto_testsuite_params *ts_params,
8678 struct crypto_unittest_params *ut_params,
8679 const struct test_crypto_vector *reference)
8681 return test_authenticated_decryption_fail_when_corruption(
8682 ts_params, ut_params, reference, 0);
8686 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8688 return test_authentication_verify_fail_when_data_corrupted(
8689 &testsuite_params, &unittest_params,
8690 &hmac_sha1_test_crypto_vector);
8694 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8696 return test_authentication_verify_fail_when_tag_corrupted(
8697 &testsuite_params, &unittest_params,
8698 &hmac_sha1_test_crypto_vector);
8702 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8704 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8705 &testsuite_params, &unittest_params,
8706 &aes128_gmac_test_vector);
8710 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8712 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8713 &testsuite_params, &unittest_params,
8714 &aes128_gmac_test_vector);
8718 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8720 return test_authenticated_decryption_fail_when_data_corrupted(
8723 &aes128cbc_hmac_sha1_test_vector);
8727 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8729 return test_authenticated_decryption_fail_when_tag_corrupted(
8732 &aes128cbc_hmac_sha1_test_vector);
8735 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8737 /* global AESNI slave IDs for the scheduler test */
8738 uint8_t aesni_ids[2];
8741 test_scheduler_attach_slave_op(void)
8743 struct crypto_testsuite_params *ts_params = &testsuite_params;
8744 uint8_t sched_id = ts_params->valid_devs[0];
8745 uint32_t nb_devs, i, nb_devs_attached = 0;
8749 /* create 2 AESNI_MB if necessary */
8750 nb_devs = rte_cryptodev_device_count_by_driver(
8751 rte_cryptodev_driver_id_get(
8752 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8754 for (i = nb_devs; i < 2; i++) {
8755 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8756 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8758 ret = rte_vdev_init(vdev_name, NULL);
8760 TEST_ASSERT(ret == 0,
8761 "Failed to create instance %u of"
8763 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8767 /* attach 2 AESNI_MB cdevs */
8768 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8770 struct rte_cryptodev_info info;
8771 unsigned int session_size;
8773 rte_cryptodev_info_get(i, &info);
8774 if (info.driver_id != rte_cryptodev_driver_id_get(
8775 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8778 session_size = rte_cryptodev_sym_get_private_session_size(i);
8780 * Create the session mempool again, since now there are new devices
8781 * to use the mempool.
8783 if (ts_params->session_mpool) {
8784 rte_mempool_free(ts_params->session_mpool);
8785 ts_params->session_mpool = NULL;
8787 if (ts_params->session_priv_mpool) {
8788 rte_mempool_free(ts_params->session_priv_mpool);
8789 ts_params->session_priv_mpool = NULL;
8792 if (info.sym.max_nb_sessions != 0 &&
8793 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8795 "Device does not support "
8796 "at least %u sessions\n",
8801 * Create mempool with maximum number of sessions,
8802 * to include the session headers
8804 if (ts_params->session_mpool == NULL) {
8805 ts_params->session_mpool =
8806 rte_cryptodev_sym_session_pool_create(
8808 MAX_NB_SESSIONS, 0, 0, 0,
8810 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8811 "session mempool allocation failed");
8815 * Create mempool with maximum number of sessions,
8816 * to include device specific session private data
8818 if (ts_params->session_priv_mpool == NULL) {
8819 ts_params->session_priv_mpool = rte_mempool_create(
8820 "test_sess_mp_priv",
8823 0, 0, NULL, NULL, NULL,
8824 NULL, SOCKET_ID_ANY,
8827 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
8828 "session mempool allocation failed");
8831 ts_params->qp_conf.mp_session = ts_params->session_mpool;
8832 ts_params->qp_conf.mp_session_private =
8833 ts_params->session_priv_mpool;
8835 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8838 TEST_ASSERT(ret == 0,
8839 "Failed to attach device %u of pmd : %s", i,
8840 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8842 aesni_ids[nb_devs_attached] = (uint8_t)i;
8851 test_scheduler_detach_slave_op(void)
8853 struct crypto_testsuite_params *ts_params = &testsuite_params;
8854 uint8_t sched_id = ts_params->valid_devs[0];
8858 for (i = 0; i < 2; i++) {
8859 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8861 TEST_ASSERT(ret == 0,
8862 "Failed to detach device %u", aesni_ids[i]);
8869 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8871 struct crypto_testsuite_params *ts_params = &testsuite_params;
8872 uint8_t sched_id = ts_params->valid_devs[0];
8874 return rte_cryptodev_scheduler_mode_set(sched_id,
8879 test_scheduler_mode_roundrobin_op(void)
8881 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8882 0, "Failed to set roundrobin mode");
8888 test_scheduler_mode_multicore_op(void)
8890 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8891 0, "Failed to set multicore mode");
8897 test_scheduler_mode_failover_op(void)
8899 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8900 0, "Failed to set failover mode");
8906 test_scheduler_mode_pkt_size_distr_op(void)
8908 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8909 0, "Failed to set pktsize mode");
8914 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8915 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8916 .setup = testsuite_setup,
8917 .teardown = testsuite_teardown,
8918 .unit_test_cases = {
8920 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8921 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8922 TEST_CASE_ST(ut_setup, ut_teardown,
8923 test_AES_chain_scheduler_all),
8924 TEST_CASE_ST(ut_setup, ut_teardown,
8925 test_AES_cipheronly_scheduler_all),
8926 TEST_CASE_ST(ut_setup, ut_teardown,
8927 test_authonly_scheduler_all),
8928 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8931 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8932 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_AES_chain_scheduler_all),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_AES_cipheronly_scheduler_all),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_authonly_scheduler_all),
8939 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8942 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8943 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 test_AES_chain_scheduler_all),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_AES_cipheronly_scheduler_all),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_authonly_scheduler_all),
8950 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8953 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8954 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 test_AES_chain_scheduler_all),
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_AES_cipheronly_scheduler_all),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_authonly_scheduler_all),
8961 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8963 TEST_CASES_END() /**< NULL terminate unit test array */
8967 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8969 static struct unit_test_suite cryptodev_qat_testsuite = {
8970 .suite_name = "Crypto QAT Unit Test Suite",
8971 .setup = testsuite_setup,
8972 .teardown = testsuite_teardown,
8973 .unit_test_cases = {
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_device_configure_invalid_dev_id),
8976 TEST_CASE_ST(ut_setup, ut_teardown,
8977 test_device_configure_invalid_queue_pair_ids),
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_queue_pair_descriptor_setup),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_multi_session),
8983 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 test_AES_cipheronly_qat_all),
8986 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_3DES_cipheronly_qat_all),
8989 TEST_CASE_ST(ut_setup, ut_teardown,
8990 test_DES_cipheronly_qat_all),
8991 TEST_CASE_ST(ut_setup, ut_teardown,
8992 test_AES_docsis_qat_all),
8993 TEST_CASE_ST(ut_setup, ut_teardown,
8994 test_DES_docsis_qat_all),
8995 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8996 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8998 /** AES CCM Authenticated Encryption 128 bits key */
8999 TEST_CASE_ST(ut_setup, ut_teardown,
9000 test_AES_CCM_authenticated_encryption_test_case_128_1),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 test_AES_CCM_authenticated_encryption_test_case_128_2),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_AES_CCM_authenticated_encryption_test_case_128_3),
9006 /** AES CCM Authenticated Decryption 128 bits key*/
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_CCM_authenticated_decryption_test_case_128_1),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_AES_CCM_authenticated_decryption_test_case_128_2),
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_AES_CCM_authenticated_decryption_test_case_128_3),
9014 /** AES GCM Authenticated Encryption */
9015 TEST_CASE_ST(ut_setup, ut_teardown,
9016 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9017 TEST_CASE_ST(ut_setup, ut_teardown,
9018 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9019 TEST_CASE_ST(ut_setup, ut_teardown,
9020 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9021 TEST_CASE_ST(ut_setup, ut_teardown,
9022 test_AES_GCM_authenticated_encryption_test_case_1),
9023 TEST_CASE_ST(ut_setup, ut_teardown,
9024 test_AES_GCM_authenticated_encryption_test_case_2),
9025 TEST_CASE_ST(ut_setup, ut_teardown,
9026 test_AES_GCM_authenticated_encryption_test_case_3),
9027 TEST_CASE_ST(ut_setup, ut_teardown,
9028 test_AES_GCM_authenticated_encryption_test_case_4),
9029 TEST_CASE_ST(ut_setup, ut_teardown,
9030 test_AES_GCM_authenticated_encryption_test_case_5),
9031 TEST_CASE_ST(ut_setup, ut_teardown,
9032 test_AES_GCM_authenticated_encryption_test_case_6),
9033 TEST_CASE_ST(ut_setup, ut_teardown,
9034 test_AES_GCM_authenticated_encryption_test_case_7),
9036 /** AES GCM Authenticated Decryption */
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_AES_GCM_authenticated_decryption_test_case_1),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_AES_GCM_authenticated_decryption_test_case_2),
9041 TEST_CASE_ST(ut_setup, ut_teardown,
9042 test_AES_GCM_authenticated_decryption_test_case_3),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_AES_GCM_authenticated_decryption_test_case_4),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_GCM_authenticated_decryption_test_case_5),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_GCM_authenticated_decryption_test_case_6),
9049 TEST_CASE_ST(ut_setup, ut_teardown,
9050 test_AES_GCM_authenticated_decryption_test_case_7),
9052 /** AES GCM Authenticated Encryption 192 bits key */
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_AES_GCM_auth_encryption_test_case_192_1),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_AES_GCM_auth_encryption_test_case_192_2),
9057 TEST_CASE_ST(ut_setup, ut_teardown,
9058 test_AES_GCM_auth_encryption_test_case_192_3),
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_AES_GCM_auth_encryption_test_case_192_4),
9061 TEST_CASE_ST(ut_setup, ut_teardown,
9062 test_AES_GCM_auth_encryption_test_case_192_5),
9063 TEST_CASE_ST(ut_setup, ut_teardown,
9064 test_AES_GCM_auth_encryption_test_case_192_6),
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_AES_GCM_auth_encryption_test_case_192_7),
9068 /** AES GCM Authenticated Decryption 192 bits key */
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_AES_GCM_auth_decryption_test_case_192_1),
9071 TEST_CASE_ST(ut_setup, ut_teardown,
9072 test_AES_GCM_auth_decryption_test_case_192_2),
9073 TEST_CASE_ST(ut_setup, ut_teardown,
9074 test_AES_GCM_auth_decryption_test_case_192_3),
9075 TEST_CASE_ST(ut_setup, ut_teardown,
9076 test_AES_GCM_auth_decryption_test_case_192_4),
9077 TEST_CASE_ST(ut_setup, ut_teardown,
9078 test_AES_GCM_auth_decryption_test_case_192_5),
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_AES_GCM_auth_decryption_test_case_192_6),
9081 TEST_CASE_ST(ut_setup, ut_teardown,
9082 test_AES_GCM_auth_decryption_test_case_192_7),
9084 /** AES GCM Authenticated Encryption 256 bits key */
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_AES_GCM_auth_encryption_test_case_256_1),
9087 TEST_CASE_ST(ut_setup, ut_teardown,
9088 test_AES_GCM_auth_encryption_test_case_256_2),
9089 TEST_CASE_ST(ut_setup, ut_teardown,
9090 test_AES_GCM_auth_encryption_test_case_256_3),
9091 TEST_CASE_ST(ut_setup, ut_teardown,
9092 test_AES_GCM_auth_encryption_test_case_256_4),
9093 TEST_CASE_ST(ut_setup, ut_teardown,
9094 test_AES_GCM_auth_encryption_test_case_256_5),
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_AES_GCM_auth_encryption_test_case_256_6),
9097 TEST_CASE_ST(ut_setup, ut_teardown,
9098 test_AES_GCM_auth_encryption_test_case_256_7),
9100 /** AES GMAC Authentication */
9101 TEST_CASE_ST(ut_setup, ut_teardown,
9102 test_AES_GMAC_authentication_test_case_1),
9103 TEST_CASE_ST(ut_setup, ut_teardown,
9104 test_AES_GMAC_authentication_verify_test_case_1),
9105 TEST_CASE_ST(ut_setup, ut_teardown,
9106 test_AES_GMAC_authentication_test_case_2),
9107 TEST_CASE_ST(ut_setup, ut_teardown,
9108 test_AES_GMAC_authentication_verify_test_case_2),
9109 TEST_CASE_ST(ut_setup, ut_teardown,
9110 test_AES_GMAC_authentication_test_case_3),
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 test_AES_GMAC_authentication_verify_test_case_3),
9114 /** SNOW 3G encrypt only (UEA2) */
9115 TEST_CASE_ST(ut_setup, ut_teardown,
9116 test_snow3g_encryption_test_case_1),
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_snow3g_encryption_test_case_2),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_snow3g_encryption_test_case_3),
9121 TEST_CASE_ST(ut_setup, ut_teardown,
9122 test_snow3g_encryption_test_case_4),
9123 TEST_CASE_ST(ut_setup, ut_teardown,
9124 test_snow3g_encryption_test_case_5),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_snow3g_encryption_test_case_1_oop),
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_snow3g_decryption_test_case_1_oop),
9131 /** SNOW 3G decrypt only (UEA2) */
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_snow3g_decryption_test_case_1),
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 test_snow3g_decryption_test_case_2),
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_snow3g_decryption_test_case_3),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_snow3g_decryption_test_case_4),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_snow3g_decryption_test_case_5),
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_snow3g_hash_generate_test_case_1),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_snow3g_hash_generate_test_case_2),
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_snow3g_hash_generate_test_case_3),
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_snow3g_hash_verify_test_case_1),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_snow3g_hash_verify_test_case_2),
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_snow3g_hash_verify_test_case_3),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_snow3g_cipher_auth_test_case_1),
9156 TEST_CASE_ST(ut_setup, ut_teardown,
9157 test_snow3g_auth_cipher_test_case_1),
9159 /** ZUC encrypt only (EEA3) */
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_zuc_encryption_test_case_1),
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_zuc_encryption_test_case_2),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_zuc_encryption_test_case_3),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_zuc_encryption_test_case_4),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_zuc_encryption_test_case_5),
9171 /** ZUC authenticate (EIA3) */
9172 TEST_CASE_ST(ut_setup, ut_teardown,
9173 test_zuc_hash_generate_test_case_6),
9174 TEST_CASE_ST(ut_setup, ut_teardown,
9175 test_zuc_hash_generate_test_case_7),
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_zuc_hash_generate_test_case_8),
9179 /** ZUC alg-chain (EEA3/EIA3) */
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_zuc_cipher_auth_test_case_1),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_zuc_cipher_auth_test_case_2),
9185 /** HMAC_MD5 Authentication */
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_MD5_HMAC_generate_case_1),
9188 TEST_CASE_ST(ut_setup, ut_teardown,
9189 test_MD5_HMAC_verify_case_1),
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 test_MD5_HMAC_generate_case_2),
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_MD5_HMAC_verify_case_2),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_null_auth_only_operation),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 test_null_cipher_only_operation),
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 test_null_cipher_auth_operation),
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 test_null_auth_cipher_operation),
9206 TEST_CASE_ST(ut_setup, ut_teardown,
9207 test_kasumi_hash_generate_test_case_1),
9208 TEST_CASE_ST(ut_setup, ut_teardown,
9209 test_kasumi_hash_generate_test_case_2),
9210 TEST_CASE_ST(ut_setup, ut_teardown,
9211 test_kasumi_hash_generate_test_case_3),
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_kasumi_hash_generate_test_case_4),
9214 TEST_CASE_ST(ut_setup, ut_teardown,
9215 test_kasumi_hash_generate_test_case_5),
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_kasumi_hash_generate_test_case_6),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_kasumi_hash_verify_test_case_1),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_kasumi_hash_verify_test_case_2),
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 test_kasumi_hash_verify_test_case_3),
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_kasumi_hash_verify_test_case_4),
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_kasumi_hash_verify_test_case_5),
9230 TEST_CASE_ST(ut_setup, ut_teardown,
9231 test_kasumi_encryption_test_case_1),
9232 TEST_CASE_ST(ut_setup, ut_teardown,
9233 test_kasumi_encryption_test_case_3),
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 test_kasumi_auth_cipher_test_case_1),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_kasumi_cipher_auth_test_case_1),
9239 /** Negative tests */
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 authentication_verify_AES128_GMAC_fail_data_corrupt),
9246 TEST_CASE_ST(ut_setup, ut_teardown,
9247 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9248 TEST_CASE_ST(ut_setup, ut_teardown,
9249 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9250 TEST_CASE_ST(ut_setup, ut_teardown,
9251 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9253 TEST_CASES_END() /**< NULL terminate unit test array */
9257 static struct unit_test_suite cryptodev_virtio_testsuite = {
9258 .suite_name = "Crypto VIRTIO Unit Test Suite",
9259 .setup = testsuite_setup,
9260 .teardown = testsuite_teardown,
9261 .unit_test_cases = {
9262 TEST_CASE_ST(ut_setup, ut_teardown,
9263 test_AES_cipheronly_virtio_all),
9265 TEST_CASES_END() /**< NULL terminate unit test array */
9269 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9270 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9271 .setup = testsuite_setup,
9272 .teardown = testsuite_teardown,
9273 .unit_test_cases = {
9274 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_AES_GCM_authenticated_encryption_test_case_1),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_AES_GCM_authenticated_encryption_test_case_2),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_AES_GCM_authenticated_encryption_test_case_3),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_AES_GCM_authenticated_encryption_test_case_4),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_AES_GCM_authenticated_encryption_test_case_5),
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_AES_GCM_authenticated_encryption_test_case_6),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_AES_GCM_authenticated_encryption_test_case_7),
9290 /** AES GCM Authenticated Decryption */
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_GCM_authenticated_decryption_test_case_1),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_AES_GCM_authenticated_decryption_test_case_2),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_AES_GCM_authenticated_decryption_test_case_3),
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_AES_GCM_authenticated_decryption_test_case_4),
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_AES_GCM_authenticated_decryption_test_case_5),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_GCM_authenticated_decryption_test_case_6),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_AES_GCM_authenticated_decryption_test_case_7),
9306 /** AES GCM Authenticated Encryption 192 bits key */
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_AES_GCM_auth_encryption_test_case_192_1),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_AES_GCM_auth_encryption_test_case_192_2),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_auth_encryption_test_case_192_3),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_AES_GCM_auth_encryption_test_case_192_4),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_auth_encryption_test_case_192_5),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_auth_encryption_test_case_192_6),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_auth_encryption_test_case_192_7),
9322 /** AES GCM Authenticated Decryption 192 bits key */
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_auth_decryption_test_case_192_1),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_AES_GCM_auth_decryption_test_case_192_2),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_auth_decryption_test_case_192_3),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_AES_GCM_auth_decryption_test_case_192_4),
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_AES_GCM_auth_decryption_test_case_192_5),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_auth_decryption_test_case_192_6),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_auth_decryption_test_case_192_7),
9338 /** AES GCM Authenticated Encryption 256 bits key */
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GCM_auth_encryption_test_case_256_1),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GCM_auth_encryption_test_case_256_2),
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_AES_GCM_auth_encryption_test_case_256_3),
9345 TEST_CASE_ST(ut_setup, ut_teardown,
9346 test_AES_GCM_auth_encryption_test_case_256_4),
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_AES_GCM_auth_encryption_test_case_256_5),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GCM_auth_encryption_test_case_256_6),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_AES_GCM_auth_encryption_test_case_256_7),
9354 /** AES GCM Authenticated Decryption 256 bits key */
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_AES_GCM_auth_decryption_test_case_256_1),
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_AES_GCM_auth_decryption_test_case_256_2),
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_AES_GCM_auth_decryption_test_case_256_3),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_AES_GCM_auth_decryption_test_case_256_4),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_GCM_auth_decryption_test_case_256_5),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_GCM_auth_decryption_test_case_256_6),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 test_AES_GCM_auth_decryption_test_case_256_7),
9370 /** AES GCM Authenticated Encryption big aad size */
9371 TEST_CASE_ST(ut_setup, ut_teardown,
9372 test_AES_GCM_auth_encryption_test_case_aad_1),
9373 TEST_CASE_ST(ut_setup, ut_teardown,
9374 test_AES_GCM_auth_encryption_test_case_aad_2),
9376 /** AES GCM Authenticated Decryption big aad size */
9377 TEST_CASE_ST(ut_setup, ut_teardown,
9378 test_AES_GCM_auth_decryption_test_case_aad_1),
9379 TEST_CASE_ST(ut_setup, ut_teardown,
9380 test_AES_GCM_auth_decryption_test_case_aad_2),
9382 /** Session-less tests */
9383 TEST_CASE_ST(ut_setup, ut_teardown,
9384 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9385 TEST_CASE_ST(ut_setup, ut_teardown,
9386 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9388 /** AES GMAC Authentication */
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_AES_GMAC_authentication_test_case_1),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_AES_GMAC_authentication_verify_test_case_1),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_AES_GMAC_authentication_test_case_2),
9395 TEST_CASE_ST(ut_setup, ut_teardown,
9396 test_AES_GMAC_authentication_verify_test_case_2),
9397 TEST_CASE_ST(ut_setup, ut_teardown,
9398 test_AES_GMAC_authentication_test_case_3),
9399 TEST_CASE_ST(ut_setup, ut_teardown,
9400 test_AES_GMAC_authentication_verify_test_case_3),
9401 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
9403 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9404 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9405 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9406 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9407 TEST_CASE_ST(ut_setup, ut_teardown,
9408 test_DES_cipheronly_mb_all),
9409 TEST_CASE_ST(ut_setup, ut_teardown,
9410 test_DES_docsis_mb_all),
9411 TEST_CASE_ST(ut_setup, ut_teardown,
9412 test_3DES_cipheronly_mb_all),
9413 TEST_CASE_ST(ut_setup, ut_teardown,
9414 test_AES_CCM_authenticated_encryption_test_case_128_1),
9415 TEST_CASE_ST(ut_setup, ut_teardown,
9416 test_AES_CCM_authenticated_decryption_test_case_128_1),
9417 TEST_CASE_ST(ut_setup, ut_teardown,
9418 test_AES_CCM_authenticated_encryption_test_case_128_2),
9419 TEST_CASE_ST(ut_setup, ut_teardown,
9420 test_AES_CCM_authenticated_decryption_test_case_128_2),
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_AES_CCM_authenticated_encryption_test_case_128_3),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_AES_CCM_authenticated_decryption_test_case_128_3),
9426 TEST_CASES_END() /**< NULL terminate unit test array */
9430 static struct unit_test_suite cryptodev_openssl_testsuite = {
9431 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9432 .setup = testsuite_setup,
9433 .teardown = testsuite_teardown,
9434 .unit_test_cases = {
9435 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_multi_session_random_usage),
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_AES_chain_openssl_all),
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_AES_cipheronly_openssl_all),
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_3DES_chain_openssl_all),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_3DES_cipheronly_openssl_all),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_DES_cipheronly_openssl_all),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_DES_docsis_openssl_all),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_authonly_openssl_all),
9453 /** AES GCM Authenticated Encryption */
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_AES_GCM_authenticated_encryption_test_case_1),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_AES_GCM_authenticated_encryption_test_case_2),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GCM_authenticated_encryption_test_case_3),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_AES_GCM_authenticated_encryption_test_case_4),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GCM_authenticated_encryption_test_case_5),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GCM_authenticated_encryption_test_case_6),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GCM_authenticated_encryption_test_case_7),
9469 /** AES GCM Authenticated Decryption */
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_AES_GCM_authenticated_decryption_test_case_1),
9472 TEST_CASE_ST(ut_setup, ut_teardown,
9473 test_AES_GCM_authenticated_decryption_test_case_2),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_AES_GCM_authenticated_decryption_test_case_3),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_AES_GCM_authenticated_decryption_test_case_4),
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_AES_GCM_authenticated_decryption_test_case_5),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_GCM_authenticated_decryption_test_case_6),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_GCM_authenticated_decryption_test_case_7),
9486 /** AES GCM Authenticated Encryption 192 bits key */
9487 TEST_CASE_ST(ut_setup, ut_teardown,
9488 test_AES_GCM_auth_encryption_test_case_192_1),
9489 TEST_CASE_ST(ut_setup, ut_teardown,
9490 test_AES_GCM_auth_encryption_test_case_192_2),
9491 TEST_CASE_ST(ut_setup, ut_teardown,
9492 test_AES_GCM_auth_encryption_test_case_192_3),
9493 TEST_CASE_ST(ut_setup, ut_teardown,
9494 test_AES_GCM_auth_encryption_test_case_192_4),
9495 TEST_CASE_ST(ut_setup, ut_teardown,
9496 test_AES_GCM_auth_encryption_test_case_192_5),
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_AES_GCM_auth_encryption_test_case_192_6),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_AES_GCM_auth_encryption_test_case_192_7),
9502 /** AES GCM Authenticated Decryption 192 bits key */
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_AES_GCM_auth_decryption_test_case_192_1),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_AES_GCM_auth_decryption_test_case_192_2),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_AES_GCM_auth_decryption_test_case_192_3),
9509 TEST_CASE_ST(ut_setup, ut_teardown,
9510 test_AES_GCM_auth_decryption_test_case_192_4),
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_AES_GCM_auth_decryption_test_case_192_5),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_AES_GCM_auth_decryption_test_case_192_6),
9515 TEST_CASE_ST(ut_setup, ut_teardown,
9516 test_AES_GCM_auth_decryption_test_case_192_7),
9518 /** AES GCM Authenticated Encryption 256 bits key */
9519 TEST_CASE_ST(ut_setup, ut_teardown,
9520 test_AES_GCM_auth_encryption_test_case_256_1),
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_AES_GCM_auth_encryption_test_case_256_2),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_AES_GCM_auth_encryption_test_case_256_3),
9525 TEST_CASE_ST(ut_setup, ut_teardown,
9526 test_AES_GCM_auth_encryption_test_case_256_4),
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_AES_GCM_auth_encryption_test_case_256_5),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_AES_GCM_auth_encryption_test_case_256_6),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_AES_GCM_auth_encryption_test_case_256_7),
9534 /** AES GCM Authenticated Decryption 256 bits key */
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_AES_GCM_auth_decryption_test_case_256_1),
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_AES_GCM_auth_decryption_test_case_256_2),
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_AES_GCM_auth_decryption_test_case_256_3),
9541 TEST_CASE_ST(ut_setup, ut_teardown,
9542 test_AES_GCM_auth_decryption_test_case_256_4),
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_AES_GCM_auth_decryption_test_case_256_5),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_AES_GCM_auth_decryption_test_case_256_6),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_AES_GCM_auth_decryption_test_case_256_7),
9550 /** AES GMAC Authentication */
9551 TEST_CASE_ST(ut_setup, ut_teardown,
9552 test_AES_GMAC_authentication_test_case_1),
9553 TEST_CASE_ST(ut_setup, ut_teardown,
9554 test_AES_GMAC_authentication_verify_test_case_1),
9555 TEST_CASE_ST(ut_setup, ut_teardown,
9556 test_AES_GMAC_authentication_test_case_2),
9557 TEST_CASE_ST(ut_setup, ut_teardown,
9558 test_AES_GMAC_authentication_verify_test_case_2),
9559 TEST_CASE_ST(ut_setup, ut_teardown,
9560 test_AES_GMAC_authentication_test_case_3),
9561 TEST_CASE_ST(ut_setup, ut_teardown,
9562 test_AES_GMAC_authentication_verify_test_case_3),
9563 TEST_CASE_ST(ut_setup, ut_teardown,
9564 test_AES_GMAC_authentication_test_case_4),
9565 TEST_CASE_ST(ut_setup, ut_teardown,
9566 test_AES_GMAC_authentication_verify_test_case_4),
9568 /** AES CCM Authenticated Encryption 128 bits key */
9569 TEST_CASE_ST(ut_setup, ut_teardown,
9570 test_AES_CCM_authenticated_encryption_test_case_128_1),
9571 TEST_CASE_ST(ut_setup, ut_teardown,
9572 test_AES_CCM_authenticated_encryption_test_case_128_2),
9573 TEST_CASE_ST(ut_setup, ut_teardown,
9574 test_AES_CCM_authenticated_encryption_test_case_128_3),
9576 /** AES CCM Authenticated Decryption 128 bits key*/
9577 TEST_CASE_ST(ut_setup, ut_teardown,
9578 test_AES_CCM_authenticated_decryption_test_case_128_1),
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 test_AES_CCM_authenticated_decryption_test_case_128_2),
9581 TEST_CASE_ST(ut_setup, ut_teardown,
9582 test_AES_CCM_authenticated_decryption_test_case_128_3),
9584 /** AES CCM Authenticated Encryption 192 bits key */
9585 TEST_CASE_ST(ut_setup, ut_teardown,
9586 test_AES_CCM_authenticated_encryption_test_case_192_1),
9587 TEST_CASE_ST(ut_setup, ut_teardown,
9588 test_AES_CCM_authenticated_encryption_test_case_192_2),
9589 TEST_CASE_ST(ut_setup, ut_teardown,
9590 test_AES_CCM_authenticated_encryption_test_case_192_3),
9592 /** AES CCM Authenticated Decryption 192 bits key*/
9593 TEST_CASE_ST(ut_setup, ut_teardown,
9594 test_AES_CCM_authenticated_decryption_test_case_192_1),
9595 TEST_CASE_ST(ut_setup, ut_teardown,
9596 test_AES_CCM_authenticated_decryption_test_case_192_2),
9597 TEST_CASE_ST(ut_setup, ut_teardown,
9598 test_AES_CCM_authenticated_decryption_test_case_192_3),
9600 /** AES CCM Authenticated Encryption 256 bits key */
9601 TEST_CASE_ST(ut_setup, ut_teardown,
9602 test_AES_CCM_authenticated_encryption_test_case_256_1),
9603 TEST_CASE_ST(ut_setup, ut_teardown,
9604 test_AES_CCM_authenticated_encryption_test_case_256_2),
9605 TEST_CASE_ST(ut_setup, ut_teardown,
9606 test_AES_CCM_authenticated_encryption_test_case_256_3),
9608 /** AES CCM Authenticated Decryption 256 bits key*/
9609 TEST_CASE_ST(ut_setup, ut_teardown,
9610 test_AES_CCM_authenticated_decryption_test_case_256_1),
9611 TEST_CASE_ST(ut_setup, ut_teardown,
9612 test_AES_CCM_authenticated_decryption_test_case_256_2),
9613 TEST_CASE_ST(ut_setup, ut_teardown,
9614 test_AES_CCM_authenticated_decryption_test_case_256_3),
9616 /** Scatter-Gather */
9617 TEST_CASE_ST(ut_setup, ut_teardown,
9618 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9620 /** Negative tests */
9621 TEST_CASE_ST(ut_setup, ut_teardown,
9622 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9623 TEST_CASE_ST(ut_setup, ut_teardown,
9624 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9625 TEST_CASE_ST(ut_setup, ut_teardown,
9626 authentication_verify_AES128_GMAC_fail_data_corrupt),
9627 TEST_CASE_ST(ut_setup, ut_teardown,
9628 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9629 TEST_CASE_ST(ut_setup, ut_teardown,
9630 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9631 TEST_CASE_ST(ut_setup, ut_teardown,
9632 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9634 TEST_CASES_END() /**< NULL terminate unit test array */
9638 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9639 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9640 .setup = testsuite_setup,
9641 .teardown = testsuite_teardown,
9642 .unit_test_cases = {
9643 /** AES GCM Authenticated Encryption */
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_GCM_authenticated_encryption_test_case_1),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_GCM_authenticated_encryption_test_case_2),
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_GCM_authenticated_encryption_test_case_3),
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_authenticated_encryption_test_case_4),
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_GCM_authenticated_encryption_test_case_5),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_authenticated_encryption_test_case_6),
9656 TEST_CASE_ST(ut_setup, ut_teardown,
9657 test_AES_GCM_authenticated_encryption_test_case_7),
9659 /** AES GCM Authenticated Decryption */
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_GCM_authenticated_decryption_test_case_1),
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_GCM_authenticated_decryption_test_case_2),
9664 TEST_CASE_ST(ut_setup, ut_teardown,
9665 test_AES_GCM_authenticated_decryption_test_case_3),
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_authenticated_decryption_test_case_4),
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_GCM_authenticated_decryption_test_case_5),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GCM_authenticated_decryption_test_case_6),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_GCM_authenticated_decryption_test_case_7),
9675 /** AES GCM Authenticated Encryption 192 bits key */
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_GCM_auth_encryption_test_case_192_1),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_AES_GCM_auth_encryption_test_case_192_2),
9680 TEST_CASE_ST(ut_setup, ut_teardown,
9681 test_AES_GCM_auth_encryption_test_case_192_3),
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GCM_auth_encryption_test_case_192_4),
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GCM_auth_encryption_test_case_192_5),
9686 TEST_CASE_ST(ut_setup, ut_teardown,
9687 test_AES_GCM_auth_encryption_test_case_192_6),
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 test_AES_GCM_auth_encryption_test_case_192_7),
9691 /** AES GCM Authenticated Decryption 192 bits key */
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 test_AES_GCM_auth_decryption_test_case_192_1),
9694 TEST_CASE_ST(ut_setup, ut_teardown,
9695 test_AES_GCM_auth_decryption_test_case_192_2),
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 test_AES_GCM_auth_decryption_test_case_192_3),
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 test_AES_GCM_auth_decryption_test_case_192_4),
9700 TEST_CASE_ST(ut_setup, ut_teardown,
9701 test_AES_GCM_auth_decryption_test_case_192_5),
9702 TEST_CASE_ST(ut_setup, ut_teardown,
9703 test_AES_GCM_auth_decryption_test_case_192_6),
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_AES_GCM_auth_decryption_test_case_192_7),
9707 /** AES GCM Authenticated Encryption 256 bits key */
9708 TEST_CASE_ST(ut_setup, ut_teardown,
9709 test_AES_GCM_auth_encryption_test_case_256_1),
9710 TEST_CASE_ST(ut_setup, ut_teardown,
9711 test_AES_GCM_auth_encryption_test_case_256_2),
9712 TEST_CASE_ST(ut_setup, ut_teardown,
9713 test_AES_GCM_auth_encryption_test_case_256_3),
9714 TEST_CASE_ST(ut_setup, ut_teardown,
9715 test_AES_GCM_auth_encryption_test_case_256_4),
9716 TEST_CASE_ST(ut_setup, ut_teardown,
9717 test_AES_GCM_auth_encryption_test_case_256_5),
9718 TEST_CASE_ST(ut_setup, ut_teardown,
9719 test_AES_GCM_auth_encryption_test_case_256_6),
9720 TEST_CASE_ST(ut_setup, ut_teardown,
9721 test_AES_GCM_auth_encryption_test_case_256_7),
9723 /** AES GCM Authenticated Decryption 256 bits key */
9724 TEST_CASE_ST(ut_setup, ut_teardown,
9725 test_AES_GCM_auth_decryption_test_case_256_1),
9726 TEST_CASE_ST(ut_setup, ut_teardown,
9727 test_AES_GCM_auth_decryption_test_case_256_2),
9728 TEST_CASE_ST(ut_setup, ut_teardown,
9729 test_AES_GCM_auth_decryption_test_case_256_3),
9730 TEST_CASE_ST(ut_setup, ut_teardown,
9731 test_AES_GCM_auth_decryption_test_case_256_4),
9732 TEST_CASE_ST(ut_setup, ut_teardown,
9733 test_AES_GCM_auth_decryption_test_case_256_5),
9734 TEST_CASE_ST(ut_setup, ut_teardown,
9735 test_AES_GCM_auth_decryption_test_case_256_6),
9736 TEST_CASE_ST(ut_setup, ut_teardown,
9737 test_AES_GCM_auth_decryption_test_case_256_7),
9739 /** AES GCM Authenticated Encryption big aad size */
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 test_AES_GCM_auth_encryption_test_case_aad_1),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 test_AES_GCM_auth_encryption_test_case_aad_2),
9745 /** AES GCM Authenticated Decryption big aad size */
9746 TEST_CASE_ST(ut_setup, ut_teardown,
9747 test_AES_GCM_auth_decryption_test_case_aad_1),
9748 TEST_CASE_ST(ut_setup, ut_teardown,
9749 test_AES_GCM_auth_decryption_test_case_aad_2),
9751 /** AES GMAC Authentication */
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 test_AES_GMAC_authentication_test_case_1),
9754 TEST_CASE_ST(ut_setup, ut_teardown,
9755 test_AES_GMAC_authentication_verify_test_case_1),
9756 TEST_CASE_ST(ut_setup, ut_teardown,
9757 test_AES_GMAC_authentication_test_case_3),
9758 TEST_CASE_ST(ut_setup, ut_teardown,
9759 test_AES_GMAC_authentication_verify_test_case_3),
9760 TEST_CASE_ST(ut_setup, ut_teardown,
9761 test_AES_GMAC_authentication_test_case_4),
9762 TEST_CASE_ST(ut_setup, ut_teardown,
9763 test_AES_GMAC_authentication_verify_test_case_4),
9765 /** Negative tests */
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 authentication_verify_AES128_GMAC_fail_data_corrupt),
9768 TEST_CASE_ST(ut_setup, ut_teardown,
9769 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9771 /** Out of place tests */
9772 TEST_CASE_ST(ut_setup, ut_teardown,
9773 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9774 TEST_CASE_ST(ut_setup, ut_teardown,
9775 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9777 /** Session-less tests */
9778 TEST_CASE_ST(ut_setup, ut_teardown,
9779 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9780 TEST_CASE_ST(ut_setup, ut_teardown,
9781 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9783 /** Scatter-Gather */
9784 TEST_CASE_ST(ut_setup, ut_teardown,
9785 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9787 TEST_CASES_END() /**< NULL terminate unit test array */
9791 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9792 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9793 .setup = testsuite_setup,
9794 .teardown = testsuite_teardown,
9795 .unit_test_cases = {
9796 /** KASUMI encrypt only (UEA1) */
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_kasumi_encryption_test_case_1),
9799 TEST_CASE_ST(ut_setup, ut_teardown,
9800 test_kasumi_encryption_test_case_1_sgl),
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_kasumi_encryption_test_case_2),
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_kasumi_encryption_test_case_3),
9805 TEST_CASE_ST(ut_setup, ut_teardown,
9806 test_kasumi_encryption_test_case_4),
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 test_kasumi_encryption_test_case_5),
9809 /** KASUMI decrypt only (UEA1) */
9810 TEST_CASE_ST(ut_setup, ut_teardown,
9811 test_kasumi_decryption_test_case_1),
9812 TEST_CASE_ST(ut_setup, ut_teardown,
9813 test_kasumi_decryption_test_case_2),
9814 TEST_CASE_ST(ut_setup, ut_teardown,
9815 test_kasumi_decryption_test_case_3),
9816 TEST_CASE_ST(ut_setup, ut_teardown,
9817 test_kasumi_decryption_test_case_4),
9818 TEST_CASE_ST(ut_setup, ut_teardown,
9819 test_kasumi_decryption_test_case_5),
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_kasumi_encryption_test_case_1_oop),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_kasumi_encryption_test_case_1_oop_sgl),
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_kasumi_decryption_test_case_1_oop),
9830 /** KASUMI hash only (UIA1) */
9831 TEST_CASE_ST(ut_setup, ut_teardown,
9832 test_kasumi_hash_generate_test_case_1),
9833 TEST_CASE_ST(ut_setup, ut_teardown,
9834 test_kasumi_hash_generate_test_case_2),
9835 TEST_CASE_ST(ut_setup, ut_teardown,
9836 test_kasumi_hash_generate_test_case_3),
9837 TEST_CASE_ST(ut_setup, ut_teardown,
9838 test_kasumi_hash_generate_test_case_4),
9839 TEST_CASE_ST(ut_setup, ut_teardown,
9840 test_kasumi_hash_generate_test_case_5),
9841 TEST_CASE_ST(ut_setup, ut_teardown,
9842 test_kasumi_hash_generate_test_case_6),
9843 TEST_CASE_ST(ut_setup, ut_teardown,
9844 test_kasumi_hash_verify_test_case_1),
9845 TEST_CASE_ST(ut_setup, ut_teardown,
9846 test_kasumi_hash_verify_test_case_2),
9847 TEST_CASE_ST(ut_setup, ut_teardown,
9848 test_kasumi_hash_verify_test_case_3),
9849 TEST_CASE_ST(ut_setup, ut_teardown,
9850 test_kasumi_hash_verify_test_case_4),
9851 TEST_CASE_ST(ut_setup, ut_teardown,
9852 test_kasumi_hash_verify_test_case_5),
9853 TEST_CASE_ST(ut_setup, ut_teardown,
9854 test_kasumi_auth_cipher_test_case_1),
9855 TEST_CASE_ST(ut_setup, ut_teardown,
9856 test_kasumi_cipher_auth_test_case_1),
9857 TEST_CASES_END() /**< NULL terminate unit test array */
9860 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9861 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9862 .setup = testsuite_setup,
9863 .teardown = testsuite_teardown,
9864 .unit_test_cases = {
9865 /** SNOW 3G encrypt only (UEA2) */
9866 TEST_CASE_ST(ut_setup, ut_teardown,
9867 test_snow3g_encryption_test_case_1),
9868 TEST_CASE_ST(ut_setup, ut_teardown,
9869 test_snow3g_encryption_test_case_2),
9870 TEST_CASE_ST(ut_setup, ut_teardown,
9871 test_snow3g_encryption_test_case_3),
9872 TEST_CASE_ST(ut_setup, ut_teardown,
9873 test_snow3g_encryption_test_case_4),
9874 TEST_CASE_ST(ut_setup, ut_teardown,
9875 test_snow3g_encryption_test_case_5),
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 test_snow3g_encryption_test_case_1_oop),
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 test_snow3g_encryption_test_case_1_oop_sgl),
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 test_snow3g_decryption_test_case_1_oop),
9884 TEST_CASE_ST(ut_setup, ut_teardown,
9885 test_snow3g_encryption_test_case_1_offset_oop),
9887 /** SNOW 3G decrypt only (UEA2) */
9888 TEST_CASE_ST(ut_setup, ut_teardown,
9889 test_snow3g_decryption_test_case_1),
9890 TEST_CASE_ST(ut_setup, ut_teardown,
9891 test_snow3g_decryption_test_case_2),
9892 TEST_CASE_ST(ut_setup, ut_teardown,
9893 test_snow3g_decryption_test_case_3),
9894 TEST_CASE_ST(ut_setup, ut_teardown,
9895 test_snow3g_decryption_test_case_4),
9896 TEST_CASE_ST(ut_setup, ut_teardown,
9897 test_snow3g_decryption_test_case_5),
9898 TEST_CASE_ST(ut_setup, ut_teardown,
9899 test_snow3g_hash_generate_test_case_1),
9900 TEST_CASE_ST(ut_setup, ut_teardown,
9901 test_snow3g_hash_generate_test_case_2),
9902 TEST_CASE_ST(ut_setup, ut_teardown,
9903 test_snow3g_hash_generate_test_case_3),
9904 /* Tests with buffers which length is not byte-aligned */
9905 TEST_CASE_ST(ut_setup, ut_teardown,
9906 test_snow3g_hash_generate_test_case_4),
9907 TEST_CASE_ST(ut_setup, ut_teardown,
9908 test_snow3g_hash_generate_test_case_5),
9909 TEST_CASE_ST(ut_setup, ut_teardown,
9910 test_snow3g_hash_generate_test_case_6),
9911 TEST_CASE_ST(ut_setup, ut_teardown,
9912 test_snow3g_hash_verify_test_case_1),
9913 TEST_CASE_ST(ut_setup, ut_teardown,
9914 test_snow3g_hash_verify_test_case_2),
9915 TEST_CASE_ST(ut_setup, ut_teardown,
9916 test_snow3g_hash_verify_test_case_3),
9917 /* Tests with buffers which length is not byte-aligned */
9918 TEST_CASE_ST(ut_setup, ut_teardown,
9919 test_snow3g_hash_verify_test_case_4),
9920 TEST_CASE_ST(ut_setup, ut_teardown,
9921 test_snow3g_hash_verify_test_case_5),
9922 TEST_CASE_ST(ut_setup, ut_teardown,
9923 test_snow3g_hash_verify_test_case_6),
9924 TEST_CASE_ST(ut_setup, ut_teardown,
9925 test_snow3g_cipher_auth_test_case_1),
9926 TEST_CASE_ST(ut_setup, ut_teardown,
9927 test_snow3g_auth_cipher_test_case_1),
9929 TEST_CASES_END() /**< NULL terminate unit test array */
9933 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9934 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9935 .setup = testsuite_setup,
9936 .teardown = testsuite_teardown,
9937 .unit_test_cases = {
9938 /** ZUC encrypt only (EEA3) */
9939 TEST_CASE_ST(ut_setup, ut_teardown,
9940 test_zuc_encryption_test_case_1),
9941 TEST_CASE_ST(ut_setup, ut_teardown,
9942 test_zuc_encryption_test_case_2),
9943 TEST_CASE_ST(ut_setup, ut_teardown,
9944 test_zuc_encryption_test_case_3),
9945 TEST_CASE_ST(ut_setup, ut_teardown,
9946 test_zuc_encryption_test_case_4),
9947 TEST_CASE_ST(ut_setup, ut_teardown,
9948 test_zuc_encryption_test_case_5),
9949 TEST_CASE_ST(ut_setup, ut_teardown,
9950 test_zuc_hash_generate_test_case_1),
9951 TEST_CASE_ST(ut_setup, ut_teardown,
9952 test_zuc_hash_generate_test_case_2),
9953 TEST_CASE_ST(ut_setup, ut_teardown,
9954 test_zuc_hash_generate_test_case_3),
9955 TEST_CASE_ST(ut_setup, ut_teardown,
9956 test_zuc_hash_generate_test_case_4),
9957 TEST_CASE_ST(ut_setup, ut_teardown,
9958 test_zuc_hash_generate_test_case_5),
9959 TEST_CASE_ST(ut_setup, ut_teardown,
9960 test_zuc_encryption_test_case_6_sgl),
9961 TEST_CASES_END() /**< NULL terminate unit test array */
9965 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
9966 .suite_name = "Crypto CAAM JR Unit Test Suite",
9967 .setup = testsuite_setup,
9968 .teardown = testsuite_teardown,
9969 .unit_test_cases = {
9970 TEST_CASE_ST(ut_setup, ut_teardown,
9971 test_device_configure_invalid_dev_id),
9972 TEST_CASE_ST(ut_setup, ut_teardown,
9973 test_multi_session),
9975 TEST_CASE_ST(ut_setup, ut_teardown,
9976 test_AES_chain_caam_jr_all),
9977 TEST_CASE_ST(ut_setup, ut_teardown,
9978 test_3DES_chain_caam_jr_all),
9979 TEST_CASE_ST(ut_setup, ut_teardown,
9980 test_AES_cipheronly_caam_jr_all),
9981 TEST_CASE_ST(ut_setup, ut_teardown,
9982 test_3DES_cipheronly_caam_jr_all),
9983 TEST_CASE_ST(ut_setup, ut_teardown,
9984 test_authonly_caam_jr_all),
9986 TEST_CASES_END() /**< NULL terminate unit test array */
9990 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9991 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9992 .setup = testsuite_setup,
9993 .teardown = testsuite_teardown,
9994 .unit_test_cases = {
9995 TEST_CASE_ST(ut_setup, ut_teardown,
9996 test_device_configure_invalid_dev_id),
9997 TEST_CASE_ST(ut_setup, ut_teardown,
9998 test_multi_session),
10000 TEST_CASE_ST(ut_setup, ut_teardown,
10001 test_AES_chain_dpaa_sec_all),
10002 TEST_CASE_ST(ut_setup, ut_teardown,
10003 test_3DES_chain_dpaa_sec_all),
10004 TEST_CASE_ST(ut_setup, ut_teardown,
10005 test_AES_cipheronly_dpaa_sec_all),
10006 TEST_CASE_ST(ut_setup, ut_teardown,
10007 test_3DES_cipheronly_dpaa_sec_all),
10008 TEST_CASE_ST(ut_setup, ut_teardown,
10009 test_authonly_dpaa_sec_all),
10011 /** AES GCM Authenticated Encryption */
10012 TEST_CASE_ST(ut_setup, ut_teardown,
10013 test_AES_GCM_authenticated_encryption_test_case_1),
10014 TEST_CASE_ST(ut_setup, ut_teardown,
10015 test_AES_GCM_authenticated_encryption_test_case_2),
10016 TEST_CASE_ST(ut_setup, ut_teardown,
10017 test_AES_GCM_authenticated_encryption_test_case_3),
10018 TEST_CASE_ST(ut_setup, ut_teardown,
10019 test_AES_GCM_authenticated_encryption_test_case_4),
10020 TEST_CASE_ST(ut_setup, ut_teardown,
10021 test_AES_GCM_authenticated_encryption_test_case_5),
10022 TEST_CASE_ST(ut_setup, ut_teardown,
10023 test_AES_GCM_authenticated_encryption_test_case_6),
10024 TEST_CASE_ST(ut_setup, ut_teardown,
10025 test_AES_GCM_authenticated_encryption_test_case_7),
10027 /** AES GCM Authenticated Decryption */
10028 TEST_CASE_ST(ut_setup, ut_teardown,
10029 test_AES_GCM_authenticated_decryption_test_case_1),
10030 TEST_CASE_ST(ut_setup, ut_teardown,
10031 test_AES_GCM_authenticated_decryption_test_case_2),
10032 TEST_CASE_ST(ut_setup, ut_teardown,
10033 test_AES_GCM_authenticated_decryption_test_case_3),
10034 TEST_CASE_ST(ut_setup, ut_teardown,
10035 test_AES_GCM_authenticated_decryption_test_case_4),
10036 TEST_CASE_ST(ut_setup, ut_teardown,
10037 test_AES_GCM_authenticated_decryption_test_case_5),
10038 TEST_CASE_ST(ut_setup, ut_teardown,
10039 test_AES_GCM_authenticated_decryption_test_case_6),
10040 TEST_CASE_ST(ut_setup, ut_teardown,
10041 test_AES_GCM_authenticated_decryption_test_case_7),
10043 /** AES GCM Authenticated Encryption 256 bits key */
10044 TEST_CASE_ST(ut_setup, ut_teardown,
10045 test_AES_GCM_auth_encryption_test_case_256_1),
10046 TEST_CASE_ST(ut_setup, ut_teardown,
10047 test_AES_GCM_auth_encryption_test_case_256_2),
10048 TEST_CASE_ST(ut_setup, ut_teardown,
10049 test_AES_GCM_auth_encryption_test_case_256_3),
10050 TEST_CASE_ST(ut_setup, ut_teardown,
10051 test_AES_GCM_auth_encryption_test_case_256_4),
10052 TEST_CASE_ST(ut_setup, ut_teardown,
10053 test_AES_GCM_auth_encryption_test_case_256_5),
10054 TEST_CASE_ST(ut_setup, ut_teardown,
10055 test_AES_GCM_auth_encryption_test_case_256_6),
10056 TEST_CASE_ST(ut_setup, ut_teardown,
10057 test_AES_GCM_auth_encryption_test_case_256_7),
10059 /** AES GCM Authenticated Decryption 256 bits key */
10060 TEST_CASE_ST(ut_setup, ut_teardown,
10061 test_AES_GCM_auth_decryption_test_case_256_1),
10062 TEST_CASE_ST(ut_setup, ut_teardown,
10063 test_AES_GCM_auth_decryption_test_case_256_2),
10064 TEST_CASE_ST(ut_setup, ut_teardown,
10065 test_AES_GCM_auth_decryption_test_case_256_3),
10066 TEST_CASE_ST(ut_setup, ut_teardown,
10067 test_AES_GCM_auth_decryption_test_case_256_4),
10068 TEST_CASE_ST(ut_setup, ut_teardown,
10069 test_AES_GCM_auth_decryption_test_case_256_5),
10070 TEST_CASE_ST(ut_setup, ut_teardown,
10071 test_AES_GCM_auth_decryption_test_case_256_6),
10072 TEST_CASE_ST(ut_setup, ut_teardown,
10073 test_AES_GCM_auth_decryption_test_case_256_7),
10075 /** Out of place tests */
10076 TEST_CASE_ST(ut_setup, ut_teardown,
10077 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10078 TEST_CASE_ST(ut_setup, ut_teardown,
10079 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10081 /** Scatter-Gather */
10082 TEST_CASE_ST(ut_setup, ut_teardown,
10083 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10084 TEST_CASE_ST(ut_setup, ut_teardown,
10085 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10086 TEST_CASE_ST(ut_setup, ut_teardown,
10087 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10088 TEST_CASE_ST(ut_setup, ut_teardown,
10089 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10091 TEST_CASES_END() /**< NULL terminate unit test array */
10095 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10096 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10097 .setup = testsuite_setup,
10098 .teardown = testsuite_teardown,
10099 .unit_test_cases = {
10100 TEST_CASE_ST(ut_setup, ut_teardown,
10101 test_device_configure_invalid_dev_id),
10102 TEST_CASE_ST(ut_setup, ut_teardown,
10103 test_multi_session),
10105 TEST_CASE_ST(ut_setup, ut_teardown,
10106 test_AES_chain_dpaa2_sec_all),
10107 TEST_CASE_ST(ut_setup, ut_teardown,
10108 test_3DES_chain_dpaa2_sec_all),
10109 TEST_CASE_ST(ut_setup, ut_teardown,
10110 test_AES_cipheronly_dpaa2_sec_all),
10111 TEST_CASE_ST(ut_setup, ut_teardown,
10112 test_3DES_cipheronly_dpaa2_sec_all),
10113 TEST_CASE_ST(ut_setup, ut_teardown,
10114 test_authonly_dpaa2_sec_all),
10116 /** AES GCM Authenticated Encryption */
10117 TEST_CASE_ST(ut_setup, ut_teardown,
10118 test_AES_GCM_authenticated_encryption_test_case_1),
10119 TEST_CASE_ST(ut_setup, ut_teardown,
10120 test_AES_GCM_authenticated_encryption_test_case_2),
10121 TEST_CASE_ST(ut_setup, ut_teardown,
10122 test_AES_GCM_authenticated_encryption_test_case_3),
10123 TEST_CASE_ST(ut_setup, ut_teardown,
10124 test_AES_GCM_authenticated_encryption_test_case_4),
10125 TEST_CASE_ST(ut_setup, ut_teardown,
10126 test_AES_GCM_authenticated_encryption_test_case_5),
10127 TEST_CASE_ST(ut_setup, ut_teardown,
10128 test_AES_GCM_authenticated_encryption_test_case_6),
10129 TEST_CASE_ST(ut_setup, ut_teardown,
10130 test_AES_GCM_authenticated_encryption_test_case_7),
10132 /** AES GCM Authenticated Decryption */
10133 TEST_CASE_ST(ut_setup, ut_teardown,
10134 test_AES_GCM_authenticated_decryption_test_case_1),
10135 TEST_CASE_ST(ut_setup, ut_teardown,
10136 test_AES_GCM_authenticated_decryption_test_case_2),
10137 TEST_CASE_ST(ut_setup, ut_teardown,
10138 test_AES_GCM_authenticated_decryption_test_case_3),
10139 TEST_CASE_ST(ut_setup, ut_teardown,
10140 test_AES_GCM_authenticated_decryption_test_case_4),
10141 TEST_CASE_ST(ut_setup, ut_teardown,
10142 test_AES_GCM_authenticated_decryption_test_case_5),
10143 TEST_CASE_ST(ut_setup, ut_teardown,
10144 test_AES_GCM_authenticated_decryption_test_case_6),
10145 TEST_CASE_ST(ut_setup, ut_teardown,
10146 test_AES_GCM_authenticated_decryption_test_case_7),
10148 /** AES GCM Authenticated Encryption 192 bits key */
10149 TEST_CASE_ST(ut_setup, ut_teardown,
10150 test_AES_GCM_auth_encryption_test_case_192_1),
10151 TEST_CASE_ST(ut_setup, ut_teardown,
10152 test_AES_GCM_auth_encryption_test_case_192_2),
10153 TEST_CASE_ST(ut_setup, ut_teardown,
10154 test_AES_GCM_auth_encryption_test_case_192_3),
10155 TEST_CASE_ST(ut_setup, ut_teardown,
10156 test_AES_GCM_auth_encryption_test_case_192_4),
10157 TEST_CASE_ST(ut_setup, ut_teardown,
10158 test_AES_GCM_auth_encryption_test_case_192_5),
10159 TEST_CASE_ST(ut_setup, ut_teardown,
10160 test_AES_GCM_auth_encryption_test_case_192_6),
10161 TEST_CASE_ST(ut_setup, ut_teardown,
10162 test_AES_GCM_auth_encryption_test_case_192_7),
10164 /** AES GCM Authenticated Decryption 192 bits key */
10165 TEST_CASE_ST(ut_setup, ut_teardown,
10166 test_AES_GCM_auth_decryption_test_case_192_1),
10167 TEST_CASE_ST(ut_setup, ut_teardown,
10168 test_AES_GCM_auth_decryption_test_case_192_2),
10169 TEST_CASE_ST(ut_setup, ut_teardown,
10170 test_AES_GCM_auth_decryption_test_case_192_3),
10171 TEST_CASE_ST(ut_setup, ut_teardown,
10172 test_AES_GCM_auth_decryption_test_case_192_4),
10173 TEST_CASE_ST(ut_setup, ut_teardown,
10174 test_AES_GCM_auth_decryption_test_case_192_5),
10175 TEST_CASE_ST(ut_setup, ut_teardown,
10176 test_AES_GCM_auth_decryption_test_case_192_6),
10177 TEST_CASE_ST(ut_setup, ut_teardown,
10178 test_AES_GCM_auth_decryption_test_case_192_7),
10180 /** AES GCM Authenticated Encryption 256 bits key */
10181 TEST_CASE_ST(ut_setup, ut_teardown,
10182 test_AES_GCM_auth_encryption_test_case_256_1),
10183 TEST_CASE_ST(ut_setup, ut_teardown,
10184 test_AES_GCM_auth_encryption_test_case_256_2),
10185 TEST_CASE_ST(ut_setup, ut_teardown,
10186 test_AES_GCM_auth_encryption_test_case_256_3),
10187 TEST_CASE_ST(ut_setup, ut_teardown,
10188 test_AES_GCM_auth_encryption_test_case_256_4),
10189 TEST_CASE_ST(ut_setup, ut_teardown,
10190 test_AES_GCM_auth_encryption_test_case_256_5),
10191 TEST_CASE_ST(ut_setup, ut_teardown,
10192 test_AES_GCM_auth_encryption_test_case_256_6),
10193 TEST_CASE_ST(ut_setup, ut_teardown,
10194 test_AES_GCM_auth_encryption_test_case_256_7),
10196 /** AES GCM Authenticated Decryption 256 bits key */
10197 TEST_CASE_ST(ut_setup, ut_teardown,
10198 test_AES_GCM_auth_decryption_test_case_256_1),
10199 TEST_CASE_ST(ut_setup, ut_teardown,
10200 test_AES_GCM_auth_decryption_test_case_256_2),
10201 TEST_CASE_ST(ut_setup, ut_teardown,
10202 test_AES_GCM_auth_decryption_test_case_256_3),
10203 TEST_CASE_ST(ut_setup, ut_teardown,
10204 test_AES_GCM_auth_decryption_test_case_256_4),
10205 TEST_CASE_ST(ut_setup, ut_teardown,
10206 test_AES_GCM_auth_decryption_test_case_256_5),
10207 TEST_CASE_ST(ut_setup, ut_teardown,
10208 test_AES_GCM_auth_decryption_test_case_256_6),
10209 TEST_CASE_ST(ut_setup, ut_teardown,
10210 test_AES_GCM_auth_decryption_test_case_256_7),
10212 /** Out of place tests */
10213 TEST_CASE_ST(ut_setup, ut_teardown,
10214 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10215 TEST_CASE_ST(ut_setup, ut_teardown,
10216 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10218 /** Scatter-Gather */
10219 TEST_CASE_ST(ut_setup, ut_teardown,
10220 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10221 TEST_CASE_ST(ut_setup, ut_teardown,
10222 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10223 TEST_CASE_ST(ut_setup, ut_teardown,
10224 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10225 TEST_CASE_ST(ut_setup, ut_teardown,
10226 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10228 TEST_CASES_END() /**< NULL terminate unit test array */
10232 static struct unit_test_suite cryptodev_null_testsuite = {
10233 .suite_name = "Crypto Device NULL Unit Test Suite",
10234 .setup = testsuite_setup,
10235 .teardown = testsuite_teardown,
10236 .unit_test_cases = {
10237 TEST_CASE_ST(ut_setup, ut_teardown,
10238 test_null_auth_only_operation),
10239 TEST_CASE_ST(ut_setup, ut_teardown,
10240 test_null_cipher_only_operation),
10241 TEST_CASE_ST(ut_setup, ut_teardown,
10242 test_null_cipher_auth_operation),
10243 TEST_CASE_ST(ut_setup, ut_teardown,
10244 test_null_auth_cipher_operation),
10245 TEST_CASE_ST(ut_setup, ut_teardown,
10246 test_null_invalid_operation),
10247 TEST_CASE_ST(ut_setup, ut_teardown,
10248 test_null_burst_operation),
10250 TEST_CASES_END() /**< NULL terminate unit test array */
10254 static struct unit_test_suite cryptodev_armv8_testsuite = {
10255 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10256 .setup = testsuite_setup,
10257 .teardown = testsuite_teardown,
10258 .unit_test_cases = {
10259 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10261 /** Negative tests */
10262 TEST_CASE_ST(ut_setup, ut_teardown,
10263 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10264 TEST_CASE_ST(ut_setup, ut_teardown,
10265 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10267 TEST_CASES_END() /**< NULL terminate unit test array */
10271 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10272 .suite_name = "Crypto Device Marvell Component Test Suite",
10273 .setup = testsuite_setup,
10274 .teardown = testsuite_teardown,
10275 .unit_test_cases = {
10276 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10277 TEST_CASE_ST(ut_setup, ut_teardown,
10278 test_multi_session_random_usage),
10279 TEST_CASE_ST(ut_setup, ut_teardown,
10280 test_AES_chain_mrvl_all),
10281 TEST_CASE_ST(ut_setup, ut_teardown,
10282 test_AES_cipheronly_mrvl_all),
10283 TEST_CASE_ST(ut_setup, ut_teardown,
10284 test_authonly_mrvl_all),
10285 TEST_CASE_ST(ut_setup, ut_teardown,
10286 test_3DES_chain_mrvl_all),
10287 TEST_CASE_ST(ut_setup, ut_teardown,
10288 test_3DES_cipheronly_mrvl_all),
10290 /** Negative tests */
10291 TEST_CASE_ST(ut_setup, ut_teardown,
10292 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10293 TEST_CASE_ST(ut_setup, ut_teardown,
10294 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10295 TEST_CASE_ST(ut_setup, ut_teardown,
10296 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10297 TEST_CASE_ST(ut_setup, ut_teardown,
10298 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10300 TEST_CASES_END() /**< NULL terminate unit test array */
10304 static struct unit_test_suite cryptodev_ccp_testsuite = {
10305 .suite_name = "Crypto Device CCP Unit Test Suite",
10306 .setup = testsuite_setup,
10307 .teardown = testsuite_teardown,
10308 .unit_test_cases = {
10309 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10310 TEST_CASE_ST(ut_setup, ut_teardown,
10311 test_multi_session_random_usage),
10312 TEST_CASE_ST(ut_setup, ut_teardown,
10313 test_AES_chain_ccp_all),
10314 TEST_CASE_ST(ut_setup, ut_teardown,
10315 test_AES_cipheronly_ccp_all),
10316 TEST_CASE_ST(ut_setup, ut_teardown,
10317 test_3DES_chain_ccp_all),
10318 TEST_CASE_ST(ut_setup, ut_teardown,
10319 test_3DES_cipheronly_ccp_all),
10320 TEST_CASE_ST(ut_setup, ut_teardown,
10321 test_authonly_ccp_all),
10323 /** Negative tests */
10324 TEST_CASE_ST(ut_setup, ut_teardown,
10325 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10326 TEST_CASE_ST(ut_setup, ut_teardown,
10327 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10328 TEST_CASE_ST(ut_setup, ut_teardown,
10329 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10330 TEST_CASE_ST(ut_setup, ut_teardown,
10331 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10333 TEST_CASES_END() /**< NULL terminate unit test array */
10337 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10338 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10339 .setup = testsuite_setup,
10340 .teardown = testsuite_teardown,
10341 .unit_test_cases = {
10342 TEST_CASE_ST(ut_setup, ut_teardown,
10343 test_AES_chain_octeontx_all),
10344 TEST_CASE_ST(ut_setup, ut_teardown,
10345 test_AES_cipheronly_octeontx_all),
10346 TEST_CASE_ST(ut_setup, ut_teardown,
10347 test_3DES_chain_octeontx_all),
10348 TEST_CASE_ST(ut_setup, ut_teardown,
10349 test_3DES_cipheronly_octeontx_all),
10350 TEST_CASE_ST(ut_setup, ut_teardown,
10351 test_authonly_octeontx_all),
10353 /** AES GCM Authenticated Encryption */
10354 TEST_CASE_ST(ut_setup, ut_teardown,
10355 test_AES_GCM_authenticated_encryption_test_case_1),
10356 TEST_CASE_ST(ut_setup, ut_teardown,
10357 test_AES_GCM_authenticated_encryption_test_case_2),
10358 TEST_CASE_ST(ut_setup, ut_teardown,
10359 test_AES_GCM_authenticated_encryption_test_case_3),
10360 TEST_CASE_ST(ut_setup, ut_teardown,
10361 test_AES_GCM_authenticated_encryption_test_case_4),
10362 TEST_CASE_ST(ut_setup, ut_teardown,
10363 test_AES_GCM_authenticated_encryption_test_case_5),
10364 TEST_CASE_ST(ut_setup, ut_teardown,
10365 test_AES_GCM_authenticated_encryption_test_case_6),
10366 TEST_CASE_ST(ut_setup, ut_teardown,
10367 test_AES_GCM_authenticated_encryption_test_case_7),
10369 /** AES GCM Authenticated Decryption */
10370 TEST_CASE_ST(ut_setup, ut_teardown,
10371 test_AES_GCM_authenticated_decryption_test_case_1),
10372 TEST_CASE_ST(ut_setup, ut_teardown,
10373 test_AES_GCM_authenticated_decryption_test_case_2),
10374 TEST_CASE_ST(ut_setup, ut_teardown,
10375 test_AES_GCM_authenticated_decryption_test_case_3),
10376 TEST_CASE_ST(ut_setup, ut_teardown,
10377 test_AES_GCM_authenticated_decryption_test_case_4),
10378 TEST_CASE_ST(ut_setup, ut_teardown,
10379 test_AES_GCM_authenticated_decryption_test_case_5),
10380 TEST_CASE_ST(ut_setup, ut_teardown,
10381 test_AES_GCM_authenticated_decryption_test_case_6),
10382 TEST_CASE_ST(ut_setup, ut_teardown,
10383 test_AES_GCM_authenticated_decryption_test_case_7),
10384 /** AES GMAC Authentication */
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 test_AES_GMAC_authentication_test_case_1),
10387 TEST_CASE_ST(ut_setup, ut_teardown,
10388 test_AES_GMAC_authentication_verify_test_case_1),
10389 TEST_CASE_ST(ut_setup, ut_teardown,
10390 test_AES_GMAC_authentication_test_case_2),
10391 TEST_CASE_ST(ut_setup, ut_teardown,
10392 test_AES_GMAC_authentication_verify_test_case_2),
10393 TEST_CASE_ST(ut_setup, ut_teardown,
10394 test_AES_GMAC_authentication_test_case_3),
10395 TEST_CASE_ST(ut_setup, ut_teardown,
10396 test_AES_GMAC_authentication_verify_test_case_3),
10398 /** SNOW 3G encrypt only (UEA2) */
10399 TEST_CASE_ST(ut_setup, ut_teardown,
10400 test_snow3g_encryption_test_case_1),
10401 TEST_CASE_ST(ut_setup, ut_teardown,
10402 test_snow3g_encryption_test_case_2),
10403 TEST_CASE_ST(ut_setup, ut_teardown,
10404 test_snow3g_encryption_test_case_3),
10405 TEST_CASE_ST(ut_setup, ut_teardown,
10406 test_snow3g_encryption_test_case_4),
10407 TEST_CASE_ST(ut_setup, ut_teardown,
10408 test_snow3g_encryption_test_case_5),
10410 TEST_CASE_ST(ut_setup, ut_teardown,
10411 test_snow3g_encryption_test_case_1_oop),
10412 TEST_CASE_ST(ut_setup, ut_teardown,
10413 test_snow3g_decryption_test_case_1_oop),
10414 TEST_CASE_ST(ut_setup, ut_teardown,
10415 test_snow3g_encryption_test_case_1_oop_sgl),
10417 /** SNOW 3G decrypt only (UEA2) */
10418 TEST_CASE_ST(ut_setup, ut_teardown,
10419 test_snow3g_decryption_test_case_1),
10420 TEST_CASE_ST(ut_setup, ut_teardown,
10421 test_snow3g_decryption_test_case_2),
10422 TEST_CASE_ST(ut_setup, ut_teardown,
10423 test_snow3g_decryption_test_case_3),
10424 TEST_CASE_ST(ut_setup, ut_teardown,
10425 test_snow3g_decryption_test_case_4),
10426 TEST_CASE_ST(ut_setup, ut_teardown,
10427 test_snow3g_decryption_test_case_5),
10429 TEST_CASE_ST(ut_setup, ut_teardown,
10430 test_snow3g_hash_generate_test_case_1),
10431 TEST_CASE_ST(ut_setup, ut_teardown,
10432 test_snow3g_hash_generate_test_case_2),
10433 TEST_CASE_ST(ut_setup, ut_teardown,
10434 test_snow3g_hash_generate_test_case_3),
10435 TEST_CASE_ST(ut_setup, ut_teardown,
10436 test_snow3g_hash_verify_test_case_1),
10437 TEST_CASE_ST(ut_setup, ut_teardown,
10438 test_snow3g_hash_verify_test_case_2),
10439 TEST_CASE_ST(ut_setup, ut_teardown,
10440 test_snow3g_hash_verify_test_case_3),
10442 /** ZUC encrypt only (EEA3) */
10443 TEST_CASE_ST(ut_setup, ut_teardown,
10444 test_zuc_encryption_test_case_1),
10445 TEST_CASE_ST(ut_setup, ut_teardown,
10446 test_zuc_encryption_test_case_2),
10447 TEST_CASE_ST(ut_setup, ut_teardown,
10448 test_zuc_encryption_test_case_3),
10449 TEST_CASE_ST(ut_setup, ut_teardown,
10450 test_zuc_encryption_test_case_4),
10451 TEST_CASE_ST(ut_setup, ut_teardown,
10452 test_zuc_encryption_test_case_5),
10453 TEST_CASE_ST(ut_setup, ut_teardown,
10454 test_zuc_hash_generate_test_case_1),
10455 TEST_CASE_ST(ut_setup, ut_teardown,
10456 test_zuc_hash_generate_test_case_2),
10457 TEST_CASE_ST(ut_setup, ut_teardown,
10458 test_zuc_hash_generate_test_case_3),
10459 TEST_CASE_ST(ut_setup, ut_teardown,
10460 test_zuc_hash_generate_test_case_4),
10461 TEST_CASE_ST(ut_setup, ut_teardown,
10462 test_zuc_hash_generate_test_case_5),
10463 TEST_CASE_ST(ut_setup, ut_teardown,
10464 test_zuc_encryption_test_case_6_sgl),
10466 /** KASUMI encrypt only (UEA1) */
10467 TEST_CASE_ST(ut_setup, ut_teardown,
10468 test_kasumi_encryption_test_case_1),
10469 TEST_CASE_ST(ut_setup, ut_teardown,
10470 test_kasumi_encryption_test_case_2),
10471 TEST_CASE_ST(ut_setup, ut_teardown,
10472 test_kasumi_encryption_test_case_3),
10473 TEST_CASE_ST(ut_setup, ut_teardown,
10474 test_kasumi_encryption_test_case_4),
10475 TEST_CASE_ST(ut_setup, ut_teardown,
10476 test_kasumi_encryption_test_case_5),
10477 TEST_CASE_ST(ut_setup, ut_teardown,
10478 test_kasumi_encryption_test_case_1_sgl),
10479 TEST_CASE_ST(ut_setup, ut_teardown,
10480 test_kasumi_encryption_test_case_1_oop_sgl),
10481 /** KASUMI decrypt only (UEA1) */
10482 TEST_CASE_ST(ut_setup, ut_teardown,
10483 test_kasumi_decryption_test_case_1),
10484 TEST_CASE_ST(ut_setup, ut_teardown,
10485 test_kasumi_decryption_test_case_2),
10486 TEST_CASE_ST(ut_setup, ut_teardown,
10487 test_kasumi_decryption_test_case_3),
10488 TEST_CASE_ST(ut_setup, ut_teardown,
10489 test_kasumi_decryption_test_case_4),
10490 TEST_CASE_ST(ut_setup, ut_teardown,
10491 test_kasumi_decryption_test_case_5),
10493 TEST_CASE_ST(ut_setup, ut_teardown,
10494 test_kasumi_encryption_test_case_1_oop),
10495 TEST_CASE_ST(ut_setup, ut_teardown,
10496 test_kasumi_decryption_test_case_1_oop),
10498 /** KASUMI hash only (UIA1) */
10499 TEST_CASE_ST(ut_setup, ut_teardown,
10500 test_kasumi_hash_generate_test_case_1),
10501 TEST_CASE_ST(ut_setup, ut_teardown,
10502 test_kasumi_hash_generate_test_case_2),
10503 TEST_CASE_ST(ut_setup, ut_teardown,
10504 test_kasumi_hash_generate_test_case_3),
10505 TEST_CASE_ST(ut_setup, ut_teardown,
10506 test_kasumi_hash_generate_test_case_4),
10507 TEST_CASE_ST(ut_setup, ut_teardown,
10508 test_kasumi_hash_generate_test_case_5),
10509 TEST_CASE_ST(ut_setup, ut_teardown,
10510 test_kasumi_hash_generate_test_case_6),
10511 TEST_CASE_ST(ut_setup, ut_teardown,
10512 test_kasumi_hash_verify_test_case_1),
10513 TEST_CASE_ST(ut_setup, ut_teardown,
10514 test_kasumi_hash_verify_test_case_2),
10515 TEST_CASE_ST(ut_setup, ut_teardown,
10516 test_kasumi_hash_verify_test_case_3),
10517 TEST_CASE_ST(ut_setup, ut_teardown,
10518 test_kasumi_hash_verify_test_case_4),
10519 TEST_CASE_ST(ut_setup, ut_teardown,
10520 test_kasumi_hash_verify_test_case_5),
10523 TEST_CASE_ST(ut_setup, ut_teardown,
10524 test_null_cipher_only_operation),
10525 TEST_CASE_ST(ut_setup, ut_teardown,
10526 test_null_auth_only_operation),
10527 TEST_CASE_ST(ut_setup, ut_teardown,
10528 test_null_cipher_auth_operation),
10529 TEST_CASE_ST(ut_setup, ut_teardown,
10530 test_null_auth_cipher_operation),
10532 /** Negative tests */
10533 TEST_CASE_ST(ut_setup, ut_teardown,
10534 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10535 TEST_CASE_ST(ut_setup, ut_teardown,
10536 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10537 TEST_CASE_ST(ut_setup, ut_teardown,
10538 authentication_verify_AES128_GMAC_fail_data_corrupt),
10539 TEST_CASE_ST(ut_setup, ut_teardown,
10540 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10541 TEST_CASE_ST(ut_setup, ut_teardown,
10542 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10543 TEST_CASE_ST(ut_setup, ut_teardown,
10544 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10545 TEST_CASES_END() /**< NULL terminate unit test array */
10550 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10552 gbl_driver_id = rte_cryptodev_driver_id_get(
10553 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10555 if (gbl_driver_id == -1) {
10556 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10557 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10558 "are enabled in config file to run this testsuite.\n");
10559 return TEST_SKIPPED;
10562 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10566 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10568 gbl_driver_id = rte_cryptodev_driver_id_get(
10569 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10571 if (gbl_driver_id == -1) {
10572 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10573 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10574 "in config file to run this testsuite.\n");
10575 return TEST_FAILED;
10578 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10582 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10584 gbl_driver_id = rte_cryptodev_driver_id_get(
10585 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10587 if (gbl_driver_id == -1) {
10588 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10589 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10590 "in config file to run this testsuite.\n");
10591 return TEST_SKIPPED;
10594 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10598 test_cryptodev_openssl(void)
10600 gbl_driver_id = rte_cryptodev_driver_id_get(
10601 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10603 if (gbl_driver_id == -1) {
10604 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10605 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10606 "in config file to run this testsuite.\n");
10607 return TEST_SKIPPED;
10610 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10614 test_cryptodev_aesni_gcm(void)
10616 gbl_driver_id = rte_cryptodev_driver_id_get(
10617 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10619 if (gbl_driver_id == -1) {
10620 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10621 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10622 "in config file to run this testsuite.\n");
10623 return TEST_SKIPPED;
10626 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10630 test_cryptodev_null(void)
10632 gbl_driver_id = rte_cryptodev_driver_id_get(
10633 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10635 if (gbl_driver_id == -1) {
10636 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10637 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10638 "in config file to run this testsuite.\n");
10639 return TEST_SKIPPED;
10642 return unit_test_suite_runner(&cryptodev_null_testsuite);
10646 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10648 gbl_driver_id = rte_cryptodev_driver_id_get(
10649 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10651 if (gbl_driver_id == -1) {
10652 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10653 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10654 "in config file to run this testsuite.\n");
10655 return TEST_SKIPPED;
10658 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10662 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10664 gbl_driver_id = rte_cryptodev_driver_id_get(
10665 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10667 if (gbl_driver_id == -1) {
10668 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10669 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10670 "in config file to run this testsuite.\n");
10671 return TEST_SKIPPED;
10674 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10678 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10680 gbl_driver_id = rte_cryptodev_driver_id_get(
10681 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10683 if (gbl_driver_id == -1) {
10684 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10685 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10686 "in config file to run this testsuite.\n");
10687 return TEST_SKIPPED;
10690 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10694 test_cryptodev_armv8(void)
10696 gbl_driver_id = rte_cryptodev_driver_id_get(
10697 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10699 if (gbl_driver_id == -1) {
10700 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10701 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10702 "in config file to run this testsuite.\n");
10703 return TEST_SKIPPED;
10706 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10710 test_cryptodev_mrvl(void)
10712 gbl_driver_id = rte_cryptodev_driver_id_get(
10713 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10715 if (gbl_driver_id == -1) {
10716 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10717 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10718 "in config file to run this testsuite.\n");
10719 return TEST_SKIPPED;
10722 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10725 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10728 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10730 gbl_driver_id = rte_cryptodev_driver_id_get(
10731 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10733 if (gbl_driver_id == -1) {
10734 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10735 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10736 "in config file to run this testsuite.\n");
10737 return TEST_SKIPPED;
10740 if (rte_cryptodev_driver_id_get(
10741 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10742 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10743 " enabled in config file to run this testsuite.\n");
10744 return TEST_SKIPPED;
10746 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10749 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10754 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10756 gbl_driver_id = rte_cryptodev_driver_id_get(
10757 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10759 if (gbl_driver_id == -1) {
10760 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10761 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10762 "in config file to run this testsuite.\n");
10763 return TEST_SKIPPED;
10766 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10770 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10772 gbl_driver_id = rte_cryptodev_driver_id_get(
10773 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10775 if (gbl_driver_id == -1) {
10776 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10777 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10778 "in config file to run this testsuite.\n");
10779 return TEST_SKIPPED;
10782 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10786 test_cryptodev_ccp(void)
10788 gbl_driver_id = rte_cryptodev_driver_id_get(
10789 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10791 if (gbl_driver_id == -1) {
10792 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10793 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10794 "in config file to run this testsuite.\n");
10795 return TEST_FAILED;
10798 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10802 test_cryptodev_octeontx(void)
10804 gbl_driver_id = rte_cryptodev_driver_id_get(
10805 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10806 if (gbl_driver_id == -1) {
10807 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10808 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10809 "enabled in config file to run this "
10811 return TEST_FAILED;
10813 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10817 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10819 gbl_driver_id = rte_cryptodev_driver_id_get(
10820 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10822 if (gbl_driver_id == -1) {
10823 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10824 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10825 "in config file to run this testsuite.\n");
10826 return TEST_FAILED;
10829 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10832 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10833 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10834 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10835 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10836 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10837 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10838 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10839 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10840 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10841 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10842 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10843 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10844 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10845 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10846 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10847 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);