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_mtod_offset(
2838 ut_params->ibuf, uint8_t *, data_pad_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 /* Copy cipher and auth IVs at the end of the crypto operation */
2849 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2851 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2852 iv_ptr += cipher_iv_len;
2853 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2855 sym_op->cipher.data.length = cipher_len;
2856 sym_op->cipher.data.offset = cipher_offset;
2858 sym_op->auth.data.length = auth_len;
2859 sym_op->auth.data.offset = auth_offset;
2865 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2867 struct crypto_testsuite_params *ts_params = &testsuite_params;
2868 struct crypto_unittest_params *ut_params = &unittest_params;
2871 unsigned plaintext_pad_len;
2872 unsigned plaintext_len;
2875 /* Create SNOW 3G session */
2876 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2877 tdata->key.data, tdata->key.len,
2878 tdata->auth_iv.len, tdata->digest.len,
2879 RTE_CRYPTO_AUTH_OP_GENERATE,
2880 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2884 /* alloc mbuf and set payload */
2885 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2887 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2888 rte_pktmbuf_tailroom(ut_params->ibuf));
2890 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2891 /* Append data which is padded to a multiple of */
2892 /* the algorithms block size */
2893 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2894 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2896 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2898 /* Create SNOW 3G operation */
2899 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2900 tdata->auth_iv.data, tdata->auth_iv.len,
2901 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2902 tdata->validAuthLenInBits.len,
2907 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2909 ut_params->obuf = ut_params->op->sym->m_src;
2910 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2911 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2912 + plaintext_pad_len;
2915 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2918 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2919 "SNOW 3G Generated auth tag not as expected");
2925 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2927 struct crypto_testsuite_params *ts_params = &testsuite_params;
2928 struct crypto_unittest_params *ut_params = &unittest_params;
2931 unsigned plaintext_pad_len;
2932 unsigned plaintext_len;
2935 /* Create SNOW 3G session */
2936 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2937 tdata->key.data, tdata->key.len,
2938 tdata->auth_iv.len, tdata->digest.len,
2939 RTE_CRYPTO_AUTH_OP_VERIFY,
2940 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2943 /* alloc mbuf and set payload */
2944 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2946 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2947 rte_pktmbuf_tailroom(ut_params->ibuf));
2949 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2950 /* Append data which is padded to a multiple of */
2951 /* the algorithms block size */
2952 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2953 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2955 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2957 /* Create SNOW 3G operation */
2958 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2960 tdata->auth_iv.data, tdata->auth_iv.len,
2962 RTE_CRYPTO_AUTH_OP_VERIFY,
2963 tdata->validAuthLenInBits.len,
2968 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2970 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2971 ut_params->obuf = ut_params->op->sym->m_src;
2972 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2973 + plaintext_pad_len;
2976 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2985 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2987 struct crypto_testsuite_params *ts_params = &testsuite_params;
2988 struct crypto_unittest_params *ut_params = &unittest_params;
2991 unsigned plaintext_pad_len;
2992 unsigned plaintext_len;
2995 /* Create KASUMI session */
2996 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2997 tdata->key.data, tdata->key.len,
2998 0, tdata->digest.len,
2999 RTE_CRYPTO_AUTH_OP_GENERATE,
3000 RTE_CRYPTO_AUTH_KASUMI_F9);
3004 /* alloc mbuf and set payload */
3005 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3008 rte_pktmbuf_tailroom(ut_params->ibuf));
3010 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3011 /* Append data which is padded to a multiple of */
3012 /* the algorithms block size */
3013 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3014 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3016 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3018 /* Create KASUMI operation */
3019 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3021 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3022 tdata->plaintext.len,
3027 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3029 ut_params->obuf = ut_params->op->sym->m_src;
3030 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3031 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3032 + plaintext_pad_len;
3035 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3038 DIGEST_BYTE_LENGTH_KASUMI_F9,
3039 "KASUMI Generated auth tag not as expected");
3045 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3047 struct crypto_testsuite_params *ts_params = &testsuite_params;
3048 struct crypto_unittest_params *ut_params = &unittest_params;
3051 unsigned plaintext_pad_len;
3052 unsigned plaintext_len;
3055 /* Create KASUMI session */
3056 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3057 tdata->key.data, tdata->key.len,
3058 0, tdata->digest.len,
3059 RTE_CRYPTO_AUTH_OP_VERIFY,
3060 RTE_CRYPTO_AUTH_KASUMI_F9);
3063 /* alloc mbuf and set payload */
3064 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3066 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3067 rte_pktmbuf_tailroom(ut_params->ibuf));
3069 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3070 /* Append data which is padded to a multiple */
3071 /* of the algorithms block size */
3072 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3073 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3075 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3077 /* Create KASUMI operation */
3078 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3082 RTE_CRYPTO_AUTH_OP_VERIFY,
3083 tdata->plaintext.len,
3088 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3090 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3091 ut_params->obuf = ut_params->op->sym->m_src;
3092 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3093 + plaintext_pad_len;
3096 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3105 test_snow3g_hash_generate_test_case_1(void)
3107 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3111 test_snow3g_hash_generate_test_case_2(void)
3113 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3117 test_snow3g_hash_generate_test_case_3(void)
3119 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3123 test_snow3g_hash_generate_test_case_4(void)
3125 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3129 test_snow3g_hash_generate_test_case_5(void)
3131 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3135 test_snow3g_hash_generate_test_case_6(void)
3137 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3141 test_snow3g_hash_verify_test_case_1(void)
3143 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3148 test_snow3g_hash_verify_test_case_2(void)
3150 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3154 test_snow3g_hash_verify_test_case_3(void)
3156 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3160 test_snow3g_hash_verify_test_case_4(void)
3162 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3166 test_snow3g_hash_verify_test_case_5(void)
3168 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3172 test_snow3g_hash_verify_test_case_6(void)
3174 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3178 test_kasumi_hash_generate_test_case_1(void)
3180 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3184 test_kasumi_hash_generate_test_case_2(void)
3186 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3190 test_kasumi_hash_generate_test_case_3(void)
3192 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3196 test_kasumi_hash_generate_test_case_4(void)
3198 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3202 test_kasumi_hash_generate_test_case_5(void)
3204 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3208 test_kasumi_hash_generate_test_case_6(void)
3210 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3214 test_kasumi_hash_verify_test_case_1(void)
3216 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3220 test_kasumi_hash_verify_test_case_2(void)
3222 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3226 test_kasumi_hash_verify_test_case_3(void)
3228 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3232 test_kasumi_hash_verify_test_case_4(void)
3234 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3238 test_kasumi_hash_verify_test_case_5(void)
3240 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3244 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3246 struct crypto_testsuite_params *ts_params = &testsuite_params;
3247 struct crypto_unittest_params *ut_params = &unittest_params;
3250 uint8_t *plaintext, *ciphertext;
3251 unsigned plaintext_pad_len;
3252 unsigned plaintext_len;
3254 /* Create KASUMI session */
3255 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3256 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3257 RTE_CRYPTO_CIPHER_KASUMI_F8,
3258 tdata->key.data, tdata->key.len,
3259 tdata->cipher_iv.len);
3263 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3265 /* Clear mbuf payload */
3266 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3267 rte_pktmbuf_tailroom(ut_params->ibuf));
3269 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3270 /* Append data which is padded to a multiple */
3271 /* of the algorithms block size */
3272 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3273 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3275 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3277 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3279 /* Create KASUMI operation */
3280 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3281 tdata->cipher_iv.len,
3282 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3283 tdata->validCipherOffsetInBits.len);
3287 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3289 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3291 ut_params->obuf = ut_params->op->sym->m_dst;
3292 if (ut_params->obuf)
3293 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3295 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3297 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3299 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3300 (tdata->validCipherOffsetInBits.len >> 3);
3302 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3304 reference_ciphertext,
3305 tdata->validCipherLenInBits.len,
3306 "KASUMI Ciphertext data not as expected");
3311 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3313 struct crypto_testsuite_params *ts_params = &testsuite_params;
3314 struct crypto_unittest_params *ut_params = &unittest_params;
3318 unsigned int plaintext_pad_len;
3319 unsigned int plaintext_len;
3321 uint8_t buffer[10000];
3322 const uint8_t *ciphertext;
3324 struct rte_cryptodev_info dev_info;
3326 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3328 uint64_t feat_flags = dev_info.feature_flags;
3330 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3331 printf("Device doesn't support in-place scatter-gather. "
3336 /* Create KASUMI session */
3337 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3338 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3339 RTE_CRYPTO_CIPHER_KASUMI_F8,
3340 tdata->key.data, tdata->key.len,
3341 tdata->cipher_iv.len);
3345 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3348 /* Append data which is padded to a multiple */
3349 /* of the algorithms block size */
3350 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3352 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3353 plaintext_pad_len, 10, 0);
3355 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3357 /* Create KASUMI operation */
3358 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3359 tdata->cipher_iv.len,
3360 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3361 tdata->validCipherOffsetInBits.len);
3365 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3367 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3369 ut_params->obuf = ut_params->op->sym->m_dst;
3371 if (ut_params->obuf)
3372 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3373 plaintext_len, buffer);
3375 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3376 tdata->validCipherOffsetInBits.len >> 3,
3377 plaintext_len, buffer);
3380 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3382 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3383 (tdata->validCipherOffsetInBits.len >> 3);
3385 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3387 reference_ciphertext,
3388 tdata->validCipherLenInBits.len,
3389 "KASUMI Ciphertext data not as expected");
3394 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3396 struct crypto_testsuite_params *ts_params = &testsuite_params;
3397 struct crypto_unittest_params *ut_params = &unittest_params;
3400 uint8_t *plaintext, *ciphertext;
3401 unsigned plaintext_pad_len;
3402 unsigned plaintext_len;
3404 /* Create KASUMI session */
3405 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3406 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3407 RTE_CRYPTO_CIPHER_KASUMI_F8,
3408 tdata->key.data, tdata->key.len,
3409 tdata->cipher_iv.len);
3413 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3414 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3416 /* Clear mbuf payload */
3417 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3418 rte_pktmbuf_tailroom(ut_params->ibuf));
3420 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3421 /* Append data which is padded to a multiple */
3422 /* of the algorithms block size */
3423 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3424 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3426 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3427 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3429 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3431 /* Create KASUMI operation */
3432 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3433 tdata->cipher_iv.len,
3434 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3435 tdata->validCipherOffsetInBits.len);
3439 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3441 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3443 ut_params->obuf = ut_params->op->sym->m_dst;
3444 if (ut_params->obuf)
3445 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3447 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3449 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3451 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3452 (tdata->validCipherOffsetInBits.len >> 3);
3454 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3456 reference_ciphertext,
3457 tdata->validCipherLenInBits.len,
3458 "KASUMI Ciphertext data not as expected");
3463 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3465 struct crypto_testsuite_params *ts_params = &testsuite_params;
3466 struct crypto_unittest_params *ut_params = &unittest_params;
3469 unsigned int plaintext_pad_len;
3470 unsigned int plaintext_len;
3472 const uint8_t *ciphertext;
3473 uint8_t buffer[2048];
3475 struct rte_cryptodev_info dev_info;
3477 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3479 uint64_t feat_flags = dev_info.feature_flags;
3480 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3481 printf("Device doesn't support out-of-place scatter-gather "
3482 "in both input and output mbufs. "
3487 /* Create KASUMI session */
3488 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3489 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3490 RTE_CRYPTO_CIPHER_KASUMI_F8,
3491 tdata->key.data, tdata->key.len,
3492 tdata->cipher_iv.len);
3496 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3497 /* Append data which is padded to a multiple */
3498 /* of the algorithms block size */
3499 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3501 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3502 plaintext_pad_len, 10, 0);
3503 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3504 plaintext_pad_len, 3, 0);
3506 /* Append data which is padded to a multiple */
3507 /* of the algorithms block size */
3508 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3510 /* Create KASUMI operation */
3511 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3512 tdata->cipher_iv.len,
3513 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3514 tdata->validCipherOffsetInBits.len);
3518 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3520 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3522 ut_params->obuf = ut_params->op->sym->m_dst;
3523 if (ut_params->obuf)
3524 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3525 plaintext_pad_len, buffer);
3527 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3528 tdata->validCipherOffsetInBits.len >> 3,
3529 plaintext_pad_len, buffer);
3531 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3532 (tdata->validCipherOffsetInBits.len >> 3);
3534 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3536 reference_ciphertext,
3537 tdata->validCipherLenInBits.len,
3538 "KASUMI Ciphertext data not as expected");
3544 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3546 struct crypto_testsuite_params *ts_params = &testsuite_params;
3547 struct crypto_unittest_params *ut_params = &unittest_params;
3550 uint8_t *ciphertext, *plaintext;
3551 unsigned ciphertext_pad_len;
3552 unsigned ciphertext_len;
3554 /* Create KASUMI session */
3555 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3556 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3557 RTE_CRYPTO_CIPHER_KASUMI_F8,
3558 tdata->key.data, tdata->key.len,
3559 tdata->cipher_iv.len);
3563 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3564 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3566 /* Clear mbuf payload */
3567 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3568 rte_pktmbuf_tailroom(ut_params->ibuf));
3570 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3571 /* Append data which is padded to a multiple */
3572 /* of the algorithms block size */
3573 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3574 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3575 ciphertext_pad_len);
3576 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3577 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3579 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3581 /* Create KASUMI operation */
3582 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3583 tdata->cipher_iv.len,
3584 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3585 tdata->validCipherOffsetInBits.len);
3589 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3591 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3593 ut_params->obuf = ut_params->op->sym->m_dst;
3594 if (ut_params->obuf)
3595 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3597 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3599 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3601 const uint8_t *reference_plaintext = tdata->plaintext.data +
3602 (tdata->validCipherOffsetInBits.len >> 3);
3604 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3606 reference_plaintext,
3607 tdata->validCipherLenInBits.len,
3608 "KASUMI Plaintext data not as expected");
3613 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3615 struct crypto_testsuite_params *ts_params = &testsuite_params;
3616 struct crypto_unittest_params *ut_params = &unittest_params;
3619 uint8_t *ciphertext, *plaintext;
3620 unsigned ciphertext_pad_len;
3621 unsigned ciphertext_len;
3623 /* Create KASUMI session */
3624 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3625 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3626 RTE_CRYPTO_CIPHER_KASUMI_F8,
3627 tdata->key.data, tdata->key.len,
3628 tdata->cipher_iv.len);
3632 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3634 /* Clear mbuf payload */
3635 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3636 rte_pktmbuf_tailroom(ut_params->ibuf));
3638 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3639 /* Append data which is padded to a multiple */
3640 /* of the algorithms block size */
3641 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3642 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3643 ciphertext_pad_len);
3644 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3646 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3648 /* Create KASUMI operation */
3649 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3650 tdata->cipher_iv.len,
3651 tdata->ciphertext.len,
3652 tdata->validCipherOffsetInBits.len);
3656 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3658 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3660 ut_params->obuf = ut_params->op->sym->m_dst;
3661 if (ut_params->obuf)
3662 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3664 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3666 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3668 const uint8_t *reference_plaintext = tdata->plaintext.data +
3669 (tdata->validCipherOffsetInBits.len >> 3);
3671 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3673 reference_plaintext,
3674 tdata->validCipherLenInBits.len,
3675 "KASUMI Plaintext data not as expected");
3680 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3682 struct crypto_testsuite_params *ts_params = &testsuite_params;
3683 struct crypto_unittest_params *ut_params = &unittest_params;
3686 uint8_t *plaintext, *ciphertext;
3687 unsigned plaintext_pad_len;
3688 unsigned plaintext_len;
3690 /* Create SNOW 3G session */
3691 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3692 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3693 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3694 tdata->key.data, tdata->key.len,
3695 tdata->cipher_iv.len);
3699 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3701 /* Clear mbuf payload */
3702 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3703 rte_pktmbuf_tailroom(ut_params->ibuf));
3705 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3706 /* Append data which is padded to a multiple of */
3707 /* the algorithms block size */
3708 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3709 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3711 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3713 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3715 /* Create SNOW 3G operation */
3716 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3717 tdata->cipher_iv.len,
3718 tdata->validCipherLenInBits.len,
3723 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3725 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3727 ut_params->obuf = ut_params->op->sym->m_dst;
3728 if (ut_params->obuf)
3729 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3731 ciphertext = plaintext;
3733 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3736 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3738 tdata->ciphertext.data,
3739 tdata->validDataLenInBits.len,
3740 "SNOW 3G Ciphertext data not as expected");
3746 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3748 struct crypto_testsuite_params *ts_params = &testsuite_params;
3749 struct crypto_unittest_params *ut_params = &unittest_params;
3750 uint8_t *plaintext, *ciphertext;
3753 unsigned plaintext_pad_len;
3754 unsigned plaintext_len;
3756 /* Create SNOW 3G session */
3757 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3758 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3759 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3760 tdata->key.data, tdata->key.len,
3761 tdata->cipher_iv.len);
3765 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3766 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3768 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3769 "Failed to allocate input buffer in mempool");
3770 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3771 "Failed to allocate output buffer in mempool");
3773 /* Clear mbuf payload */
3774 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3775 rte_pktmbuf_tailroom(ut_params->ibuf));
3777 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3778 /* Append data which is padded to a multiple of */
3779 /* the algorithms block size */
3780 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3781 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3783 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3784 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3786 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3788 /* Create SNOW 3G operation */
3789 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3790 tdata->cipher_iv.len,
3791 tdata->validCipherLenInBits.len,
3796 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3798 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3800 ut_params->obuf = ut_params->op->sym->m_dst;
3801 if (ut_params->obuf)
3802 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3804 ciphertext = plaintext;
3806 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3809 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3811 tdata->ciphertext.data,
3812 tdata->validDataLenInBits.len,
3813 "SNOW 3G Ciphertext data not as expected");
3818 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3820 struct crypto_testsuite_params *ts_params = &testsuite_params;
3821 struct crypto_unittest_params *ut_params = &unittest_params;
3824 unsigned int plaintext_pad_len;
3825 unsigned int plaintext_len;
3826 uint8_t buffer[10000];
3827 const uint8_t *ciphertext;
3829 struct rte_cryptodev_info dev_info;
3831 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3833 uint64_t feat_flags = dev_info.feature_flags;
3835 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3836 printf("Device doesn't support out-of-place scatter-gather "
3837 "in both input and output mbufs. "
3842 /* Create SNOW 3G session */
3843 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3844 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3845 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3846 tdata->key.data, tdata->key.len,
3847 tdata->cipher_iv.len);
3851 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3852 /* Append data which is padded to a multiple of */
3853 /* the algorithms block size */
3854 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3856 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3857 plaintext_pad_len, 10, 0);
3858 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3859 plaintext_pad_len, 3, 0);
3861 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3862 "Failed to allocate input buffer in mempool");
3863 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3864 "Failed to allocate output buffer in mempool");
3866 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3868 /* Create SNOW 3G operation */
3869 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3870 tdata->cipher_iv.len,
3871 tdata->validCipherLenInBits.len,
3876 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3878 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3880 ut_params->obuf = ut_params->op->sym->m_dst;
3881 if (ut_params->obuf)
3882 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3883 plaintext_len, buffer);
3885 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3886 plaintext_len, buffer);
3888 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3891 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3893 tdata->ciphertext.data,
3894 tdata->validDataLenInBits.len,
3895 "SNOW 3G Ciphertext data not as expected");
3900 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3902 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3904 uint8_t curr_byte, prev_byte;
3905 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3906 uint8_t lower_byte_mask = (1 << offset) - 1;
3909 prev_byte = buffer[0];
3910 buffer[0] >>= offset;
3912 for (i = 1; i < length_in_bytes; i++) {
3913 curr_byte = buffer[i];
3914 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3915 (curr_byte >> offset);
3916 prev_byte = curr_byte;
3921 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3923 struct crypto_testsuite_params *ts_params = &testsuite_params;
3924 struct crypto_unittest_params *ut_params = &unittest_params;
3925 uint8_t *plaintext, *ciphertext;
3927 uint32_t plaintext_len;
3928 uint32_t plaintext_pad_len;
3929 uint8_t extra_offset = 4;
3930 uint8_t *expected_ciphertext_shifted;
3932 /* Create SNOW 3G session */
3933 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3934 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3935 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3936 tdata->key.data, tdata->key.len,
3937 tdata->cipher_iv.len);
3941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3942 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3944 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3945 "Failed to allocate input buffer in mempool");
3946 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3947 "Failed to allocate output buffer in mempool");
3949 /* Clear mbuf payload */
3950 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3951 rte_pktmbuf_tailroom(ut_params->ibuf));
3953 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3955 * Append data which is padded to a
3956 * multiple of the algorithms block size
3958 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3960 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3963 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3965 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3966 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3968 #ifdef RTE_APP_TEST_DEBUG
3969 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3971 /* Create SNOW 3G operation */
3972 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3973 tdata->cipher_iv.len,
3974 tdata->validCipherLenInBits.len,
3979 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3981 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3983 ut_params->obuf = ut_params->op->sym->m_dst;
3984 if (ut_params->obuf)
3985 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3987 ciphertext = plaintext;
3989 #ifdef RTE_APP_TEST_DEBUG
3990 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3993 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3995 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3996 "failed to reserve memory for ciphertext shifted\n");
3998 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3999 ceil_byte_length(tdata->ciphertext.len));
4000 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4003 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4005 expected_ciphertext_shifted,
4006 tdata->validDataLenInBits.len,
4008 "SNOW 3G Ciphertext data not as expected");
4012 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4014 struct crypto_testsuite_params *ts_params = &testsuite_params;
4015 struct crypto_unittest_params *ut_params = &unittest_params;
4019 uint8_t *plaintext, *ciphertext;
4020 unsigned ciphertext_pad_len;
4021 unsigned ciphertext_len;
4023 /* Create SNOW 3G session */
4024 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4025 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4026 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4027 tdata->key.data, tdata->key.len,
4028 tdata->cipher_iv.len);
4032 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4034 /* Clear mbuf payload */
4035 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4036 rte_pktmbuf_tailroom(ut_params->ibuf));
4038 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4039 /* Append data which is padded to a multiple of */
4040 /* the algorithms block size */
4041 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4042 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4043 ciphertext_pad_len);
4044 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4046 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4048 /* Create SNOW 3G operation */
4049 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4050 tdata->cipher_iv.len,
4051 tdata->validCipherLenInBits.len,
4052 tdata->cipher.offset_bits);
4056 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4058 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4059 ut_params->obuf = ut_params->op->sym->m_dst;
4060 if (ut_params->obuf)
4061 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4063 plaintext = ciphertext;
4065 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4068 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4069 tdata->plaintext.data,
4070 tdata->validDataLenInBits.len,
4071 "SNOW 3G Plaintext data not as expected");
4075 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4077 struct crypto_testsuite_params *ts_params = &testsuite_params;
4078 struct crypto_unittest_params *ut_params = &unittest_params;
4082 uint8_t *plaintext, *ciphertext;
4083 unsigned ciphertext_pad_len;
4084 unsigned ciphertext_len;
4086 /* Create SNOW 3G session */
4087 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4088 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4089 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4090 tdata->key.data, tdata->key.len,
4091 tdata->cipher_iv.len);
4095 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4096 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4098 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4099 "Failed to allocate input buffer");
4100 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4101 "Failed to allocate output buffer");
4103 /* Clear mbuf payload */
4104 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4105 rte_pktmbuf_tailroom(ut_params->ibuf));
4107 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4108 rte_pktmbuf_tailroom(ut_params->obuf));
4110 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4111 /* Append data which is padded to a multiple of */
4112 /* the algorithms block size */
4113 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4114 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4115 ciphertext_pad_len);
4116 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4117 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4119 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4121 /* Create SNOW 3G operation */
4122 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4123 tdata->cipher_iv.len,
4124 tdata->validCipherLenInBits.len,
4129 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4131 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4132 ut_params->obuf = ut_params->op->sym->m_dst;
4133 if (ut_params->obuf)
4134 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4136 plaintext = ciphertext;
4138 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4141 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4142 tdata->plaintext.data,
4143 tdata->validDataLenInBits.len,
4144 "SNOW 3G Plaintext data not as expected");
4149 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4151 struct crypto_testsuite_params *ts_params = &testsuite_params;
4152 struct crypto_unittest_params *ut_params = &unittest_params;
4156 uint8_t *plaintext, *ciphertext;
4157 unsigned int plaintext_pad_len;
4158 unsigned int plaintext_len;
4160 struct rte_cryptodev_sym_capability_idx cap_idx;
4162 /* Check if device supports ZUC EEA3 */
4163 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4164 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4166 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4170 /* Check if device supports ZUC EIA3 */
4171 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4172 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4174 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4178 /* Create ZUC session */
4179 retval = create_zuc_cipher_auth_encrypt_generate_session(
4180 ts_params->valid_devs[0],
4184 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4186 /* clear mbuf payload */
4187 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4188 rte_pktmbuf_tailroom(ut_params->ibuf));
4190 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4191 /* Append data which is padded to a multiple of */
4192 /* the algorithms block size */
4193 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4194 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4196 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4198 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4200 /* Create ZUC operation */
4201 retval = create_zuc_cipher_hash_generate_operation(tdata);
4205 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4207 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4208 ut_params->obuf = ut_params->op->sym->m_src;
4209 if (ut_params->obuf)
4210 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4212 ciphertext = plaintext;
4214 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4216 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4218 tdata->ciphertext.data,
4219 tdata->validDataLenInBits.len,
4220 "ZUC Ciphertext data not as expected");
4222 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4223 + plaintext_pad_len;
4226 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4230 "ZUC Generated auth tag not as expected");
4235 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4237 struct crypto_testsuite_params *ts_params = &testsuite_params;
4238 struct crypto_unittest_params *ut_params = &unittest_params;
4242 uint8_t *plaintext, *ciphertext;
4243 unsigned plaintext_pad_len;
4244 unsigned plaintext_len;
4246 /* Create SNOW 3G session */
4247 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4248 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4249 RTE_CRYPTO_AUTH_OP_GENERATE,
4250 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4251 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4252 tdata->key.data, tdata->key.len,
4253 tdata->auth_iv.len, tdata->digest.len,
4254 tdata->cipher_iv.len);
4257 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4259 /* clear mbuf payload */
4260 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4261 rte_pktmbuf_tailroom(ut_params->ibuf));
4263 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4264 /* Append data which is padded to a multiple of */
4265 /* the algorithms block size */
4266 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4267 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4269 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4271 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4273 /* Create SNOW 3G operation */
4274 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4275 tdata->digest.len, tdata->auth_iv.data,
4277 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4278 tdata->cipher_iv.data, tdata->cipher_iv.len,
4279 tdata->validCipherLenInBits.len,
4281 tdata->validAuthLenInBits.len,
4287 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4289 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4290 ut_params->obuf = ut_params->op->sym->m_src;
4291 if (ut_params->obuf)
4292 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4294 ciphertext = plaintext;
4296 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4298 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4300 tdata->ciphertext.data,
4301 tdata->validDataLenInBits.len,
4302 "SNOW 3G Ciphertext data not as expected");
4304 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4305 + plaintext_pad_len;
4308 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4311 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4312 "SNOW 3G Generated auth tag not as expected");
4316 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4318 struct crypto_testsuite_params *ts_params = &testsuite_params;
4319 struct crypto_unittest_params *ut_params = &unittest_params;
4323 uint8_t *plaintext, *ciphertext;
4324 unsigned plaintext_pad_len;
4325 unsigned plaintext_len;
4327 /* Create SNOW 3G session */
4328 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4329 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4330 RTE_CRYPTO_AUTH_OP_GENERATE,
4331 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4332 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4333 tdata->key.data, tdata->key.len,
4334 tdata->auth_iv.len, tdata->digest.len,
4335 tdata->cipher_iv.len);
4339 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4341 /* clear mbuf payload */
4342 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4343 rte_pktmbuf_tailroom(ut_params->ibuf));
4345 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4346 /* Append data which is padded to a multiple of */
4347 /* the algorithms block size */
4348 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4349 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4351 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4353 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4355 /* Create SNOW 3G operation */
4356 retval = create_wireless_algo_auth_cipher_operation(
4358 tdata->cipher_iv.data, tdata->cipher_iv.len,
4359 tdata->auth_iv.data, tdata->auth_iv.len,
4360 tdata->digest.offset_bytes == 0 ?
4361 plaintext_pad_len : tdata->digest.offset_bytes,
4362 tdata->validCipherLenInBits.len,
4363 tdata->cipher.offset_bits,
4364 tdata->validAuthLenInBits.len,
4365 tdata->auth.offset_bits);
4370 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4372 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4373 ut_params->obuf = ut_params->op->sym->m_src;
4374 if (ut_params->obuf)
4375 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4377 ciphertext = plaintext;
4379 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4380 + (tdata->digest.offset_bytes == 0 ?
4381 plaintext_pad_len : tdata->digest.offset_bytes);
4383 debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.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);
4979 * Function prepares snow3g_hash_test_data from snow3g_test_data.
4980 * Pattern digest from snow3g_test_data must be allocated as
4981 * 4 last bytes in plaintext.
4984 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
4985 struct snow3g_hash_test_data *output)
4987 if ((pattern != NULL) && (output != NULL)) {
4988 output->key.len = pattern->key.len;
4990 memcpy(output->key.data,
4991 pattern->key.data, pattern->key.len);
4993 output->auth_iv.len = pattern->auth_iv.len;
4995 memcpy(output->auth_iv.data,
4996 pattern->auth_iv.data, pattern->auth_iv.len);
4998 output->plaintext.len = pattern->plaintext.len;
5000 memcpy(output->plaintext.data,
5001 pattern->plaintext.data, pattern->plaintext.len >> 3);
5003 output->digest.len = pattern->digest.len;
5005 memcpy(output->digest.data,
5006 &pattern->plaintext.data[pattern->digest.offset_bytes],
5007 pattern->digest.len);
5009 output->validAuthLenInBits.len =
5010 pattern->validAuthLenInBits.len;
5015 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5018 test_snow3g_decryption_with_digest_test_case_1(void)
5020 struct snow3g_hash_test_data snow3g_hash_data;
5023 * Function prepare data for hash veryfication test case.
5024 * Digest is allocated in 4 last bytes in plaintext, pattern.
5026 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5028 return test_snow3g_decryption(&snow3g_test_case_7) &
5029 test_snow3g_authentication_verify(&snow3g_hash_data);
5033 test_snow3g_cipher_auth_test_case_1(void)
5035 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5039 test_snow3g_auth_cipher_test_case_1(void)
5041 return test_snow3g_auth_cipher(&snow3g_test_case_6);
5045 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5047 return test_snow3g_auth_cipher(&snow3g_test_case_7);
5051 test_kasumi_auth_cipher_test_case_1(void)
5053 return test_kasumi_auth_cipher(&kasumi_test_case_3);
5057 test_kasumi_cipher_auth_test_case_1(void)
5059 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5063 test_zuc_encryption_test_case_1(void)
5065 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5069 test_zuc_encryption_test_case_2(void)
5071 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5075 test_zuc_encryption_test_case_3(void)
5077 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5081 test_zuc_encryption_test_case_4(void)
5083 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5087 test_zuc_encryption_test_case_5(void)
5089 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5093 test_zuc_encryption_test_case_6_sgl(void)
5095 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5099 test_zuc_hash_generate_test_case_1(void)
5101 return test_zuc_authentication(&zuc_test_case_auth_1b);
5105 test_zuc_hash_generate_test_case_2(void)
5107 return test_zuc_authentication(&zuc_test_case_auth_90b);
5111 test_zuc_hash_generate_test_case_3(void)
5113 return test_zuc_authentication(&zuc_test_case_auth_577b);
5117 test_zuc_hash_generate_test_case_4(void)
5119 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5123 test_zuc_hash_generate_test_case_5(void)
5125 return test_zuc_authentication(&zuc_test_auth_5670b);
5129 test_zuc_hash_generate_test_case_6(void)
5131 return test_zuc_authentication(&zuc_test_case_auth_128b);
5135 test_zuc_hash_generate_test_case_7(void)
5137 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5141 test_zuc_hash_generate_test_case_8(void)
5143 return test_zuc_authentication(&zuc_test_case_auth_584b);
5147 test_zuc_cipher_auth_test_case_1(void)
5149 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5153 test_zuc_cipher_auth_test_case_2(void)
5155 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5159 test_3DES_chain_qat_all(void)
5161 struct crypto_testsuite_params *ts_params = &testsuite_params;
5164 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5165 ts_params->op_mpool,
5166 ts_params->session_mpool, ts_params->session_priv_mpool,
5167 ts_params->valid_devs[0],
5168 rte_cryptodev_driver_id_get(
5169 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5170 BLKCIPHER_3DES_CHAIN_TYPE);
5172 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5174 return TEST_SUCCESS;
5178 test_DES_cipheronly_qat_all(void)
5180 struct crypto_testsuite_params *ts_params = &testsuite_params;
5183 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5184 ts_params->op_mpool,
5185 ts_params->session_mpool, ts_params->session_priv_mpool,
5186 ts_params->valid_devs[0],
5187 rte_cryptodev_driver_id_get(
5188 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5189 BLKCIPHER_DES_CIPHERONLY_TYPE);
5191 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5193 return TEST_SUCCESS;
5197 test_DES_cipheronly_openssl_all(void)
5199 struct crypto_testsuite_params *ts_params = &testsuite_params;
5202 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5203 ts_params->op_mpool,
5204 ts_params->session_mpool, ts_params->session_priv_mpool,
5205 ts_params->valid_devs[0],
5206 rte_cryptodev_driver_id_get(
5207 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5208 BLKCIPHER_DES_CIPHERONLY_TYPE);
5210 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5212 return TEST_SUCCESS;
5216 test_DES_docsis_openssl_all(void)
5218 struct crypto_testsuite_params *ts_params = &testsuite_params;
5221 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5222 ts_params->op_mpool,
5223 ts_params->session_mpool, ts_params->session_priv_mpool,
5224 ts_params->valid_devs[0],
5225 rte_cryptodev_driver_id_get(
5226 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5227 BLKCIPHER_DES_DOCSIS_TYPE);
5229 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5231 return TEST_SUCCESS;
5235 test_DES_cipheronly_mb_all(void)
5237 struct crypto_testsuite_params *ts_params = &testsuite_params;
5240 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5241 ts_params->op_mpool,
5242 ts_params->session_mpool, ts_params->session_priv_mpool,
5243 ts_params->valid_devs[0],
5244 rte_cryptodev_driver_id_get(
5245 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5246 BLKCIPHER_DES_CIPHERONLY_TYPE);
5248 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5250 return TEST_SUCCESS;
5253 test_3DES_cipheronly_mb_all(void)
5255 struct crypto_testsuite_params *ts_params = &testsuite_params;
5258 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5259 ts_params->op_mpool,
5260 ts_params->session_mpool, ts_params->session_priv_mpool,
5261 ts_params->valid_devs[0],
5262 rte_cryptodev_driver_id_get(
5263 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5264 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5266 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5268 return TEST_SUCCESS;
5272 test_DES_docsis_mb_all(void)
5274 struct crypto_testsuite_params *ts_params = &testsuite_params;
5277 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5278 ts_params->op_mpool,
5279 ts_params->session_mpool, ts_params->session_priv_mpool,
5280 ts_params->valid_devs[0],
5281 rte_cryptodev_driver_id_get(
5282 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5283 BLKCIPHER_DES_DOCSIS_TYPE);
5285 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5287 return TEST_SUCCESS;
5291 test_3DES_chain_caam_jr_all(void)
5293 struct crypto_testsuite_params *ts_params = &testsuite_params;
5296 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5297 ts_params->op_mpool,
5298 ts_params->session_mpool, ts_params->session_priv_mpool,
5299 ts_params->valid_devs[0],
5300 rte_cryptodev_driver_id_get(
5301 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5302 BLKCIPHER_3DES_CHAIN_TYPE);
5304 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5306 return TEST_SUCCESS;
5310 test_3DES_cipheronly_caam_jr_all(void)
5312 struct crypto_testsuite_params *ts_params = &testsuite_params;
5315 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5316 ts_params->op_mpool,
5317 ts_params->session_mpool, ts_params->session_priv_mpool,
5318 ts_params->valid_devs[0],
5319 rte_cryptodev_driver_id_get(
5320 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5321 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5323 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5325 return TEST_SUCCESS;
5329 test_3DES_chain_dpaa_sec_all(void)
5331 struct crypto_testsuite_params *ts_params = &testsuite_params;
5334 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5335 ts_params->op_mpool,
5336 ts_params->session_mpool, ts_params->session_priv_mpool,
5337 ts_params->valid_devs[0],
5338 rte_cryptodev_driver_id_get(
5339 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5340 BLKCIPHER_3DES_CHAIN_TYPE);
5342 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5344 return TEST_SUCCESS;
5348 test_3DES_cipheronly_dpaa_sec_all(void)
5350 struct crypto_testsuite_params *ts_params = &testsuite_params;
5353 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5354 ts_params->op_mpool,
5355 ts_params->session_mpool, ts_params->session_priv_mpool,
5356 ts_params->valid_devs[0],
5357 rte_cryptodev_driver_id_get(
5358 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5359 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5361 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5363 return TEST_SUCCESS;
5367 test_3DES_chain_dpaa2_sec_all(void)
5369 struct crypto_testsuite_params *ts_params = &testsuite_params;
5372 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5373 ts_params->op_mpool,
5374 ts_params->session_mpool, ts_params->session_priv_mpool,
5375 ts_params->valid_devs[0],
5376 rte_cryptodev_driver_id_get(
5377 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5378 BLKCIPHER_3DES_CHAIN_TYPE);
5380 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5382 return TEST_SUCCESS;
5386 test_3DES_cipheronly_dpaa2_sec_all(void)
5388 struct crypto_testsuite_params *ts_params = &testsuite_params;
5391 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5392 ts_params->op_mpool,
5393 ts_params->session_mpool, ts_params->session_priv_mpool,
5394 ts_params->valid_devs[0],
5395 rte_cryptodev_driver_id_get(
5396 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5397 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5399 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5401 return TEST_SUCCESS;
5405 test_3DES_chain_ccp_all(void)
5407 struct crypto_testsuite_params *ts_params = &testsuite_params;
5410 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5411 ts_params->op_mpool,
5412 ts_params->session_mpool, ts_params->session_priv_mpool,
5413 ts_params->valid_devs[0],
5414 rte_cryptodev_driver_id_get(
5415 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5416 BLKCIPHER_3DES_CHAIN_TYPE);
5418 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5420 return TEST_SUCCESS;
5424 test_3DES_cipheronly_ccp_all(void)
5426 struct crypto_testsuite_params *ts_params = &testsuite_params;
5429 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5430 ts_params->op_mpool,
5431 ts_params->session_mpool, ts_params->session_priv_mpool,
5432 ts_params->valid_devs[0],
5433 rte_cryptodev_driver_id_get(
5434 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5435 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5437 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5439 return TEST_SUCCESS;
5443 test_3DES_cipheronly_qat_all(void)
5445 struct crypto_testsuite_params *ts_params = &testsuite_params;
5448 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5449 ts_params->op_mpool,
5450 ts_params->session_mpool, ts_params->session_priv_mpool,
5451 ts_params->valid_devs[0],
5452 rte_cryptodev_driver_id_get(
5453 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5454 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5456 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5458 return TEST_SUCCESS;
5462 test_3DES_chain_openssl_all(void)
5464 struct crypto_testsuite_params *ts_params = &testsuite_params;
5467 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5468 ts_params->op_mpool,
5469 ts_params->session_mpool, ts_params->session_priv_mpool,
5470 ts_params->valid_devs[0],
5471 rte_cryptodev_driver_id_get(
5472 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5473 BLKCIPHER_3DES_CHAIN_TYPE);
5475 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5477 return TEST_SUCCESS;
5481 test_3DES_cipheronly_openssl_all(void)
5483 struct crypto_testsuite_params *ts_params = &testsuite_params;
5486 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5487 ts_params->op_mpool,
5488 ts_params->session_mpool, ts_params->session_priv_mpool,
5489 ts_params->valid_devs[0],
5490 rte_cryptodev_driver_id_get(
5491 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5492 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5494 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5496 return TEST_SUCCESS;
5499 /* ***** AEAD algorithm Tests ***** */
5502 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5503 enum rte_crypto_aead_operation op,
5504 const uint8_t *key, const uint8_t key_len,
5505 const uint16_t aad_len, const uint8_t auth_len,
5508 uint8_t aead_key[key_len];
5510 struct crypto_testsuite_params *ts_params = &testsuite_params;
5511 struct crypto_unittest_params *ut_params = &unittest_params;
5513 memcpy(aead_key, key, key_len);
5515 /* Setup AEAD Parameters */
5516 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5517 ut_params->aead_xform.next = NULL;
5518 ut_params->aead_xform.aead.algo = algo;
5519 ut_params->aead_xform.aead.op = op;
5520 ut_params->aead_xform.aead.key.data = aead_key;
5521 ut_params->aead_xform.aead.key.length = key_len;
5522 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5523 ut_params->aead_xform.aead.iv.length = iv_len;
5524 ut_params->aead_xform.aead.digest_length = auth_len;
5525 ut_params->aead_xform.aead.aad_length = aad_len;
5527 debug_hexdump(stdout, "key:", key, key_len);
5529 /* Create Crypto session*/
5530 ut_params->sess = rte_cryptodev_sym_session_create(
5531 ts_params->session_mpool);
5533 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5534 &ut_params->aead_xform,
5535 ts_params->session_priv_mpool);
5537 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5543 create_aead_xform(struct rte_crypto_op *op,
5544 enum rte_crypto_aead_algorithm algo,
5545 enum rte_crypto_aead_operation aead_op,
5546 uint8_t *key, const uint8_t key_len,
5547 const uint8_t aad_len, const uint8_t auth_len,
5550 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5551 "failed to allocate space for crypto transform");
5553 struct rte_crypto_sym_op *sym_op = op->sym;
5555 /* Setup AEAD Parameters */
5556 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5557 sym_op->xform->next = NULL;
5558 sym_op->xform->aead.algo = algo;
5559 sym_op->xform->aead.op = aead_op;
5560 sym_op->xform->aead.key.data = key;
5561 sym_op->xform->aead.key.length = key_len;
5562 sym_op->xform->aead.iv.offset = IV_OFFSET;
5563 sym_op->xform->aead.iv.length = iv_len;
5564 sym_op->xform->aead.digest_length = auth_len;
5565 sym_op->xform->aead.aad_length = aad_len;
5567 debug_hexdump(stdout, "key:", key, key_len);
5573 create_aead_operation(enum rte_crypto_aead_operation op,
5574 const struct aead_test_data *tdata)
5576 struct crypto_testsuite_params *ts_params = &testsuite_params;
5577 struct crypto_unittest_params *ut_params = &unittest_params;
5579 uint8_t *plaintext, *ciphertext;
5580 unsigned int aad_pad_len, plaintext_pad_len;
5582 /* Generate Crypto op data structure */
5583 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5584 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5585 TEST_ASSERT_NOT_NULL(ut_params->op,
5586 "Failed to allocate symmetric crypto operation struct");
5588 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5590 /* Append aad data */
5591 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5592 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5593 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5595 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5596 "no room to append aad");
5598 sym_op->aead.aad.phys_addr =
5599 rte_pktmbuf_iova(ut_params->ibuf);
5600 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5601 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5602 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5605 /* Append IV at the end of the crypto operation*/
5606 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5607 uint8_t *, IV_OFFSET);
5609 /* Copy IV 1 byte after the IV pointer, according to the API */
5610 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5611 debug_hexdump(stdout, "iv:", iv_ptr,
5614 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5615 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5617 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5618 "no room to append aad");
5620 sym_op->aead.aad.phys_addr =
5621 rte_pktmbuf_iova(ut_params->ibuf);
5622 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5623 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5626 /* Append IV at the end of the crypto operation*/
5627 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5628 uint8_t *, IV_OFFSET);
5630 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5631 debug_hexdump(stdout, "iv:", iv_ptr,
5635 /* Append plaintext/ciphertext */
5636 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5637 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5638 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5640 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5642 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5643 debug_hexdump(stdout, "plaintext:", plaintext,
5644 tdata->plaintext.len);
5646 if (ut_params->obuf) {
5647 ciphertext = (uint8_t *)rte_pktmbuf_append(
5649 plaintext_pad_len + aad_pad_len);
5650 TEST_ASSERT_NOT_NULL(ciphertext,
5651 "no room to append ciphertext");
5653 memset(ciphertext + aad_pad_len, 0,
5654 tdata->ciphertext.len);
5657 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5658 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5660 TEST_ASSERT_NOT_NULL(ciphertext,
5661 "no room to append ciphertext");
5663 memcpy(ciphertext, tdata->ciphertext.data,
5664 tdata->ciphertext.len);
5665 debug_hexdump(stdout, "ciphertext:", ciphertext,
5666 tdata->ciphertext.len);
5668 if (ut_params->obuf) {
5669 plaintext = (uint8_t *)rte_pktmbuf_append(
5671 plaintext_pad_len + aad_pad_len);
5672 TEST_ASSERT_NOT_NULL(plaintext,
5673 "no room to append plaintext");
5675 memset(plaintext + aad_pad_len, 0,
5676 tdata->plaintext.len);
5680 /* Append digest data */
5681 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5682 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5683 ut_params->obuf ? ut_params->obuf :
5685 tdata->auth_tag.len);
5686 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5687 "no room to append digest");
5688 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5689 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5690 ut_params->obuf ? ut_params->obuf :
5695 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5696 ut_params->ibuf, tdata->auth_tag.len);
5697 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5698 "no room to append digest");
5699 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5701 plaintext_pad_len + aad_pad_len);
5703 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5704 tdata->auth_tag.len);
5705 debug_hexdump(stdout, "digest:",
5706 sym_op->aead.digest.data,
5707 tdata->auth_tag.len);
5710 sym_op->aead.data.length = tdata->plaintext.len;
5711 sym_op->aead.data.offset = aad_pad_len;
5717 test_authenticated_encryption(const struct aead_test_data *tdata)
5719 struct crypto_testsuite_params *ts_params = &testsuite_params;
5720 struct crypto_unittest_params *ut_params = &unittest_params;
5723 uint8_t *ciphertext, *auth_tag;
5724 uint16_t plaintext_pad_len;
5727 /* Create AEAD session */
5728 retval = create_aead_session(ts_params->valid_devs[0],
5730 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5731 tdata->key.data, tdata->key.len,
5732 tdata->aad.len, tdata->auth_tag.len,
5737 if (tdata->aad.len > MBUF_SIZE) {
5738 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5739 /* Populate full size of add data */
5740 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5741 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5743 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5745 /* clear mbuf payload */
5746 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5747 rte_pktmbuf_tailroom(ut_params->ibuf));
5749 /* Create AEAD operation */
5750 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5754 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5756 ut_params->op->sym->m_src = ut_params->ibuf;
5758 /* Process crypto operation */
5759 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5760 ut_params->op), "failed to process sym crypto op");
5762 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5763 "crypto op processing failed");
5765 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5767 if (ut_params->op->sym->m_dst) {
5768 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5770 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5771 uint8_t *, plaintext_pad_len);
5773 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5775 ut_params->op->sym->cipher.data.offset);
5776 auth_tag = ciphertext + plaintext_pad_len;
5779 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5780 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5783 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5785 tdata->ciphertext.data,
5786 tdata->ciphertext.len,
5787 "Ciphertext data not as expected");
5789 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5791 tdata->auth_tag.data,
5792 tdata->auth_tag.len,
5793 "Generated auth tag not as expected");
5800 test_AES_GCM_authenticated_encryption_test_case_1(void)
5802 return test_authenticated_encryption(&gcm_test_case_1);
5806 test_AES_GCM_authenticated_encryption_test_case_2(void)
5808 return test_authenticated_encryption(&gcm_test_case_2);
5812 test_AES_GCM_authenticated_encryption_test_case_3(void)
5814 return test_authenticated_encryption(&gcm_test_case_3);
5818 test_AES_GCM_authenticated_encryption_test_case_4(void)
5820 return test_authenticated_encryption(&gcm_test_case_4);
5824 test_AES_GCM_authenticated_encryption_test_case_5(void)
5826 return test_authenticated_encryption(&gcm_test_case_5);
5830 test_AES_GCM_authenticated_encryption_test_case_6(void)
5832 return test_authenticated_encryption(&gcm_test_case_6);
5836 test_AES_GCM_authenticated_encryption_test_case_7(void)
5838 return test_authenticated_encryption(&gcm_test_case_7);
5842 test_AES_GCM_auth_encryption_test_case_192_1(void)
5844 return test_authenticated_encryption(&gcm_test_case_192_1);
5848 test_AES_GCM_auth_encryption_test_case_192_2(void)
5850 return test_authenticated_encryption(&gcm_test_case_192_2);
5854 test_AES_GCM_auth_encryption_test_case_192_3(void)
5856 return test_authenticated_encryption(&gcm_test_case_192_3);
5860 test_AES_GCM_auth_encryption_test_case_192_4(void)
5862 return test_authenticated_encryption(&gcm_test_case_192_4);
5866 test_AES_GCM_auth_encryption_test_case_192_5(void)
5868 return test_authenticated_encryption(&gcm_test_case_192_5);
5872 test_AES_GCM_auth_encryption_test_case_192_6(void)
5874 return test_authenticated_encryption(&gcm_test_case_192_6);
5878 test_AES_GCM_auth_encryption_test_case_192_7(void)
5880 return test_authenticated_encryption(&gcm_test_case_192_7);
5884 test_AES_GCM_auth_encryption_test_case_256_1(void)
5886 return test_authenticated_encryption(&gcm_test_case_256_1);
5890 test_AES_GCM_auth_encryption_test_case_256_2(void)
5892 return test_authenticated_encryption(&gcm_test_case_256_2);
5896 test_AES_GCM_auth_encryption_test_case_256_3(void)
5898 return test_authenticated_encryption(&gcm_test_case_256_3);
5902 test_AES_GCM_auth_encryption_test_case_256_4(void)
5904 return test_authenticated_encryption(&gcm_test_case_256_4);
5908 test_AES_GCM_auth_encryption_test_case_256_5(void)
5910 return test_authenticated_encryption(&gcm_test_case_256_5);
5914 test_AES_GCM_auth_encryption_test_case_256_6(void)
5916 return test_authenticated_encryption(&gcm_test_case_256_6);
5920 test_AES_GCM_auth_encryption_test_case_256_7(void)
5922 return test_authenticated_encryption(&gcm_test_case_256_7);
5926 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5928 return test_authenticated_encryption(&gcm_test_case_aad_1);
5932 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5934 return test_authenticated_encryption(&gcm_test_case_aad_2);
5938 test_authenticated_decryption(const struct aead_test_data *tdata)
5940 struct crypto_testsuite_params *ts_params = &testsuite_params;
5941 struct crypto_unittest_params *ut_params = &unittest_params;
5947 /* Create AEAD session */
5948 retval = create_aead_session(ts_params->valid_devs[0],
5950 RTE_CRYPTO_AEAD_OP_DECRYPT,
5951 tdata->key.data, tdata->key.len,
5952 tdata->aad.len, tdata->auth_tag.len,
5957 /* alloc mbuf and set payload */
5958 if (tdata->aad.len > MBUF_SIZE) {
5959 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5960 /* Populate full size of add data */
5961 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5962 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5964 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5966 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5967 rte_pktmbuf_tailroom(ut_params->ibuf));
5969 /* Create AEAD operation */
5970 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5974 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5976 ut_params->op->sym->m_src = ut_params->ibuf;
5978 /* Process crypto operation */
5979 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5980 ut_params->op), "failed to process sym crypto op");
5982 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5983 "crypto op processing failed");
5985 if (ut_params->op->sym->m_dst)
5986 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5989 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5991 ut_params->op->sym->cipher.data.offset);
5993 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5996 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5998 tdata->plaintext.data,
5999 tdata->plaintext.len,
6000 "Plaintext data not as expected");
6002 TEST_ASSERT_EQUAL(ut_params->op->status,
6003 RTE_CRYPTO_OP_STATUS_SUCCESS,
6004 "Authentication failed");
6009 test_AES_GCM_authenticated_decryption_test_case_1(void)
6011 return test_authenticated_decryption(&gcm_test_case_1);
6015 test_AES_GCM_authenticated_decryption_test_case_2(void)
6017 return test_authenticated_decryption(&gcm_test_case_2);
6021 test_AES_GCM_authenticated_decryption_test_case_3(void)
6023 return test_authenticated_decryption(&gcm_test_case_3);
6027 test_AES_GCM_authenticated_decryption_test_case_4(void)
6029 return test_authenticated_decryption(&gcm_test_case_4);
6033 test_AES_GCM_authenticated_decryption_test_case_5(void)
6035 return test_authenticated_decryption(&gcm_test_case_5);
6039 test_AES_GCM_authenticated_decryption_test_case_6(void)
6041 return test_authenticated_decryption(&gcm_test_case_6);
6045 test_AES_GCM_authenticated_decryption_test_case_7(void)
6047 return test_authenticated_decryption(&gcm_test_case_7);
6051 test_AES_GCM_auth_decryption_test_case_192_1(void)
6053 return test_authenticated_decryption(&gcm_test_case_192_1);
6057 test_AES_GCM_auth_decryption_test_case_192_2(void)
6059 return test_authenticated_decryption(&gcm_test_case_192_2);
6063 test_AES_GCM_auth_decryption_test_case_192_3(void)
6065 return test_authenticated_decryption(&gcm_test_case_192_3);
6069 test_AES_GCM_auth_decryption_test_case_192_4(void)
6071 return test_authenticated_decryption(&gcm_test_case_192_4);
6075 test_AES_GCM_auth_decryption_test_case_192_5(void)
6077 return test_authenticated_decryption(&gcm_test_case_192_5);
6081 test_AES_GCM_auth_decryption_test_case_192_6(void)
6083 return test_authenticated_decryption(&gcm_test_case_192_6);
6087 test_AES_GCM_auth_decryption_test_case_192_7(void)
6089 return test_authenticated_decryption(&gcm_test_case_192_7);
6093 test_AES_GCM_auth_decryption_test_case_256_1(void)
6095 return test_authenticated_decryption(&gcm_test_case_256_1);
6099 test_AES_GCM_auth_decryption_test_case_256_2(void)
6101 return test_authenticated_decryption(&gcm_test_case_256_2);
6105 test_AES_GCM_auth_decryption_test_case_256_3(void)
6107 return test_authenticated_decryption(&gcm_test_case_256_3);
6111 test_AES_GCM_auth_decryption_test_case_256_4(void)
6113 return test_authenticated_decryption(&gcm_test_case_256_4);
6117 test_AES_GCM_auth_decryption_test_case_256_5(void)
6119 return test_authenticated_decryption(&gcm_test_case_256_5);
6123 test_AES_GCM_auth_decryption_test_case_256_6(void)
6125 return test_authenticated_decryption(&gcm_test_case_256_6);
6129 test_AES_GCM_auth_decryption_test_case_256_7(void)
6131 return test_authenticated_decryption(&gcm_test_case_256_7);
6135 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6137 return test_authenticated_decryption(&gcm_test_case_aad_1);
6141 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6143 return test_authenticated_decryption(&gcm_test_case_aad_2);
6147 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6149 struct crypto_testsuite_params *ts_params = &testsuite_params;
6150 struct crypto_unittest_params *ut_params = &unittest_params;
6153 uint8_t *ciphertext, *auth_tag;
6154 uint16_t plaintext_pad_len;
6156 /* Create AEAD session */
6157 retval = create_aead_session(ts_params->valid_devs[0],
6159 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6160 tdata->key.data, tdata->key.len,
6161 tdata->aad.len, tdata->auth_tag.len,
6166 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6167 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6169 /* clear mbuf payload */
6170 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6171 rte_pktmbuf_tailroom(ut_params->ibuf));
6172 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6173 rte_pktmbuf_tailroom(ut_params->obuf));
6175 /* Create AEAD operation */
6176 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6180 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6182 ut_params->op->sym->m_src = ut_params->ibuf;
6183 ut_params->op->sym->m_dst = ut_params->obuf;
6185 /* Process crypto operation */
6186 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6187 ut_params->op), "failed to process sym crypto op");
6189 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6190 "crypto op processing failed");
6192 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6194 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6195 ut_params->op->sym->cipher.data.offset);
6196 auth_tag = ciphertext + plaintext_pad_len;
6198 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6199 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6202 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6204 tdata->ciphertext.data,
6205 tdata->ciphertext.len,
6206 "Ciphertext data not as expected");
6208 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6210 tdata->auth_tag.data,
6211 tdata->auth_tag.len,
6212 "Generated auth tag not as expected");
6219 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6221 return test_authenticated_encryption_oop(&gcm_test_case_5);
6225 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6227 struct crypto_testsuite_params *ts_params = &testsuite_params;
6228 struct crypto_unittest_params *ut_params = &unittest_params;
6233 /* Create AEAD session */
6234 retval = create_aead_session(ts_params->valid_devs[0],
6236 RTE_CRYPTO_AEAD_OP_DECRYPT,
6237 tdata->key.data, tdata->key.len,
6238 tdata->aad.len, tdata->auth_tag.len,
6243 /* alloc mbuf and set payload */
6244 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6245 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6248 rte_pktmbuf_tailroom(ut_params->ibuf));
6249 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6250 rte_pktmbuf_tailroom(ut_params->obuf));
6252 /* Create AEAD operation */
6253 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6257 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6259 ut_params->op->sym->m_src = ut_params->ibuf;
6260 ut_params->op->sym->m_dst = ut_params->obuf;
6262 /* Process crypto operation */
6263 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6264 ut_params->op), "failed to process sym crypto op");
6266 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6267 "crypto op processing failed");
6269 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6270 ut_params->op->sym->cipher.data.offset);
6272 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6275 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6277 tdata->plaintext.data,
6278 tdata->plaintext.len,
6279 "Plaintext data not as expected");
6281 TEST_ASSERT_EQUAL(ut_params->op->status,
6282 RTE_CRYPTO_OP_STATUS_SUCCESS,
6283 "Authentication failed");
6288 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6290 return test_authenticated_decryption_oop(&gcm_test_case_5);
6294 test_authenticated_encryption_sessionless(
6295 const struct aead_test_data *tdata)
6297 struct crypto_testsuite_params *ts_params = &testsuite_params;
6298 struct crypto_unittest_params *ut_params = &unittest_params;
6301 uint8_t *ciphertext, *auth_tag;
6302 uint16_t plaintext_pad_len;
6303 uint8_t key[tdata->key.len + 1];
6305 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6307 /* clear mbuf payload */
6308 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6309 rte_pktmbuf_tailroom(ut_params->ibuf));
6311 /* Create AEAD operation */
6312 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6316 /* Create GCM xform */
6317 memcpy(key, tdata->key.data, tdata->key.len);
6318 retval = create_aead_xform(ut_params->op,
6320 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6321 key, tdata->key.len,
6322 tdata->aad.len, tdata->auth_tag.len,
6327 ut_params->op->sym->m_src = ut_params->ibuf;
6329 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6330 RTE_CRYPTO_OP_SESSIONLESS,
6331 "crypto op session type not sessionless");
6333 /* Process crypto operation */
6334 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6335 ut_params->op), "failed to process sym crypto op");
6337 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6339 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6340 "crypto op status not success");
6342 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6344 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6345 ut_params->op->sym->cipher.data.offset);
6346 auth_tag = ciphertext + plaintext_pad_len;
6348 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6349 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6352 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6354 tdata->ciphertext.data,
6355 tdata->ciphertext.len,
6356 "Ciphertext data not as expected");
6358 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6360 tdata->auth_tag.data,
6361 tdata->auth_tag.len,
6362 "Generated auth tag not as expected");
6369 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6371 return test_authenticated_encryption_sessionless(
6376 test_authenticated_decryption_sessionless(
6377 const struct aead_test_data *tdata)
6379 struct crypto_testsuite_params *ts_params = &testsuite_params;
6380 struct crypto_unittest_params *ut_params = &unittest_params;
6384 uint8_t key[tdata->key.len + 1];
6386 /* alloc mbuf and set payload */
6387 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6389 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6390 rte_pktmbuf_tailroom(ut_params->ibuf));
6392 /* Create AEAD operation */
6393 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6397 /* Create AEAD xform */
6398 memcpy(key, tdata->key.data, tdata->key.len);
6399 retval = create_aead_xform(ut_params->op,
6401 RTE_CRYPTO_AEAD_OP_DECRYPT,
6402 key, tdata->key.len,
6403 tdata->aad.len, tdata->auth_tag.len,
6408 ut_params->op->sym->m_src = ut_params->ibuf;
6410 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6411 RTE_CRYPTO_OP_SESSIONLESS,
6412 "crypto op session type not sessionless");
6414 /* Process crypto operation */
6415 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6416 ut_params->op), "failed to process sym crypto op");
6418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6420 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6421 "crypto op status not success");
6423 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6424 ut_params->op->sym->cipher.data.offset);
6426 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6429 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6431 tdata->plaintext.data,
6432 tdata->plaintext.len,
6433 "Plaintext data not as expected");
6435 TEST_ASSERT_EQUAL(ut_params->op->status,
6436 RTE_CRYPTO_OP_STATUS_SUCCESS,
6437 "Authentication failed");
6442 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6444 return test_authenticated_decryption_sessionless(
6449 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6451 return test_authenticated_encryption(&ccm_test_case_128_1);
6455 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6457 return test_authenticated_encryption(&ccm_test_case_128_2);
6461 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6463 return test_authenticated_encryption(&ccm_test_case_128_3);
6467 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6469 return test_authenticated_decryption(&ccm_test_case_128_1);
6473 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6475 return test_authenticated_decryption(&ccm_test_case_128_2);
6479 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6481 return test_authenticated_decryption(&ccm_test_case_128_3);
6485 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6487 return test_authenticated_encryption(&ccm_test_case_192_1);
6491 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6493 return test_authenticated_encryption(&ccm_test_case_192_2);
6497 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6499 return test_authenticated_encryption(&ccm_test_case_192_3);
6503 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6505 return test_authenticated_decryption(&ccm_test_case_192_1);
6509 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6511 return test_authenticated_decryption(&ccm_test_case_192_2);
6515 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6517 return test_authenticated_decryption(&ccm_test_case_192_3);
6521 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6523 return test_authenticated_encryption(&ccm_test_case_256_1);
6527 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6529 return test_authenticated_encryption(&ccm_test_case_256_2);
6533 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6535 return test_authenticated_encryption(&ccm_test_case_256_3);
6539 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6541 return test_authenticated_decryption(&ccm_test_case_256_1);
6545 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6547 return test_authenticated_decryption(&ccm_test_case_256_2);
6551 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6553 return test_authenticated_decryption(&ccm_test_case_256_3);
6559 struct crypto_testsuite_params *ts_params = &testsuite_params;
6560 struct rte_cryptodev_stats stats;
6561 struct rte_cryptodev *dev;
6562 cryptodev_stats_get_t temp_pfn;
6564 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6565 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6566 &stats) == -ENODEV),
6567 "rte_cryptodev_stats_get invalid dev failed");
6568 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6569 "rte_cryptodev_stats_get invalid Param failed");
6570 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6571 temp_pfn = dev->dev_ops->stats_get;
6572 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6573 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6575 "rte_cryptodev_stats_get invalid Param failed");
6576 dev->dev_ops->stats_get = temp_pfn;
6578 /* Test expected values */
6580 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6582 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6584 "rte_cryptodev_stats_get failed");
6585 TEST_ASSERT((stats.enqueued_count == 1),
6586 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6587 TEST_ASSERT((stats.dequeued_count == 1),
6588 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6589 TEST_ASSERT((stats.enqueue_err_count == 0),
6590 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6591 TEST_ASSERT((stats.dequeue_err_count == 0),
6592 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6594 /* invalid device but should ignore and not reset device stats*/
6595 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6596 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6598 "rte_cryptodev_stats_get failed");
6599 TEST_ASSERT((stats.enqueued_count == 1),
6600 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6602 /* check that a valid reset clears stats */
6603 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6604 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6606 "rte_cryptodev_stats_get failed");
6607 TEST_ASSERT((stats.enqueued_count == 0),
6608 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6609 TEST_ASSERT((stats.dequeued_count == 0),
6610 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6612 return TEST_SUCCESS;
6615 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6616 struct crypto_unittest_params *ut_params,
6617 enum rte_crypto_auth_operation op,
6618 const struct HMAC_MD5_vector *test_case)
6622 memcpy(key, test_case->key.data, test_case->key.len);
6624 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6625 ut_params->auth_xform.next = NULL;
6626 ut_params->auth_xform.auth.op = op;
6628 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6630 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6631 ut_params->auth_xform.auth.key.length = test_case->key.len;
6632 ut_params->auth_xform.auth.key.data = key;
6634 ut_params->sess = rte_cryptodev_sym_session_create(
6635 ts_params->session_mpool);
6637 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6638 ut_params->sess, &ut_params->auth_xform,
6639 ts_params->session_priv_mpool);
6641 if (ut_params->sess == NULL)
6644 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6646 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6647 rte_pktmbuf_tailroom(ut_params->ibuf));
6652 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6653 const struct HMAC_MD5_vector *test_case,
6654 uint8_t **plaintext)
6656 uint16_t plaintext_pad_len;
6658 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6660 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6663 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6665 memcpy(*plaintext, test_case->plaintext.data,
6666 test_case->plaintext.len);
6668 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6669 ut_params->ibuf, MD5_DIGEST_LEN);
6670 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6671 "no room to append digest");
6672 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6673 ut_params->ibuf, plaintext_pad_len);
6675 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6676 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6677 test_case->auth_tag.len);
6680 sym_op->auth.data.offset = 0;
6681 sym_op->auth.data.length = test_case->plaintext.len;
6683 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6684 ut_params->op->sym->m_src = ut_params->ibuf;
6690 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6692 uint16_t plaintext_pad_len;
6693 uint8_t *plaintext, *auth_tag;
6695 struct crypto_testsuite_params *ts_params = &testsuite_params;
6696 struct crypto_unittest_params *ut_params = &unittest_params;
6698 if (MD5_HMAC_create_session(ts_params, ut_params,
6699 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6702 /* Generate Crypto op data structure */
6703 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6704 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6705 TEST_ASSERT_NOT_NULL(ut_params->op,
6706 "Failed to allocate symmetric crypto operation struct");
6708 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6711 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6714 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6715 ut_params->op), "failed to process sym crypto op");
6717 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6718 "crypto op processing failed");
6720 if (ut_params->op->sym->m_dst) {
6721 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6722 uint8_t *, plaintext_pad_len);
6724 auth_tag = plaintext + plaintext_pad_len;
6727 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6729 test_case->auth_tag.data,
6730 test_case->auth_tag.len,
6731 "HMAC_MD5 generated tag not as expected");
6733 return TEST_SUCCESS;
6737 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6741 struct crypto_testsuite_params *ts_params = &testsuite_params;
6742 struct crypto_unittest_params *ut_params = &unittest_params;
6744 if (MD5_HMAC_create_session(ts_params, ut_params,
6745 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6749 /* Generate Crypto op data structure */
6750 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6751 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6752 TEST_ASSERT_NOT_NULL(ut_params->op,
6753 "Failed to allocate symmetric crypto operation struct");
6755 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6758 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6759 ut_params->op), "failed to process sym crypto op");
6761 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6762 "HMAC_MD5 crypto op processing failed");
6764 return TEST_SUCCESS;
6768 test_MD5_HMAC_generate_case_1(void)
6770 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6774 test_MD5_HMAC_verify_case_1(void)
6776 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6780 test_MD5_HMAC_generate_case_2(void)
6782 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6786 test_MD5_HMAC_verify_case_2(void)
6788 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6792 test_multi_session(void)
6794 struct crypto_testsuite_params *ts_params = &testsuite_params;
6795 struct crypto_unittest_params *ut_params = &unittest_params;
6797 struct rte_cryptodev_info dev_info;
6798 struct rte_cryptodev_sym_session **sessions;
6802 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6803 aes_cbc_key, hmac_sha512_key);
6806 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6808 sessions = rte_malloc(NULL,
6809 (sizeof(struct rte_cryptodev_sym_session *) *
6810 MAX_NB_SESSIONS) + 1, 0);
6812 /* Create multiple crypto sessions*/
6813 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6815 sessions[i] = rte_cryptodev_sym_session_create(
6816 ts_params->session_mpool);
6818 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6819 sessions[i], &ut_params->auth_xform,
6820 ts_params->session_priv_mpool);
6821 TEST_ASSERT_NOT_NULL(sessions[i],
6822 "Session creation failed at session number %u",
6825 /* Attempt to send a request on each session */
6826 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6830 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6831 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6833 "Failed to perform decrypt on request number %u.", i);
6834 /* free crypto operation structure */
6836 rte_crypto_op_free(ut_params->op);
6839 * free mbuf - both obuf and ibuf are usually the same,
6840 * so check if they point at the same address is necessary,
6841 * to avoid freeing the mbuf twice.
6843 if (ut_params->obuf) {
6844 rte_pktmbuf_free(ut_params->obuf);
6845 if (ut_params->ibuf == ut_params->obuf)
6846 ut_params->ibuf = 0;
6847 ut_params->obuf = 0;
6849 if (ut_params->ibuf) {
6850 rte_pktmbuf_free(ut_params->ibuf);
6851 ut_params->ibuf = 0;
6855 /* Next session create should fail */
6856 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6857 sessions[i], &ut_params->auth_xform,
6858 ts_params->session_priv_mpool);
6859 TEST_ASSERT_NULL(sessions[i],
6860 "Session creation succeeded unexpectedly!");
6862 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6863 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6865 rte_cryptodev_sym_session_free(sessions[i]);
6870 return TEST_SUCCESS;
6873 struct multi_session_params {
6874 struct crypto_unittest_params ut_params;
6875 uint8_t *cipher_key;
6877 const uint8_t *cipher;
6878 const uint8_t *digest;
6882 #define MB_SESSION_NUMBER 3
6885 test_multi_session_random_usage(void)
6887 struct crypto_testsuite_params *ts_params = &testsuite_params;
6888 struct rte_cryptodev_info dev_info;
6889 struct rte_cryptodev_sym_session **sessions;
6891 struct multi_session_params ut_paramz[] = {
6894 .cipher_key = ms_aes_cbc_key0,
6895 .hmac_key = ms_hmac_key0,
6896 .cipher = ms_aes_cbc_cipher0,
6897 .digest = ms_hmac_digest0,
6898 .iv = ms_aes_cbc_iv0
6901 .cipher_key = ms_aes_cbc_key1,
6902 .hmac_key = ms_hmac_key1,
6903 .cipher = ms_aes_cbc_cipher1,
6904 .digest = ms_hmac_digest1,
6905 .iv = ms_aes_cbc_iv1
6908 .cipher_key = ms_aes_cbc_key2,
6909 .hmac_key = ms_hmac_key2,
6910 .cipher = ms_aes_cbc_cipher2,
6911 .digest = ms_hmac_digest2,
6912 .iv = ms_aes_cbc_iv2
6917 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6919 sessions = rte_malloc(NULL,
6920 (sizeof(struct rte_cryptodev_sym_session *)
6921 * MAX_NB_SESSIONS) + 1, 0);
6923 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6924 sessions[i] = rte_cryptodev_sym_session_create(
6925 ts_params->session_mpool);
6927 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6928 sizeof(struct crypto_unittest_params));
6930 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6931 &ut_paramz[i].ut_params,
6932 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6934 /* Create multiple crypto sessions*/
6935 rte_cryptodev_sym_session_init(
6936 ts_params->valid_devs[0],
6938 &ut_paramz[i].ut_params.auth_xform,
6939 ts_params->session_priv_mpool);
6941 TEST_ASSERT_NOT_NULL(sessions[i],
6942 "Session creation failed at session number %u",
6948 for (i = 0; i < 40000; i++) {
6950 j = rand() % MB_SESSION_NUMBER;
6952 TEST_ASSERT_SUCCESS(
6953 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6955 &ut_paramz[j].ut_params,
6956 ts_params, ut_paramz[j].cipher,
6957 ut_paramz[j].digest,
6959 "Failed to perform decrypt on request number %u.", i);
6961 if (ut_paramz[j].ut_params.op)
6962 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6965 * free mbuf - both obuf and ibuf are usually the same,
6966 * so check if they point at the same address is necessary,
6967 * to avoid freeing the mbuf twice.
6969 if (ut_paramz[j].ut_params.obuf) {
6970 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6971 if (ut_paramz[j].ut_params.ibuf
6972 == ut_paramz[j].ut_params.obuf)
6973 ut_paramz[j].ut_params.ibuf = 0;
6974 ut_paramz[j].ut_params.obuf = 0;
6976 if (ut_paramz[j].ut_params.ibuf) {
6977 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6978 ut_paramz[j].ut_params.ibuf = 0;
6982 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6983 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6985 rte_cryptodev_sym_session_free(sessions[i]);
6990 return TEST_SUCCESS;
6994 test_null_cipher_only_operation(void)
6996 struct crypto_testsuite_params *ts_params = &testsuite_params;
6997 struct crypto_unittest_params *ut_params = &unittest_params;
6999 /* Generate test mbuf data and space for digest */
7000 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7001 catch_22_quote, QUOTE_512_BYTES, 0);
7003 /* Setup Cipher Parameters */
7004 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7005 ut_params->cipher_xform.next = NULL;
7007 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7008 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7010 ut_params->sess = rte_cryptodev_sym_session_create(
7011 ts_params->session_mpool);
7013 /* Create Crypto session*/
7014 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7016 &ut_params->cipher_xform,
7017 ts_params->session_priv_mpool);
7018 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7020 /* Generate Crypto op data structure */
7021 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7022 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7023 TEST_ASSERT_NOT_NULL(ut_params->op,
7024 "Failed to allocate symmetric crypto operation struct");
7026 /* Set crypto operation data parameters */
7027 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7029 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7031 /* set crypto operation source mbuf */
7032 sym_op->m_src = ut_params->ibuf;
7034 sym_op->cipher.data.offset = 0;
7035 sym_op->cipher.data.length = QUOTE_512_BYTES;
7037 /* Process crypto operation */
7038 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7040 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7042 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7043 "crypto operation processing failed");
7046 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7047 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7050 "Ciphertext data not as expected");
7052 return TEST_SUCCESS;
7054 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
7055 0xab, 0xab, 0xab, 0xab,
7056 0xab, 0xab, 0xab, 0xab,
7057 0xab, 0xab, 0xab, 0xab};
7059 test_null_auth_only_operation(void)
7061 struct crypto_testsuite_params *ts_params = &testsuite_params;
7062 struct crypto_unittest_params *ut_params = &unittest_params;
7065 /* Generate test mbuf data and space for digest */
7066 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7067 catch_22_quote, QUOTE_512_BYTES, 0);
7069 /* create a pointer for digest, but don't expect anything to be written
7070 * here in a NULL auth algo so no mbuf append done.
7072 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7074 /* prefill the memory pointed to by digest */
7075 memcpy(digest, orig_data, sizeof(orig_data));
7077 /* Setup HMAC Parameters */
7078 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7079 ut_params->auth_xform.next = NULL;
7081 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7082 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7084 ut_params->sess = rte_cryptodev_sym_session_create(
7085 ts_params->session_mpool);
7087 /* Create Crypto session*/
7088 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7089 ut_params->sess, &ut_params->auth_xform,
7090 ts_params->session_priv_mpool);
7091 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7093 /* Generate Crypto op data structure */
7094 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7095 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7096 TEST_ASSERT_NOT_NULL(ut_params->op,
7097 "Failed to allocate symmetric crypto operation struct");
7099 /* Set crypto operation data parameters */
7100 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7102 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7104 sym_op->m_src = ut_params->ibuf;
7106 sym_op->auth.data.offset = 0;
7107 sym_op->auth.data.length = QUOTE_512_BYTES;
7108 sym_op->auth.digest.data = digest;
7109 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7112 /* Process crypto operation */
7113 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7115 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7117 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7118 "crypto operation processing failed");
7119 /* Make sure memory pointed to by digest hasn't been overwritten */
7120 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7124 "Memory at digest ptr overwritten unexpectedly");
7126 return TEST_SUCCESS;
7131 test_null_cipher_auth_operation(void)
7133 struct crypto_testsuite_params *ts_params = &testsuite_params;
7134 struct crypto_unittest_params *ut_params = &unittest_params;
7137 /* Generate test mbuf data and space for digest */
7138 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7139 catch_22_quote, QUOTE_512_BYTES, 0);
7141 /* create a pointer for digest, but don't expect anything to be written
7142 * here in a NULL auth algo so no mbuf append done.
7144 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7146 /* prefill the memory pointed to by digest */
7147 memcpy(digest, orig_data, sizeof(orig_data));
7149 /* Setup Cipher Parameters */
7150 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7151 ut_params->cipher_xform.next = &ut_params->auth_xform;
7153 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7154 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7156 /* Setup HMAC Parameters */
7157 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7158 ut_params->auth_xform.next = NULL;
7160 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7161 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7163 ut_params->sess = rte_cryptodev_sym_session_create(
7164 ts_params->session_mpool);
7166 /* Create Crypto session*/
7167 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7168 ut_params->sess, &ut_params->cipher_xform,
7169 ts_params->session_priv_mpool);
7170 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7172 /* Generate Crypto op data structure */
7173 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7174 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7175 TEST_ASSERT_NOT_NULL(ut_params->op,
7176 "Failed to allocate symmetric crypto operation struct");
7178 /* Set crypto operation data parameters */
7179 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7181 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7183 sym_op->m_src = ut_params->ibuf;
7185 sym_op->cipher.data.offset = 0;
7186 sym_op->cipher.data.length = QUOTE_512_BYTES;
7188 sym_op->auth.data.offset = 0;
7189 sym_op->auth.data.length = QUOTE_512_BYTES;
7190 sym_op->auth.digest.data = digest;
7191 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7194 /* Process crypto operation */
7195 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7197 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7199 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7200 "crypto operation processing failed");
7203 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7204 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7207 "Ciphertext data not as expected");
7208 /* Make sure memory pointed to by digest hasn't been overwritten */
7209 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7213 "Memory at digest ptr overwritten unexpectedly");
7215 return TEST_SUCCESS;
7219 test_null_auth_cipher_operation(void)
7221 struct crypto_testsuite_params *ts_params = &testsuite_params;
7222 struct crypto_unittest_params *ut_params = &unittest_params;
7225 /* Generate test mbuf data */
7226 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7227 catch_22_quote, QUOTE_512_BYTES, 0);
7229 /* create a pointer for digest, but don't expect anything to be written
7230 * here in a NULL auth algo so no mbuf append done.
7232 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7234 /* prefill the memory pointed to by digest */
7235 memcpy(digest, orig_data, sizeof(orig_data));
7237 /* Setup Cipher Parameters */
7238 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7239 ut_params->cipher_xform.next = NULL;
7241 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7242 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7244 /* Setup HMAC Parameters */
7245 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7246 ut_params->auth_xform.next = &ut_params->cipher_xform;
7248 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7249 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7251 ut_params->sess = rte_cryptodev_sym_session_create(
7252 ts_params->session_mpool);
7254 /* Create Crypto session*/
7255 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7256 ut_params->sess, &ut_params->cipher_xform,
7257 ts_params->session_priv_mpool);
7258 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7260 /* Generate Crypto op data structure */
7261 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7262 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7263 TEST_ASSERT_NOT_NULL(ut_params->op,
7264 "Failed to allocate symmetric crypto operation struct");
7266 /* Set crypto operation data parameters */
7267 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7269 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7271 sym_op->m_src = ut_params->ibuf;
7273 sym_op->cipher.data.offset = 0;
7274 sym_op->cipher.data.length = QUOTE_512_BYTES;
7276 sym_op->auth.data.offset = 0;
7277 sym_op->auth.data.length = QUOTE_512_BYTES;
7278 sym_op->auth.digest.data = digest;
7279 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7282 /* Process crypto operation */
7283 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7285 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7287 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7288 "crypto operation processing failed");
7291 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7292 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7295 "Ciphertext data not as expected");
7296 /* Make sure memory pointed to by digest hasn't been overwritten */
7297 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7301 "Memory at digest ptr overwritten unexpectedly");
7303 return TEST_SUCCESS;
7308 test_null_invalid_operation(void)
7310 struct crypto_testsuite_params *ts_params = &testsuite_params;
7311 struct crypto_unittest_params *ut_params = &unittest_params;
7314 /* Setup Cipher Parameters */
7315 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7316 ut_params->cipher_xform.next = NULL;
7318 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7319 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7321 ut_params->sess = rte_cryptodev_sym_session_create(
7322 ts_params->session_mpool);
7324 /* Create Crypto session*/
7325 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7326 ut_params->sess, &ut_params->cipher_xform,
7327 ts_params->session_priv_mpool);
7328 TEST_ASSERT(ret < 0,
7329 "Session creation succeeded unexpectedly");
7332 /* Setup HMAC Parameters */
7333 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7334 ut_params->auth_xform.next = NULL;
7336 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7337 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7339 ut_params->sess = rte_cryptodev_sym_session_create(
7340 ts_params->session_mpool);
7342 /* Create Crypto session*/
7343 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7344 ut_params->sess, &ut_params->auth_xform,
7345 ts_params->session_priv_mpool);
7346 TEST_ASSERT(ret < 0,
7347 "Session creation succeeded unexpectedly");
7349 return TEST_SUCCESS;
7353 #define NULL_BURST_LENGTH (32)
7356 test_null_burst_operation(void)
7358 struct crypto_testsuite_params *ts_params = &testsuite_params;
7359 struct crypto_unittest_params *ut_params = &unittest_params;
7361 unsigned i, burst_len = NULL_BURST_LENGTH;
7363 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7364 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7366 /* Setup Cipher Parameters */
7367 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7368 ut_params->cipher_xform.next = &ut_params->auth_xform;
7370 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7371 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7373 /* Setup HMAC Parameters */
7374 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7375 ut_params->auth_xform.next = NULL;
7377 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7378 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7380 ut_params->sess = rte_cryptodev_sym_session_create(
7381 ts_params->session_mpool);
7383 /* Create Crypto session*/
7384 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7385 ut_params->sess, &ut_params->cipher_xform,
7386 ts_params->session_priv_mpool);
7387 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7389 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7390 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7391 burst_len, "failed to generate burst of crypto ops");
7393 /* Generate an operation for each mbuf in burst */
7394 for (i = 0; i < burst_len; i++) {
7395 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7397 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7399 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7403 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7405 burst[i]->sym->m_src = m;
7408 /* Process crypto operation */
7409 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7410 0, burst, burst_len),
7412 "Error enqueuing burst");
7414 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7415 0, burst_dequeued, burst_len),
7417 "Error dequeuing burst");
7420 for (i = 0; i < burst_len; i++) {
7422 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7423 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7425 "data not as expected");
7427 rte_pktmbuf_free(burst[i]->sym->m_src);
7428 rte_crypto_op_free(burst[i]);
7431 return TEST_SUCCESS;
7435 generate_gmac_large_plaintext(uint8_t *data)
7439 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7440 memcpy(&data[i], &data[0], 32);
7444 create_gmac_operation(enum rte_crypto_auth_operation op,
7445 const struct gmac_test_data *tdata)
7447 struct crypto_testsuite_params *ts_params = &testsuite_params;
7448 struct crypto_unittest_params *ut_params = &unittest_params;
7449 struct rte_crypto_sym_op *sym_op;
7451 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7453 /* Generate Crypto op data structure */
7454 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7455 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7456 TEST_ASSERT_NOT_NULL(ut_params->op,
7457 "Failed to allocate symmetric crypto operation struct");
7459 sym_op = ut_params->op->sym;
7461 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7462 ut_params->ibuf, tdata->gmac_tag.len);
7463 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7464 "no room to append digest");
7466 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7467 ut_params->ibuf, plaintext_pad_len);
7469 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7470 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7471 tdata->gmac_tag.len);
7472 debug_hexdump(stdout, "digest:",
7473 sym_op->auth.digest.data,
7474 tdata->gmac_tag.len);
7477 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7478 uint8_t *, IV_OFFSET);
7480 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7482 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7484 sym_op->cipher.data.length = 0;
7485 sym_op->cipher.data.offset = 0;
7487 sym_op->auth.data.offset = 0;
7488 sym_op->auth.data.length = tdata->plaintext.len;
7493 static int create_gmac_session(uint8_t dev_id,
7494 const struct gmac_test_data *tdata,
7495 enum rte_crypto_auth_operation auth_op)
7497 uint8_t auth_key[tdata->key.len];
7499 struct crypto_testsuite_params *ts_params = &testsuite_params;
7500 struct crypto_unittest_params *ut_params = &unittest_params;
7502 memcpy(auth_key, tdata->key.data, tdata->key.len);
7504 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7505 ut_params->auth_xform.next = NULL;
7507 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7508 ut_params->auth_xform.auth.op = auth_op;
7509 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7510 ut_params->auth_xform.auth.key.length = tdata->key.len;
7511 ut_params->auth_xform.auth.key.data = auth_key;
7512 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7513 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7516 ut_params->sess = rte_cryptodev_sym_session_create(
7517 ts_params->session_mpool);
7519 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7520 &ut_params->auth_xform,
7521 ts_params->session_priv_mpool);
7523 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7529 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7531 struct crypto_testsuite_params *ts_params = &testsuite_params;
7532 struct crypto_unittest_params *ut_params = &unittest_params;
7536 uint8_t *auth_tag, *plaintext;
7537 uint16_t plaintext_pad_len;
7539 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7540 "No GMAC length in the source data");
7542 retval = create_gmac_session(ts_params->valid_devs[0],
7543 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7548 if (tdata->plaintext.len > MBUF_SIZE)
7549 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7551 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7552 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7553 "Failed to allocate input buffer in mempool");
7555 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7556 rte_pktmbuf_tailroom(ut_params->ibuf));
7558 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7560 * Runtime generate the large plain text instead of use hard code
7561 * plain text vector. It is done to avoid create huge source file
7562 * with the test vector.
7564 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7565 generate_gmac_large_plaintext(tdata->plaintext.data);
7567 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7569 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7571 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7572 debug_hexdump(stdout, "plaintext:", plaintext,
7573 tdata->plaintext.len);
7575 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7581 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7583 ut_params->op->sym->m_src = ut_params->ibuf;
7585 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7586 ut_params->op), "failed to process sym crypto op");
7588 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7589 "crypto op processing failed");
7591 if (ut_params->op->sym->m_dst) {
7592 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7593 uint8_t *, plaintext_pad_len);
7595 auth_tag = plaintext + plaintext_pad_len;
7598 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7600 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7602 tdata->gmac_tag.data,
7603 tdata->gmac_tag.len,
7604 "GMAC Generated auth tag not as expected");
7610 test_AES_GMAC_authentication_test_case_1(void)
7612 return test_AES_GMAC_authentication(&gmac_test_case_1);
7616 test_AES_GMAC_authentication_test_case_2(void)
7618 return test_AES_GMAC_authentication(&gmac_test_case_2);
7622 test_AES_GMAC_authentication_test_case_3(void)
7624 return test_AES_GMAC_authentication(&gmac_test_case_3);
7628 test_AES_GMAC_authentication_test_case_4(void)
7630 return test_AES_GMAC_authentication(&gmac_test_case_4);
7634 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7636 struct crypto_testsuite_params *ts_params = &testsuite_params;
7637 struct crypto_unittest_params *ut_params = &unittest_params;
7639 uint32_t plaintext_pad_len;
7642 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7643 "No GMAC length in the source data");
7645 retval = create_gmac_session(ts_params->valid_devs[0],
7646 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7651 if (tdata->plaintext.len > MBUF_SIZE)
7652 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7654 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7655 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7656 "Failed to allocate input buffer in mempool");
7658 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7659 rte_pktmbuf_tailroom(ut_params->ibuf));
7661 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7664 * Runtime generate the large plain text instead of use hard code
7665 * plain text vector. It is done to avoid create huge source file
7666 * with the test vector.
7668 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7669 generate_gmac_large_plaintext(tdata->plaintext.data);
7671 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7673 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7675 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7676 debug_hexdump(stdout, "plaintext:", plaintext,
7677 tdata->plaintext.len);
7679 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7685 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7687 ut_params->op->sym->m_src = ut_params->ibuf;
7689 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7690 ut_params->op), "failed to process sym crypto op");
7692 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7693 "crypto op processing failed");
7700 test_AES_GMAC_authentication_verify_test_case_1(void)
7702 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7706 test_AES_GMAC_authentication_verify_test_case_2(void)
7708 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7712 test_AES_GMAC_authentication_verify_test_case_3(void)
7714 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7718 test_AES_GMAC_authentication_verify_test_case_4(void)
7720 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7723 struct test_crypto_vector {
7724 enum rte_crypto_cipher_algorithm crypto_algo;
7737 const uint8_t *data;
7742 const uint8_t *data;
7746 enum rte_crypto_auth_algorithm auth_algo;
7754 const uint8_t *data;
7764 static const struct test_crypto_vector
7765 hmac_sha1_test_crypto_vector = {
7766 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7768 .data = plaintext_hash,
7773 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7774 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7775 0xDE, 0xF4, 0xDE, 0xAD
7781 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7782 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7783 0x3F, 0x91, 0x64, 0x59
7789 static const struct test_crypto_vector
7790 aes128_gmac_test_vector = {
7791 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7793 .data = plaintext_hash,
7798 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7799 0x08, 0x09, 0x0A, 0x0B
7805 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7806 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7812 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7813 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7819 static const struct test_crypto_vector
7820 aes128cbc_hmac_sha1_test_vector = {
7821 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7824 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7825 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7831 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7832 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7837 .data = plaintext_hash,
7841 .data = ciphertext512_aes128cbc,
7844 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7847 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7848 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7849 0xDE, 0xF4, 0xDE, 0xAD
7855 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7856 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7857 0x18, 0x8C, 0x1D, 0x32
7864 data_corruption(uint8_t *data)
7870 tag_corruption(uint8_t *data, unsigned int tag_offset)
7872 data[tag_offset] += 1;
7876 create_auth_session(struct crypto_unittest_params *ut_params,
7878 const struct test_crypto_vector *reference,
7879 enum rte_crypto_auth_operation auth_op)
7881 struct crypto_testsuite_params *ts_params = &testsuite_params;
7882 uint8_t auth_key[reference->auth_key.len + 1];
7884 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7886 /* Setup Authentication Parameters */
7887 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7888 ut_params->auth_xform.auth.op = auth_op;
7889 ut_params->auth_xform.next = NULL;
7890 ut_params->auth_xform.auth.algo = reference->auth_algo;
7891 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7892 ut_params->auth_xform.auth.key.data = auth_key;
7893 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7895 /* Create Crypto session*/
7896 ut_params->sess = rte_cryptodev_sym_session_create(
7897 ts_params->session_mpool);
7899 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7900 &ut_params->auth_xform,
7901 ts_params->session_priv_mpool);
7903 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7909 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7911 const struct test_crypto_vector *reference,
7912 enum rte_crypto_auth_operation auth_op,
7913 enum rte_crypto_cipher_operation cipher_op)
7915 struct crypto_testsuite_params *ts_params = &testsuite_params;
7916 uint8_t cipher_key[reference->cipher_key.len + 1];
7917 uint8_t auth_key[reference->auth_key.len + 1];
7919 memcpy(cipher_key, reference->cipher_key.data,
7920 reference->cipher_key.len);
7921 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7923 /* Setup Authentication Parameters */
7924 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7925 ut_params->auth_xform.auth.op = auth_op;
7926 ut_params->auth_xform.auth.algo = reference->auth_algo;
7927 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7928 ut_params->auth_xform.auth.key.data = auth_key;
7929 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7931 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7932 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7933 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7935 ut_params->auth_xform.next = &ut_params->cipher_xform;
7937 /* Setup Cipher Parameters */
7938 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7939 ut_params->cipher_xform.next = NULL;
7940 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7941 ut_params->cipher_xform.cipher.op = cipher_op;
7942 ut_params->cipher_xform.cipher.key.data = cipher_key;
7943 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7944 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7945 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7948 /* Create Crypto session*/
7949 ut_params->sess = rte_cryptodev_sym_session_create(
7950 ts_params->session_mpool);
7952 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7953 &ut_params->auth_xform,
7954 ts_params->session_priv_mpool);
7956 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7962 create_auth_operation(struct crypto_testsuite_params *ts_params,
7963 struct crypto_unittest_params *ut_params,
7964 const struct test_crypto_vector *reference,
7965 unsigned int auth_generate)
7967 /* Generate Crypto op data structure */
7968 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7969 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7970 TEST_ASSERT_NOT_NULL(ut_params->op,
7971 "Failed to allocate pktmbuf offload");
7973 /* Set crypto operation data parameters */
7974 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7976 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7978 /* set crypto operation source mbuf */
7979 sym_op->m_src = ut_params->ibuf;
7982 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7983 ut_params->ibuf, reference->digest.len);
7985 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7986 "no room to append auth tag");
7988 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7989 ut_params->ibuf, reference->plaintext.len);
7992 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7994 memcpy(sym_op->auth.digest.data,
7995 reference->digest.data,
7996 reference->digest.len);
7998 debug_hexdump(stdout, "digest:",
7999 sym_op->auth.digest.data,
8000 reference->digest.len);
8002 sym_op->auth.data.length = reference->plaintext.len;
8003 sym_op->auth.data.offset = 0;
8009 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
8010 struct crypto_unittest_params *ut_params,
8011 const struct test_crypto_vector *reference,
8012 unsigned int auth_generate)
8014 /* Generate Crypto op data structure */
8015 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8016 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8017 TEST_ASSERT_NOT_NULL(ut_params->op,
8018 "Failed to allocate pktmbuf offload");
8020 /* Set crypto operation data parameters */
8021 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8023 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8025 /* set crypto operation source mbuf */
8026 sym_op->m_src = ut_params->ibuf;
8029 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8030 ut_params->ibuf, reference->digest.len);
8032 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8033 "no room to append auth tag");
8035 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8036 ut_params->ibuf, reference->ciphertext.len);
8039 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8041 memcpy(sym_op->auth.digest.data,
8042 reference->digest.data,
8043 reference->digest.len);
8045 debug_hexdump(stdout, "digest:",
8046 sym_op->auth.digest.data,
8047 reference->digest.len);
8049 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8050 reference->iv.data, reference->iv.len);
8052 sym_op->cipher.data.length = 0;
8053 sym_op->cipher.data.offset = 0;
8055 sym_op->auth.data.length = reference->plaintext.len;
8056 sym_op->auth.data.offset = 0;
8062 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8063 struct crypto_unittest_params *ut_params,
8064 const struct test_crypto_vector *reference,
8065 unsigned int auth_generate)
8067 /* Generate Crypto op data structure */
8068 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8069 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8070 TEST_ASSERT_NOT_NULL(ut_params->op,
8071 "Failed to allocate pktmbuf offload");
8073 /* Set crypto operation data parameters */
8074 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8076 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8078 /* set crypto operation source mbuf */
8079 sym_op->m_src = ut_params->ibuf;
8082 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8083 ut_params->ibuf, reference->digest.len);
8085 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8086 "no room to append auth tag");
8088 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8089 ut_params->ibuf, reference->ciphertext.len);
8092 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8094 memcpy(sym_op->auth.digest.data,
8095 reference->digest.data,
8096 reference->digest.len);
8098 debug_hexdump(stdout, "digest:",
8099 sym_op->auth.digest.data,
8100 reference->digest.len);
8102 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8103 reference->iv.data, reference->iv.len);
8105 sym_op->cipher.data.length = reference->ciphertext.len;
8106 sym_op->cipher.data.offset = 0;
8108 sym_op->auth.data.length = reference->ciphertext.len;
8109 sym_op->auth.data.offset = 0;
8115 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8116 struct crypto_unittest_params *ut_params,
8117 const struct test_crypto_vector *reference)
8119 return create_auth_operation(ts_params, ut_params, reference, 0);
8123 create_auth_verify_GMAC_operation(
8124 struct crypto_testsuite_params *ts_params,
8125 struct crypto_unittest_params *ut_params,
8126 const struct test_crypto_vector *reference)
8128 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8132 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8133 struct crypto_unittest_params *ut_params,
8134 const struct test_crypto_vector *reference)
8136 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8140 test_authentication_verify_fail_when_data_corruption(
8141 struct crypto_testsuite_params *ts_params,
8142 struct crypto_unittest_params *ut_params,
8143 const struct test_crypto_vector *reference,
8144 unsigned int data_corrupted)
8150 /* Create session */
8151 retval = create_auth_session(ut_params,
8152 ts_params->valid_devs[0],
8154 RTE_CRYPTO_AUTH_OP_VERIFY);
8158 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8159 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8160 "Failed to allocate input buffer in mempool");
8162 /* clear mbuf payload */
8163 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8164 rte_pktmbuf_tailroom(ut_params->ibuf));
8166 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8167 reference->plaintext.len);
8168 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8169 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8171 debug_hexdump(stdout, "plaintext:", plaintext,
8172 reference->plaintext.len);
8174 /* Create operation */
8175 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8181 data_corruption(plaintext);
8183 tag_corruption(plaintext, reference->plaintext.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_authentication_verify_GMAC_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)
8208 /* Create session */
8209 retval = create_auth_cipher_session(ut_params,
8210 ts_params->valid_devs[0],
8212 RTE_CRYPTO_AUTH_OP_VERIFY,
8213 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8217 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8218 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8219 "Failed to allocate input buffer in mempool");
8221 /* clear mbuf payload */
8222 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8223 rte_pktmbuf_tailroom(ut_params->ibuf));
8225 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8226 reference->plaintext.len);
8227 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8228 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8230 debug_hexdump(stdout, "plaintext:", plaintext,
8231 reference->plaintext.len);
8233 /* Create operation */
8234 retval = create_auth_verify_GMAC_operation(ts_params,
8242 data_corruption(plaintext);
8244 tag_corruption(plaintext, reference->aad.len);
8246 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 test_authenticated_decryption_fail_when_corruption(
8261 struct crypto_testsuite_params *ts_params,
8262 struct crypto_unittest_params *ut_params,
8263 const struct test_crypto_vector *reference,
8264 unsigned int data_corrupted)
8268 uint8_t *ciphertext;
8270 /* Create session */
8271 retval = create_auth_cipher_session(ut_params,
8272 ts_params->valid_devs[0],
8274 RTE_CRYPTO_AUTH_OP_VERIFY,
8275 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8279 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8280 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8281 "Failed to allocate input buffer in mempool");
8283 /* clear mbuf payload */
8284 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8285 rte_pktmbuf_tailroom(ut_params->ibuf));
8287 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8288 reference->ciphertext.len);
8289 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8290 memcpy(ciphertext, reference->ciphertext.data,
8291 reference->ciphertext.len);
8293 /* Create operation */
8294 retval = create_cipher_auth_verify_operation(ts_params,
8302 data_corruption(ciphertext);
8304 tag_corruption(ciphertext, reference->ciphertext.len);
8306 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8309 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8310 TEST_ASSERT_EQUAL(ut_params->op->status,
8311 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8312 "authentication not failed");
8314 ut_params->obuf = ut_params->op->sym->m_src;
8315 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8321 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8322 const struct aead_test_data *tdata,
8323 void *digest_mem, uint64_t digest_phys)
8325 struct crypto_testsuite_params *ts_params = &testsuite_params;
8326 struct crypto_unittest_params *ut_params = &unittest_params;
8328 const unsigned int auth_tag_len = tdata->auth_tag.len;
8329 const unsigned int iv_len = tdata->iv.len;
8330 unsigned int aad_len = tdata->aad.len;
8332 /* Generate Crypto op data structure */
8333 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8334 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8335 TEST_ASSERT_NOT_NULL(ut_params->op,
8336 "Failed to allocate symmetric crypto operation struct");
8338 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8340 sym_op->aead.digest.data = digest_mem;
8342 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8343 "no room to append digest");
8345 sym_op->aead.digest.phys_addr = digest_phys;
8347 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8348 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8350 debug_hexdump(stdout, "digest:",
8351 sym_op->aead.digest.data,
8355 /* Append aad data */
8356 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8357 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8358 uint8_t *, IV_OFFSET);
8360 /* Copy IV 1 byte after the IV pointer, according to the API */
8361 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8363 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8365 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8366 ut_params->ibuf, aad_len);
8367 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8368 "no room to prepend aad");
8369 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8372 memset(sym_op->aead.aad.data, 0, aad_len);
8373 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8374 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8376 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8377 debug_hexdump(stdout, "aad:",
8378 sym_op->aead.aad.data, aad_len);
8380 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8381 uint8_t *, IV_OFFSET);
8383 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8385 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8386 ut_params->ibuf, aad_len);
8387 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8388 "no room to prepend aad");
8389 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8392 memset(sym_op->aead.aad.data, 0, aad_len);
8393 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8395 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8396 debug_hexdump(stdout, "aad:",
8397 sym_op->aead.aad.data, aad_len);
8400 sym_op->aead.data.length = tdata->plaintext.len;
8401 sym_op->aead.data.offset = aad_len;
8406 #define SGL_MAX_NO 16
8409 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8410 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8412 struct crypto_testsuite_params *ts_params = &testsuite_params;
8413 struct crypto_unittest_params *ut_params = &unittest_params;
8414 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8417 int to_trn_tbl[SGL_MAX_NO];
8419 unsigned int trn_data = 0;
8420 uint8_t *plaintext, *ciphertext, *auth_tag;
8422 if (fragsz > tdata->plaintext.len)
8423 fragsz = tdata->plaintext.len;
8425 uint16_t plaintext_len = fragsz;
8426 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8428 if (fragsz_oop > tdata->plaintext.len)
8429 frag_size_oop = tdata->plaintext.len;
8432 void *digest_mem = NULL;
8434 uint32_t prepend_len = tdata->aad.len;
8436 if (tdata->plaintext.len % fragsz != 0) {
8437 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8440 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8445 * For out-op-place we need to alloc another mbuf
8448 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8449 rte_pktmbuf_append(ut_params->obuf,
8450 frag_size_oop + prepend_len);
8451 buf_oop = ut_params->obuf;
8454 /* Create AEAD session */
8455 retval = create_aead_session(ts_params->valid_devs[0],
8457 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8458 tdata->key.data, tdata->key.len,
8459 tdata->aad.len, tdata->auth_tag.len,
8464 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8466 /* clear mbuf payload */
8467 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8468 rte_pktmbuf_tailroom(ut_params->ibuf));
8470 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8473 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8475 trn_data += plaintext_len;
8477 buf = ut_params->ibuf;
8480 * Loop until no more fragments
8483 while (trn_data < tdata->plaintext.len) {
8485 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8486 (tdata->plaintext.len - trn_data) : fragsz;
8488 to_trn_tbl[ecx++] = to_trn;
8490 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8493 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8494 rte_pktmbuf_tailroom(buf));
8497 if (oop && !fragsz_oop) {
8498 buf_last_oop = buf_oop->next =
8499 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8500 buf_oop = buf_oop->next;
8501 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8502 0, rte_pktmbuf_tailroom(buf_oop));
8503 rte_pktmbuf_append(buf_oop, to_trn);
8506 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8509 memcpy(plaintext, tdata->plaintext.data + trn_data,
8512 if (trn_data == tdata->plaintext.len) {
8515 digest_mem = rte_pktmbuf_append(buf_oop,
8516 tdata->auth_tag.len);
8518 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8519 tdata->auth_tag.len);
8523 uint64_t digest_phys = 0;
8525 ut_params->ibuf->nb_segs = segs;
8528 if (fragsz_oop && oop) {
8532 if (frag_size_oop == tdata->plaintext.len) {
8533 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8534 tdata->auth_tag.len);
8536 digest_phys = rte_pktmbuf_iova_offset(
8538 tdata->plaintext.len + prepend_len);
8541 trn_data = frag_size_oop;
8542 while (trn_data < tdata->plaintext.len) {
8545 (tdata->plaintext.len - trn_data <
8547 (tdata->plaintext.len - trn_data) :
8550 to_trn_tbl[ecx++] = to_trn;
8552 buf_last_oop = buf_oop->next =
8553 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8554 buf_oop = buf_oop->next;
8555 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8556 0, rte_pktmbuf_tailroom(buf_oop));
8557 rte_pktmbuf_append(buf_oop, to_trn);
8561 if (trn_data == tdata->plaintext.len) {
8562 digest_mem = rte_pktmbuf_append(buf_oop,
8563 tdata->auth_tag.len);
8567 ut_params->obuf->nb_segs = segs;
8571 * Place digest at the end of the last buffer
8574 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8575 if (oop && buf_last_oop)
8576 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8578 if (!digest_mem && !oop) {
8579 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8580 + tdata->auth_tag.len);
8581 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8582 tdata->plaintext.len);
8585 /* Create AEAD operation */
8586 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8587 tdata, digest_mem, digest_phys);
8592 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8594 ut_params->op->sym->m_src = ut_params->ibuf;
8596 ut_params->op->sym->m_dst = ut_params->obuf;
8598 /* Process crypto operation */
8599 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8600 ut_params->op), "failed to process sym crypto op");
8602 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8603 "crypto op processing failed");
8606 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8607 uint8_t *, prepend_len);
8609 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8610 uint8_t *, prepend_len);
8614 fragsz = fragsz_oop;
8616 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8618 tdata->ciphertext.data,
8620 "Ciphertext data not as expected");
8622 buf = ut_params->op->sym->m_src->next;
8624 buf = ut_params->op->sym->m_dst->next;
8626 unsigned int off = fragsz;
8630 ciphertext = rte_pktmbuf_mtod(buf,
8633 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8635 tdata->ciphertext.data + off,
8637 "Ciphertext data not as expected");
8639 off += to_trn_tbl[ecx++];
8643 auth_tag = digest_mem;
8644 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8646 tdata->auth_tag.data,
8647 tdata->auth_tag.len,
8648 "Generated auth tag not as expected");
8654 #define OUT_OF_PLACE 1
8657 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8659 return test_authenticated_encryption_SGL(
8660 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8664 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8666 return test_authenticated_encryption_SGL(
8667 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8671 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8673 return test_authenticated_encryption_SGL(
8674 &gcm_test_case_8, OUT_OF_PLACE, 400,
8675 gcm_test_case_8.plaintext.len);
8679 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8682 return test_authenticated_encryption_SGL(
8683 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8687 test_authentication_verify_fail_when_data_corrupted(
8688 struct crypto_testsuite_params *ts_params,
8689 struct crypto_unittest_params *ut_params,
8690 const struct test_crypto_vector *reference)
8692 return test_authentication_verify_fail_when_data_corruption(
8693 ts_params, ut_params, reference, 1);
8697 test_authentication_verify_fail_when_tag_corrupted(
8698 struct crypto_testsuite_params *ts_params,
8699 struct crypto_unittest_params *ut_params,
8700 const struct test_crypto_vector *reference)
8702 return test_authentication_verify_fail_when_data_corruption(
8703 ts_params, ut_params, reference, 0);
8707 test_authentication_verify_GMAC_fail_when_data_corrupted(
8708 struct crypto_testsuite_params *ts_params,
8709 struct crypto_unittest_params *ut_params,
8710 const struct test_crypto_vector *reference)
8712 return test_authentication_verify_GMAC_fail_when_corruption(
8713 ts_params, ut_params, reference, 1);
8717 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8718 struct crypto_testsuite_params *ts_params,
8719 struct crypto_unittest_params *ut_params,
8720 const struct test_crypto_vector *reference)
8722 return test_authentication_verify_GMAC_fail_when_corruption(
8723 ts_params, ut_params, reference, 0);
8727 test_authenticated_decryption_fail_when_data_corrupted(
8728 struct crypto_testsuite_params *ts_params,
8729 struct crypto_unittest_params *ut_params,
8730 const struct test_crypto_vector *reference)
8732 return test_authenticated_decryption_fail_when_corruption(
8733 ts_params, ut_params, reference, 1);
8737 test_authenticated_decryption_fail_when_tag_corrupted(
8738 struct crypto_testsuite_params *ts_params,
8739 struct crypto_unittest_params *ut_params,
8740 const struct test_crypto_vector *reference)
8742 return test_authenticated_decryption_fail_when_corruption(
8743 ts_params, ut_params, reference, 0);
8747 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8749 return test_authentication_verify_fail_when_data_corrupted(
8750 &testsuite_params, &unittest_params,
8751 &hmac_sha1_test_crypto_vector);
8755 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8757 return test_authentication_verify_fail_when_tag_corrupted(
8758 &testsuite_params, &unittest_params,
8759 &hmac_sha1_test_crypto_vector);
8763 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8765 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8766 &testsuite_params, &unittest_params,
8767 &aes128_gmac_test_vector);
8771 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8773 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8774 &testsuite_params, &unittest_params,
8775 &aes128_gmac_test_vector);
8779 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8781 return test_authenticated_decryption_fail_when_data_corrupted(
8784 &aes128cbc_hmac_sha1_test_vector);
8788 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8790 return test_authenticated_decryption_fail_when_tag_corrupted(
8793 &aes128cbc_hmac_sha1_test_vector);
8796 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8798 /* global AESNI slave IDs for the scheduler test */
8799 uint8_t aesni_ids[2];
8802 test_scheduler_attach_slave_op(void)
8804 struct crypto_testsuite_params *ts_params = &testsuite_params;
8805 uint8_t sched_id = ts_params->valid_devs[0];
8806 uint32_t nb_devs, i, nb_devs_attached = 0;
8810 /* create 2 AESNI_MB if necessary */
8811 nb_devs = rte_cryptodev_device_count_by_driver(
8812 rte_cryptodev_driver_id_get(
8813 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8815 for (i = nb_devs; i < 2; i++) {
8816 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8817 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8819 ret = rte_vdev_init(vdev_name, NULL);
8821 TEST_ASSERT(ret == 0,
8822 "Failed to create instance %u of"
8824 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8828 /* attach 2 AESNI_MB cdevs */
8829 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8831 struct rte_cryptodev_info info;
8832 unsigned int session_size;
8834 rte_cryptodev_info_get(i, &info);
8835 if (info.driver_id != rte_cryptodev_driver_id_get(
8836 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8839 session_size = rte_cryptodev_sym_get_private_session_size(i);
8841 * Create the session mempool again, since now there are new devices
8842 * to use the mempool.
8844 if (ts_params->session_mpool) {
8845 rte_mempool_free(ts_params->session_mpool);
8846 ts_params->session_mpool = NULL;
8848 if (ts_params->session_priv_mpool) {
8849 rte_mempool_free(ts_params->session_priv_mpool);
8850 ts_params->session_priv_mpool = NULL;
8853 if (info.sym.max_nb_sessions != 0 &&
8854 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8856 "Device does not support "
8857 "at least %u sessions\n",
8862 * Create mempool with maximum number of sessions,
8863 * to include the session headers
8865 if (ts_params->session_mpool == NULL) {
8866 ts_params->session_mpool =
8867 rte_cryptodev_sym_session_pool_create(
8869 MAX_NB_SESSIONS, 0, 0, 0,
8871 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8872 "session mempool allocation failed");
8876 * Create mempool with maximum number of sessions,
8877 * to include device specific session private data
8879 if (ts_params->session_priv_mpool == NULL) {
8880 ts_params->session_priv_mpool = rte_mempool_create(
8881 "test_sess_mp_priv",
8884 0, 0, NULL, NULL, NULL,
8885 NULL, SOCKET_ID_ANY,
8888 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
8889 "session mempool allocation failed");
8892 ts_params->qp_conf.mp_session = ts_params->session_mpool;
8893 ts_params->qp_conf.mp_session_private =
8894 ts_params->session_priv_mpool;
8896 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8899 TEST_ASSERT(ret == 0,
8900 "Failed to attach device %u of pmd : %s", i,
8901 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8903 aesni_ids[nb_devs_attached] = (uint8_t)i;
8912 test_scheduler_detach_slave_op(void)
8914 struct crypto_testsuite_params *ts_params = &testsuite_params;
8915 uint8_t sched_id = ts_params->valid_devs[0];
8919 for (i = 0; i < 2; i++) {
8920 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8922 TEST_ASSERT(ret == 0,
8923 "Failed to detach device %u", aesni_ids[i]);
8930 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8932 struct crypto_testsuite_params *ts_params = &testsuite_params;
8933 uint8_t sched_id = ts_params->valid_devs[0];
8935 return rte_cryptodev_scheduler_mode_set(sched_id,
8940 test_scheduler_mode_roundrobin_op(void)
8942 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8943 0, "Failed to set roundrobin mode");
8949 test_scheduler_mode_multicore_op(void)
8951 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8952 0, "Failed to set multicore mode");
8958 test_scheduler_mode_failover_op(void)
8960 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8961 0, "Failed to set failover mode");
8967 test_scheduler_mode_pkt_size_distr_op(void)
8969 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8970 0, "Failed to set pktsize mode");
8975 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8976 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8977 .setup = testsuite_setup,
8978 .teardown = testsuite_teardown,
8979 .unit_test_cases = {
8981 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8982 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_AES_chain_scheduler_all),
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_AES_cipheronly_scheduler_all),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_authonly_scheduler_all),
8989 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8992 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8993 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8994 TEST_CASE_ST(ut_setup, ut_teardown,
8995 test_AES_chain_scheduler_all),
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 test_AES_cipheronly_scheduler_all),
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 test_authonly_scheduler_all),
9000 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9003 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9004 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_AES_chain_scheduler_all),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_cipheronly_scheduler_all),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_authonly_scheduler_all),
9011 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9014 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9015 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_AES_chain_scheduler_all),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_AES_cipheronly_scheduler_all),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_authonly_scheduler_all),
9022 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9024 TEST_CASES_END() /**< NULL terminate unit test array */
9028 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
9030 static struct unit_test_suite cryptodev_qat_testsuite = {
9031 .suite_name = "Crypto QAT Unit Test Suite",
9032 .setup = testsuite_setup,
9033 .teardown = testsuite_teardown,
9034 .unit_test_cases = {
9035 TEST_CASE_ST(ut_setup, ut_teardown,
9036 test_device_configure_invalid_dev_id),
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_device_configure_invalid_queue_pair_ids),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_queue_pair_descriptor_setup),
9041 TEST_CASE_ST(ut_setup, ut_teardown,
9042 test_multi_session),
9044 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_cipheronly_qat_all),
9047 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_3DES_cipheronly_qat_all),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_DES_cipheronly_qat_all),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_docsis_qat_all),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_DES_docsis_qat_all),
9056 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
9057 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
9059 /** AES CCM Authenticated Encryption 128 bits key */
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_CCM_authenticated_encryption_test_case_128_1),
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_CCM_authenticated_encryption_test_case_128_2),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_CCM_authenticated_encryption_test_case_128_3),
9067 /** AES CCM Authenticated Decryption 128 bits key*/
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_CCM_authenticated_decryption_test_case_128_1),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_CCM_authenticated_decryption_test_case_128_2),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_CCM_authenticated_decryption_test_case_128_3),
9075 /** AES GCM Authenticated Encryption */
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_AES_GCM_authenticated_encryption_test_case_1),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_GCM_authenticated_encryption_test_case_2),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_GCM_authenticated_encryption_test_case_3),
9088 TEST_CASE_ST(ut_setup, ut_teardown,
9089 test_AES_GCM_authenticated_encryption_test_case_4),
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_AES_GCM_authenticated_encryption_test_case_5),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_AES_GCM_authenticated_encryption_test_case_6),
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_AES_GCM_authenticated_encryption_test_case_7),
9097 /** AES GCM Authenticated Decryption */
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_GCM_authenticated_decryption_test_case_1),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GCM_authenticated_decryption_test_case_2),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GCM_authenticated_decryption_test_case_3),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_authenticated_decryption_test_case_4),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_GCM_authenticated_decryption_test_case_5),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_AES_GCM_authenticated_decryption_test_case_6),
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_AES_GCM_authenticated_decryption_test_case_7),
9113 /** AES GCM Authenticated Encryption 192 bits key */
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_AES_GCM_auth_encryption_test_case_192_1),
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_AES_GCM_auth_encryption_test_case_192_2),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_AES_GCM_auth_encryption_test_case_192_3),
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_AES_GCM_auth_encryption_test_case_192_4),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_AES_GCM_auth_encryption_test_case_192_5),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_AES_GCM_auth_encryption_test_case_192_6),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_AES_GCM_auth_encryption_test_case_192_7),
9129 /** AES GCM Authenticated Decryption 192 bits key */
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_AES_GCM_auth_decryption_test_case_192_1),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_AES_GCM_auth_decryption_test_case_192_2),
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 test_AES_GCM_auth_decryption_test_case_192_3),
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_AES_GCM_auth_decryption_test_case_192_4),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_AES_GCM_auth_decryption_test_case_192_5),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_AES_GCM_auth_decryption_test_case_192_6),
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_AES_GCM_auth_decryption_test_case_192_7),
9145 /** AES GCM Authenticated Encryption 256 bits key */
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_AES_GCM_auth_encryption_test_case_256_1),
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_AES_GCM_auth_encryption_test_case_256_2),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_AES_GCM_auth_encryption_test_case_256_3),
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_AES_GCM_auth_encryption_test_case_256_4),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_AES_GCM_auth_encryption_test_case_256_5),
9156 TEST_CASE_ST(ut_setup, ut_teardown,
9157 test_AES_GCM_auth_encryption_test_case_256_6),
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_AES_GCM_auth_encryption_test_case_256_7),
9161 /** AES GMAC Authentication */
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_AES_GMAC_authentication_test_case_1),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_AES_GMAC_authentication_verify_test_case_1),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_AES_GMAC_authentication_test_case_2),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_AES_GMAC_authentication_verify_test_case_2),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_AES_GMAC_authentication_test_case_3),
9172 TEST_CASE_ST(ut_setup, ut_teardown,
9173 test_AES_GMAC_authentication_verify_test_case_3),
9175 /** SNOW 3G encrypt only (UEA2) */
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_snow3g_encryption_test_case_1),
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_snow3g_encryption_test_case_2),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_snow3g_encryption_test_case_3),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_snow3g_encryption_test_case_4),
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_snow3g_encryption_test_case_5),
9187 TEST_CASE_ST(ut_setup, ut_teardown,
9188 test_snow3g_encryption_test_case_1_oop),
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_snow3g_decryption_test_case_1_oop),
9192 /** SNOW 3G decrypt only (UEA2) */
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_snow3g_decryption_test_case_1),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_snow3g_decryption_test_case_2),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_snow3g_decryption_test_case_3),
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 test_snow3g_decryption_test_case_4),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_snow3g_decryption_test_case_5),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_snow3g_decryption_with_digest_test_case_1),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_snow3g_hash_generate_test_case_1),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_snow3g_hash_generate_test_case_2),
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_snow3g_hash_generate_test_case_3),
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_snow3g_hash_verify_test_case_1),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 test_snow3g_hash_verify_test_case_2),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_snow3g_hash_verify_test_case_3),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 test_snow3g_cipher_auth_test_case_1),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_snow3g_auth_cipher_test_case_1),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_snow3g_auth_cipher_with_digest_test_case_1),
9224 /** ZUC encrypt only (EEA3) */
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_zuc_encryption_test_case_1),
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_zuc_encryption_test_case_2),
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_zuc_encryption_test_case_3),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_zuc_encryption_test_case_4),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_zuc_encryption_test_case_5),
9236 /** ZUC authenticate (EIA3) */
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_zuc_hash_generate_test_case_6),
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_zuc_hash_generate_test_case_7),
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_zuc_hash_generate_test_case_8),
9244 /** ZUC alg-chain (EEA3/EIA3) */
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 test_zuc_cipher_auth_test_case_1),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_zuc_cipher_auth_test_case_2),
9250 /** HMAC_MD5 Authentication */
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_MD5_HMAC_generate_case_1),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_MD5_HMAC_verify_case_1),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_MD5_HMAC_generate_case_2),
9257 TEST_CASE_ST(ut_setup, ut_teardown,
9258 test_MD5_HMAC_verify_case_2),
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_null_auth_only_operation),
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_null_cipher_only_operation),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_null_cipher_auth_operation),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_null_auth_cipher_operation),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_kasumi_hash_generate_test_case_1),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_kasumi_hash_generate_test_case_2),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_kasumi_hash_generate_test_case_3),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_kasumi_hash_generate_test_case_4),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_kasumi_hash_generate_test_case_5),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_kasumi_hash_generate_test_case_6),
9284 TEST_CASE_ST(ut_setup, ut_teardown,
9285 test_kasumi_hash_verify_test_case_1),
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_kasumi_hash_verify_test_case_2),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_kasumi_hash_verify_test_case_3),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_kasumi_hash_verify_test_case_4),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_kasumi_hash_verify_test_case_5),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_kasumi_encryption_test_case_1),
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_kasumi_encryption_test_case_3),
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_kasumi_auth_cipher_test_case_1),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_kasumi_cipher_auth_test_case_1),
9304 /** Negative tests */
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 authentication_verify_AES128_GMAC_fail_data_corrupt),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9318 TEST_CASES_END() /**< NULL terminate unit test array */
9322 static struct unit_test_suite cryptodev_virtio_testsuite = {
9323 .suite_name = "Crypto VIRTIO Unit Test Suite",
9324 .setup = testsuite_setup,
9325 .teardown = testsuite_teardown,
9326 .unit_test_cases = {
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_cipheronly_virtio_all),
9330 TEST_CASES_END() /**< NULL terminate unit test array */
9334 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9335 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9336 .setup = testsuite_setup,
9337 .teardown = testsuite_teardown,
9338 .unit_test_cases = {
9339 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_AES_GCM_authenticated_encryption_test_case_1),
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GCM_authenticated_encryption_test_case_2),
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_AES_GCM_authenticated_encryption_test_case_3),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GCM_authenticated_encryption_test_case_4),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_AES_GCM_authenticated_encryption_test_case_5),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GCM_authenticated_encryption_test_case_6),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_AES_GCM_authenticated_encryption_test_case_7),
9355 /** AES GCM Authenticated Decryption */
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 test_AES_GCM_authenticated_decryption_test_case_1),
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_AES_GCM_authenticated_decryption_test_case_2),
9360 TEST_CASE_ST(ut_setup, ut_teardown,
9361 test_AES_GCM_authenticated_decryption_test_case_3),
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_GCM_authenticated_decryption_test_case_4),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_GCM_authenticated_decryption_test_case_5),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_GCM_authenticated_decryption_test_case_6),
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_AES_GCM_authenticated_decryption_test_case_7),
9371 /** AES GCM Authenticated Encryption 192 bits key */
9372 TEST_CASE_ST(ut_setup, ut_teardown,
9373 test_AES_GCM_auth_encryption_test_case_192_1),
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_AES_GCM_auth_encryption_test_case_192_2),
9376 TEST_CASE_ST(ut_setup, ut_teardown,
9377 test_AES_GCM_auth_encryption_test_case_192_3),
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_AES_GCM_auth_encryption_test_case_192_4),
9380 TEST_CASE_ST(ut_setup, ut_teardown,
9381 test_AES_GCM_auth_encryption_test_case_192_5),
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_AES_GCM_auth_encryption_test_case_192_6),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_AES_GCM_auth_encryption_test_case_192_7),
9387 /** AES GCM Authenticated Decryption 192 bits key */
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 test_AES_GCM_auth_decryption_test_case_192_1),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_AES_GCM_auth_decryption_test_case_192_2),
9392 TEST_CASE_ST(ut_setup, ut_teardown,
9393 test_AES_GCM_auth_decryption_test_case_192_3),
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_GCM_auth_decryption_test_case_192_4),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GCM_auth_decryption_test_case_192_5),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_GCM_auth_decryption_test_case_192_6),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_GCM_auth_decryption_test_case_192_7),
9403 /** AES GCM Authenticated Encryption 256 bits key */
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_AES_GCM_auth_encryption_test_case_256_1),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_auth_encryption_test_case_256_2),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_AES_GCM_auth_encryption_test_case_256_3),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_AES_GCM_auth_encryption_test_case_256_4),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_auth_encryption_test_case_256_5),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_auth_encryption_test_case_256_6),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_auth_encryption_test_case_256_7),
9419 /** AES GCM Authenticated Decryption 256 bits key */
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_GCM_auth_decryption_test_case_256_1),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_auth_decryption_test_case_256_2),
9424 TEST_CASE_ST(ut_setup, ut_teardown,
9425 test_AES_GCM_auth_decryption_test_case_256_3),
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_auth_decryption_test_case_256_4),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_AES_GCM_auth_decryption_test_case_256_5),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_auth_decryption_test_case_256_6),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_auth_decryption_test_case_256_7),
9435 /** AES GCM Authenticated Encryption big aad size */
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_AES_GCM_auth_encryption_test_case_aad_1),
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_AES_GCM_auth_encryption_test_case_aad_2),
9441 /** AES GCM Authenticated Decryption big aad size */
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_AES_GCM_auth_decryption_test_case_aad_1),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_AES_GCM_auth_decryption_test_case_aad_2),
9447 /** Session-less tests */
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9453 /** AES GMAC Authentication */
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_AES_GMAC_authentication_test_case_1),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_AES_GMAC_authentication_verify_test_case_1),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GMAC_authentication_test_case_2),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_AES_GMAC_authentication_verify_test_case_2),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GMAC_authentication_test_case_3),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GMAC_authentication_verify_test_case_3),
9466 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
9468 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9469 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9470 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9471 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9472 TEST_CASE_ST(ut_setup, ut_teardown,
9473 test_DES_cipheronly_mb_all),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_DES_docsis_mb_all),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_3DES_cipheronly_mb_all),
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_AES_CCM_authenticated_encryption_test_case_128_1),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_CCM_authenticated_decryption_test_case_128_1),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_CCM_authenticated_encryption_test_case_128_2),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_AES_CCM_authenticated_decryption_test_case_128_2),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_AES_CCM_authenticated_encryption_test_case_128_3),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_AES_CCM_authenticated_decryption_test_case_128_3),
9491 TEST_CASES_END() /**< NULL terminate unit test array */
9495 static struct unit_test_suite cryptodev_openssl_testsuite = {
9496 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9497 .setup = testsuite_setup,
9498 .teardown = testsuite_teardown,
9499 .unit_test_cases = {
9500 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_multi_session_random_usage),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_AES_chain_openssl_all),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_AES_cipheronly_openssl_all),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_3DES_chain_openssl_all),
9509 TEST_CASE_ST(ut_setup, ut_teardown,
9510 test_3DES_cipheronly_openssl_all),
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_DES_cipheronly_openssl_all),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_DES_docsis_openssl_all),
9515 TEST_CASE_ST(ut_setup, ut_teardown,
9516 test_authonly_openssl_all),
9518 /** AES GCM Authenticated Encryption */
9519 TEST_CASE_ST(ut_setup, ut_teardown,
9520 test_AES_GCM_authenticated_encryption_test_case_1),
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_AES_GCM_authenticated_encryption_test_case_2),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_AES_GCM_authenticated_encryption_test_case_3),
9525 TEST_CASE_ST(ut_setup, ut_teardown,
9526 test_AES_GCM_authenticated_encryption_test_case_4),
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_AES_GCM_authenticated_encryption_test_case_5),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_AES_GCM_authenticated_encryption_test_case_6),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_AES_GCM_authenticated_encryption_test_case_7),
9534 /** AES GCM Authenticated Decryption */
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_AES_GCM_authenticated_decryption_test_case_1),
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_AES_GCM_authenticated_decryption_test_case_2),
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_AES_GCM_authenticated_decryption_test_case_3),
9541 TEST_CASE_ST(ut_setup, ut_teardown,
9542 test_AES_GCM_authenticated_decryption_test_case_4),
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_AES_GCM_authenticated_decryption_test_case_5),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_AES_GCM_authenticated_decryption_test_case_6),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_AES_GCM_authenticated_decryption_test_case_7),
9551 /** AES GCM Authenticated Encryption 192 bits key */
9552 TEST_CASE_ST(ut_setup, ut_teardown,
9553 test_AES_GCM_auth_encryption_test_case_192_1),
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_AES_GCM_auth_encryption_test_case_192_2),
9556 TEST_CASE_ST(ut_setup, ut_teardown,
9557 test_AES_GCM_auth_encryption_test_case_192_3),
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_AES_GCM_auth_encryption_test_case_192_4),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_AES_GCM_auth_encryption_test_case_192_5),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_AES_GCM_auth_encryption_test_case_192_6),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_AES_GCM_auth_encryption_test_case_192_7),
9567 /** AES GCM Authenticated Decryption 192 bits key */
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 test_AES_GCM_auth_decryption_test_case_192_1),
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 test_AES_GCM_auth_decryption_test_case_192_2),
9572 TEST_CASE_ST(ut_setup, ut_teardown,
9573 test_AES_GCM_auth_decryption_test_case_192_3),
9574 TEST_CASE_ST(ut_setup, ut_teardown,
9575 test_AES_GCM_auth_decryption_test_case_192_4),
9576 TEST_CASE_ST(ut_setup, ut_teardown,
9577 test_AES_GCM_auth_decryption_test_case_192_5),
9578 TEST_CASE_ST(ut_setup, ut_teardown,
9579 test_AES_GCM_auth_decryption_test_case_192_6),
9580 TEST_CASE_ST(ut_setup, ut_teardown,
9581 test_AES_GCM_auth_decryption_test_case_192_7),
9583 /** AES GCM Authenticated Encryption 256 bits key */
9584 TEST_CASE_ST(ut_setup, ut_teardown,
9585 test_AES_GCM_auth_encryption_test_case_256_1),
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_AES_GCM_auth_encryption_test_case_256_2),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_AES_GCM_auth_encryption_test_case_256_3),
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_AES_GCM_auth_encryption_test_case_256_4),
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_AES_GCM_auth_encryption_test_case_256_5),
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_AES_GCM_auth_encryption_test_case_256_6),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_GCM_auth_encryption_test_case_256_7),
9599 /** AES GCM Authenticated Decryption 256 bits key */
9600 TEST_CASE_ST(ut_setup, ut_teardown,
9601 test_AES_GCM_auth_decryption_test_case_256_1),
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_auth_decryption_test_case_256_2),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_GCM_auth_decryption_test_case_256_3),
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_auth_decryption_test_case_256_4),
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_GCM_auth_decryption_test_case_256_5),
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_auth_decryption_test_case_256_6),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_auth_decryption_test_case_256_7),
9615 /** AES GMAC Authentication */
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GMAC_authentication_test_case_1),
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GMAC_authentication_verify_test_case_1),
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 test_AES_GMAC_authentication_test_case_2),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GMAC_authentication_verify_test_case_2),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_GMAC_authentication_test_case_3),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GMAC_authentication_verify_test_case_3),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GMAC_authentication_test_case_4),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GMAC_authentication_verify_test_case_4),
9633 /** AES CCM Authenticated Encryption 128 bits key */
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_CCM_authenticated_encryption_test_case_128_1),
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 test_AES_CCM_authenticated_encryption_test_case_128_2),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_CCM_authenticated_encryption_test_case_128_3),
9641 /** AES CCM Authenticated Decryption 128 bits key*/
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 test_AES_CCM_authenticated_decryption_test_case_128_1),
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_CCM_authenticated_decryption_test_case_128_2),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_CCM_authenticated_decryption_test_case_128_3),
9649 /** AES CCM Authenticated Encryption 192 bits key */
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_CCM_authenticated_encryption_test_case_192_1),
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_CCM_authenticated_encryption_test_case_192_2),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_CCM_authenticated_encryption_test_case_192_3),
9657 /** AES CCM Authenticated Decryption 192 bits key*/
9658 TEST_CASE_ST(ut_setup, ut_teardown,
9659 test_AES_CCM_authenticated_decryption_test_case_192_1),
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_CCM_authenticated_decryption_test_case_192_2),
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_CCM_authenticated_decryption_test_case_192_3),
9665 /** AES CCM Authenticated Encryption 256 bits key */
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_CCM_authenticated_encryption_test_case_256_1),
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_CCM_authenticated_encryption_test_case_256_2),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_CCM_authenticated_encryption_test_case_256_3),
9673 /** AES CCM Authenticated Decryption 256 bits key*/
9674 TEST_CASE_ST(ut_setup, ut_teardown,
9675 test_AES_CCM_authenticated_decryption_test_case_256_1),
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_CCM_authenticated_decryption_test_case_256_2),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_AES_CCM_authenticated_decryption_test_case_256_3),
9681 /** Scatter-Gather */
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9685 /** Negative tests */
9686 TEST_CASE_ST(ut_setup, ut_teardown,
9687 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9690 TEST_CASE_ST(ut_setup, ut_teardown,
9691 authentication_verify_AES128_GMAC_fail_data_corrupt),
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9694 TEST_CASE_ST(ut_setup, ut_teardown,
9695 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9699 TEST_CASES_END() /**< NULL terminate unit test array */
9703 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9704 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9705 .setup = testsuite_setup,
9706 .teardown = testsuite_teardown,
9707 .unit_test_cases = {
9708 /** AES GCM Authenticated Encryption */
9709 TEST_CASE_ST(ut_setup, ut_teardown,
9710 test_AES_GCM_authenticated_encryption_test_case_1),
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 test_AES_GCM_authenticated_encryption_test_case_2),
9713 TEST_CASE_ST(ut_setup, ut_teardown,
9714 test_AES_GCM_authenticated_encryption_test_case_3),
9715 TEST_CASE_ST(ut_setup, ut_teardown,
9716 test_AES_GCM_authenticated_encryption_test_case_4),
9717 TEST_CASE_ST(ut_setup, ut_teardown,
9718 test_AES_GCM_authenticated_encryption_test_case_5),
9719 TEST_CASE_ST(ut_setup, ut_teardown,
9720 test_AES_GCM_authenticated_encryption_test_case_6),
9721 TEST_CASE_ST(ut_setup, ut_teardown,
9722 test_AES_GCM_authenticated_encryption_test_case_7),
9724 /** AES GCM Authenticated Decryption */
9725 TEST_CASE_ST(ut_setup, ut_teardown,
9726 test_AES_GCM_authenticated_decryption_test_case_1),
9727 TEST_CASE_ST(ut_setup, ut_teardown,
9728 test_AES_GCM_authenticated_decryption_test_case_2),
9729 TEST_CASE_ST(ut_setup, ut_teardown,
9730 test_AES_GCM_authenticated_decryption_test_case_3),
9731 TEST_CASE_ST(ut_setup, ut_teardown,
9732 test_AES_GCM_authenticated_decryption_test_case_4),
9733 TEST_CASE_ST(ut_setup, ut_teardown,
9734 test_AES_GCM_authenticated_decryption_test_case_5),
9735 TEST_CASE_ST(ut_setup, ut_teardown,
9736 test_AES_GCM_authenticated_decryption_test_case_6),
9737 TEST_CASE_ST(ut_setup, ut_teardown,
9738 test_AES_GCM_authenticated_decryption_test_case_7),
9740 /** AES GCM Authenticated Encryption 192 bits key */
9741 TEST_CASE_ST(ut_setup, ut_teardown,
9742 test_AES_GCM_auth_encryption_test_case_192_1),
9743 TEST_CASE_ST(ut_setup, ut_teardown,
9744 test_AES_GCM_auth_encryption_test_case_192_2),
9745 TEST_CASE_ST(ut_setup, ut_teardown,
9746 test_AES_GCM_auth_encryption_test_case_192_3),
9747 TEST_CASE_ST(ut_setup, ut_teardown,
9748 test_AES_GCM_auth_encryption_test_case_192_4),
9749 TEST_CASE_ST(ut_setup, ut_teardown,
9750 test_AES_GCM_auth_encryption_test_case_192_5),
9751 TEST_CASE_ST(ut_setup, ut_teardown,
9752 test_AES_GCM_auth_encryption_test_case_192_6),
9753 TEST_CASE_ST(ut_setup, ut_teardown,
9754 test_AES_GCM_auth_encryption_test_case_192_7),
9756 /** AES GCM Authenticated Decryption 192 bits key */
9757 TEST_CASE_ST(ut_setup, ut_teardown,
9758 test_AES_GCM_auth_decryption_test_case_192_1),
9759 TEST_CASE_ST(ut_setup, ut_teardown,
9760 test_AES_GCM_auth_decryption_test_case_192_2),
9761 TEST_CASE_ST(ut_setup, ut_teardown,
9762 test_AES_GCM_auth_decryption_test_case_192_3),
9763 TEST_CASE_ST(ut_setup, ut_teardown,
9764 test_AES_GCM_auth_decryption_test_case_192_4),
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 test_AES_GCM_auth_decryption_test_case_192_5),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 test_AES_GCM_auth_decryption_test_case_192_6),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_AES_GCM_auth_decryption_test_case_192_7),
9772 /** AES GCM Authenticated Encryption 256 bits key */
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_AES_GCM_auth_encryption_test_case_256_1),
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_AES_GCM_auth_encryption_test_case_256_2),
9777 TEST_CASE_ST(ut_setup, ut_teardown,
9778 test_AES_GCM_auth_encryption_test_case_256_3),
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 test_AES_GCM_auth_encryption_test_case_256_4),
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 test_AES_GCM_auth_encryption_test_case_256_5),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_AES_GCM_auth_encryption_test_case_256_6),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_AES_GCM_auth_encryption_test_case_256_7),
9788 /** AES GCM Authenticated Decryption 256 bits key */
9789 TEST_CASE_ST(ut_setup, ut_teardown,
9790 test_AES_GCM_auth_decryption_test_case_256_1),
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_AES_GCM_auth_decryption_test_case_256_2),
9793 TEST_CASE_ST(ut_setup, ut_teardown,
9794 test_AES_GCM_auth_decryption_test_case_256_3),
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_AES_GCM_auth_decryption_test_case_256_4),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_AES_GCM_auth_decryption_test_case_256_5),
9799 TEST_CASE_ST(ut_setup, ut_teardown,
9800 test_AES_GCM_auth_decryption_test_case_256_6),
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_AES_GCM_auth_decryption_test_case_256_7),
9804 /** AES GCM Authenticated Encryption big aad size */
9805 TEST_CASE_ST(ut_setup, ut_teardown,
9806 test_AES_GCM_auth_encryption_test_case_aad_1),
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 test_AES_GCM_auth_encryption_test_case_aad_2),
9810 /** AES GCM Authenticated Decryption big aad size */
9811 TEST_CASE_ST(ut_setup, ut_teardown,
9812 test_AES_GCM_auth_decryption_test_case_aad_1),
9813 TEST_CASE_ST(ut_setup, ut_teardown,
9814 test_AES_GCM_auth_decryption_test_case_aad_2),
9816 /** AES GMAC Authentication */
9817 TEST_CASE_ST(ut_setup, ut_teardown,
9818 test_AES_GMAC_authentication_test_case_1),
9819 TEST_CASE_ST(ut_setup, ut_teardown,
9820 test_AES_GMAC_authentication_verify_test_case_1),
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_AES_GMAC_authentication_test_case_3),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_AES_GMAC_authentication_verify_test_case_3),
9825 TEST_CASE_ST(ut_setup, ut_teardown,
9826 test_AES_GMAC_authentication_test_case_4),
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_AES_GMAC_authentication_verify_test_case_4),
9830 /** Negative tests */
9831 TEST_CASE_ST(ut_setup, ut_teardown,
9832 authentication_verify_AES128_GMAC_fail_data_corrupt),
9833 TEST_CASE_ST(ut_setup, ut_teardown,
9834 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9836 /** Out of place tests */
9837 TEST_CASE_ST(ut_setup, ut_teardown,
9838 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9839 TEST_CASE_ST(ut_setup, ut_teardown,
9840 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9842 /** Session-less tests */
9843 TEST_CASE_ST(ut_setup, ut_teardown,
9844 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9845 TEST_CASE_ST(ut_setup, ut_teardown,
9846 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9848 /** Scatter-Gather */
9849 TEST_CASE_ST(ut_setup, ut_teardown,
9850 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9852 TEST_CASES_END() /**< NULL terminate unit test array */
9856 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9857 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9858 .setup = testsuite_setup,
9859 .teardown = testsuite_teardown,
9860 .unit_test_cases = {
9861 /** KASUMI encrypt only (UEA1) */
9862 TEST_CASE_ST(ut_setup, ut_teardown,
9863 test_kasumi_encryption_test_case_1),
9864 TEST_CASE_ST(ut_setup, ut_teardown,
9865 test_kasumi_encryption_test_case_1_sgl),
9866 TEST_CASE_ST(ut_setup, ut_teardown,
9867 test_kasumi_encryption_test_case_2),
9868 TEST_CASE_ST(ut_setup, ut_teardown,
9869 test_kasumi_encryption_test_case_3),
9870 TEST_CASE_ST(ut_setup, ut_teardown,
9871 test_kasumi_encryption_test_case_4),
9872 TEST_CASE_ST(ut_setup, ut_teardown,
9873 test_kasumi_encryption_test_case_5),
9874 /** KASUMI decrypt only (UEA1) */
9875 TEST_CASE_ST(ut_setup, ut_teardown,
9876 test_kasumi_decryption_test_case_1),
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 test_kasumi_decryption_test_case_2),
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 test_kasumi_decryption_test_case_3),
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 test_kasumi_decryption_test_case_4),
9883 TEST_CASE_ST(ut_setup, ut_teardown,
9884 test_kasumi_decryption_test_case_5),
9886 TEST_CASE_ST(ut_setup, ut_teardown,
9887 test_kasumi_encryption_test_case_1_oop),
9888 TEST_CASE_ST(ut_setup, ut_teardown,
9889 test_kasumi_encryption_test_case_1_oop_sgl),
9892 TEST_CASE_ST(ut_setup, ut_teardown,
9893 test_kasumi_decryption_test_case_1_oop),
9895 /** KASUMI hash only (UIA1) */
9896 TEST_CASE_ST(ut_setup, ut_teardown,
9897 test_kasumi_hash_generate_test_case_1),
9898 TEST_CASE_ST(ut_setup, ut_teardown,
9899 test_kasumi_hash_generate_test_case_2),
9900 TEST_CASE_ST(ut_setup, ut_teardown,
9901 test_kasumi_hash_generate_test_case_3),
9902 TEST_CASE_ST(ut_setup, ut_teardown,
9903 test_kasumi_hash_generate_test_case_4),
9904 TEST_CASE_ST(ut_setup, ut_teardown,
9905 test_kasumi_hash_generate_test_case_5),
9906 TEST_CASE_ST(ut_setup, ut_teardown,
9907 test_kasumi_hash_generate_test_case_6),
9908 TEST_CASE_ST(ut_setup, ut_teardown,
9909 test_kasumi_hash_verify_test_case_1),
9910 TEST_CASE_ST(ut_setup, ut_teardown,
9911 test_kasumi_hash_verify_test_case_2),
9912 TEST_CASE_ST(ut_setup, ut_teardown,
9913 test_kasumi_hash_verify_test_case_3),
9914 TEST_CASE_ST(ut_setup, ut_teardown,
9915 test_kasumi_hash_verify_test_case_4),
9916 TEST_CASE_ST(ut_setup, ut_teardown,
9917 test_kasumi_hash_verify_test_case_5),
9918 TEST_CASE_ST(ut_setup, ut_teardown,
9919 test_kasumi_auth_cipher_test_case_1),
9920 TEST_CASE_ST(ut_setup, ut_teardown,
9921 test_kasumi_cipher_auth_test_case_1),
9922 TEST_CASES_END() /**< NULL terminate unit test array */
9925 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9926 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9927 .setup = testsuite_setup,
9928 .teardown = testsuite_teardown,
9929 .unit_test_cases = {
9930 /** SNOW 3G encrypt only (UEA2) */
9931 TEST_CASE_ST(ut_setup, ut_teardown,
9932 test_snow3g_encryption_test_case_1),
9933 TEST_CASE_ST(ut_setup, ut_teardown,
9934 test_snow3g_encryption_test_case_2),
9935 TEST_CASE_ST(ut_setup, ut_teardown,
9936 test_snow3g_encryption_test_case_3),
9937 TEST_CASE_ST(ut_setup, ut_teardown,
9938 test_snow3g_encryption_test_case_4),
9939 TEST_CASE_ST(ut_setup, ut_teardown,
9940 test_snow3g_encryption_test_case_5),
9941 TEST_CASE_ST(ut_setup, ut_teardown,
9942 test_snow3g_auth_cipher_with_digest_test_case_1),
9944 TEST_CASE_ST(ut_setup, ut_teardown,
9945 test_snow3g_encryption_test_case_1_oop),
9946 TEST_CASE_ST(ut_setup, ut_teardown,
9947 test_snow3g_encryption_test_case_1_oop_sgl),
9948 TEST_CASE_ST(ut_setup, ut_teardown,
9949 test_snow3g_decryption_test_case_1_oop),
9951 TEST_CASE_ST(ut_setup, ut_teardown,
9952 test_snow3g_encryption_test_case_1_offset_oop),
9954 /** SNOW 3G decrypt only (UEA2) */
9955 TEST_CASE_ST(ut_setup, ut_teardown,
9956 test_snow3g_decryption_test_case_1),
9957 TEST_CASE_ST(ut_setup, ut_teardown,
9958 test_snow3g_decryption_test_case_2),
9959 TEST_CASE_ST(ut_setup, ut_teardown,
9960 test_snow3g_decryption_test_case_3),
9961 TEST_CASE_ST(ut_setup, ut_teardown,
9962 test_snow3g_decryption_test_case_4),
9963 TEST_CASE_ST(ut_setup, ut_teardown,
9964 test_snow3g_decryption_test_case_5),
9965 TEST_CASE_ST(ut_setup, ut_teardown,
9966 test_snow3g_decryption_with_digest_test_case_1),
9967 TEST_CASE_ST(ut_setup, ut_teardown,
9968 test_snow3g_hash_generate_test_case_1),
9969 TEST_CASE_ST(ut_setup, ut_teardown,
9970 test_snow3g_hash_generate_test_case_2),
9971 TEST_CASE_ST(ut_setup, ut_teardown,
9972 test_snow3g_hash_generate_test_case_3),
9973 /* Tests with buffers which length is not byte-aligned */
9974 TEST_CASE_ST(ut_setup, ut_teardown,
9975 test_snow3g_hash_generate_test_case_4),
9976 TEST_CASE_ST(ut_setup, ut_teardown,
9977 test_snow3g_hash_generate_test_case_5),
9978 TEST_CASE_ST(ut_setup, ut_teardown,
9979 test_snow3g_hash_generate_test_case_6),
9980 TEST_CASE_ST(ut_setup, ut_teardown,
9981 test_snow3g_hash_verify_test_case_1),
9982 TEST_CASE_ST(ut_setup, ut_teardown,
9983 test_snow3g_hash_verify_test_case_2),
9984 TEST_CASE_ST(ut_setup, ut_teardown,
9985 test_snow3g_hash_verify_test_case_3),
9986 /* Tests with buffers which length is not byte-aligned */
9987 TEST_CASE_ST(ut_setup, ut_teardown,
9988 test_snow3g_hash_verify_test_case_4),
9989 TEST_CASE_ST(ut_setup, ut_teardown,
9990 test_snow3g_hash_verify_test_case_5),
9991 TEST_CASE_ST(ut_setup, ut_teardown,
9992 test_snow3g_hash_verify_test_case_6),
9993 TEST_CASE_ST(ut_setup, ut_teardown,
9994 test_snow3g_cipher_auth_test_case_1),
9995 TEST_CASE_ST(ut_setup, ut_teardown,
9996 test_snow3g_auth_cipher_test_case_1),
9998 TEST_CASES_END() /**< NULL terminate unit test array */
10002 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
10003 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
10004 .setup = testsuite_setup,
10005 .teardown = testsuite_teardown,
10006 .unit_test_cases = {
10007 /** ZUC encrypt only (EEA3) */
10008 TEST_CASE_ST(ut_setup, ut_teardown,
10009 test_zuc_encryption_test_case_1),
10010 TEST_CASE_ST(ut_setup, ut_teardown,
10011 test_zuc_encryption_test_case_2),
10012 TEST_CASE_ST(ut_setup, ut_teardown,
10013 test_zuc_encryption_test_case_3),
10014 TEST_CASE_ST(ut_setup, ut_teardown,
10015 test_zuc_encryption_test_case_4),
10016 TEST_CASE_ST(ut_setup, ut_teardown,
10017 test_zuc_encryption_test_case_5),
10018 TEST_CASE_ST(ut_setup, ut_teardown,
10019 test_zuc_hash_generate_test_case_1),
10020 TEST_CASE_ST(ut_setup, ut_teardown,
10021 test_zuc_hash_generate_test_case_2),
10022 TEST_CASE_ST(ut_setup, ut_teardown,
10023 test_zuc_hash_generate_test_case_3),
10024 TEST_CASE_ST(ut_setup, ut_teardown,
10025 test_zuc_hash_generate_test_case_4),
10026 TEST_CASE_ST(ut_setup, ut_teardown,
10027 test_zuc_hash_generate_test_case_5),
10028 TEST_CASE_ST(ut_setup, ut_teardown,
10029 test_zuc_encryption_test_case_6_sgl),
10030 TEST_CASES_END() /**< NULL terminate unit test array */
10034 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
10035 .suite_name = "Crypto CAAM JR Unit Test Suite",
10036 .setup = testsuite_setup,
10037 .teardown = testsuite_teardown,
10038 .unit_test_cases = {
10039 TEST_CASE_ST(ut_setup, ut_teardown,
10040 test_device_configure_invalid_dev_id),
10041 TEST_CASE_ST(ut_setup, ut_teardown,
10042 test_multi_session),
10044 TEST_CASE_ST(ut_setup, ut_teardown,
10045 test_AES_chain_caam_jr_all),
10046 TEST_CASE_ST(ut_setup, ut_teardown,
10047 test_3DES_chain_caam_jr_all),
10048 TEST_CASE_ST(ut_setup, ut_teardown,
10049 test_AES_cipheronly_caam_jr_all),
10050 TEST_CASE_ST(ut_setup, ut_teardown,
10051 test_3DES_cipheronly_caam_jr_all),
10052 TEST_CASE_ST(ut_setup, ut_teardown,
10053 test_authonly_caam_jr_all),
10055 TEST_CASES_END() /**< NULL terminate unit test array */
10059 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
10060 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
10061 .setup = testsuite_setup,
10062 .teardown = testsuite_teardown,
10063 .unit_test_cases = {
10064 TEST_CASE_ST(ut_setup, ut_teardown,
10065 test_device_configure_invalid_dev_id),
10066 TEST_CASE_ST(ut_setup, ut_teardown,
10067 test_multi_session),
10069 TEST_CASE_ST(ut_setup, ut_teardown,
10070 test_AES_chain_dpaa_sec_all),
10071 TEST_CASE_ST(ut_setup, ut_teardown,
10072 test_3DES_chain_dpaa_sec_all),
10073 TEST_CASE_ST(ut_setup, ut_teardown,
10074 test_AES_cipheronly_dpaa_sec_all),
10075 TEST_CASE_ST(ut_setup, ut_teardown,
10076 test_3DES_cipheronly_dpaa_sec_all),
10077 TEST_CASE_ST(ut_setup, ut_teardown,
10078 test_authonly_dpaa_sec_all),
10080 /** AES GCM Authenticated Encryption */
10081 TEST_CASE_ST(ut_setup, ut_teardown,
10082 test_AES_GCM_authenticated_encryption_test_case_1),
10083 TEST_CASE_ST(ut_setup, ut_teardown,
10084 test_AES_GCM_authenticated_encryption_test_case_2),
10085 TEST_CASE_ST(ut_setup, ut_teardown,
10086 test_AES_GCM_authenticated_encryption_test_case_3),
10087 TEST_CASE_ST(ut_setup, ut_teardown,
10088 test_AES_GCM_authenticated_encryption_test_case_4),
10089 TEST_CASE_ST(ut_setup, ut_teardown,
10090 test_AES_GCM_authenticated_encryption_test_case_5),
10091 TEST_CASE_ST(ut_setup, ut_teardown,
10092 test_AES_GCM_authenticated_encryption_test_case_6),
10093 TEST_CASE_ST(ut_setup, ut_teardown,
10094 test_AES_GCM_authenticated_encryption_test_case_7),
10096 /** AES GCM Authenticated Decryption */
10097 TEST_CASE_ST(ut_setup, ut_teardown,
10098 test_AES_GCM_authenticated_decryption_test_case_1),
10099 TEST_CASE_ST(ut_setup, ut_teardown,
10100 test_AES_GCM_authenticated_decryption_test_case_2),
10101 TEST_CASE_ST(ut_setup, ut_teardown,
10102 test_AES_GCM_authenticated_decryption_test_case_3),
10103 TEST_CASE_ST(ut_setup, ut_teardown,
10104 test_AES_GCM_authenticated_decryption_test_case_4),
10105 TEST_CASE_ST(ut_setup, ut_teardown,
10106 test_AES_GCM_authenticated_decryption_test_case_5),
10107 TEST_CASE_ST(ut_setup, ut_teardown,
10108 test_AES_GCM_authenticated_decryption_test_case_6),
10109 TEST_CASE_ST(ut_setup, ut_teardown,
10110 test_AES_GCM_authenticated_decryption_test_case_7),
10112 /** AES GCM Authenticated Encryption 256 bits key */
10113 TEST_CASE_ST(ut_setup, ut_teardown,
10114 test_AES_GCM_auth_encryption_test_case_256_1),
10115 TEST_CASE_ST(ut_setup, ut_teardown,
10116 test_AES_GCM_auth_encryption_test_case_256_2),
10117 TEST_CASE_ST(ut_setup, ut_teardown,
10118 test_AES_GCM_auth_encryption_test_case_256_3),
10119 TEST_CASE_ST(ut_setup, ut_teardown,
10120 test_AES_GCM_auth_encryption_test_case_256_4),
10121 TEST_CASE_ST(ut_setup, ut_teardown,
10122 test_AES_GCM_auth_encryption_test_case_256_5),
10123 TEST_CASE_ST(ut_setup, ut_teardown,
10124 test_AES_GCM_auth_encryption_test_case_256_6),
10125 TEST_CASE_ST(ut_setup, ut_teardown,
10126 test_AES_GCM_auth_encryption_test_case_256_7),
10128 /** AES GCM Authenticated Decryption 256 bits key */
10129 TEST_CASE_ST(ut_setup, ut_teardown,
10130 test_AES_GCM_auth_decryption_test_case_256_1),
10131 TEST_CASE_ST(ut_setup, ut_teardown,
10132 test_AES_GCM_auth_decryption_test_case_256_2),
10133 TEST_CASE_ST(ut_setup, ut_teardown,
10134 test_AES_GCM_auth_decryption_test_case_256_3),
10135 TEST_CASE_ST(ut_setup, ut_teardown,
10136 test_AES_GCM_auth_decryption_test_case_256_4),
10137 TEST_CASE_ST(ut_setup, ut_teardown,
10138 test_AES_GCM_auth_decryption_test_case_256_5),
10139 TEST_CASE_ST(ut_setup, ut_teardown,
10140 test_AES_GCM_auth_decryption_test_case_256_6),
10141 TEST_CASE_ST(ut_setup, ut_teardown,
10142 test_AES_GCM_auth_decryption_test_case_256_7),
10144 /** Out of place tests */
10145 TEST_CASE_ST(ut_setup, ut_teardown,
10146 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10147 TEST_CASE_ST(ut_setup, ut_teardown,
10148 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10150 /** Scatter-Gather */
10151 TEST_CASE_ST(ut_setup, ut_teardown,
10152 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10153 TEST_CASE_ST(ut_setup, ut_teardown,
10154 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10155 TEST_CASE_ST(ut_setup, ut_teardown,
10156 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10157 TEST_CASE_ST(ut_setup, ut_teardown,
10158 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10160 TEST_CASES_END() /**< NULL terminate unit test array */
10164 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10165 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10166 .setup = testsuite_setup,
10167 .teardown = testsuite_teardown,
10168 .unit_test_cases = {
10169 TEST_CASE_ST(ut_setup, ut_teardown,
10170 test_device_configure_invalid_dev_id),
10171 TEST_CASE_ST(ut_setup, ut_teardown,
10172 test_multi_session),
10174 TEST_CASE_ST(ut_setup, ut_teardown,
10175 test_AES_chain_dpaa2_sec_all),
10176 TEST_CASE_ST(ut_setup, ut_teardown,
10177 test_3DES_chain_dpaa2_sec_all),
10178 TEST_CASE_ST(ut_setup, ut_teardown,
10179 test_AES_cipheronly_dpaa2_sec_all),
10180 TEST_CASE_ST(ut_setup, ut_teardown,
10181 test_3DES_cipheronly_dpaa2_sec_all),
10182 TEST_CASE_ST(ut_setup, ut_teardown,
10183 test_authonly_dpaa2_sec_all),
10185 /** AES GCM Authenticated Encryption */
10186 TEST_CASE_ST(ut_setup, ut_teardown,
10187 test_AES_GCM_authenticated_encryption_test_case_1),
10188 TEST_CASE_ST(ut_setup, ut_teardown,
10189 test_AES_GCM_authenticated_encryption_test_case_2),
10190 TEST_CASE_ST(ut_setup, ut_teardown,
10191 test_AES_GCM_authenticated_encryption_test_case_3),
10192 TEST_CASE_ST(ut_setup, ut_teardown,
10193 test_AES_GCM_authenticated_encryption_test_case_4),
10194 TEST_CASE_ST(ut_setup, ut_teardown,
10195 test_AES_GCM_authenticated_encryption_test_case_5),
10196 TEST_CASE_ST(ut_setup, ut_teardown,
10197 test_AES_GCM_authenticated_encryption_test_case_6),
10198 TEST_CASE_ST(ut_setup, ut_teardown,
10199 test_AES_GCM_authenticated_encryption_test_case_7),
10201 /** AES GCM Authenticated Decryption */
10202 TEST_CASE_ST(ut_setup, ut_teardown,
10203 test_AES_GCM_authenticated_decryption_test_case_1),
10204 TEST_CASE_ST(ut_setup, ut_teardown,
10205 test_AES_GCM_authenticated_decryption_test_case_2),
10206 TEST_CASE_ST(ut_setup, ut_teardown,
10207 test_AES_GCM_authenticated_decryption_test_case_3),
10208 TEST_CASE_ST(ut_setup, ut_teardown,
10209 test_AES_GCM_authenticated_decryption_test_case_4),
10210 TEST_CASE_ST(ut_setup, ut_teardown,
10211 test_AES_GCM_authenticated_decryption_test_case_5),
10212 TEST_CASE_ST(ut_setup, ut_teardown,
10213 test_AES_GCM_authenticated_decryption_test_case_6),
10214 TEST_CASE_ST(ut_setup, ut_teardown,
10215 test_AES_GCM_authenticated_decryption_test_case_7),
10217 /** AES GCM Authenticated Encryption 192 bits key */
10218 TEST_CASE_ST(ut_setup, ut_teardown,
10219 test_AES_GCM_auth_encryption_test_case_192_1),
10220 TEST_CASE_ST(ut_setup, ut_teardown,
10221 test_AES_GCM_auth_encryption_test_case_192_2),
10222 TEST_CASE_ST(ut_setup, ut_teardown,
10223 test_AES_GCM_auth_encryption_test_case_192_3),
10224 TEST_CASE_ST(ut_setup, ut_teardown,
10225 test_AES_GCM_auth_encryption_test_case_192_4),
10226 TEST_CASE_ST(ut_setup, ut_teardown,
10227 test_AES_GCM_auth_encryption_test_case_192_5),
10228 TEST_CASE_ST(ut_setup, ut_teardown,
10229 test_AES_GCM_auth_encryption_test_case_192_6),
10230 TEST_CASE_ST(ut_setup, ut_teardown,
10231 test_AES_GCM_auth_encryption_test_case_192_7),
10233 /** AES GCM Authenticated Decryption 192 bits key */
10234 TEST_CASE_ST(ut_setup, ut_teardown,
10235 test_AES_GCM_auth_decryption_test_case_192_1),
10236 TEST_CASE_ST(ut_setup, ut_teardown,
10237 test_AES_GCM_auth_decryption_test_case_192_2),
10238 TEST_CASE_ST(ut_setup, ut_teardown,
10239 test_AES_GCM_auth_decryption_test_case_192_3),
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 test_AES_GCM_auth_decryption_test_case_192_4),
10242 TEST_CASE_ST(ut_setup, ut_teardown,
10243 test_AES_GCM_auth_decryption_test_case_192_5),
10244 TEST_CASE_ST(ut_setup, ut_teardown,
10245 test_AES_GCM_auth_decryption_test_case_192_6),
10246 TEST_CASE_ST(ut_setup, ut_teardown,
10247 test_AES_GCM_auth_decryption_test_case_192_7),
10249 /** AES GCM Authenticated Encryption 256 bits key */
10250 TEST_CASE_ST(ut_setup, ut_teardown,
10251 test_AES_GCM_auth_encryption_test_case_256_1),
10252 TEST_CASE_ST(ut_setup, ut_teardown,
10253 test_AES_GCM_auth_encryption_test_case_256_2),
10254 TEST_CASE_ST(ut_setup, ut_teardown,
10255 test_AES_GCM_auth_encryption_test_case_256_3),
10256 TEST_CASE_ST(ut_setup, ut_teardown,
10257 test_AES_GCM_auth_encryption_test_case_256_4),
10258 TEST_CASE_ST(ut_setup, ut_teardown,
10259 test_AES_GCM_auth_encryption_test_case_256_5),
10260 TEST_CASE_ST(ut_setup, ut_teardown,
10261 test_AES_GCM_auth_encryption_test_case_256_6),
10262 TEST_CASE_ST(ut_setup, ut_teardown,
10263 test_AES_GCM_auth_encryption_test_case_256_7),
10265 /** AES GCM Authenticated Decryption 256 bits key */
10266 TEST_CASE_ST(ut_setup, ut_teardown,
10267 test_AES_GCM_auth_decryption_test_case_256_1),
10268 TEST_CASE_ST(ut_setup, ut_teardown,
10269 test_AES_GCM_auth_decryption_test_case_256_2),
10270 TEST_CASE_ST(ut_setup, ut_teardown,
10271 test_AES_GCM_auth_decryption_test_case_256_3),
10272 TEST_CASE_ST(ut_setup, ut_teardown,
10273 test_AES_GCM_auth_decryption_test_case_256_4),
10274 TEST_CASE_ST(ut_setup, ut_teardown,
10275 test_AES_GCM_auth_decryption_test_case_256_5),
10276 TEST_CASE_ST(ut_setup, ut_teardown,
10277 test_AES_GCM_auth_decryption_test_case_256_6),
10278 TEST_CASE_ST(ut_setup, ut_teardown,
10279 test_AES_GCM_auth_decryption_test_case_256_7),
10281 /** Out of place tests */
10282 TEST_CASE_ST(ut_setup, ut_teardown,
10283 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10284 TEST_CASE_ST(ut_setup, ut_teardown,
10285 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10287 /** Scatter-Gather */
10288 TEST_CASE_ST(ut_setup, ut_teardown,
10289 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10290 TEST_CASE_ST(ut_setup, ut_teardown,
10291 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10292 TEST_CASE_ST(ut_setup, ut_teardown,
10293 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10294 TEST_CASE_ST(ut_setup, ut_teardown,
10295 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10297 TEST_CASES_END() /**< NULL terminate unit test array */
10301 static struct unit_test_suite cryptodev_null_testsuite = {
10302 .suite_name = "Crypto Device NULL Unit Test Suite",
10303 .setup = testsuite_setup,
10304 .teardown = testsuite_teardown,
10305 .unit_test_cases = {
10306 TEST_CASE_ST(ut_setup, ut_teardown,
10307 test_null_auth_only_operation),
10308 TEST_CASE_ST(ut_setup, ut_teardown,
10309 test_null_cipher_only_operation),
10310 TEST_CASE_ST(ut_setup, ut_teardown,
10311 test_null_cipher_auth_operation),
10312 TEST_CASE_ST(ut_setup, ut_teardown,
10313 test_null_auth_cipher_operation),
10314 TEST_CASE_ST(ut_setup, ut_teardown,
10315 test_null_invalid_operation),
10316 TEST_CASE_ST(ut_setup, ut_teardown,
10317 test_null_burst_operation),
10319 TEST_CASES_END() /**< NULL terminate unit test array */
10323 static struct unit_test_suite cryptodev_armv8_testsuite = {
10324 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10325 .setup = testsuite_setup,
10326 .teardown = testsuite_teardown,
10327 .unit_test_cases = {
10328 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10330 /** Negative tests */
10331 TEST_CASE_ST(ut_setup, ut_teardown,
10332 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10333 TEST_CASE_ST(ut_setup, ut_teardown,
10334 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10336 TEST_CASES_END() /**< NULL terminate unit test array */
10340 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10341 .suite_name = "Crypto Device Marvell Component Test Suite",
10342 .setup = testsuite_setup,
10343 .teardown = testsuite_teardown,
10344 .unit_test_cases = {
10345 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10346 TEST_CASE_ST(ut_setup, ut_teardown,
10347 test_multi_session_random_usage),
10348 TEST_CASE_ST(ut_setup, ut_teardown,
10349 test_AES_chain_mrvl_all),
10350 TEST_CASE_ST(ut_setup, ut_teardown,
10351 test_AES_cipheronly_mrvl_all),
10352 TEST_CASE_ST(ut_setup, ut_teardown,
10353 test_authonly_mrvl_all),
10354 TEST_CASE_ST(ut_setup, ut_teardown,
10355 test_3DES_chain_mrvl_all),
10356 TEST_CASE_ST(ut_setup, ut_teardown,
10357 test_3DES_cipheronly_mrvl_all),
10359 /** Negative tests */
10360 TEST_CASE_ST(ut_setup, ut_teardown,
10361 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10362 TEST_CASE_ST(ut_setup, ut_teardown,
10363 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10364 TEST_CASE_ST(ut_setup, ut_teardown,
10365 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10366 TEST_CASE_ST(ut_setup, ut_teardown,
10367 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10369 TEST_CASES_END() /**< NULL terminate unit test array */
10373 static struct unit_test_suite cryptodev_ccp_testsuite = {
10374 .suite_name = "Crypto Device CCP Unit Test Suite",
10375 .setup = testsuite_setup,
10376 .teardown = testsuite_teardown,
10377 .unit_test_cases = {
10378 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10379 TEST_CASE_ST(ut_setup, ut_teardown,
10380 test_multi_session_random_usage),
10381 TEST_CASE_ST(ut_setup, ut_teardown,
10382 test_AES_chain_ccp_all),
10383 TEST_CASE_ST(ut_setup, ut_teardown,
10384 test_AES_cipheronly_ccp_all),
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 test_3DES_chain_ccp_all),
10387 TEST_CASE_ST(ut_setup, ut_teardown,
10388 test_3DES_cipheronly_ccp_all),
10389 TEST_CASE_ST(ut_setup, ut_teardown,
10390 test_authonly_ccp_all),
10392 /** Negative tests */
10393 TEST_CASE_ST(ut_setup, ut_teardown,
10394 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10395 TEST_CASE_ST(ut_setup, ut_teardown,
10396 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10397 TEST_CASE_ST(ut_setup, ut_teardown,
10398 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10399 TEST_CASE_ST(ut_setup, ut_teardown,
10400 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10402 TEST_CASES_END() /**< NULL terminate unit test array */
10406 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10407 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10408 .setup = testsuite_setup,
10409 .teardown = testsuite_teardown,
10410 .unit_test_cases = {
10411 TEST_CASE_ST(ut_setup, ut_teardown,
10412 test_AES_chain_octeontx_all),
10413 TEST_CASE_ST(ut_setup, ut_teardown,
10414 test_AES_cipheronly_octeontx_all),
10415 TEST_CASE_ST(ut_setup, ut_teardown,
10416 test_3DES_chain_octeontx_all),
10417 TEST_CASE_ST(ut_setup, ut_teardown,
10418 test_3DES_cipheronly_octeontx_all),
10419 TEST_CASE_ST(ut_setup, ut_teardown,
10420 test_authonly_octeontx_all),
10422 /** AES GCM Authenticated Encryption */
10423 TEST_CASE_ST(ut_setup, ut_teardown,
10424 test_AES_GCM_authenticated_encryption_test_case_1),
10425 TEST_CASE_ST(ut_setup, ut_teardown,
10426 test_AES_GCM_authenticated_encryption_test_case_2),
10427 TEST_CASE_ST(ut_setup, ut_teardown,
10428 test_AES_GCM_authenticated_encryption_test_case_3),
10429 TEST_CASE_ST(ut_setup, ut_teardown,
10430 test_AES_GCM_authenticated_encryption_test_case_4),
10431 TEST_CASE_ST(ut_setup, ut_teardown,
10432 test_AES_GCM_authenticated_encryption_test_case_5),
10433 TEST_CASE_ST(ut_setup, ut_teardown,
10434 test_AES_GCM_authenticated_encryption_test_case_6),
10435 TEST_CASE_ST(ut_setup, ut_teardown,
10436 test_AES_GCM_authenticated_encryption_test_case_7),
10438 /** AES GCM Authenticated Decryption */
10439 TEST_CASE_ST(ut_setup, ut_teardown,
10440 test_AES_GCM_authenticated_decryption_test_case_1),
10441 TEST_CASE_ST(ut_setup, ut_teardown,
10442 test_AES_GCM_authenticated_decryption_test_case_2),
10443 TEST_CASE_ST(ut_setup, ut_teardown,
10444 test_AES_GCM_authenticated_decryption_test_case_3),
10445 TEST_CASE_ST(ut_setup, ut_teardown,
10446 test_AES_GCM_authenticated_decryption_test_case_4),
10447 TEST_CASE_ST(ut_setup, ut_teardown,
10448 test_AES_GCM_authenticated_decryption_test_case_5),
10449 TEST_CASE_ST(ut_setup, ut_teardown,
10450 test_AES_GCM_authenticated_decryption_test_case_6),
10451 TEST_CASE_ST(ut_setup, ut_teardown,
10452 test_AES_GCM_authenticated_decryption_test_case_7),
10453 /** AES GMAC Authentication */
10454 TEST_CASE_ST(ut_setup, ut_teardown,
10455 test_AES_GMAC_authentication_test_case_1),
10456 TEST_CASE_ST(ut_setup, ut_teardown,
10457 test_AES_GMAC_authentication_verify_test_case_1),
10458 TEST_CASE_ST(ut_setup, ut_teardown,
10459 test_AES_GMAC_authentication_test_case_2),
10460 TEST_CASE_ST(ut_setup, ut_teardown,
10461 test_AES_GMAC_authentication_verify_test_case_2),
10462 TEST_CASE_ST(ut_setup, ut_teardown,
10463 test_AES_GMAC_authentication_test_case_3),
10464 TEST_CASE_ST(ut_setup, ut_teardown,
10465 test_AES_GMAC_authentication_verify_test_case_3),
10467 /** SNOW 3G encrypt only (UEA2) */
10468 TEST_CASE_ST(ut_setup, ut_teardown,
10469 test_snow3g_encryption_test_case_1),
10470 TEST_CASE_ST(ut_setup, ut_teardown,
10471 test_snow3g_encryption_test_case_2),
10472 TEST_CASE_ST(ut_setup, ut_teardown,
10473 test_snow3g_encryption_test_case_3),
10474 TEST_CASE_ST(ut_setup, ut_teardown,
10475 test_snow3g_encryption_test_case_4),
10476 TEST_CASE_ST(ut_setup, ut_teardown,
10477 test_snow3g_encryption_test_case_5),
10479 TEST_CASE_ST(ut_setup, ut_teardown,
10480 test_snow3g_encryption_test_case_1_oop),
10481 TEST_CASE_ST(ut_setup, ut_teardown,
10482 test_snow3g_decryption_test_case_1_oop),
10483 TEST_CASE_ST(ut_setup, ut_teardown,
10484 test_snow3g_encryption_test_case_1_oop_sgl),
10486 /** SNOW 3G decrypt only (UEA2) */
10487 TEST_CASE_ST(ut_setup, ut_teardown,
10488 test_snow3g_decryption_test_case_1),
10489 TEST_CASE_ST(ut_setup, ut_teardown,
10490 test_snow3g_decryption_test_case_2),
10491 TEST_CASE_ST(ut_setup, ut_teardown,
10492 test_snow3g_decryption_test_case_3),
10493 TEST_CASE_ST(ut_setup, ut_teardown,
10494 test_snow3g_decryption_test_case_4),
10495 TEST_CASE_ST(ut_setup, ut_teardown,
10496 test_snow3g_decryption_test_case_5),
10498 TEST_CASE_ST(ut_setup, ut_teardown,
10499 test_snow3g_hash_generate_test_case_1),
10500 TEST_CASE_ST(ut_setup, ut_teardown,
10501 test_snow3g_hash_generate_test_case_2),
10502 TEST_CASE_ST(ut_setup, ut_teardown,
10503 test_snow3g_hash_generate_test_case_3),
10504 TEST_CASE_ST(ut_setup, ut_teardown,
10505 test_snow3g_hash_verify_test_case_1),
10506 TEST_CASE_ST(ut_setup, ut_teardown,
10507 test_snow3g_hash_verify_test_case_2),
10508 TEST_CASE_ST(ut_setup, ut_teardown,
10509 test_snow3g_hash_verify_test_case_3),
10511 /** ZUC encrypt only (EEA3) */
10512 TEST_CASE_ST(ut_setup, ut_teardown,
10513 test_zuc_encryption_test_case_1),
10514 TEST_CASE_ST(ut_setup, ut_teardown,
10515 test_zuc_encryption_test_case_2),
10516 TEST_CASE_ST(ut_setup, ut_teardown,
10517 test_zuc_encryption_test_case_3),
10518 TEST_CASE_ST(ut_setup, ut_teardown,
10519 test_zuc_encryption_test_case_4),
10520 TEST_CASE_ST(ut_setup, ut_teardown,
10521 test_zuc_encryption_test_case_5),
10522 TEST_CASE_ST(ut_setup, ut_teardown,
10523 test_zuc_hash_generate_test_case_1),
10524 TEST_CASE_ST(ut_setup, ut_teardown,
10525 test_zuc_hash_generate_test_case_2),
10526 TEST_CASE_ST(ut_setup, ut_teardown,
10527 test_zuc_hash_generate_test_case_3),
10528 TEST_CASE_ST(ut_setup, ut_teardown,
10529 test_zuc_hash_generate_test_case_4),
10530 TEST_CASE_ST(ut_setup, ut_teardown,
10531 test_zuc_hash_generate_test_case_5),
10532 TEST_CASE_ST(ut_setup, ut_teardown,
10533 test_zuc_encryption_test_case_6_sgl),
10535 /** KASUMI encrypt only (UEA1) */
10536 TEST_CASE_ST(ut_setup, ut_teardown,
10537 test_kasumi_encryption_test_case_1),
10538 TEST_CASE_ST(ut_setup, ut_teardown,
10539 test_kasumi_encryption_test_case_2),
10540 TEST_CASE_ST(ut_setup, ut_teardown,
10541 test_kasumi_encryption_test_case_3),
10542 TEST_CASE_ST(ut_setup, ut_teardown,
10543 test_kasumi_encryption_test_case_4),
10544 TEST_CASE_ST(ut_setup, ut_teardown,
10545 test_kasumi_encryption_test_case_5),
10546 TEST_CASE_ST(ut_setup, ut_teardown,
10547 test_kasumi_encryption_test_case_1_sgl),
10548 TEST_CASE_ST(ut_setup, ut_teardown,
10549 test_kasumi_encryption_test_case_1_oop_sgl),
10550 /** KASUMI decrypt only (UEA1) */
10551 TEST_CASE_ST(ut_setup, ut_teardown,
10552 test_kasumi_decryption_test_case_1),
10553 TEST_CASE_ST(ut_setup, ut_teardown,
10554 test_kasumi_decryption_test_case_2),
10555 TEST_CASE_ST(ut_setup, ut_teardown,
10556 test_kasumi_decryption_test_case_3),
10557 TEST_CASE_ST(ut_setup, ut_teardown,
10558 test_kasumi_decryption_test_case_4),
10559 TEST_CASE_ST(ut_setup, ut_teardown,
10560 test_kasumi_decryption_test_case_5),
10562 TEST_CASE_ST(ut_setup, ut_teardown,
10563 test_kasumi_encryption_test_case_1_oop),
10564 TEST_CASE_ST(ut_setup, ut_teardown,
10565 test_kasumi_decryption_test_case_1_oop),
10567 /** KASUMI hash only (UIA1) */
10568 TEST_CASE_ST(ut_setup, ut_teardown,
10569 test_kasumi_hash_generate_test_case_1),
10570 TEST_CASE_ST(ut_setup, ut_teardown,
10571 test_kasumi_hash_generate_test_case_2),
10572 TEST_CASE_ST(ut_setup, ut_teardown,
10573 test_kasumi_hash_generate_test_case_3),
10574 TEST_CASE_ST(ut_setup, ut_teardown,
10575 test_kasumi_hash_generate_test_case_4),
10576 TEST_CASE_ST(ut_setup, ut_teardown,
10577 test_kasumi_hash_generate_test_case_5),
10578 TEST_CASE_ST(ut_setup, ut_teardown,
10579 test_kasumi_hash_generate_test_case_6),
10580 TEST_CASE_ST(ut_setup, ut_teardown,
10581 test_kasumi_hash_verify_test_case_1),
10582 TEST_CASE_ST(ut_setup, ut_teardown,
10583 test_kasumi_hash_verify_test_case_2),
10584 TEST_CASE_ST(ut_setup, ut_teardown,
10585 test_kasumi_hash_verify_test_case_3),
10586 TEST_CASE_ST(ut_setup, ut_teardown,
10587 test_kasumi_hash_verify_test_case_4),
10588 TEST_CASE_ST(ut_setup, ut_teardown,
10589 test_kasumi_hash_verify_test_case_5),
10592 TEST_CASE_ST(ut_setup, ut_teardown,
10593 test_null_cipher_only_operation),
10594 TEST_CASE_ST(ut_setup, ut_teardown,
10595 test_null_auth_only_operation),
10596 TEST_CASE_ST(ut_setup, ut_teardown,
10597 test_null_cipher_auth_operation),
10598 TEST_CASE_ST(ut_setup, ut_teardown,
10599 test_null_auth_cipher_operation),
10601 /** Negative tests */
10602 TEST_CASE_ST(ut_setup, ut_teardown,
10603 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10604 TEST_CASE_ST(ut_setup, ut_teardown,
10605 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10606 TEST_CASE_ST(ut_setup, ut_teardown,
10607 authentication_verify_AES128_GMAC_fail_data_corrupt),
10608 TEST_CASE_ST(ut_setup, ut_teardown,
10609 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10610 TEST_CASE_ST(ut_setup, ut_teardown,
10611 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10612 TEST_CASE_ST(ut_setup, ut_teardown,
10613 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10614 TEST_CASES_END() /**< NULL terminate unit test array */
10619 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10621 gbl_driver_id = rte_cryptodev_driver_id_get(
10622 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10624 if (gbl_driver_id == -1) {
10625 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10626 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10627 "are enabled in config file to run this testsuite.\n");
10628 return TEST_SKIPPED;
10631 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10635 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10637 gbl_driver_id = rte_cryptodev_driver_id_get(
10638 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10640 if (gbl_driver_id == -1) {
10641 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10642 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10643 "in config file to run this testsuite.\n");
10644 return TEST_FAILED;
10647 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10651 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10653 gbl_driver_id = rte_cryptodev_driver_id_get(
10654 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10656 if (gbl_driver_id == -1) {
10657 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10658 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10659 "in config file to run this testsuite.\n");
10660 return TEST_SKIPPED;
10663 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10667 test_cryptodev_openssl(void)
10669 gbl_driver_id = rte_cryptodev_driver_id_get(
10670 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10672 if (gbl_driver_id == -1) {
10673 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10674 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10675 "in config file to run this testsuite.\n");
10676 return TEST_SKIPPED;
10679 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10683 test_cryptodev_aesni_gcm(void)
10685 gbl_driver_id = rte_cryptodev_driver_id_get(
10686 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10688 if (gbl_driver_id == -1) {
10689 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10690 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10691 "in config file to run this testsuite.\n");
10692 return TEST_SKIPPED;
10695 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10699 test_cryptodev_null(void)
10701 gbl_driver_id = rte_cryptodev_driver_id_get(
10702 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10704 if (gbl_driver_id == -1) {
10705 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10706 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10707 "in config file to run this testsuite.\n");
10708 return TEST_SKIPPED;
10711 return unit_test_suite_runner(&cryptodev_null_testsuite);
10715 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10717 gbl_driver_id = rte_cryptodev_driver_id_get(
10718 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10720 if (gbl_driver_id == -1) {
10721 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10722 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10723 "in config file to run this testsuite.\n");
10724 return TEST_SKIPPED;
10727 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10731 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10733 gbl_driver_id = rte_cryptodev_driver_id_get(
10734 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10736 if (gbl_driver_id == -1) {
10737 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10738 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10739 "in config file to run this testsuite.\n");
10740 return TEST_SKIPPED;
10743 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10747 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10749 gbl_driver_id = rte_cryptodev_driver_id_get(
10750 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10752 if (gbl_driver_id == -1) {
10753 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10754 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10755 "in config file to run this testsuite.\n");
10756 return TEST_SKIPPED;
10759 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10763 test_cryptodev_armv8(void)
10765 gbl_driver_id = rte_cryptodev_driver_id_get(
10766 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10768 if (gbl_driver_id == -1) {
10769 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10770 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10771 "in config file to run this testsuite.\n");
10772 return TEST_SKIPPED;
10775 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10779 test_cryptodev_mrvl(void)
10781 gbl_driver_id = rte_cryptodev_driver_id_get(
10782 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10784 if (gbl_driver_id == -1) {
10785 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10786 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10787 "in config file to run this testsuite.\n");
10788 return TEST_SKIPPED;
10791 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10794 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10797 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10799 gbl_driver_id = rte_cryptodev_driver_id_get(
10800 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10802 if (gbl_driver_id == -1) {
10803 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10804 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10805 "in config file to run this testsuite.\n");
10806 return TEST_SKIPPED;
10809 if (rte_cryptodev_driver_id_get(
10810 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10811 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10812 " enabled in config file to run this testsuite.\n");
10813 return TEST_SKIPPED;
10815 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10818 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10823 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10825 gbl_driver_id = rte_cryptodev_driver_id_get(
10826 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10828 if (gbl_driver_id == -1) {
10829 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10830 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10831 "in config file to run this testsuite.\n");
10832 return TEST_SKIPPED;
10835 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10839 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10841 gbl_driver_id = rte_cryptodev_driver_id_get(
10842 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10844 if (gbl_driver_id == -1) {
10845 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10846 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10847 "in config file to run this testsuite.\n");
10848 return TEST_SKIPPED;
10851 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10855 test_cryptodev_ccp(void)
10857 gbl_driver_id = rte_cryptodev_driver_id_get(
10858 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10860 if (gbl_driver_id == -1) {
10861 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10862 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10863 "in config file to run this testsuite.\n");
10864 return TEST_FAILED;
10867 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10871 test_cryptodev_octeontx(void)
10873 gbl_driver_id = rte_cryptodev_driver_id_get(
10874 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10875 if (gbl_driver_id == -1) {
10876 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10877 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10878 "enabled in config file to run this "
10880 return TEST_FAILED;
10882 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10886 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10888 gbl_driver_id = rte_cryptodev_driver_id_get(
10889 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10891 if (gbl_driver_id == -1) {
10892 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10893 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10894 "in config file to run this testsuite.\n");
10895 return TEST_FAILED;
10898 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10901 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10902 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10903 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10904 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10905 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10906 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10907 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10908 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10909 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10910 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10911 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10912 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10913 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10914 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10915 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10916 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);