1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2017 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
42 #define VDEV_ARGS_SIZE 100
43 #define MAX_NB_SESSIONS 4
45 static int gbl_driver_id;
47 struct crypto_testsuite_params {
48 struct rte_mempool *mbuf_pool;
49 struct rte_mempool *large_mbuf_pool;
50 struct rte_mempool *op_mpool;
51 struct rte_mempool *session_mpool;
52 struct rte_mempool *session_priv_mpool;
53 struct rte_cryptodev_config conf;
54 struct rte_cryptodev_qp_conf qp_conf;
56 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
57 uint8_t valid_dev_count;
60 struct crypto_unittest_params {
61 struct rte_crypto_sym_xform cipher_xform;
62 struct rte_crypto_sym_xform auth_xform;
63 struct rte_crypto_sym_xform aead_xform;
65 struct rte_cryptodev_sym_session *sess;
67 struct rte_crypto_op *op;
69 struct rte_mbuf *obuf, *ibuf;
74 #define ALIGN_POW2_ROUNDUP(num, align) \
75 (((num) + (align) - 1) & ~((align) - 1))
78 * Forward declarations.
81 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
82 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
86 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
87 struct crypto_unittest_params *ut_params,
88 struct crypto_testsuite_params *ts_param,
89 const uint8_t *cipher,
90 const uint8_t *digest,
93 static struct rte_mbuf *
94 setup_test_string(struct rte_mempool *mpool,
95 const char *string, size_t len, uint8_t blocksize)
97 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
98 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
100 memset(m->buf_addr, 0, m->buf_len);
102 char *dst = rte_pktmbuf_append(m, t_len);
109 rte_memcpy(dst, string, t_len);
111 memset(dst, 0, t_len);
117 /* Get number of bytes in X bits (rounding up) */
119 ceil_byte_length(uint32_t num_bits)
122 return ((num_bits >> 3) + 1);
124 return (num_bits >> 3);
127 static struct rte_crypto_op *
128 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
130 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
131 printf("Error sending packet for encryption");
137 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
143 static struct crypto_testsuite_params testsuite_params = { NULL };
144 static struct crypto_unittest_params unittest_params;
147 testsuite_setup(void)
149 struct crypto_testsuite_params *ts_params = &testsuite_params;
150 struct rte_cryptodev_info info;
151 uint32_t i = 0, nb_devs, dev_id;
155 memset(ts_params, 0, sizeof(*ts_params));
157 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
158 if (ts_params->mbuf_pool == NULL) {
159 /* Not already created so create */
160 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
162 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
164 if (ts_params->mbuf_pool == NULL) {
165 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
170 ts_params->large_mbuf_pool = rte_mempool_lookup(
171 "CRYPTO_LARGE_MBUFPOOL");
172 if (ts_params->large_mbuf_pool == NULL) {
173 /* Not already created so create */
174 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
175 "CRYPTO_LARGE_MBUFPOOL",
178 if (ts_params->large_mbuf_pool == NULL) {
180 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
185 ts_params->op_mpool = rte_crypto_op_pool_create(
186 "MBUF_CRYPTO_SYM_OP_POOL",
187 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
188 NUM_MBUFS, MBUF_CACHE_SIZE,
190 sizeof(struct rte_crypto_sym_xform) +
193 if (ts_params->op_mpool == NULL) {
194 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
198 /* Create an AESNI MB device if required */
199 if (gbl_driver_id == rte_cryptodev_driver_id_get(
200 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
201 nb_devs = rte_cryptodev_device_count_by_driver(
202 rte_cryptodev_driver_id_get(
203 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
206 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
208 TEST_ASSERT(ret == 0,
209 "Failed to create instance of"
211 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
215 /* Create an AESNI GCM device if required */
216 if (gbl_driver_id == rte_cryptodev_driver_id_get(
217 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
218 nb_devs = rte_cryptodev_device_count_by_driver(
219 rte_cryptodev_driver_id_get(
220 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
222 TEST_ASSERT_SUCCESS(rte_vdev_init(
223 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
224 "Failed to create instance of"
226 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
230 /* Create a SNOW 3G device if required */
231 if (gbl_driver_id == rte_cryptodev_driver_id_get(
232 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
233 nb_devs = rte_cryptodev_device_count_by_driver(
234 rte_cryptodev_driver_id_get(
235 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
237 TEST_ASSERT_SUCCESS(rte_vdev_init(
238 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
239 "Failed to create instance of"
241 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
245 /* Create a KASUMI device if required */
246 if (gbl_driver_id == rte_cryptodev_driver_id_get(
247 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
248 nb_devs = rte_cryptodev_device_count_by_driver(
249 rte_cryptodev_driver_id_get(
250 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
252 TEST_ASSERT_SUCCESS(rte_vdev_init(
253 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
254 "Failed to create instance of"
256 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
260 /* Create a ZUC device if required */
261 if (gbl_driver_id == rte_cryptodev_driver_id_get(
262 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
263 nb_devs = rte_cryptodev_device_count_by_driver(
264 rte_cryptodev_driver_id_get(
265 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
267 TEST_ASSERT_SUCCESS(rte_vdev_init(
268 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
269 "Failed to create instance of"
271 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
275 /* Create a NULL device if required */
276 if (gbl_driver_id == rte_cryptodev_driver_id_get(
277 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
278 nb_devs = rte_cryptodev_device_count_by_driver(
279 rte_cryptodev_driver_id_get(
280 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
283 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
285 TEST_ASSERT(ret == 0,
286 "Failed to create instance of"
288 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
292 /* Create an OPENSSL device if required */
293 if (gbl_driver_id == rte_cryptodev_driver_id_get(
294 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
295 nb_devs = rte_cryptodev_device_count_by_driver(
296 rte_cryptodev_driver_id_get(
297 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
300 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
303 TEST_ASSERT(ret == 0, "Failed to create "
304 "instance of pmd : %s",
305 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
309 /* Create a ARMv8 device if required */
310 if (gbl_driver_id == rte_cryptodev_driver_id_get(
311 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
312 nb_devs = rte_cryptodev_device_count_by_driver(
313 rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
317 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
320 TEST_ASSERT(ret == 0, "Failed to create "
321 "instance of pmd : %s",
322 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
326 /* Create a MVSAM device if required */
327 if (gbl_driver_id == rte_cryptodev_driver_id_get(
328 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
329 nb_devs = rte_cryptodev_device_count_by_driver(
330 rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
334 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
337 TEST_ASSERT(ret == 0, "Failed to create "
338 "instance of pmd : %s",
339 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
343 /* Create an CCP device if required */
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
346 nb_devs = rte_cryptodev_device_count_by_driver(
347 rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
351 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
354 TEST_ASSERT(ret == 0, "Failed to create "
355 "instance of pmd : %s",
356 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
360 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
361 char vdev_args[VDEV_ARGS_SIZE] = {""};
362 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
363 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
364 uint16_t slave_core_count = 0;
365 uint16_t socket_id = 0;
367 if (gbl_driver_id == rte_cryptodev_driver_id_get(
368 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
370 /* Identify the Slave Cores
371 * Use 2 slave cores for the device args
373 RTE_LCORE_FOREACH_SLAVE(i) {
374 if (slave_core_count > 1)
376 snprintf(vdev_args, sizeof(vdev_args),
377 "%s%d", temp_str, i);
378 strcpy(temp_str, vdev_args);
379 strlcat(temp_str, ";", sizeof(temp_str));
381 socket_id = rte_lcore_to_socket_id(i);
383 if (slave_core_count != 2) {
385 "Cryptodev scheduler test require at least "
386 "two slave cores to run. "
387 "Please use the correct coremask.\n");
390 strcpy(temp_str, vdev_args);
391 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
392 temp_str, socket_id);
393 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
394 nb_devs = rte_cryptodev_device_count_by_driver(
395 rte_cryptodev_driver_id_get(
396 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
399 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
401 TEST_ASSERT(ret == 0,
402 "Failed to create instance %u of"
404 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
407 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
409 nb_devs = rte_cryptodev_count();
411 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
415 /* Create list of valid crypto devs */
416 for (i = 0; i < nb_devs; i++) {
417 rte_cryptodev_info_get(i, &info);
418 if (info.driver_id == gbl_driver_id)
419 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
422 if (ts_params->valid_dev_count < 1)
425 /* Set up all the qps on the first of the valid devices found */
427 dev_id = ts_params->valid_devs[0];
429 rte_cryptodev_info_get(dev_id, &info);
431 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
432 ts_params->conf.socket_id = SOCKET_ID_ANY;
433 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
435 unsigned int session_size =
436 rte_cryptodev_sym_get_private_session_size(dev_id);
439 * Create mempool with maximum number of sessions * 2,
440 * to include the session headers
442 if (info.sym.max_nb_sessions != 0 &&
443 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
444 RTE_LOG(ERR, USER1, "Device does not support "
445 "at least %u sessions\n",
450 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
451 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
453 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
454 "session mempool allocation failed");
456 ts_params->session_priv_mpool = rte_mempool_create(
460 0, 0, NULL, NULL, NULL,
463 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
464 "session mempool allocation failed");
468 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
470 "Failed to configure cryptodev %u with %u qps",
471 dev_id, ts_params->conf.nb_queue_pairs);
473 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
474 ts_params->qp_conf.mp_session = ts_params->session_mpool;
475 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
477 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
478 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
479 dev_id, qp_id, &ts_params->qp_conf,
480 rte_cryptodev_socket_id(dev_id)),
481 "Failed to setup queue pair %u on cryptodev %u",
489 testsuite_teardown(void)
491 struct crypto_testsuite_params *ts_params = &testsuite_params;
493 if (ts_params->mbuf_pool != NULL) {
494 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
495 rte_mempool_avail_count(ts_params->mbuf_pool));
498 if (ts_params->op_mpool != NULL) {
499 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
500 rte_mempool_avail_count(ts_params->op_mpool));
503 /* Free session mempools */
504 if (ts_params->session_priv_mpool != NULL) {
505 rte_mempool_free(ts_params->session_priv_mpool);
506 ts_params->session_priv_mpool = NULL;
509 if (ts_params->session_mpool != NULL) {
510 rte_mempool_free(ts_params->session_mpool);
511 ts_params->session_mpool = NULL;
518 struct crypto_testsuite_params *ts_params = &testsuite_params;
519 struct crypto_unittest_params *ut_params = &unittest_params;
523 /* Clear unit test parameters before running test */
524 memset(ut_params, 0, sizeof(*ut_params));
526 /* Reconfigure device to default parameters */
527 ts_params->conf.socket_id = SOCKET_ID_ANY;
528 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
529 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
530 ts_params->qp_conf.mp_session = ts_params->session_mpool;
531 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
533 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
535 "Failed to configure cryptodev %u",
536 ts_params->valid_devs[0]);
538 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
539 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
540 ts_params->valid_devs[0], qp_id,
542 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
543 "Failed to setup queue pair %u on cryptodev %u",
544 qp_id, ts_params->valid_devs[0]);
548 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
550 /* Start the device */
551 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
552 "Failed to start cryptodev %u",
553 ts_params->valid_devs[0]);
561 struct crypto_testsuite_params *ts_params = &testsuite_params;
562 struct crypto_unittest_params *ut_params = &unittest_params;
563 struct rte_cryptodev_stats stats;
565 /* free crypto session structure */
566 if (ut_params->sess) {
567 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
569 rte_cryptodev_sym_session_free(ut_params->sess);
570 ut_params->sess = NULL;
573 /* free crypto operation structure */
575 rte_crypto_op_free(ut_params->op);
578 * free mbuf - both obuf and ibuf are usually the same,
579 * so check if they point at the same address is necessary,
580 * to avoid freeing the mbuf twice.
582 if (ut_params->obuf) {
583 rte_pktmbuf_free(ut_params->obuf);
584 if (ut_params->ibuf == ut_params->obuf)
588 if (ut_params->ibuf) {
589 rte_pktmbuf_free(ut_params->ibuf);
593 if (ts_params->mbuf_pool != NULL)
594 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
595 rte_mempool_avail_count(ts_params->mbuf_pool));
597 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
599 /* Stop the device */
600 rte_cryptodev_stop(ts_params->valid_devs[0]);
604 test_device_configure_invalid_dev_id(void)
606 struct crypto_testsuite_params *ts_params = &testsuite_params;
607 uint16_t dev_id, num_devs = 0;
609 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
610 "Need at least %d devices for test", 1);
612 /* valid dev_id values */
613 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
615 /* Stop the device in case it's started so it can be configured */
616 rte_cryptodev_stop(dev_id);
618 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
619 "Failed test for rte_cryptodev_configure: "
620 "invalid dev_num %u", dev_id);
622 /* invalid dev_id values */
625 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
626 "Failed test for rte_cryptodev_configure: "
627 "invalid dev_num %u", dev_id);
631 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
632 "Failed test for rte_cryptodev_configure:"
633 "invalid dev_num %u", dev_id);
639 test_device_configure_invalid_queue_pair_ids(void)
641 struct crypto_testsuite_params *ts_params = &testsuite_params;
642 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
644 /* Stop the device in case it's started so it can be configured */
645 rte_cryptodev_stop(ts_params->valid_devs[0]);
647 /* valid - one queue pairs */
648 ts_params->conf.nb_queue_pairs = 1;
650 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
652 "Failed to configure cryptodev: dev_id %u, qp_id %u",
653 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
656 /* valid - max value queue pairs */
657 ts_params->conf.nb_queue_pairs = orig_nb_qps;
659 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
661 "Failed to configure cryptodev: dev_id %u, qp_id %u",
662 ts_params->valid_devs[0],
663 ts_params->conf.nb_queue_pairs);
666 /* invalid - zero queue pairs */
667 ts_params->conf.nb_queue_pairs = 0;
669 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
671 "Failed test for rte_cryptodev_configure, dev_id %u,"
673 ts_params->valid_devs[0],
674 ts_params->conf.nb_queue_pairs);
677 /* invalid - max value supported by field queue pairs */
678 ts_params->conf.nb_queue_pairs = UINT16_MAX;
680 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
682 "Failed test for rte_cryptodev_configure, dev_id %u,"
684 ts_params->valid_devs[0],
685 ts_params->conf.nb_queue_pairs);
688 /* invalid - max value + 1 queue pairs */
689 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
691 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
693 "Failed test for rte_cryptodev_configure, dev_id %u,"
695 ts_params->valid_devs[0],
696 ts_params->conf.nb_queue_pairs);
698 /* revert to original testsuite value */
699 ts_params->conf.nb_queue_pairs = orig_nb_qps;
705 test_queue_pair_descriptor_setup(void)
707 struct crypto_testsuite_params *ts_params = &testsuite_params;
708 struct rte_cryptodev_info dev_info;
709 struct rte_cryptodev_qp_conf qp_conf = {
710 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
715 /* Stop the device in case it's started so it can be configured */
716 rte_cryptodev_stop(ts_params->valid_devs[0]);
719 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
721 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
723 "Failed to configure cryptodev %u",
724 ts_params->valid_devs[0]);
727 * Test various ring sizes on this device. memzones can't be
728 * freed so are re-used if ring is released and re-created.
730 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
731 qp_conf.mp_session = ts_params->session_mpool;
732 qp_conf.mp_session_private = ts_params->session_priv_mpool;
734 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
735 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
736 ts_params->valid_devs[0], qp_id, &qp_conf,
737 rte_cryptodev_socket_id(
738 ts_params->valid_devs[0])),
740 "rte_cryptodev_queue_pair_setup: num_inflights "
741 "%u on qp %u on cryptodev %u",
742 qp_conf.nb_descriptors, qp_id,
743 ts_params->valid_devs[0]);
746 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
748 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
749 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
750 ts_params->valid_devs[0], qp_id, &qp_conf,
751 rte_cryptodev_socket_id(
752 ts_params->valid_devs[0])),
754 " rte_cryptodev_queue_pair_setup: num_inflights"
755 " %u on qp %u on cryptodev %u",
756 qp_conf.nb_descriptors, qp_id,
757 ts_params->valid_devs[0]);
760 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
762 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
763 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
764 ts_params->valid_devs[0], qp_id, &qp_conf,
765 rte_cryptodev_socket_id(
766 ts_params->valid_devs[0])),
768 "rte_cryptodev_queue_pair_setup: num_inflights"
769 " %u on qp %u on cryptodev %u",
770 qp_conf.nb_descriptors, qp_id,
771 ts_params->valid_devs[0]);
774 /* invalid number of descriptors - max supported + 2 */
775 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
777 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
778 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
779 ts_params->valid_devs[0], qp_id, &qp_conf,
780 rte_cryptodev_socket_id(
781 ts_params->valid_devs[0])),
782 "Unexpectedly passed test for "
783 "rte_cryptodev_queue_pair_setup:"
784 "num_inflights %u on qp %u on cryptodev %u",
785 qp_conf.nb_descriptors, qp_id,
786 ts_params->valid_devs[0]);
789 /* invalid number of descriptors - max value of parameter */
790 qp_conf.nb_descriptors = UINT32_MAX-1;
792 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
793 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
794 ts_params->valid_devs[0], qp_id, &qp_conf,
795 rte_cryptodev_socket_id(
796 ts_params->valid_devs[0])),
797 "Unexpectedly passed test for "
798 "rte_cryptodev_queue_pair_setup:"
799 "num_inflights %u on qp %u on cryptodev %u",
800 qp_conf.nb_descriptors, qp_id,
801 ts_params->valid_devs[0]);
804 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
806 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
807 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
808 ts_params->valid_devs[0], qp_id, &qp_conf,
809 rte_cryptodev_socket_id(
810 ts_params->valid_devs[0])),
812 " rte_cryptodev_queue_pair_setup:"
813 "num_inflights %u on qp %u on cryptodev %u",
814 qp_conf.nb_descriptors, qp_id,
815 ts_params->valid_devs[0]);
818 /* invalid number of descriptors - max supported + 1 */
819 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
821 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
822 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
823 ts_params->valid_devs[0], qp_id, &qp_conf,
824 rte_cryptodev_socket_id(
825 ts_params->valid_devs[0])),
826 "Unexpectedly passed test for "
827 "rte_cryptodev_queue_pair_setup:"
828 "num_inflights %u on qp %u on cryptodev %u",
829 qp_conf.nb_descriptors, qp_id,
830 ts_params->valid_devs[0]);
833 /* test invalid queue pair id */
834 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
836 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
838 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
839 ts_params->valid_devs[0],
841 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
842 "Failed test for rte_cryptodev_queue_pair_setup:"
843 "invalid qp %u on cryptodev %u",
844 qp_id, ts_params->valid_devs[0]);
846 qp_id = 0xffff; /*invalid*/
848 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
849 ts_params->valid_devs[0],
851 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
852 "Failed test for rte_cryptodev_queue_pair_setup:"
853 "invalid qp %u on cryptodev %u",
854 qp_id, ts_params->valid_devs[0]);
859 /* ***** Plaintext data for tests ***** */
861 const char catch_22_quote_1[] =
862 "There was only one catch and that was Catch-22, which "
863 "specified that a concern for one's safety in the face of "
864 "dangers that were real and immediate was the process of a "
865 "rational mind. Orr was crazy and could be grounded. All he "
866 "had to do was ask; and as soon as he did, he would no longer "
867 "be crazy and would have to fly more missions. Orr would be "
868 "crazy to fly more missions and sane if he didn't, but if he "
869 "was sane he had to fly them. If he flew them he was crazy "
870 "and didn't have to; but if he didn't want to he was sane and "
871 "had to. Yossarian was moved very deeply by the absolute "
872 "simplicity of this clause of Catch-22 and let out a "
873 "respectful whistle. \"That's some catch, that Catch-22\", he "
874 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
876 const char catch_22_quote[] =
877 "What a lousy earth! He wondered how many people were "
878 "destitute that same night even in his own prosperous country, "
879 "how many homes were shanties, how many husbands were drunk "
880 "and wives socked, and how many children were bullied, abused, "
881 "or abandoned. How many families hungered for food they could "
882 "not afford to buy? How many hearts were broken? How many "
883 "suicides would take place that same night, how many people "
884 "would go insane? How many cockroaches and landlords would "
885 "triumph? How many winners were losers, successes failures, "
886 "and rich men poor men? How many wise guys were stupid? How "
887 "many happy endings were unhappy endings? How many honest men "
888 "were liars, brave men cowards, loyal men traitors, how many "
889 "sainted men were corrupt, how many people in positions of "
890 "trust had sold their souls to bodyguards, how many had never "
891 "had souls? How many straight-and-narrow paths were crooked "
892 "paths? How many best families were worst families and how "
893 "many good people were bad people? When you added them all up "
894 "and then subtracted, you might be left with only the children, "
895 "and perhaps with Albert Einstein and an old violinist or "
896 "sculptor somewhere.";
898 #define QUOTE_480_BYTES (480)
899 #define QUOTE_512_BYTES (512)
900 #define QUOTE_768_BYTES (768)
901 #define QUOTE_1024_BYTES (1024)
905 /* ***** SHA1 Hash Tests ***** */
907 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
909 static uint8_t hmac_sha1_key[] = {
910 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
911 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
912 0xDE, 0xF4, 0xDE, 0xAD };
914 /* ***** SHA224 Hash Tests ***** */
916 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
919 /* ***** AES-CBC Cipher Tests ***** */
921 #define CIPHER_KEY_LENGTH_AES_CBC (16)
922 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
924 static uint8_t aes_cbc_key[] = {
925 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
926 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
928 static uint8_t aes_cbc_iv[] = {
929 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
930 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
933 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
935 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
936 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
937 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
938 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
939 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
940 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
941 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
942 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
943 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
944 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
945 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
946 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
947 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
948 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
949 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
950 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
951 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
952 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
953 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
954 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
955 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
956 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
957 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
958 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
959 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
960 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
961 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
962 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
963 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
964 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
965 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
966 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
967 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
968 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
969 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
970 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
971 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
972 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
973 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
974 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
975 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
976 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
977 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
978 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
979 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
980 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
981 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
982 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
983 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
984 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
985 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
986 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
987 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
988 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
989 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
990 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
991 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
992 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
993 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
994 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
995 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
996 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
997 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
998 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
999 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1002 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1003 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1004 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1005 0x18, 0x8c, 0x1d, 0x32
1009 /* Multisession Vector context Test */
1010 /*Begin Session 0 */
1011 static uint8_t ms_aes_cbc_key0[] = {
1012 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1013 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1016 static uint8_t ms_aes_cbc_iv0[] = {
1017 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1018 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1021 static const uint8_t ms_aes_cbc_cipher0[] = {
1022 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1023 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1024 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1025 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1026 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1027 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1028 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1029 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1030 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1031 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1032 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1033 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1034 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1035 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1036 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1037 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1038 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1039 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1040 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1041 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1042 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1043 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1044 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1045 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1046 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1047 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1048 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1049 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1050 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1051 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1052 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1053 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1054 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1055 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1056 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1057 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1058 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1059 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1060 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1061 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1062 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1063 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1064 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1065 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1066 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1067 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1068 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1069 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1070 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1071 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1072 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1073 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1074 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1075 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1076 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1077 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1078 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1079 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1080 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1081 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1082 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1083 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1084 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1085 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1089 static uint8_t ms_hmac_key0[] = {
1090 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1091 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1092 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1093 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1094 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1095 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1096 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1097 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1100 static const uint8_t ms_hmac_digest0[] = {
1101 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1102 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1103 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1104 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1105 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1106 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1107 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1108 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1112 /* Begin session 1 */
1114 static uint8_t ms_aes_cbc_key1[] = {
1115 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1116 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1119 static uint8_t ms_aes_cbc_iv1[] = {
1120 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1121 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1124 static const uint8_t ms_aes_cbc_cipher1[] = {
1125 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1126 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1127 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1128 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1129 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1130 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1131 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1132 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1133 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1134 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1135 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1136 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1137 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1138 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1139 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1140 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1141 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1142 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1143 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1144 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1145 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1146 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1147 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1148 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1149 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1150 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1151 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1152 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1153 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1154 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1155 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1156 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1157 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1158 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1159 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1160 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1161 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1162 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1163 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1164 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1165 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1166 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1167 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1168 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1169 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1170 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1171 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1172 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1173 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1174 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1175 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1176 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1177 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1178 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1179 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1180 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1181 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1182 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1183 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1184 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1185 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1186 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1187 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1188 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1192 static uint8_t ms_hmac_key1[] = {
1193 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1194 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1195 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1196 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1197 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1198 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1199 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1200 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1203 static const uint8_t ms_hmac_digest1[] = {
1204 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1205 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1206 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1207 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1208 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1209 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1210 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1211 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1214 /* Begin Session 2 */
1215 static uint8_t ms_aes_cbc_key2[] = {
1216 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1217 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1220 static uint8_t ms_aes_cbc_iv2[] = {
1221 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1222 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1225 static const uint8_t ms_aes_cbc_cipher2[] = {
1226 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1227 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1228 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1229 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1230 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1231 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1232 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1233 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1234 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1235 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1236 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1237 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1238 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1239 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1240 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1241 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1242 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1243 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1244 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1245 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1246 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1247 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1248 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1249 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1250 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1251 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1252 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1253 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1254 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1255 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1256 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1257 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1258 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1259 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1260 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1261 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1262 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1263 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1264 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1265 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1266 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1267 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1268 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1269 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1270 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1271 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1272 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1273 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1274 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1275 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1276 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1277 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1278 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1279 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1280 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1281 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1282 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1283 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1284 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1285 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1286 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1287 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1288 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1289 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1292 static uint8_t ms_hmac_key2[] = {
1293 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1294 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1295 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1296 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1297 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1298 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1299 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1300 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1303 static const uint8_t ms_hmac_digest2[] = {
1304 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1305 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1306 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1307 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1308 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1309 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1310 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1311 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1318 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1320 struct crypto_testsuite_params *ts_params = &testsuite_params;
1321 struct crypto_unittest_params *ut_params = &unittest_params;
1323 /* Generate test mbuf data and space for digest */
1324 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1325 catch_22_quote, QUOTE_512_BYTES, 0);
1327 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1328 DIGEST_BYTE_LENGTH_SHA1);
1329 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1331 /* Setup Cipher Parameters */
1332 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1333 ut_params->cipher_xform.next = &ut_params->auth_xform;
1335 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1336 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1337 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1338 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1339 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1340 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1342 /* Setup HMAC Parameters */
1343 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1345 ut_params->auth_xform.next = NULL;
1347 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1348 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1349 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1350 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1351 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1353 ut_params->sess = rte_cryptodev_sym_session_create(
1354 ts_params->session_mpool);
1356 /* Create crypto session*/
1357 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1358 ut_params->sess, &ut_params->cipher_xform,
1359 ts_params->session_priv_mpool);
1360 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1362 /* Generate crypto op data structure */
1363 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1364 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1365 TEST_ASSERT_NOT_NULL(ut_params->op,
1366 "Failed to allocate symmetric crypto operation struct");
1368 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1370 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1372 /* set crypto operation source mbuf */
1373 sym_op->m_src = ut_params->ibuf;
1375 /* Set crypto operation authentication parameters */
1376 sym_op->auth.digest.data = ut_params->digest;
1377 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1378 ut_params->ibuf, QUOTE_512_BYTES);
1380 sym_op->auth.data.offset = 0;
1381 sym_op->auth.data.length = QUOTE_512_BYTES;
1383 /* Copy IV at the end of the crypto operation */
1384 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1385 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1387 /* Set crypto operation cipher parameters */
1388 sym_op->cipher.data.offset = 0;
1389 sym_op->cipher.data.length = QUOTE_512_BYTES;
1391 /* Process crypto operation */
1392 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1393 ut_params->op), "failed to process sym crypto op");
1395 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1396 "crypto op processing failed");
1399 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1402 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1403 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1405 "ciphertext data not as expected");
1407 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1409 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1410 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1411 gbl_driver_id == rte_cryptodev_driver_id_get(
1412 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1413 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1414 DIGEST_BYTE_LENGTH_SHA1,
1415 "Generated digest data not as expected");
1417 return TEST_SUCCESS;
1420 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1422 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1424 static uint8_t hmac_sha512_key[] = {
1425 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1426 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1427 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1428 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1429 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1430 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1431 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1432 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1434 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1435 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1436 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1437 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1438 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1439 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1440 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1441 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1442 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1447 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1448 struct crypto_unittest_params *ut_params,
1449 uint8_t *cipher_key,
1453 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1454 struct crypto_unittest_params *ut_params,
1455 struct crypto_testsuite_params *ts_params,
1456 const uint8_t *cipher,
1457 const uint8_t *digest,
1462 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1463 struct crypto_unittest_params *ut_params,
1464 uint8_t *cipher_key,
1468 /* Setup Cipher Parameters */
1469 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1470 ut_params->cipher_xform.next = NULL;
1472 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1473 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1474 ut_params->cipher_xform.cipher.key.data = cipher_key;
1475 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1476 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1477 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1479 /* Setup HMAC Parameters */
1480 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1481 ut_params->auth_xform.next = &ut_params->cipher_xform;
1483 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1484 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1485 ut_params->auth_xform.auth.key.data = hmac_key;
1486 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1487 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1489 return TEST_SUCCESS;
1494 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1495 struct crypto_unittest_params *ut_params,
1496 struct crypto_testsuite_params *ts_params,
1497 const uint8_t *cipher,
1498 const uint8_t *digest,
1501 /* Generate test mbuf data and digest */
1502 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1505 QUOTE_512_BYTES, 0);
1507 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1508 DIGEST_BYTE_LENGTH_SHA512);
1509 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1511 rte_memcpy(ut_params->digest,
1513 DIGEST_BYTE_LENGTH_SHA512);
1515 /* Generate Crypto op data structure */
1516 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1517 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1518 TEST_ASSERT_NOT_NULL(ut_params->op,
1519 "Failed to allocate symmetric crypto operation struct");
1521 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1523 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1525 /* set crypto operation source mbuf */
1526 sym_op->m_src = ut_params->ibuf;
1528 sym_op->auth.digest.data = ut_params->digest;
1529 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1530 ut_params->ibuf, QUOTE_512_BYTES);
1532 sym_op->auth.data.offset = 0;
1533 sym_op->auth.data.length = QUOTE_512_BYTES;
1535 /* Copy IV at the end of the crypto operation */
1536 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1537 iv, CIPHER_IV_LENGTH_AES_CBC);
1539 sym_op->cipher.data.offset = 0;
1540 sym_op->cipher.data.length = QUOTE_512_BYTES;
1542 /* Process crypto operation */
1543 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1544 ut_params->op), "failed to process sym crypto op");
1546 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1547 "crypto op processing failed");
1549 ut_params->obuf = ut_params->op->sym->m_src;
1552 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1553 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1556 "Plaintext data not as expected");
1559 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1560 "Digest verification failed");
1562 return TEST_SUCCESS;
1566 test_AES_cipheronly_mb_all(void)
1568 struct crypto_testsuite_params *ts_params = &testsuite_params;
1571 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1572 ts_params->op_mpool,
1573 ts_params->session_mpool, ts_params->session_priv_mpool,
1574 ts_params->valid_devs[0],
1575 rte_cryptodev_driver_id_get(
1576 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1577 BLKCIPHER_AES_CIPHERONLY_TYPE);
1579 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1581 return TEST_SUCCESS;
1585 test_AES_docsis_mb_all(void)
1587 struct crypto_testsuite_params *ts_params = &testsuite_params;
1590 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1591 ts_params->op_mpool,
1592 ts_params->session_mpool, ts_params->session_priv_mpool,
1593 ts_params->valid_devs[0],
1594 rte_cryptodev_driver_id_get(
1595 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1596 BLKCIPHER_AES_DOCSIS_TYPE);
1598 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1600 return TEST_SUCCESS;
1604 test_AES_docsis_qat_all(void)
1606 struct crypto_testsuite_params *ts_params = &testsuite_params;
1609 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1610 ts_params->op_mpool,
1611 ts_params->session_mpool, ts_params->session_priv_mpool,
1612 ts_params->valid_devs[0],
1613 rte_cryptodev_driver_id_get(
1614 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1615 BLKCIPHER_AES_DOCSIS_TYPE);
1617 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1619 return TEST_SUCCESS;
1623 test_DES_docsis_qat_all(void)
1625 struct crypto_testsuite_params *ts_params = &testsuite_params;
1628 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1629 ts_params->op_mpool,
1630 ts_params->session_mpool, ts_params->session_priv_mpool,
1631 ts_params->valid_devs[0],
1632 rte_cryptodev_driver_id_get(
1633 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1634 BLKCIPHER_DES_DOCSIS_TYPE);
1636 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1638 return TEST_SUCCESS;
1642 test_authonly_mb_all(void)
1644 struct crypto_testsuite_params *ts_params = &testsuite_params;
1647 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1648 ts_params->op_mpool,
1649 ts_params->session_mpool, ts_params->session_priv_mpool,
1650 ts_params->valid_devs[0],
1651 rte_cryptodev_driver_id_get(
1652 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1653 BLKCIPHER_AUTHONLY_TYPE);
1655 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1657 return TEST_SUCCESS;
1661 test_authonly_qat_all(void)
1663 struct crypto_testsuite_params *ts_params = &testsuite_params;
1666 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1667 ts_params->op_mpool,
1668 ts_params->session_mpool, ts_params->session_priv_mpool,
1669 ts_params->valid_devs[0],
1670 rte_cryptodev_driver_id_get(
1671 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1672 BLKCIPHER_AUTHONLY_TYPE);
1674 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1676 return TEST_SUCCESS;
1680 test_AES_chain_null_all(void)
1682 struct crypto_testsuite_params *ts_params = &testsuite_params;
1685 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1686 ts_params->op_mpool,
1687 ts_params->session_mpool, ts_params->session_priv_mpool,
1688 ts_params->valid_devs[0],
1689 rte_cryptodev_driver_id_get(
1690 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1691 BLKCIPHER_AES_CHAIN_TYPE);
1693 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1695 return TEST_SUCCESS;
1699 test_AES_cipheronly_null_all(void)
1701 struct crypto_testsuite_params *ts_params = &testsuite_params;
1704 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1705 ts_params->op_mpool,
1706 ts_params->session_mpool, ts_params->session_priv_mpool,
1707 ts_params->valid_devs[0],
1708 rte_cryptodev_driver_id_get(
1709 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1710 BLKCIPHER_AES_CIPHERONLY_TYPE);
1712 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1714 return TEST_SUCCESS;
1718 test_authonly_null_all(void)
1720 struct crypto_testsuite_params *ts_params = &testsuite_params;
1723 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1724 ts_params->op_mpool,
1725 ts_params->session_mpool, ts_params->session_priv_mpool,
1726 ts_params->valid_devs[0],
1727 rte_cryptodev_driver_id_get(
1728 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1729 BLKCIPHER_AUTHONLY_TYPE);
1731 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1733 return TEST_SUCCESS;
1737 test_AES_chain_mb_all(void)
1739 struct crypto_testsuite_params *ts_params = &testsuite_params;
1742 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1743 ts_params->op_mpool,
1744 ts_params->session_mpool, ts_params->session_priv_mpool,
1745 ts_params->valid_devs[0],
1746 rte_cryptodev_driver_id_get(
1747 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1748 BLKCIPHER_AES_CHAIN_TYPE);
1750 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1752 return TEST_SUCCESS;
1755 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1758 test_AES_cipheronly_scheduler_all(void)
1760 struct crypto_testsuite_params *ts_params = &testsuite_params;
1763 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1764 ts_params->op_mpool,
1765 ts_params->session_mpool, ts_params->session_priv_mpool,
1766 ts_params->valid_devs[0],
1767 rte_cryptodev_driver_id_get(
1768 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1769 BLKCIPHER_AES_CIPHERONLY_TYPE);
1771 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1773 return TEST_SUCCESS;
1777 test_AES_chain_scheduler_all(void)
1779 struct crypto_testsuite_params *ts_params = &testsuite_params;
1782 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1783 ts_params->op_mpool,
1784 ts_params->session_mpool, ts_params->session_priv_mpool,
1785 ts_params->valid_devs[0],
1786 rte_cryptodev_driver_id_get(
1787 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1788 BLKCIPHER_AES_CHAIN_TYPE);
1790 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1792 return TEST_SUCCESS;
1796 test_authonly_scheduler_all(void)
1798 struct crypto_testsuite_params *ts_params = &testsuite_params;
1801 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1802 ts_params->op_mpool,
1803 ts_params->session_mpool, ts_params->session_priv_mpool,
1804 ts_params->valid_devs[0],
1805 rte_cryptodev_driver_id_get(
1806 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1807 BLKCIPHER_AUTHONLY_TYPE);
1809 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1811 return TEST_SUCCESS;
1814 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1817 test_AES_chain_openssl_all(void)
1819 struct crypto_testsuite_params *ts_params = &testsuite_params;
1822 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1823 ts_params->op_mpool,
1824 ts_params->session_mpool, ts_params->session_priv_mpool,
1825 ts_params->valid_devs[0],
1826 rte_cryptodev_driver_id_get(
1827 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1828 BLKCIPHER_AES_CHAIN_TYPE);
1830 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1832 return TEST_SUCCESS;
1836 test_AES_cipheronly_openssl_all(void)
1838 struct crypto_testsuite_params *ts_params = &testsuite_params;
1841 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1842 ts_params->op_mpool,
1843 ts_params->session_mpool, ts_params->session_priv_mpool,
1844 ts_params->valid_devs[0],
1845 rte_cryptodev_driver_id_get(
1846 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1847 BLKCIPHER_AES_CIPHERONLY_TYPE);
1849 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1851 return TEST_SUCCESS;
1855 test_AES_chain_ccp_all(void)
1857 struct crypto_testsuite_params *ts_params = &testsuite_params;
1860 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1861 ts_params->op_mpool,
1862 ts_params->session_mpool, ts_params->session_priv_mpool,
1863 ts_params->valid_devs[0],
1864 rte_cryptodev_driver_id_get(
1865 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1866 BLKCIPHER_AES_CHAIN_TYPE);
1868 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1870 return TEST_SUCCESS;
1874 test_AES_cipheronly_ccp_all(void)
1876 struct crypto_testsuite_params *ts_params = &testsuite_params;
1879 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1880 ts_params->op_mpool,
1881 ts_params->session_mpool, ts_params->session_priv_mpool,
1882 ts_params->valid_devs[0],
1883 rte_cryptodev_driver_id_get(
1884 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1885 BLKCIPHER_AES_CIPHERONLY_TYPE);
1887 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1889 return TEST_SUCCESS;
1893 test_AES_chain_qat_all(void)
1895 struct crypto_testsuite_params *ts_params = &testsuite_params;
1898 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1899 ts_params->op_mpool,
1900 ts_params->session_mpool, ts_params->session_priv_mpool,
1901 ts_params->valid_devs[0],
1902 rte_cryptodev_driver_id_get(
1903 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1904 BLKCIPHER_AES_CHAIN_TYPE);
1906 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1908 return TEST_SUCCESS;
1912 test_AES_cipheronly_qat_all(void)
1914 struct crypto_testsuite_params *ts_params = &testsuite_params;
1917 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1918 ts_params->op_mpool,
1919 ts_params->session_mpool, ts_params->session_priv_mpool,
1920 ts_params->valid_devs[0],
1921 rte_cryptodev_driver_id_get(
1922 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1923 BLKCIPHER_AES_CIPHERONLY_TYPE);
1925 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1927 return TEST_SUCCESS;
1931 test_AES_cipheronly_virtio_all(void)
1933 struct crypto_testsuite_params *ts_params = &testsuite_params;
1936 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1937 ts_params->op_mpool,
1938 ts_params->session_mpool, ts_params->session_priv_mpool,
1939 ts_params->valid_devs[0],
1940 rte_cryptodev_driver_id_get(
1941 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1942 BLKCIPHER_AES_CIPHERONLY_TYPE);
1944 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1946 return TEST_SUCCESS;
1950 test_AES_chain_caam_jr_all(void)
1952 struct crypto_testsuite_params *ts_params = &testsuite_params;
1955 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1956 ts_params->op_mpool,
1957 ts_params->session_mpool, ts_params->session_priv_mpool,
1958 ts_params->valid_devs[0],
1959 rte_cryptodev_driver_id_get(
1960 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1961 BLKCIPHER_AES_CHAIN_TYPE);
1963 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1965 return TEST_SUCCESS;
1969 test_AES_cipheronly_caam_jr_all(void)
1971 struct crypto_testsuite_params *ts_params = &testsuite_params;
1974 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1975 ts_params->op_mpool,
1976 ts_params->session_mpool, ts_params->session_priv_mpool,
1977 ts_params->valid_devs[0],
1978 rte_cryptodev_driver_id_get(
1979 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1980 BLKCIPHER_AES_CIPHERONLY_TYPE);
1982 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1984 return TEST_SUCCESS;
1988 test_authonly_caam_jr_all(void)
1990 struct crypto_testsuite_params *ts_params = &testsuite_params;
1993 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1994 ts_params->op_mpool,
1995 ts_params->session_mpool, ts_params->session_priv_mpool,
1996 ts_params->valid_devs[0],
1997 rte_cryptodev_driver_id_get(
1998 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1999 BLKCIPHER_AUTHONLY_TYPE);
2001 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2003 return TEST_SUCCESS;
2008 test_AES_chain_dpaa_sec_all(void)
2010 struct crypto_testsuite_params *ts_params = &testsuite_params;
2013 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2014 ts_params->op_mpool,
2015 ts_params->session_mpool, ts_params->session_priv_mpool,
2016 ts_params->valid_devs[0],
2017 rte_cryptodev_driver_id_get(
2018 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2019 BLKCIPHER_AES_CHAIN_TYPE);
2021 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2023 return TEST_SUCCESS;
2027 test_AES_cipheronly_dpaa_sec_all(void)
2029 struct crypto_testsuite_params *ts_params = &testsuite_params;
2032 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2033 ts_params->op_mpool,
2034 ts_params->session_mpool, ts_params->session_priv_mpool,
2035 ts_params->valid_devs[0],
2036 rte_cryptodev_driver_id_get(
2037 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2038 BLKCIPHER_AES_CIPHERONLY_TYPE);
2040 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2042 return TEST_SUCCESS;
2046 test_authonly_dpaa_sec_all(void)
2048 struct crypto_testsuite_params *ts_params = &testsuite_params;
2051 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2052 ts_params->op_mpool,
2053 ts_params->session_mpool, ts_params->session_priv_mpool,
2054 ts_params->valid_devs[0],
2055 rte_cryptodev_driver_id_get(
2056 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2057 BLKCIPHER_AUTHONLY_TYPE);
2059 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2061 return TEST_SUCCESS;
2065 test_AES_chain_dpaa2_sec_all(void)
2067 struct crypto_testsuite_params *ts_params = &testsuite_params;
2070 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2071 ts_params->op_mpool,
2072 ts_params->session_mpool, ts_params->session_priv_mpool,
2073 ts_params->valid_devs[0],
2074 rte_cryptodev_driver_id_get(
2075 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2076 BLKCIPHER_AES_CHAIN_TYPE);
2078 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2080 return TEST_SUCCESS;
2084 test_AES_cipheronly_dpaa2_sec_all(void)
2086 struct crypto_testsuite_params *ts_params = &testsuite_params;
2089 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2090 ts_params->op_mpool,
2091 ts_params->session_mpool, ts_params->session_priv_mpool,
2092 ts_params->valid_devs[0],
2093 rte_cryptodev_driver_id_get(
2094 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2095 BLKCIPHER_AES_CIPHERONLY_TYPE);
2097 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2099 return TEST_SUCCESS;
2103 test_authonly_dpaa2_sec_all(void)
2105 struct crypto_testsuite_params *ts_params = &testsuite_params;
2108 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2109 ts_params->op_mpool,
2110 ts_params->session_mpool, ts_params->session_priv_mpool,
2111 ts_params->valid_devs[0],
2112 rte_cryptodev_driver_id_get(
2113 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2114 BLKCIPHER_AUTHONLY_TYPE);
2116 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2118 return TEST_SUCCESS;
2122 test_authonly_openssl_all(void)
2124 struct crypto_testsuite_params *ts_params = &testsuite_params;
2127 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2128 ts_params->op_mpool,
2129 ts_params->session_mpool, ts_params->session_priv_mpool,
2130 ts_params->valid_devs[0],
2131 rte_cryptodev_driver_id_get(
2132 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2133 BLKCIPHER_AUTHONLY_TYPE);
2135 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2137 return TEST_SUCCESS;
2141 test_authonly_ccp_all(void)
2143 struct crypto_testsuite_params *ts_params = &testsuite_params;
2146 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2147 ts_params->op_mpool,
2148 ts_params->session_mpool, ts_params->session_priv_mpool,
2149 ts_params->valid_devs[0],
2150 rte_cryptodev_driver_id_get(
2151 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2152 BLKCIPHER_AUTHONLY_TYPE);
2154 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2156 return TEST_SUCCESS;
2160 test_AES_chain_armv8_all(void)
2162 struct crypto_testsuite_params *ts_params = &testsuite_params;
2165 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2166 ts_params->op_mpool,
2167 ts_params->session_mpool, ts_params->session_priv_mpool,
2168 ts_params->valid_devs[0],
2169 rte_cryptodev_driver_id_get(
2170 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2171 BLKCIPHER_AES_CHAIN_TYPE);
2173 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2175 return TEST_SUCCESS;
2179 test_AES_chain_mrvl_all(void)
2181 struct crypto_testsuite_params *ts_params = &testsuite_params;
2184 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2185 ts_params->op_mpool,
2186 ts_params->session_mpool, ts_params->session_priv_mpool,
2187 ts_params->valid_devs[0],
2188 rte_cryptodev_driver_id_get(
2189 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2190 BLKCIPHER_AES_CHAIN_TYPE);
2192 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2194 return TEST_SUCCESS;
2198 test_AES_cipheronly_mrvl_all(void)
2200 struct crypto_testsuite_params *ts_params = &testsuite_params;
2203 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2204 ts_params->op_mpool,
2205 ts_params->session_mpool, ts_params->session_priv_mpool,
2206 ts_params->valid_devs[0],
2207 rte_cryptodev_driver_id_get(
2208 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2209 BLKCIPHER_AES_CIPHERONLY_TYPE);
2211 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2213 return TEST_SUCCESS;
2217 test_authonly_mrvl_all(void)
2219 struct crypto_testsuite_params *ts_params = &testsuite_params;
2222 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2223 ts_params->op_mpool,
2224 ts_params->session_mpool, ts_params->session_priv_mpool,
2225 ts_params->valid_devs[0],
2226 rte_cryptodev_driver_id_get(
2227 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2228 BLKCIPHER_AUTHONLY_TYPE);
2230 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2232 return TEST_SUCCESS;
2236 test_3DES_chain_mrvl_all(void)
2238 struct crypto_testsuite_params *ts_params = &testsuite_params;
2241 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2242 ts_params->op_mpool,
2243 ts_params->session_mpool, ts_params->session_priv_mpool,
2244 ts_params->valid_devs[0],
2245 rte_cryptodev_driver_id_get(
2246 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2247 BLKCIPHER_3DES_CHAIN_TYPE);
2249 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2251 return TEST_SUCCESS;
2255 test_3DES_cipheronly_mrvl_all(void)
2257 struct crypto_testsuite_params *ts_params = &testsuite_params;
2260 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2261 ts_params->op_mpool,
2262 ts_params->session_mpool, ts_params->session_priv_mpool,
2263 ts_params->valid_devs[0],
2264 rte_cryptodev_driver_id_get(
2265 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2266 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2268 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2270 return TEST_SUCCESS;
2274 test_AES_chain_octeontx_all(void)
2276 struct crypto_testsuite_params *ts_params = &testsuite_params;
2279 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2280 ts_params->op_mpool, ts_params->session_mpool,
2281 ts_params->session_priv_mpool,
2282 ts_params->valid_devs[0],
2283 rte_cryptodev_driver_id_get(
2284 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2285 BLKCIPHER_AES_CHAIN_TYPE);
2287 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2289 return TEST_SUCCESS;
2293 test_AES_cipheronly_octeontx_all(void)
2295 struct crypto_testsuite_params *ts_params = &testsuite_params;
2298 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2299 ts_params->op_mpool, ts_params->session_mpool,
2300 ts_params->session_priv_mpool,
2301 ts_params->valid_devs[0],
2302 rte_cryptodev_driver_id_get(
2303 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2304 BLKCIPHER_AES_CIPHERONLY_TYPE);
2306 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2308 return TEST_SUCCESS;
2312 test_3DES_chain_octeontx_all(void)
2314 struct crypto_testsuite_params *ts_params = &testsuite_params;
2317 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2318 ts_params->op_mpool, ts_params->session_mpool,
2319 ts_params->session_priv_mpool,
2320 ts_params->valid_devs[0],
2321 rte_cryptodev_driver_id_get(
2322 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2323 BLKCIPHER_3DES_CHAIN_TYPE);
2325 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2327 return TEST_SUCCESS;
2331 test_3DES_cipheronly_octeontx_all(void)
2333 struct crypto_testsuite_params *ts_params = &testsuite_params;
2336 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2337 ts_params->op_mpool, ts_params->session_mpool,
2338 ts_params->session_priv_mpool,
2339 ts_params->valid_devs[0],
2340 rte_cryptodev_driver_id_get(
2341 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2342 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2344 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2346 return TEST_SUCCESS;
2350 test_authonly_octeontx_all(void)
2352 struct crypto_testsuite_params *ts_params = &testsuite_params;
2355 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2356 ts_params->op_mpool, ts_params->session_mpool,
2357 ts_params->session_priv_mpool,
2358 ts_params->valid_devs[0],
2359 rte_cryptodev_driver_id_get(
2360 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2361 BLKCIPHER_AUTHONLY_TYPE);
2363 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2365 return TEST_SUCCESS;
2368 /* ***** SNOW 3G Tests ***** */
2370 create_wireless_algo_hash_session(uint8_t dev_id,
2371 const uint8_t *key, const uint8_t key_len,
2372 const uint8_t iv_len, const uint8_t auth_len,
2373 enum rte_crypto_auth_operation op,
2374 enum rte_crypto_auth_algorithm algo)
2376 uint8_t hash_key[key_len];
2378 struct crypto_testsuite_params *ts_params = &testsuite_params;
2379 struct crypto_unittest_params *ut_params = &unittest_params;
2381 memcpy(hash_key, key, key_len);
2383 debug_hexdump(stdout, "key:", key, key_len);
2385 /* Setup Authentication Parameters */
2386 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2387 ut_params->auth_xform.next = NULL;
2389 ut_params->auth_xform.auth.op = op;
2390 ut_params->auth_xform.auth.algo = algo;
2391 ut_params->auth_xform.auth.key.length = key_len;
2392 ut_params->auth_xform.auth.key.data = hash_key;
2393 ut_params->auth_xform.auth.digest_length = auth_len;
2394 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2395 ut_params->auth_xform.auth.iv.length = iv_len;
2396 ut_params->sess = rte_cryptodev_sym_session_create(
2397 ts_params->session_mpool);
2399 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2400 &ut_params->auth_xform,
2401 ts_params->session_priv_mpool);
2402 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2407 create_wireless_algo_cipher_session(uint8_t dev_id,
2408 enum rte_crypto_cipher_operation op,
2409 enum rte_crypto_cipher_algorithm algo,
2410 const uint8_t *key, const uint8_t key_len,
2413 uint8_t cipher_key[key_len];
2415 struct crypto_testsuite_params *ts_params = &testsuite_params;
2416 struct crypto_unittest_params *ut_params = &unittest_params;
2418 memcpy(cipher_key, key, key_len);
2420 /* Setup Cipher Parameters */
2421 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2422 ut_params->cipher_xform.next = NULL;
2424 ut_params->cipher_xform.cipher.algo = algo;
2425 ut_params->cipher_xform.cipher.op = op;
2426 ut_params->cipher_xform.cipher.key.data = cipher_key;
2427 ut_params->cipher_xform.cipher.key.length = key_len;
2428 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2429 ut_params->cipher_xform.cipher.iv.length = iv_len;
2431 debug_hexdump(stdout, "key:", key, key_len);
2433 /* Create Crypto session */
2434 ut_params->sess = rte_cryptodev_sym_session_create(
2435 ts_params->session_mpool);
2437 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2438 &ut_params->cipher_xform,
2439 ts_params->session_priv_mpool);
2440 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2445 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2446 unsigned int cipher_len,
2447 unsigned int cipher_offset)
2449 struct crypto_testsuite_params *ts_params = &testsuite_params;
2450 struct crypto_unittest_params *ut_params = &unittest_params;
2452 /* Generate Crypto op data structure */
2453 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2454 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2455 TEST_ASSERT_NOT_NULL(ut_params->op,
2456 "Failed to allocate pktmbuf offload");
2458 /* Set crypto operation data parameters */
2459 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2461 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2463 /* set crypto operation source mbuf */
2464 sym_op->m_src = ut_params->ibuf;
2467 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2469 sym_op->cipher.data.length = cipher_len;
2470 sym_op->cipher.data.offset = cipher_offset;
2475 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2476 unsigned int cipher_len,
2477 unsigned int cipher_offset)
2479 struct crypto_testsuite_params *ts_params = &testsuite_params;
2480 struct crypto_unittest_params *ut_params = &unittest_params;
2482 /* Generate Crypto op data structure */
2483 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2484 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2485 TEST_ASSERT_NOT_NULL(ut_params->op,
2486 "Failed to allocate pktmbuf offload");
2488 /* Set crypto operation data parameters */
2489 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2491 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2493 /* set crypto operation source mbuf */
2494 sym_op->m_src = ut_params->ibuf;
2495 sym_op->m_dst = ut_params->obuf;
2498 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2500 sym_op->cipher.data.length = cipher_len;
2501 sym_op->cipher.data.offset = cipher_offset;
2506 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2507 enum rte_crypto_cipher_operation cipher_op,
2508 enum rte_crypto_auth_operation auth_op,
2509 enum rte_crypto_auth_algorithm auth_algo,
2510 enum rte_crypto_cipher_algorithm cipher_algo,
2511 const uint8_t *key, uint8_t key_len,
2512 uint8_t auth_iv_len, uint8_t auth_len,
2513 uint8_t cipher_iv_len)
2516 uint8_t cipher_auth_key[key_len];
2518 struct crypto_testsuite_params *ts_params = &testsuite_params;
2519 struct crypto_unittest_params *ut_params = &unittest_params;
2521 memcpy(cipher_auth_key, key, key_len);
2523 /* Setup Authentication Parameters */
2524 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2525 ut_params->auth_xform.next = NULL;
2527 ut_params->auth_xform.auth.op = auth_op;
2528 ut_params->auth_xform.auth.algo = auth_algo;
2529 ut_params->auth_xform.auth.key.length = key_len;
2530 /* Hash key = cipher key */
2531 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2532 ut_params->auth_xform.auth.digest_length = auth_len;
2533 /* Auth IV will be after cipher IV */
2534 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2535 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2537 /* Setup Cipher Parameters */
2538 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2539 ut_params->cipher_xform.next = &ut_params->auth_xform;
2541 ut_params->cipher_xform.cipher.algo = cipher_algo;
2542 ut_params->cipher_xform.cipher.op = cipher_op;
2543 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2544 ut_params->cipher_xform.cipher.key.length = key_len;
2545 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2546 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_wireless_cipher_auth_session(uint8_t dev_id,
2564 enum rte_crypto_cipher_operation cipher_op,
2565 enum rte_crypto_auth_operation auth_op,
2566 enum rte_crypto_auth_algorithm auth_algo,
2567 enum rte_crypto_cipher_algorithm cipher_algo,
2568 const struct wireless_test_data *tdata)
2570 const uint8_t key_len = tdata->key.len;
2571 uint8_t cipher_auth_key[key_len];
2573 struct crypto_testsuite_params *ts_params = &testsuite_params;
2574 struct crypto_unittest_params *ut_params = &unittest_params;
2575 const uint8_t *key = tdata->key.data;
2576 const uint8_t auth_len = tdata->digest.len;
2577 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2578 uint8_t auth_iv_len = tdata->auth_iv.len;
2580 memcpy(cipher_auth_key, key, key_len);
2582 /* Setup Authentication Parameters */
2583 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2584 ut_params->auth_xform.next = NULL;
2586 ut_params->auth_xform.auth.op = auth_op;
2587 ut_params->auth_xform.auth.algo = auth_algo;
2588 ut_params->auth_xform.auth.key.length = key_len;
2589 /* Hash key = cipher key */
2590 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2591 ut_params->auth_xform.auth.digest_length = auth_len;
2592 /* Auth IV will be after cipher IV */
2593 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2594 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2596 /* Setup Cipher Parameters */
2597 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2598 ut_params->cipher_xform.next = &ut_params->auth_xform;
2600 ut_params->cipher_xform.cipher.algo = cipher_algo;
2601 ut_params->cipher_xform.cipher.op = cipher_op;
2602 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2603 ut_params->cipher_xform.cipher.key.length = key_len;
2604 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2605 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2608 debug_hexdump(stdout, "key:", key, key_len);
2610 /* Create Crypto session*/
2611 ut_params->sess = rte_cryptodev_sym_session_create(
2612 ts_params->session_mpool);
2614 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2615 &ut_params->cipher_xform,
2616 ts_params->session_priv_mpool);
2618 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2623 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2624 const struct wireless_test_data *tdata)
2626 return create_wireless_cipher_auth_session(dev_id,
2627 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2628 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2629 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2633 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2634 enum rte_crypto_cipher_operation cipher_op,
2635 enum rte_crypto_auth_operation auth_op,
2636 enum rte_crypto_auth_algorithm auth_algo,
2637 enum rte_crypto_cipher_algorithm cipher_algo,
2638 const uint8_t *key, const uint8_t key_len,
2639 uint8_t auth_iv_len, uint8_t auth_len,
2640 uint8_t cipher_iv_len)
2642 uint8_t auth_cipher_key[key_len];
2644 struct crypto_testsuite_params *ts_params = &testsuite_params;
2645 struct crypto_unittest_params *ut_params = &unittest_params;
2647 memcpy(auth_cipher_key, key, key_len);
2649 /* Setup Authentication Parameters */
2650 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2651 ut_params->auth_xform.auth.op = auth_op;
2652 ut_params->auth_xform.next = &ut_params->cipher_xform;
2653 ut_params->auth_xform.auth.algo = auth_algo;
2654 ut_params->auth_xform.auth.key.length = key_len;
2655 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2656 ut_params->auth_xform.auth.digest_length = auth_len;
2657 /* Auth IV will be after cipher IV */
2658 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2659 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2661 /* Setup Cipher Parameters */
2662 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2663 ut_params->cipher_xform.next = NULL;
2664 ut_params->cipher_xform.cipher.algo = cipher_algo;
2665 ut_params->cipher_xform.cipher.op = cipher_op;
2666 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2667 ut_params->cipher_xform.cipher.key.length = key_len;
2668 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2669 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2671 debug_hexdump(stdout, "key:", key, key_len);
2673 /* Create Crypto session*/
2674 ut_params->sess = rte_cryptodev_sym_session_create(
2675 ts_params->session_mpool);
2677 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2678 &ut_params->auth_xform,
2679 ts_params->session_priv_mpool);
2681 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2687 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2688 unsigned int auth_tag_len,
2689 const uint8_t *iv, unsigned int iv_len,
2690 unsigned int data_pad_len,
2691 enum rte_crypto_auth_operation op,
2692 unsigned int auth_len, unsigned int auth_offset)
2694 struct crypto_testsuite_params *ts_params = &testsuite_params;
2696 struct crypto_unittest_params *ut_params = &unittest_params;
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");
2704 /* Set crypto operation data parameters */
2705 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2707 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2709 /* set crypto operation source mbuf */
2710 sym_op->m_src = ut_params->ibuf;
2713 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2716 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2717 ut_params->ibuf, auth_tag_len);
2719 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2720 "no room to append auth tag");
2721 ut_params->digest = sym_op->auth.digest.data;
2722 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2723 ut_params->ibuf, data_pad_len);
2724 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2725 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2727 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2729 debug_hexdump(stdout, "digest:",
2730 sym_op->auth.digest.data,
2733 sym_op->auth.data.length = auth_len;
2734 sym_op->auth.data.offset = auth_offset;
2740 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2741 enum rte_crypto_auth_operation op)
2743 struct crypto_testsuite_params *ts_params = &testsuite_params;
2744 struct crypto_unittest_params *ut_params = &unittest_params;
2746 const uint8_t *auth_tag = tdata->digest.data;
2747 const unsigned int auth_tag_len = tdata->digest.len;
2748 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2749 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2751 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2752 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2753 const uint8_t *auth_iv = tdata->auth_iv.data;
2754 const uint8_t auth_iv_len = tdata->auth_iv.len;
2755 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2756 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2758 /* Generate Crypto op data structure */
2759 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2760 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2761 TEST_ASSERT_NOT_NULL(ut_params->op,
2762 "Failed to allocate pktmbuf offload");
2763 /* Set crypto operation data parameters */
2764 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2766 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2768 /* set crypto operation source mbuf */
2769 sym_op->m_src = ut_params->ibuf;
2772 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2773 ut_params->ibuf, auth_tag_len);
2775 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2776 "no room to append auth tag");
2777 ut_params->digest = sym_op->auth.digest.data;
2778 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2779 ut_params->ibuf, data_pad_len);
2780 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2781 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2783 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2785 debug_hexdump(stdout, "digest:",
2786 sym_op->auth.digest.data,
2789 /* Copy cipher and auth IVs at the end of the crypto operation */
2790 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2792 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2793 iv_ptr += cipher_iv_len;
2794 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2796 sym_op->cipher.data.length = cipher_len;
2797 sym_op->cipher.data.offset = 0;
2798 sym_op->auth.data.length = auth_len;
2799 sym_op->auth.data.offset = 0;
2805 create_zuc_cipher_hash_generate_operation(
2806 const struct wireless_test_data *tdata)
2808 return create_wireless_cipher_hash_operation(tdata,
2809 RTE_CRYPTO_AUTH_OP_GENERATE);
2813 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2814 const unsigned auth_tag_len,
2815 const uint8_t *auth_iv, uint8_t auth_iv_len,
2816 unsigned data_pad_len,
2817 enum rte_crypto_auth_operation op,
2818 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2819 const unsigned cipher_len, const unsigned cipher_offset,
2820 const unsigned auth_len, const unsigned auth_offset)
2822 struct crypto_testsuite_params *ts_params = &testsuite_params;
2823 struct crypto_unittest_params *ut_params = &unittest_params;
2825 /* Generate Crypto op data structure */
2826 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2827 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2828 TEST_ASSERT_NOT_NULL(ut_params->op,
2829 "Failed to allocate pktmbuf offload");
2830 /* Set crypto operation data parameters */
2831 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2833 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2835 /* set crypto operation source mbuf */
2836 sym_op->m_src = ut_params->ibuf;
2839 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2840 ut_params->ibuf, auth_tag_len);
2842 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2843 "no room to append auth tag");
2844 ut_params->digest = sym_op->auth.digest.data;
2845 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2846 ut_params->ibuf, data_pad_len);
2847 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2848 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2850 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2852 debug_hexdump(stdout, "digest:",
2853 sym_op->auth.digest.data,
2856 /* Copy cipher and auth IVs at the end of the crypto operation */
2857 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2859 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2860 iv_ptr += cipher_iv_len;
2861 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2863 sym_op->cipher.data.length = cipher_len;
2864 sym_op->cipher.data.offset = cipher_offset;
2865 sym_op->auth.data.length = auth_len;
2866 sym_op->auth.data.offset = auth_offset;
2872 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2873 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2874 const uint8_t *auth_iv, uint8_t auth_iv_len,
2875 unsigned int data_pad_len,
2876 unsigned int cipher_len, unsigned int cipher_offset,
2877 unsigned int auth_len, unsigned int auth_offset)
2879 struct crypto_testsuite_params *ts_params = &testsuite_params;
2880 struct crypto_unittest_params *ut_params = &unittest_params;
2882 /* Generate Crypto op data structure */
2883 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2884 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2885 TEST_ASSERT_NOT_NULL(ut_params->op,
2886 "Failed to allocate pktmbuf offload");
2888 /* Set crypto operation data parameters */
2889 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2891 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2893 /* set crypto operation source mbuf */
2894 sym_op->m_src = ut_params->ibuf;
2897 sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
2898 ut_params->ibuf, uint8_t *, data_pad_len);
2900 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2901 "no room to append auth tag");
2903 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2904 ut_params->ibuf, data_pad_len);
2906 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2908 /* Copy cipher and auth IVs at the end of the crypto operation */
2909 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2911 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2912 iv_ptr += cipher_iv_len;
2913 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2915 sym_op->cipher.data.length = cipher_len;
2916 sym_op->cipher.data.offset = cipher_offset;
2918 sym_op->auth.data.length = auth_len;
2919 sym_op->auth.data.offset = auth_offset;
2925 test_snow3g_authentication(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_GENERATE,
2940 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2944 /* alloc mbuf and set payload */
2945 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2947 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2948 rte_pktmbuf_tailroom(ut_params->ibuf));
2950 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2951 /* Append data which is padded to a multiple of */
2952 /* the algorithms block size */
2953 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2954 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2956 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2958 /* Create SNOW 3G operation */
2959 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2960 tdata->auth_iv.data, tdata->auth_iv.len,
2961 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2962 tdata->validAuthLenInBits.len,
2967 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2969 ut_params->obuf = ut_params->op->sym->m_src;
2970 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2971 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2972 + plaintext_pad_len;
2975 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2978 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2979 "SNOW 3G Generated auth tag not as expected");
2985 test_snow3g_authentication_verify(const struct snow3g_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 SNOW 3G session */
2996 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2997 tdata->key.data, tdata->key.len,
2998 tdata->auth_iv.len, tdata->digest.len,
2999 RTE_CRYPTO_AUTH_OP_VERIFY,
3000 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3003 /* alloc mbuf and set payload */
3004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3006 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3007 rte_pktmbuf_tailroom(ut_params->ibuf));
3009 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3010 /* Append data which is padded to a multiple of */
3011 /* the algorithms block size */
3012 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3013 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3015 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3017 /* Create SNOW 3G operation */
3018 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3020 tdata->auth_iv.data, tdata->auth_iv.len,
3022 RTE_CRYPTO_AUTH_OP_VERIFY,
3023 tdata->validAuthLenInBits.len,
3028 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3030 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3031 ut_params->obuf = ut_params->op->sym->m_src;
3032 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3033 + plaintext_pad_len;
3036 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3045 test_kasumi_authentication(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_GENERATE,
3060 RTE_CRYPTO_AUTH_KASUMI_F9);
3064 /* alloc mbuf and set payload */
3065 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3067 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3068 rte_pktmbuf_tailroom(ut_params->ibuf));
3070 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3071 /* Append data which is padded to a multiple of */
3072 /* the algorithms block size */
3073 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3074 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3076 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3078 /* Create KASUMI operation */
3079 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3081 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3082 tdata->plaintext.len,
3087 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3089 ut_params->obuf = ut_params->op->sym->m_src;
3090 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3091 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3092 + plaintext_pad_len;
3095 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3098 DIGEST_BYTE_LENGTH_KASUMI_F9,
3099 "KASUMI Generated auth tag not as expected");
3105 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3107 struct crypto_testsuite_params *ts_params = &testsuite_params;
3108 struct crypto_unittest_params *ut_params = &unittest_params;
3111 unsigned plaintext_pad_len;
3112 unsigned plaintext_len;
3115 /* Create KASUMI session */
3116 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3117 tdata->key.data, tdata->key.len,
3118 0, tdata->digest.len,
3119 RTE_CRYPTO_AUTH_OP_VERIFY,
3120 RTE_CRYPTO_AUTH_KASUMI_F9);
3123 /* alloc mbuf and set payload */
3124 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3126 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3127 rte_pktmbuf_tailroom(ut_params->ibuf));
3129 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3130 /* Append data which is padded to a multiple */
3131 /* of the algorithms block size */
3132 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3133 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3135 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3137 /* Create KASUMI operation */
3138 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3142 RTE_CRYPTO_AUTH_OP_VERIFY,
3143 tdata->plaintext.len,
3148 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3150 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3151 ut_params->obuf = ut_params->op->sym->m_src;
3152 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3153 + plaintext_pad_len;
3156 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3165 test_snow3g_hash_generate_test_case_1(void)
3167 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3171 test_snow3g_hash_generate_test_case_2(void)
3173 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3177 test_snow3g_hash_generate_test_case_3(void)
3179 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3183 test_snow3g_hash_generate_test_case_4(void)
3185 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3189 test_snow3g_hash_generate_test_case_5(void)
3191 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3195 test_snow3g_hash_generate_test_case_6(void)
3197 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3201 test_snow3g_hash_verify_test_case_1(void)
3203 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3208 test_snow3g_hash_verify_test_case_2(void)
3210 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3214 test_snow3g_hash_verify_test_case_3(void)
3216 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3220 test_snow3g_hash_verify_test_case_4(void)
3222 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3226 test_snow3g_hash_verify_test_case_5(void)
3228 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3232 test_snow3g_hash_verify_test_case_6(void)
3234 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3238 test_kasumi_hash_generate_test_case_1(void)
3240 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3244 test_kasumi_hash_generate_test_case_2(void)
3246 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3250 test_kasumi_hash_generate_test_case_3(void)
3252 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3256 test_kasumi_hash_generate_test_case_4(void)
3258 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3262 test_kasumi_hash_generate_test_case_5(void)
3264 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3268 test_kasumi_hash_generate_test_case_6(void)
3270 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3274 test_kasumi_hash_verify_test_case_1(void)
3276 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3280 test_kasumi_hash_verify_test_case_2(void)
3282 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3286 test_kasumi_hash_verify_test_case_3(void)
3288 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3292 test_kasumi_hash_verify_test_case_4(void)
3294 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3298 test_kasumi_hash_verify_test_case_5(void)
3300 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3304 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3306 struct crypto_testsuite_params *ts_params = &testsuite_params;
3307 struct crypto_unittest_params *ut_params = &unittest_params;
3310 uint8_t *plaintext, *ciphertext;
3311 unsigned plaintext_pad_len;
3312 unsigned plaintext_len;
3314 /* Create KASUMI session */
3315 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3316 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3317 RTE_CRYPTO_CIPHER_KASUMI_F8,
3318 tdata->key.data, tdata->key.len,
3319 tdata->cipher_iv.len);
3323 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3325 /* Clear mbuf payload */
3326 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3327 rte_pktmbuf_tailroom(ut_params->ibuf));
3329 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3330 /* Append data which is padded to a multiple */
3331 /* of the algorithms block size */
3332 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3333 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3335 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3337 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3339 /* Create KASUMI operation */
3340 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3341 tdata->cipher_iv.len,
3342 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3343 tdata->validCipherOffsetInBits.len);
3347 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3349 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3351 ut_params->obuf = ut_params->op->sym->m_dst;
3352 if (ut_params->obuf)
3353 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3355 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3357 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3359 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3360 (tdata->validCipherOffsetInBits.len >> 3);
3362 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3364 reference_ciphertext,
3365 tdata->validCipherLenInBits.len,
3366 "KASUMI Ciphertext data not as expected");
3371 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3373 struct crypto_testsuite_params *ts_params = &testsuite_params;
3374 struct crypto_unittest_params *ut_params = &unittest_params;
3378 unsigned int plaintext_pad_len;
3379 unsigned int plaintext_len;
3381 uint8_t buffer[10000];
3382 const uint8_t *ciphertext;
3384 struct rte_cryptodev_info dev_info;
3386 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3388 uint64_t feat_flags = dev_info.feature_flags;
3390 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3391 printf("Device doesn't support in-place scatter-gather. "
3396 /* Create KASUMI session */
3397 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3398 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3399 RTE_CRYPTO_CIPHER_KASUMI_F8,
3400 tdata->key.data, tdata->key.len,
3401 tdata->cipher_iv.len);
3405 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3408 /* Append data which is padded to a multiple */
3409 /* of the algorithms block size */
3410 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3412 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3413 plaintext_pad_len, 10, 0);
3415 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3417 /* Create KASUMI operation */
3418 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3419 tdata->cipher_iv.len,
3420 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3421 tdata->validCipherOffsetInBits.len);
3425 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3427 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3429 ut_params->obuf = ut_params->op->sym->m_dst;
3431 if (ut_params->obuf)
3432 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3433 plaintext_len, buffer);
3435 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3436 tdata->validCipherOffsetInBits.len >> 3,
3437 plaintext_len, buffer);
3440 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3442 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3443 (tdata->validCipherOffsetInBits.len >> 3);
3445 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3447 reference_ciphertext,
3448 tdata->validCipherLenInBits.len,
3449 "KASUMI Ciphertext data not as expected");
3454 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3456 struct crypto_testsuite_params *ts_params = &testsuite_params;
3457 struct crypto_unittest_params *ut_params = &unittest_params;
3460 uint8_t *plaintext, *ciphertext;
3461 unsigned plaintext_pad_len;
3462 unsigned plaintext_len;
3464 /* Create KASUMI session */
3465 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3466 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3467 RTE_CRYPTO_CIPHER_KASUMI_F8,
3468 tdata->key.data, tdata->key.len,
3469 tdata->cipher_iv.len);
3473 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3474 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3476 /* Clear mbuf payload */
3477 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3478 rte_pktmbuf_tailroom(ut_params->ibuf));
3480 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3481 /* Append data which is padded to a multiple */
3482 /* of the algorithms block size */
3483 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3484 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3486 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3487 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3489 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3491 /* Create KASUMI operation */
3492 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3493 tdata->cipher_iv.len,
3494 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3495 tdata->validCipherOffsetInBits.len);
3499 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3501 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3503 ut_params->obuf = ut_params->op->sym->m_dst;
3504 if (ut_params->obuf)
3505 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3507 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3509 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3511 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3512 (tdata->validCipherOffsetInBits.len >> 3);
3514 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3516 reference_ciphertext,
3517 tdata->validCipherLenInBits.len,
3518 "KASUMI Ciphertext data not as expected");
3523 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3525 struct crypto_testsuite_params *ts_params = &testsuite_params;
3526 struct crypto_unittest_params *ut_params = &unittest_params;
3529 unsigned int plaintext_pad_len;
3530 unsigned int plaintext_len;
3532 const uint8_t *ciphertext;
3533 uint8_t buffer[2048];
3535 struct rte_cryptodev_info dev_info;
3537 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3539 uint64_t feat_flags = dev_info.feature_flags;
3540 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3541 printf("Device doesn't support out-of-place scatter-gather "
3542 "in both input and output mbufs. "
3547 /* Create KASUMI session */
3548 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3549 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3550 RTE_CRYPTO_CIPHER_KASUMI_F8,
3551 tdata->key.data, tdata->key.len,
3552 tdata->cipher_iv.len);
3556 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3557 /* Append data which is padded to a multiple */
3558 /* of the algorithms block size */
3559 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3561 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3562 plaintext_pad_len, 10, 0);
3563 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3564 plaintext_pad_len, 3, 0);
3566 /* Append data which is padded to a multiple */
3567 /* of the algorithms block size */
3568 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3570 /* Create KASUMI operation */
3571 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3572 tdata->cipher_iv.len,
3573 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3574 tdata->validCipherOffsetInBits.len);
3578 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3580 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3582 ut_params->obuf = ut_params->op->sym->m_dst;
3583 if (ut_params->obuf)
3584 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3585 plaintext_pad_len, buffer);
3587 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3588 tdata->validCipherOffsetInBits.len >> 3,
3589 plaintext_pad_len, buffer);
3591 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3592 (tdata->validCipherOffsetInBits.len >> 3);
3594 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3596 reference_ciphertext,
3597 tdata->validCipherLenInBits.len,
3598 "KASUMI Ciphertext data not as expected");
3604 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3606 struct crypto_testsuite_params *ts_params = &testsuite_params;
3607 struct crypto_unittest_params *ut_params = &unittest_params;
3610 uint8_t *ciphertext, *plaintext;
3611 unsigned ciphertext_pad_len;
3612 unsigned ciphertext_len;
3614 /* Create KASUMI session */
3615 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3616 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3617 RTE_CRYPTO_CIPHER_KASUMI_F8,
3618 tdata->key.data, tdata->key.len,
3619 tdata->cipher_iv.len);
3623 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3624 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3626 /* Clear mbuf payload */
3627 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3628 rte_pktmbuf_tailroom(ut_params->ibuf));
3630 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3631 /* Append data which is padded to a multiple */
3632 /* of the algorithms block size */
3633 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3634 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3635 ciphertext_pad_len);
3636 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3637 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3639 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3641 /* Create KASUMI operation */
3642 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3643 tdata->cipher_iv.len,
3644 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3645 tdata->validCipherOffsetInBits.len);
3649 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3651 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3653 ut_params->obuf = ut_params->op->sym->m_dst;
3654 if (ut_params->obuf)
3655 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3657 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3659 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3661 const uint8_t *reference_plaintext = tdata->plaintext.data +
3662 (tdata->validCipherOffsetInBits.len >> 3);
3664 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3666 reference_plaintext,
3667 tdata->validCipherLenInBits.len,
3668 "KASUMI Plaintext data not as expected");
3673 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3675 struct crypto_testsuite_params *ts_params = &testsuite_params;
3676 struct crypto_unittest_params *ut_params = &unittest_params;
3679 uint8_t *ciphertext, *plaintext;
3680 unsigned ciphertext_pad_len;
3681 unsigned ciphertext_len;
3683 /* Create KASUMI session */
3684 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3685 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3686 RTE_CRYPTO_CIPHER_KASUMI_F8,
3687 tdata->key.data, tdata->key.len,
3688 tdata->cipher_iv.len);
3692 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3694 /* Clear mbuf payload */
3695 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3696 rte_pktmbuf_tailroom(ut_params->ibuf));
3698 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3699 /* Append data which is padded to a multiple */
3700 /* of the algorithms block size */
3701 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3702 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3703 ciphertext_pad_len);
3704 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3706 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3708 /* Create KASUMI operation */
3709 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3710 tdata->cipher_iv.len,
3711 tdata->ciphertext.len,
3712 tdata->validCipherOffsetInBits.len);
3716 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3718 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3720 ut_params->obuf = ut_params->op->sym->m_dst;
3721 if (ut_params->obuf)
3722 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3724 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3726 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3728 const uint8_t *reference_plaintext = tdata->plaintext.data +
3729 (tdata->validCipherOffsetInBits.len >> 3);
3731 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3733 reference_plaintext,
3734 tdata->validCipherLenInBits.len,
3735 "KASUMI Plaintext data not as expected");
3740 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3742 struct crypto_testsuite_params *ts_params = &testsuite_params;
3743 struct crypto_unittest_params *ut_params = &unittest_params;
3746 uint8_t *plaintext, *ciphertext;
3747 unsigned plaintext_pad_len;
3748 unsigned plaintext_len;
3750 /* Create SNOW 3G session */
3751 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3752 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3753 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3754 tdata->key.data, tdata->key.len,
3755 tdata->cipher_iv.len);
3759 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3761 /* Clear mbuf payload */
3762 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3763 rte_pktmbuf_tailroom(ut_params->ibuf));
3765 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3766 /* Append data which is padded to a multiple of */
3767 /* the algorithms block size */
3768 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3769 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3771 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3773 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3775 /* Create SNOW 3G operation */
3776 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3777 tdata->cipher_iv.len,
3778 tdata->validCipherLenInBits.len,
3783 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3785 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3787 ut_params->obuf = ut_params->op->sym->m_dst;
3788 if (ut_params->obuf)
3789 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3791 ciphertext = plaintext;
3793 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3796 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3798 tdata->ciphertext.data,
3799 tdata->validDataLenInBits.len,
3800 "SNOW 3G Ciphertext data not as expected");
3806 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3808 struct crypto_testsuite_params *ts_params = &testsuite_params;
3809 struct crypto_unittest_params *ut_params = &unittest_params;
3810 uint8_t *plaintext, *ciphertext;
3813 unsigned plaintext_pad_len;
3814 unsigned plaintext_len;
3816 /* Create SNOW 3G session */
3817 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3818 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3819 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3820 tdata->key.data, tdata->key.len,
3821 tdata->cipher_iv.len);
3825 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3826 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3828 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3829 "Failed to allocate input buffer in mempool");
3830 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3831 "Failed to allocate output buffer in mempool");
3833 /* Clear mbuf payload */
3834 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3835 rte_pktmbuf_tailroom(ut_params->ibuf));
3837 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3838 /* Append data which is padded to a multiple of */
3839 /* the algorithms block size */
3840 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3841 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3843 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3844 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3846 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3848 /* Create SNOW 3G operation */
3849 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3850 tdata->cipher_iv.len,
3851 tdata->validCipherLenInBits.len,
3856 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3858 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3860 ut_params->obuf = ut_params->op->sym->m_dst;
3861 if (ut_params->obuf)
3862 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3864 ciphertext = plaintext;
3866 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3869 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3871 tdata->ciphertext.data,
3872 tdata->validDataLenInBits.len,
3873 "SNOW 3G Ciphertext data not as expected");
3878 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3880 struct crypto_testsuite_params *ts_params = &testsuite_params;
3881 struct crypto_unittest_params *ut_params = &unittest_params;
3884 unsigned int plaintext_pad_len;
3885 unsigned int plaintext_len;
3886 uint8_t buffer[10000];
3887 const uint8_t *ciphertext;
3889 struct rte_cryptodev_info dev_info;
3891 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3893 uint64_t feat_flags = dev_info.feature_flags;
3895 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3896 printf("Device doesn't support out-of-place scatter-gather "
3897 "in both input and output mbufs. "
3902 /* Create SNOW 3G session */
3903 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3904 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3905 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3906 tdata->key.data, tdata->key.len,
3907 tdata->cipher_iv.len);
3911 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3912 /* Append data which is padded to a multiple of */
3913 /* the algorithms block size */
3914 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3916 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3917 plaintext_pad_len, 10, 0);
3918 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3919 plaintext_pad_len, 3, 0);
3921 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3922 "Failed to allocate input buffer in mempool");
3923 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3924 "Failed to allocate output buffer in mempool");
3926 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3928 /* Create SNOW 3G operation */
3929 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3930 tdata->cipher_iv.len,
3931 tdata->validCipherLenInBits.len,
3936 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3938 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3940 ut_params->obuf = ut_params->op->sym->m_dst;
3941 if (ut_params->obuf)
3942 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3943 plaintext_len, buffer);
3945 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3946 plaintext_len, buffer);
3948 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3951 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3953 tdata->ciphertext.data,
3954 tdata->validDataLenInBits.len,
3955 "SNOW 3G Ciphertext data not as expected");
3960 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3962 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3964 uint8_t curr_byte, prev_byte;
3965 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3966 uint8_t lower_byte_mask = (1 << offset) - 1;
3969 prev_byte = buffer[0];
3970 buffer[0] >>= offset;
3972 for (i = 1; i < length_in_bytes; i++) {
3973 curr_byte = buffer[i];
3974 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3975 (curr_byte >> offset);
3976 prev_byte = curr_byte;
3981 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3983 struct crypto_testsuite_params *ts_params = &testsuite_params;
3984 struct crypto_unittest_params *ut_params = &unittest_params;
3985 uint8_t *plaintext, *ciphertext;
3987 uint32_t plaintext_len;
3988 uint32_t plaintext_pad_len;
3989 uint8_t extra_offset = 4;
3990 uint8_t *expected_ciphertext_shifted;
3992 /* Create SNOW 3G session */
3993 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3994 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3995 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3996 tdata->key.data, tdata->key.len,
3997 tdata->cipher_iv.len);
4001 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4002 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4004 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4005 "Failed to allocate input buffer in mempool");
4006 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4007 "Failed to allocate output buffer in mempool");
4009 /* Clear mbuf payload */
4010 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4011 rte_pktmbuf_tailroom(ut_params->ibuf));
4013 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4015 * Append data which is padded to a
4016 * multiple of the algorithms block size
4018 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4020 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4023 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4025 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4026 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4028 #ifdef RTE_APP_TEST_DEBUG
4029 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4031 /* Create SNOW 3G operation */
4032 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4033 tdata->cipher_iv.len,
4034 tdata->validCipherLenInBits.len,
4039 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4041 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4043 ut_params->obuf = ut_params->op->sym->m_dst;
4044 if (ut_params->obuf)
4045 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4047 ciphertext = plaintext;
4049 #ifdef RTE_APP_TEST_DEBUG
4050 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4053 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4055 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4056 "failed to reserve memory for ciphertext shifted\n");
4058 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4059 ceil_byte_length(tdata->ciphertext.len));
4060 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4063 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4065 expected_ciphertext_shifted,
4066 tdata->validDataLenInBits.len,
4068 "SNOW 3G Ciphertext data not as expected");
4072 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4074 struct crypto_testsuite_params *ts_params = &testsuite_params;
4075 struct crypto_unittest_params *ut_params = &unittest_params;
4079 uint8_t *plaintext, *ciphertext;
4080 unsigned ciphertext_pad_len;
4081 unsigned ciphertext_len;
4083 /* Create SNOW 3G session */
4084 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4085 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4086 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4087 tdata->key.data, tdata->key.len,
4088 tdata->cipher_iv.len);
4092 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4094 /* Clear mbuf payload */
4095 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4096 rte_pktmbuf_tailroom(ut_params->ibuf));
4098 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4099 /* Append data which is padded to a multiple of */
4100 /* the algorithms block size */
4101 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4102 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4103 ciphertext_pad_len);
4104 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4106 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4108 /* Create SNOW 3G operation */
4109 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4110 tdata->cipher_iv.len,
4111 tdata->validCipherLenInBits.len,
4112 tdata->cipher.offset_bits);
4116 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4118 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4119 ut_params->obuf = ut_params->op->sym->m_dst;
4120 if (ut_params->obuf)
4121 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4123 plaintext = ciphertext;
4125 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4128 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4129 tdata->plaintext.data,
4130 tdata->validDataLenInBits.len,
4131 "SNOW 3G Plaintext data not as expected");
4135 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4137 struct crypto_testsuite_params *ts_params = &testsuite_params;
4138 struct crypto_unittest_params *ut_params = &unittest_params;
4142 uint8_t *plaintext, *ciphertext;
4143 unsigned ciphertext_pad_len;
4144 unsigned ciphertext_len;
4146 /* Create SNOW 3G session */
4147 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4148 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4149 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4150 tdata->key.data, tdata->key.len,
4151 tdata->cipher_iv.len);
4155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4156 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4158 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4159 "Failed to allocate input buffer");
4160 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4161 "Failed to allocate output buffer");
4163 /* Clear mbuf payload */
4164 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4165 rte_pktmbuf_tailroom(ut_params->ibuf));
4167 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4168 rte_pktmbuf_tailroom(ut_params->obuf));
4170 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4171 /* Append data which is padded to a multiple of */
4172 /* the algorithms block size */
4173 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4174 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4175 ciphertext_pad_len);
4176 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4177 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4179 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4181 /* Create SNOW 3G operation */
4182 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4183 tdata->cipher_iv.len,
4184 tdata->validCipherLenInBits.len,
4189 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4192 ut_params->obuf = ut_params->op->sym->m_dst;
4193 if (ut_params->obuf)
4194 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4196 plaintext = ciphertext;
4198 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4201 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4202 tdata->plaintext.data,
4203 tdata->validDataLenInBits.len,
4204 "SNOW 3G Plaintext data not as expected");
4209 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4211 struct crypto_testsuite_params *ts_params = &testsuite_params;
4212 struct crypto_unittest_params *ut_params = &unittest_params;
4216 uint8_t *plaintext, *ciphertext;
4217 unsigned int plaintext_pad_len;
4218 unsigned int plaintext_len;
4220 struct rte_cryptodev_sym_capability_idx cap_idx;
4222 /* Check if device supports ZUC EEA3 */
4223 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4224 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4226 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4230 /* Check if device supports ZUC EIA3 */
4231 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4232 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4234 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4238 /* Create ZUC session */
4239 retval = create_zuc_cipher_auth_encrypt_generate_session(
4240 ts_params->valid_devs[0],
4244 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4246 /* clear mbuf payload */
4247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4248 rte_pktmbuf_tailroom(ut_params->ibuf));
4250 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4251 /* Append data which is padded to a multiple of */
4252 /* the algorithms block size */
4253 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4254 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4256 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4258 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4260 /* Create ZUC operation */
4261 retval = create_zuc_cipher_hash_generate_operation(tdata);
4265 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4267 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4268 ut_params->obuf = ut_params->op->sym->m_src;
4269 if (ut_params->obuf)
4270 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4272 ciphertext = plaintext;
4274 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4276 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4278 tdata->ciphertext.data,
4279 tdata->validDataLenInBits.len,
4280 "ZUC Ciphertext data not as expected");
4282 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4283 + plaintext_pad_len;
4286 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4290 "ZUC Generated auth tag not as expected");
4295 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4297 struct crypto_testsuite_params *ts_params = &testsuite_params;
4298 struct crypto_unittest_params *ut_params = &unittest_params;
4302 uint8_t *plaintext, *ciphertext;
4303 unsigned plaintext_pad_len;
4304 unsigned plaintext_len;
4306 /* Create SNOW 3G session */
4307 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4308 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4309 RTE_CRYPTO_AUTH_OP_GENERATE,
4310 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4311 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4312 tdata->key.data, tdata->key.len,
4313 tdata->auth_iv.len, tdata->digest.len,
4314 tdata->cipher_iv.len);
4317 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4319 /* clear mbuf payload */
4320 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4321 rte_pktmbuf_tailroom(ut_params->ibuf));
4323 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4324 /* Append data which is padded to a multiple of */
4325 /* the algorithms block size */
4326 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4327 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4329 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4331 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4333 /* Create SNOW 3G operation */
4334 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4335 tdata->digest.len, tdata->auth_iv.data,
4337 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4338 tdata->cipher_iv.data, tdata->cipher_iv.len,
4339 tdata->validCipherLenInBits.len,
4341 tdata->validAuthLenInBits.len,
4347 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4349 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4350 ut_params->obuf = ut_params->op->sym->m_src;
4351 if (ut_params->obuf)
4352 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4354 ciphertext = plaintext;
4356 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4358 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4360 tdata->ciphertext.data,
4361 tdata->validDataLenInBits.len,
4362 "SNOW 3G Ciphertext data not as expected");
4364 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4365 + plaintext_pad_len;
4368 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4371 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4372 "SNOW 3G Generated auth tag not as expected");
4376 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4378 struct crypto_testsuite_params *ts_params = &testsuite_params;
4379 struct crypto_unittest_params *ut_params = &unittest_params;
4383 uint8_t *plaintext, *ciphertext;
4384 unsigned plaintext_pad_len;
4385 unsigned plaintext_len;
4387 /* Create SNOW 3G session */
4388 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4389 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4390 RTE_CRYPTO_AUTH_OP_GENERATE,
4391 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4392 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4393 tdata->key.data, tdata->key.len,
4394 tdata->auth_iv.len, tdata->digest.len,
4395 tdata->cipher_iv.len);
4399 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4401 /* clear mbuf payload */
4402 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4403 rte_pktmbuf_tailroom(ut_params->ibuf));
4405 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4406 /* Append data which is padded to a multiple of */
4407 /* the algorithms block size */
4408 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4409 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4411 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4413 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4415 /* Create SNOW 3G operation */
4416 retval = create_wireless_algo_auth_cipher_operation(
4418 tdata->cipher_iv.data, tdata->cipher_iv.len,
4419 tdata->auth_iv.data, tdata->auth_iv.len,
4420 tdata->digest.offset_bytes == 0 ?
4421 plaintext_pad_len : tdata->digest.offset_bytes,
4422 tdata->validCipherLenInBits.len,
4423 tdata->cipher.offset_bits,
4424 tdata->validAuthLenInBits.len,
4425 tdata->auth.offset_bits);
4430 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4432 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4433 ut_params->obuf = ut_params->op->sym->m_src;
4434 if (ut_params->obuf)
4435 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4437 ciphertext = plaintext;
4439 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4440 + (tdata->digest.offset_bytes == 0 ?
4441 plaintext_pad_len : tdata->digest.offset_bytes);
4443 debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
4444 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4447 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4449 tdata->ciphertext.data,
4450 tdata->validDataLenInBits.len,
4451 "SNOW 3G Ciphertext data not as expected");
4454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4457 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4458 "SNOW 3G Generated auth tag not as expected");
4463 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4465 struct crypto_testsuite_params *ts_params = &testsuite_params;
4466 struct crypto_unittest_params *ut_params = &unittest_params;
4470 uint8_t *plaintext, *ciphertext;
4471 unsigned plaintext_pad_len;
4472 unsigned plaintext_len;
4474 /* Create KASUMI session */
4475 retval = create_wireless_algo_auth_cipher_session(
4476 ts_params->valid_devs[0],
4477 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4478 RTE_CRYPTO_AUTH_OP_GENERATE,
4479 RTE_CRYPTO_AUTH_KASUMI_F9,
4480 RTE_CRYPTO_CIPHER_KASUMI_F8,
4481 tdata->key.data, tdata->key.len,
4482 0, tdata->digest.len,
4483 tdata->cipher_iv.len);
4486 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4488 /* clear mbuf payload */
4489 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4490 rte_pktmbuf_tailroom(ut_params->ibuf));
4492 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4493 /* Append data which is padded to a multiple of */
4494 /* the algorithms block size */
4495 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4496 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4498 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4500 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4502 /* Create KASUMI operation */
4503 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4504 tdata->cipher_iv.data, tdata->cipher_iv.len,
4507 tdata->validCipherLenInBits.len,
4508 tdata->validCipherOffsetInBits.len,
4509 tdata->validAuthLenInBits.len,
4516 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4518 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4519 if (ut_params->op->sym->m_dst)
4520 ut_params->obuf = ut_params->op->sym->m_dst;
4522 ut_params->obuf = ut_params->op->sym->m_src;
4524 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4525 tdata->validCipherOffsetInBits.len >> 3);
4527 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4528 (tdata->validCipherOffsetInBits.len >> 3);
4530 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4532 reference_ciphertext,
4533 tdata->validCipherLenInBits.len,
4534 "KASUMI Ciphertext data not as expected");
4535 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4536 + plaintext_pad_len;
4539 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4542 DIGEST_BYTE_LENGTH_KASUMI_F9,
4543 "KASUMI Generated auth tag not as expected");
4548 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4550 struct crypto_testsuite_params *ts_params = &testsuite_params;
4551 struct crypto_unittest_params *ut_params = &unittest_params;
4555 uint8_t *plaintext, *ciphertext;
4556 unsigned plaintext_pad_len;
4557 unsigned plaintext_len;
4559 /* Create KASUMI session */
4560 retval = create_wireless_algo_cipher_auth_session(
4561 ts_params->valid_devs[0],
4562 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4563 RTE_CRYPTO_AUTH_OP_GENERATE,
4564 RTE_CRYPTO_AUTH_KASUMI_F9,
4565 RTE_CRYPTO_CIPHER_KASUMI_F8,
4566 tdata->key.data, tdata->key.len,
4567 0, tdata->digest.len,
4568 tdata->cipher_iv.len);
4572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4574 /* clear mbuf payload */
4575 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4576 rte_pktmbuf_tailroom(ut_params->ibuf));
4578 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4579 /* Append data which is padded to a multiple of */
4580 /* the algorithms block size */
4581 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4582 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4584 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4586 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4588 /* Create KASUMI operation */
4589 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4590 tdata->digest.len, NULL, 0,
4591 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4592 tdata->cipher_iv.data, tdata->cipher_iv.len,
4593 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4594 tdata->validCipherOffsetInBits.len,
4595 tdata->validAuthLenInBits.len,
4601 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4603 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4605 if (ut_params->op->sym->m_dst)
4606 ut_params->obuf = ut_params->op->sym->m_dst;
4608 ut_params->obuf = ut_params->op->sym->m_src;
4610 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4611 tdata->validCipherOffsetInBits.len >> 3);
4613 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4614 + plaintext_pad_len;
4616 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4617 (tdata->validCipherOffsetInBits.len >> 3);
4619 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4621 reference_ciphertext,
4622 tdata->validCipherLenInBits.len,
4623 "KASUMI Ciphertext data not as expected");
4626 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4629 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4630 "KASUMI Generated auth tag not as expected");
4635 test_zuc_encryption(const struct wireless_test_data *tdata)
4637 struct crypto_testsuite_params *ts_params = &testsuite_params;
4638 struct crypto_unittest_params *ut_params = &unittest_params;
4641 uint8_t *plaintext, *ciphertext;
4642 unsigned plaintext_pad_len;
4643 unsigned plaintext_len;
4645 struct rte_cryptodev_sym_capability_idx cap_idx;
4647 /* Check if device supports ZUC EEA3 */
4648 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4649 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4651 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4655 /* Create ZUC session */
4656 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4657 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4658 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4659 tdata->key.data, tdata->key.len,
4660 tdata->cipher_iv.len);
4664 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4666 /* Clear mbuf payload */
4667 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4668 rte_pktmbuf_tailroom(ut_params->ibuf));
4670 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4671 /* Append data which is padded to a multiple */
4672 /* of the algorithms block size */
4673 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4674 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4676 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4678 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4680 /* Create ZUC operation */
4681 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4682 tdata->cipher_iv.len,
4683 tdata->plaintext.len,
4688 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4690 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4692 ut_params->obuf = ut_params->op->sym->m_dst;
4693 if (ut_params->obuf)
4694 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4696 ciphertext = plaintext;
4698 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4701 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4703 tdata->ciphertext.data,
4704 tdata->validCipherLenInBits.len,
4705 "ZUC Ciphertext data not as expected");
4710 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4712 struct crypto_testsuite_params *ts_params = &testsuite_params;
4713 struct crypto_unittest_params *ut_params = &unittest_params;
4717 unsigned int plaintext_pad_len;
4718 unsigned int plaintext_len;
4719 const uint8_t *ciphertext;
4720 uint8_t ciphertext_buffer[2048];
4721 struct rte_cryptodev_info dev_info;
4723 struct rte_cryptodev_sym_capability_idx cap_idx;
4725 /* Check if device supports ZUC EEA3 */
4726 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4727 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4729 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4733 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4735 uint64_t feat_flags = dev_info.feature_flags;
4737 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4738 printf("Device doesn't support in-place scatter-gather. "
4743 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4745 /* Append data which is padded to a multiple */
4746 /* of the algorithms block size */
4747 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4749 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4750 plaintext_pad_len, 10, 0);
4752 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4753 tdata->plaintext.data);
4755 /* Create ZUC session */
4756 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4757 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4758 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4759 tdata->key.data, tdata->key.len,
4760 tdata->cipher_iv.len);
4764 /* Clear mbuf payload */
4766 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4768 /* Create ZUC operation */
4769 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4770 tdata->cipher_iv.len, tdata->plaintext.len,
4775 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4777 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4779 ut_params->obuf = ut_params->op->sym->m_dst;
4780 if (ut_params->obuf)
4781 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4782 0, plaintext_len, ciphertext_buffer);
4784 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4785 0, plaintext_len, ciphertext_buffer);
4788 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4793 tdata->ciphertext.data,
4794 tdata->validCipherLenInBits.len,
4795 "ZUC Ciphertext data not as expected");
4801 test_zuc_authentication(const struct wireless_test_data *tdata)
4803 struct crypto_testsuite_params *ts_params = &testsuite_params;
4804 struct crypto_unittest_params *ut_params = &unittest_params;
4807 unsigned plaintext_pad_len;
4808 unsigned plaintext_len;
4811 struct rte_cryptodev_sym_capability_idx cap_idx;
4813 /* Check if device supports ZUC EIA3 */
4814 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4815 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4817 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4821 /* Create ZUC session */
4822 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4823 tdata->key.data, tdata->key.len,
4824 tdata->auth_iv.len, tdata->digest.len,
4825 RTE_CRYPTO_AUTH_OP_GENERATE,
4826 RTE_CRYPTO_AUTH_ZUC_EIA3);
4830 /* alloc mbuf and set payload */
4831 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4833 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4834 rte_pktmbuf_tailroom(ut_params->ibuf));
4836 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4837 /* Append data which is padded to a multiple of */
4838 /* the algorithms block size */
4839 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4840 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4842 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4844 /* Create ZUC operation */
4845 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4846 tdata->auth_iv.data, tdata->auth_iv.len,
4847 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4848 tdata->validAuthLenInBits.len,
4853 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4855 ut_params->obuf = ut_params->op->sym->m_src;
4856 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4857 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4858 + plaintext_pad_len;
4861 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4864 DIGEST_BYTE_LENGTH_KASUMI_F9,
4865 "ZUC Generated auth tag not as expected");
4871 test_kasumi_encryption_test_case_1(void)
4873 return test_kasumi_encryption(&kasumi_test_case_1);
4877 test_kasumi_encryption_test_case_1_sgl(void)
4879 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4883 test_kasumi_encryption_test_case_1_oop(void)
4885 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4889 test_kasumi_encryption_test_case_1_oop_sgl(void)
4891 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4895 test_kasumi_encryption_test_case_2(void)
4897 return test_kasumi_encryption(&kasumi_test_case_2);
4901 test_kasumi_encryption_test_case_3(void)
4903 return test_kasumi_encryption(&kasumi_test_case_3);
4907 test_kasumi_encryption_test_case_4(void)
4909 return test_kasumi_encryption(&kasumi_test_case_4);
4913 test_kasumi_encryption_test_case_5(void)
4915 return test_kasumi_encryption(&kasumi_test_case_5);
4919 test_kasumi_decryption_test_case_1(void)
4921 return test_kasumi_decryption(&kasumi_test_case_1);
4925 test_kasumi_decryption_test_case_1_oop(void)
4927 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4931 test_kasumi_decryption_test_case_2(void)
4933 return test_kasumi_decryption(&kasumi_test_case_2);
4937 test_kasumi_decryption_test_case_3(void)
4939 return test_kasumi_decryption(&kasumi_test_case_3);
4943 test_kasumi_decryption_test_case_4(void)
4945 return test_kasumi_decryption(&kasumi_test_case_4);
4949 test_kasumi_decryption_test_case_5(void)
4951 return test_kasumi_decryption(&kasumi_test_case_5);
4954 test_snow3g_encryption_test_case_1(void)
4956 return test_snow3g_encryption(&snow3g_test_case_1);
4960 test_snow3g_encryption_test_case_1_oop(void)
4962 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4966 test_snow3g_encryption_test_case_1_oop_sgl(void)
4968 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4973 test_snow3g_encryption_test_case_1_offset_oop(void)
4975 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4979 test_snow3g_encryption_test_case_2(void)
4981 return test_snow3g_encryption(&snow3g_test_case_2);
4985 test_snow3g_encryption_test_case_3(void)
4987 return test_snow3g_encryption(&snow3g_test_case_3);
4991 test_snow3g_encryption_test_case_4(void)
4993 return test_snow3g_encryption(&snow3g_test_case_4);
4997 test_snow3g_encryption_test_case_5(void)
4999 return test_snow3g_encryption(&snow3g_test_case_5);
5003 test_snow3g_decryption_test_case_1(void)
5005 return test_snow3g_decryption(&snow3g_test_case_1);
5009 test_snow3g_decryption_test_case_1_oop(void)
5011 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5015 test_snow3g_decryption_test_case_2(void)
5017 return test_snow3g_decryption(&snow3g_test_case_2);
5021 test_snow3g_decryption_test_case_3(void)
5023 return test_snow3g_decryption(&snow3g_test_case_3);
5027 test_snow3g_decryption_test_case_4(void)
5029 return test_snow3g_decryption(&snow3g_test_case_4);
5033 test_snow3g_decryption_test_case_5(void)
5035 return test_snow3g_decryption(&snow3g_test_case_5);
5039 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5040 * Pattern digest from snow3g_test_data must be allocated as
5041 * 4 last bytes in plaintext.
5044 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5045 struct snow3g_hash_test_data *output)
5047 if ((pattern != NULL) && (output != NULL)) {
5048 output->key.len = pattern->key.len;
5050 memcpy(output->key.data,
5051 pattern->key.data, pattern->key.len);
5053 output->auth_iv.len = pattern->auth_iv.len;
5055 memcpy(output->auth_iv.data,
5056 pattern->auth_iv.data, pattern->auth_iv.len);
5058 output->plaintext.len = pattern->plaintext.len;
5060 memcpy(output->plaintext.data,
5061 pattern->plaintext.data, pattern->plaintext.len >> 3);
5063 output->digest.len = pattern->digest.len;
5065 memcpy(output->digest.data,
5066 &pattern->plaintext.data[pattern->digest.offset_bytes],
5067 pattern->digest.len);
5069 output->validAuthLenInBits.len =
5070 pattern->validAuthLenInBits.len;
5075 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5078 test_snow3g_decryption_with_digest_test_case_1(void)
5080 struct snow3g_hash_test_data snow3g_hash_data;
5083 * Function prepare data for hash veryfication test case.
5084 * Digest is allocated in 4 last bytes in plaintext, pattern.
5086 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5088 return test_snow3g_decryption(&snow3g_test_case_7) &
5089 test_snow3g_authentication_verify(&snow3g_hash_data);
5093 test_snow3g_cipher_auth_test_case_1(void)
5095 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5099 test_snow3g_auth_cipher_test_case_1(void)
5101 return test_snow3g_auth_cipher(&snow3g_test_case_6);
5105 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5107 return test_snow3g_auth_cipher(&snow3g_test_case_7);
5111 test_kasumi_auth_cipher_test_case_1(void)
5113 return test_kasumi_auth_cipher(&kasumi_test_case_3);
5117 test_kasumi_cipher_auth_test_case_1(void)
5119 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5123 test_zuc_encryption_test_case_1(void)
5125 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5129 test_zuc_encryption_test_case_2(void)
5131 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5135 test_zuc_encryption_test_case_3(void)
5137 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5141 test_zuc_encryption_test_case_4(void)
5143 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5147 test_zuc_encryption_test_case_5(void)
5149 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5153 test_zuc_encryption_test_case_6_sgl(void)
5155 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5159 test_zuc_hash_generate_test_case_1(void)
5161 return test_zuc_authentication(&zuc_test_case_auth_1b);
5165 test_zuc_hash_generate_test_case_2(void)
5167 return test_zuc_authentication(&zuc_test_case_auth_90b);
5171 test_zuc_hash_generate_test_case_3(void)
5173 return test_zuc_authentication(&zuc_test_case_auth_577b);
5177 test_zuc_hash_generate_test_case_4(void)
5179 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5183 test_zuc_hash_generate_test_case_5(void)
5185 return test_zuc_authentication(&zuc_test_auth_5670b);
5189 test_zuc_hash_generate_test_case_6(void)
5191 return test_zuc_authentication(&zuc_test_case_auth_128b);
5195 test_zuc_hash_generate_test_case_7(void)
5197 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5201 test_zuc_hash_generate_test_case_8(void)
5203 return test_zuc_authentication(&zuc_test_case_auth_584b);
5207 test_zuc_cipher_auth_test_case_1(void)
5209 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5213 test_zuc_cipher_auth_test_case_2(void)
5215 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5219 test_3DES_chain_qat_all(void)
5221 struct crypto_testsuite_params *ts_params = &testsuite_params;
5224 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5225 ts_params->op_mpool,
5226 ts_params->session_mpool, ts_params->session_priv_mpool,
5227 ts_params->valid_devs[0],
5228 rte_cryptodev_driver_id_get(
5229 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5230 BLKCIPHER_3DES_CHAIN_TYPE);
5232 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5234 return TEST_SUCCESS;
5238 test_DES_cipheronly_qat_all(void)
5240 struct crypto_testsuite_params *ts_params = &testsuite_params;
5243 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5244 ts_params->op_mpool,
5245 ts_params->session_mpool, ts_params->session_priv_mpool,
5246 ts_params->valid_devs[0],
5247 rte_cryptodev_driver_id_get(
5248 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5249 BLKCIPHER_DES_CIPHERONLY_TYPE);
5251 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5253 return TEST_SUCCESS;
5257 test_DES_cipheronly_openssl_all(void)
5259 struct crypto_testsuite_params *ts_params = &testsuite_params;
5262 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5263 ts_params->op_mpool,
5264 ts_params->session_mpool, ts_params->session_priv_mpool,
5265 ts_params->valid_devs[0],
5266 rte_cryptodev_driver_id_get(
5267 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5268 BLKCIPHER_DES_CIPHERONLY_TYPE);
5270 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5272 return TEST_SUCCESS;
5276 test_DES_docsis_openssl_all(void)
5278 struct crypto_testsuite_params *ts_params = &testsuite_params;
5281 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5282 ts_params->op_mpool,
5283 ts_params->session_mpool, ts_params->session_priv_mpool,
5284 ts_params->valid_devs[0],
5285 rte_cryptodev_driver_id_get(
5286 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5287 BLKCIPHER_DES_DOCSIS_TYPE);
5289 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5291 return TEST_SUCCESS;
5295 test_DES_cipheronly_mb_all(void)
5297 struct crypto_testsuite_params *ts_params = &testsuite_params;
5300 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5301 ts_params->op_mpool,
5302 ts_params->session_mpool, ts_params->session_priv_mpool,
5303 ts_params->valid_devs[0],
5304 rte_cryptodev_driver_id_get(
5305 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5306 BLKCIPHER_DES_CIPHERONLY_TYPE);
5308 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5310 return TEST_SUCCESS;
5313 test_3DES_cipheronly_mb_all(void)
5315 struct crypto_testsuite_params *ts_params = &testsuite_params;
5318 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5319 ts_params->op_mpool,
5320 ts_params->session_mpool, ts_params->session_priv_mpool,
5321 ts_params->valid_devs[0],
5322 rte_cryptodev_driver_id_get(
5323 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5324 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5326 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5328 return TEST_SUCCESS;
5332 test_DES_docsis_mb_all(void)
5334 struct crypto_testsuite_params *ts_params = &testsuite_params;
5337 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5338 ts_params->op_mpool,
5339 ts_params->session_mpool, ts_params->session_priv_mpool,
5340 ts_params->valid_devs[0],
5341 rte_cryptodev_driver_id_get(
5342 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5343 BLKCIPHER_DES_DOCSIS_TYPE);
5345 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5347 return TEST_SUCCESS;
5351 test_3DES_chain_caam_jr_all(void)
5353 struct crypto_testsuite_params *ts_params = &testsuite_params;
5356 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5357 ts_params->op_mpool,
5358 ts_params->session_mpool, ts_params->session_priv_mpool,
5359 ts_params->valid_devs[0],
5360 rte_cryptodev_driver_id_get(
5361 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5362 BLKCIPHER_3DES_CHAIN_TYPE);
5364 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5366 return TEST_SUCCESS;
5370 test_3DES_cipheronly_caam_jr_all(void)
5372 struct crypto_testsuite_params *ts_params = &testsuite_params;
5375 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5376 ts_params->op_mpool,
5377 ts_params->session_mpool, ts_params->session_priv_mpool,
5378 ts_params->valid_devs[0],
5379 rte_cryptodev_driver_id_get(
5380 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5381 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5383 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5385 return TEST_SUCCESS;
5389 test_3DES_chain_dpaa_sec_all(void)
5391 struct crypto_testsuite_params *ts_params = &testsuite_params;
5394 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5395 ts_params->op_mpool,
5396 ts_params->session_mpool, ts_params->session_priv_mpool,
5397 ts_params->valid_devs[0],
5398 rte_cryptodev_driver_id_get(
5399 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5400 BLKCIPHER_3DES_CHAIN_TYPE);
5402 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5404 return TEST_SUCCESS;
5408 test_3DES_cipheronly_dpaa_sec_all(void)
5410 struct crypto_testsuite_params *ts_params = &testsuite_params;
5413 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5414 ts_params->op_mpool,
5415 ts_params->session_mpool, ts_params->session_priv_mpool,
5416 ts_params->valid_devs[0],
5417 rte_cryptodev_driver_id_get(
5418 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5419 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5421 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5423 return TEST_SUCCESS;
5427 test_3DES_chain_dpaa2_sec_all(void)
5429 struct crypto_testsuite_params *ts_params = &testsuite_params;
5432 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5433 ts_params->op_mpool,
5434 ts_params->session_mpool, ts_params->session_priv_mpool,
5435 ts_params->valid_devs[0],
5436 rte_cryptodev_driver_id_get(
5437 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5438 BLKCIPHER_3DES_CHAIN_TYPE);
5440 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5442 return TEST_SUCCESS;
5446 test_3DES_cipheronly_dpaa2_sec_all(void)
5448 struct crypto_testsuite_params *ts_params = &testsuite_params;
5451 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5452 ts_params->op_mpool,
5453 ts_params->session_mpool, ts_params->session_priv_mpool,
5454 ts_params->valid_devs[0],
5455 rte_cryptodev_driver_id_get(
5456 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5457 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5459 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5461 return TEST_SUCCESS;
5465 test_3DES_chain_ccp_all(void)
5467 struct crypto_testsuite_params *ts_params = &testsuite_params;
5470 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5471 ts_params->op_mpool,
5472 ts_params->session_mpool, ts_params->session_priv_mpool,
5473 ts_params->valid_devs[0],
5474 rte_cryptodev_driver_id_get(
5475 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5476 BLKCIPHER_3DES_CHAIN_TYPE);
5478 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5480 return TEST_SUCCESS;
5484 test_3DES_cipheronly_ccp_all(void)
5486 struct crypto_testsuite_params *ts_params = &testsuite_params;
5489 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5490 ts_params->op_mpool,
5491 ts_params->session_mpool, ts_params->session_priv_mpool,
5492 ts_params->valid_devs[0],
5493 rte_cryptodev_driver_id_get(
5494 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5495 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5497 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5499 return TEST_SUCCESS;
5503 test_3DES_cipheronly_qat_all(void)
5505 struct crypto_testsuite_params *ts_params = &testsuite_params;
5508 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5509 ts_params->op_mpool,
5510 ts_params->session_mpool, ts_params->session_priv_mpool,
5511 ts_params->valid_devs[0],
5512 rte_cryptodev_driver_id_get(
5513 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5514 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5516 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5518 return TEST_SUCCESS;
5522 test_3DES_chain_openssl_all(void)
5524 struct crypto_testsuite_params *ts_params = &testsuite_params;
5527 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5528 ts_params->op_mpool,
5529 ts_params->session_mpool, ts_params->session_priv_mpool,
5530 ts_params->valid_devs[0],
5531 rte_cryptodev_driver_id_get(
5532 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5533 BLKCIPHER_3DES_CHAIN_TYPE);
5535 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5537 return TEST_SUCCESS;
5541 test_3DES_cipheronly_openssl_all(void)
5543 struct crypto_testsuite_params *ts_params = &testsuite_params;
5546 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5547 ts_params->op_mpool,
5548 ts_params->session_mpool, ts_params->session_priv_mpool,
5549 ts_params->valid_devs[0],
5550 rte_cryptodev_driver_id_get(
5551 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5552 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5554 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5556 return TEST_SUCCESS;
5559 /* ***** AEAD algorithm Tests ***** */
5562 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5563 enum rte_crypto_aead_operation op,
5564 const uint8_t *key, const uint8_t key_len,
5565 const uint16_t aad_len, const uint8_t auth_len,
5568 uint8_t aead_key[key_len];
5570 struct crypto_testsuite_params *ts_params = &testsuite_params;
5571 struct crypto_unittest_params *ut_params = &unittest_params;
5573 memcpy(aead_key, key, key_len);
5575 /* Setup AEAD Parameters */
5576 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5577 ut_params->aead_xform.next = NULL;
5578 ut_params->aead_xform.aead.algo = algo;
5579 ut_params->aead_xform.aead.op = op;
5580 ut_params->aead_xform.aead.key.data = aead_key;
5581 ut_params->aead_xform.aead.key.length = key_len;
5582 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5583 ut_params->aead_xform.aead.iv.length = iv_len;
5584 ut_params->aead_xform.aead.digest_length = auth_len;
5585 ut_params->aead_xform.aead.aad_length = aad_len;
5587 debug_hexdump(stdout, "key:", key, key_len);
5589 /* Create Crypto session*/
5590 ut_params->sess = rte_cryptodev_sym_session_create(
5591 ts_params->session_mpool);
5593 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5594 &ut_params->aead_xform,
5595 ts_params->session_priv_mpool);
5597 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5603 create_aead_xform(struct rte_crypto_op *op,
5604 enum rte_crypto_aead_algorithm algo,
5605 enum rte_crypto_aead_operation aead_op,
5606 uint8_t *key, const uint8_t key_len,
5607 const uint8_t aad_len, const uint8_t auth_len,
5610 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5611 "failed to allocate space for crypto transform");
5613 struct rte_crypto_sym_op *sym_op = op->sym;
5615 /* Setup AEAD Parameters */
5616 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5617 sym_op->xform->next = NULL;
5618 sym_op->xform->aead.algo = algo;
5619 sym_op->xform->aead.op = aead_op;
5620 sym_op->xform->aead.key.data = key;
5621 sym_op->xform->aead.key.length = key_len;
5622 sym_op->xform->aead.iv.offset = IV_OFFSET;
5623 sym_op->xform->aead.iv.length = iv_len;
5624 sym_op->xform->aead.digest_length = auth_len;
5625 sym_op->xform->aead.aad_length = aad_len;
5627 debug_hexdump(stdout, "key:", key, key_len);
5633 create_aead_operation(enum rte_crypto_aead_operation op,
5634 const struct aead_test_data *tdata)
5636 struct crypto_testsuite_params *ts_params = &testsuite_params;
5637 struct crypto_unittest_params *ut_params = &unittest_params;
5639 uint8_t *plaintext, *ciphertext;
5640 unsigned int aad_pad_len, plaintext_pad_len;
5642 /* Generate Crypto op data structure */
5643 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5644 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5645 TEST_ASSERT_NOT_NULL(ut_params->op,
5646 "Failed to allocate symmetric crypto operation struct");
5648 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5650 /* Append aad data */
5651 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5652 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5653 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5655 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5656 "no room to append aad");
5658 sym_op->aead.aad.phys_addr =
5659 rte_pktmbuf_iova(ut_params->ibuf);
5660 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5661 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5662 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5665 /* Append IV at the end of the crypto operation*/
5666 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5667 uint8_t *, IV_OFFSET);
5669 /* Copy IV 1 byte after the IV pointer, according to the API */
5670 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5671 debug_hexdump(stdout, "iv:", iv_ptr,
5674 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5675 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5677 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5678 "no room to append aad");
5680 sym_op->aead.aad.phys_addr =
5681 rte_pktmbuf_iova(ut_params->ibuf);
5682 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5683 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5686 /* Append IV at the end of the crypto operation*/
5687 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5688 uint8_t *, IV_OFFSET);
5690 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5691 debug_hexdump(stdout, "iv:", iv_ptr,
5695 /* Append plaintext/ciphertext */
5696 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5697 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5698 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5700 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5702 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5703 debug_hexdump(stdout, "plaintext:", plaintext,
5704 tdata->plaintext.len);
5706 if (ut_params->obuf) {
5707 ciphertext = (uint8_t *)rte_pktmbuf_append(
5709 plaintext_pad_len + aad_pad_len);
5710 TEST_ASSERT_NOT_NULL(ciphertext,
5711 "no room to append ciphertext");
5713 memset(ciphertext + aad_pad_len, 0,
5714 tdata->ciphertext.len);
5717 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5718 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5720 TEST_ASSERT_NOT_NULL(ciphertext,
5721 "no room to append ciphertext");
5723 memcpy(ciphertext, tdata->ciphertext.data,
5724 tdata->ciphertext.len);
5725 debug_hexdump(stdout, "ciphertext:", ciphertext,
5726 tdata->ciphertext.len);
5728 if (ut_params->obuf) {
5729 plaintext = (uint8_t *)rte_pktmbuf_append(
5731 plaintext_pad_len + aad_pad_len);
5732 TEST_ASSERT_NOT_NULL(plaintext,
5733 "no room to append plaintext");
5735 memset(plaintext + aad_pad_len, 0,
5736 tdata->plaintext.len);
5740 /* Append digest data */
5741 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5742 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5743 ut_params->obuf ? ut_params->obuf :
5745 tdata->auth_tag.len);
5746 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5747 "no room to append digest");
5748 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5749 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5750 ut_params->obuf ? ut_params->obuf :
5755 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5756 ut_params->ibuf, tdata->auth_tag.len);
5757 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5758 "no room to append digest");
5759 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5761 plaintext_pad_len + aad_pad_len);
5763 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5764 tdata->auth_tag.len);
5765 debug_hexdump(stdout, "digest:",
5766 sym_op->aead.digest.data,
5767 tdata->auth_tag.len);
5770 sym_op->aead.data.length = tdata->plaintext.len;
5771 sym_op->aead.data.offset = aad_pad_len;
5777 test_authenticated_encryption(const struct aead_test_data *tdata)
5779 struct crypto_testsuite_params *ts_params = &testsuite_params;
5780 struct crypto_unittest_params *ut_params = &unittest_params;
5783 uint8_t *ciphertext, *auth_tag;
5784 uint16_t plaintext_pad_len;
5787 /* Create AEAD session */
5788 retval = create_aead_session(ts_params->valid_devs[0],
5790 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5791 tdata->key.data, tdata->key.len,
5792 tdata->aad.len, tdata->auth_tag.len,
5797 if (tdata->aad.len > MBUF_SIZE) {
5798 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5799 /* Populate full size of add data */
5800 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5801 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5803 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5805 /* clear mbuf payload */
5806 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5807 rte_pktmbuf_tailroom(ut_params->ibuf));
5809 /* Create AEAD operation */
5810 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5814 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5816 ut_params->op->sym->m_src = ut_params->ibuf;
5818 /* Process crypto operation */
5819 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5820 ut_params->op), "failed to process sym crypto op");
5822 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5823 "crypto op processing failed");
5825 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5827 if (ut_params->op->sym->m_dst) {
5828 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5830 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5831 uint8_t *, plaintext_pad_len);
5833 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5835 ut_params->op->sym->cipher.data.offset);
5836 auth_tag = ciphertext + plaintext_pad_len;
5839 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5840 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5843 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5845 tdata->ciphertext.data,
5846 tdata->ciphertext.len,
5847 "Ciphertext data not as expected");
5849 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5851 tdata->auth_tag.data,
5852 tdata->auth_tag.len,
5853 "Generated auth tag not as expected");
5860 test_AES_GCM_authenticated_encryption_test_case_1(void)
5862 return test_authenticated_encryption(&gcm_test_case_1);
5866 test_AES_GCM_authenticated_encryption_test_case_2(void)
5868 return test_authenticated_encryption(&gcm_test_case_2);
5872 test_AES_GCM_authenticated_encryption_test_case_3(void)
5874 return test_authenticated_encryption(&gcm_test_case_3);
5878 test_AES_GCM_authenticated_encryption_test_case_4(void)
5880 return test_authenticated_encryption(&gcm_test_case_4);
5884 test_AES_GCM_authenticated_encryption_test_case_5(void)
5886 return test_authenticated_encryption(&gcm_test_case_5);
5890 test_AES_GCM_authenticated_encryption_test_case_6(void)
5892 return test_authenticated_encryption(&gcm_test_case_6);
5896 test_AES_GCM_authenticated_encryption_test_case_7(void)
5898 return test_authenticated_encryption(&gcm_test_case_7);
5902 test_AES_GCM_auth_encryption_test_case_192_1(void)
5904 return test_authenticated_encryption(&gcm_test_case_192_1);
5908 test_AES_GCM_auth_encryption_test_case_192_2(void)
5910 return test_authenticated_encryption(&gcm_test_case_192_2);
5914 test_AES_GCM_auth_encryption_test_case_192_3(void)
5916 return test_authenticated_encryption(&gcm_test_case_192_3);
5920 test_AES_GCM_auth_encryption_test_case_192_4(void)
5922 return test_authenticated_encryption(&gcm_test_case_192_4);
5926 test_AES_GCM_auth_encryption_test_case_192_5(void)
5928 return test_authenticated_encryption(&gcm_test_case_192_5);
5932 test_AES_GCM_auth_encryption_test_case_192_6(void)
5934 return test_authenticated_encryption(&gcm_test_case_192_6);
5938 test_AES_GCM_auth_encryption_test_case_192_7(void)
5940 return test_authenticated_encryption(&gcm_test_case_192_7);
5944 test_AES_GCM_auth_encryption_test_case_256_1(void)
5946 return test_authenticated_encryption(&gcm_test_case_256_1);
5950 test_AES_GCM_auth_encryption_test_case_256_2(void)
5952 return test_authenticated_encryption(&gcm_test_case_256_2);
5956 test_AES_GCM_auth_encryption_test_case_256_3(void)
5958 return test_authenticated_encryption(&gcm_test_case_256_3);
5962 test_AES_GCM_auth_encryption_test_case_256_4(void)
5964 return test_authenticated_encryption(&gcm_test_case_256_4);
5968 test_AES_GCM_auth_encryption_test_case_256_5(void)
5970 return test_authenticated_encryption(&gcm_test_case_256_5);
5974 test_AES_GCM_auth_encryption_test_case_256_6(void)
5976 return test_authenticated_encryption(&gcm_test_case_256_6);
5980 test_AES_GCM_auth_encryption_test_case_256_7(void)
5982 return test_authenticated_encryption(&gcm_test_case_256_7);
5986 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5988 return test_authenticated_encryption(&gcm_test_case_aad_1);
5992 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5994 return test_authenticated_encryption(&gcm_test_case_aad_2);
5998 test_authenticated_decryption(const struct aead_test_data *tdata)
6000 struct crypto_testsuite_params *ts_params = &testsuite_params;
6001 struct crypto_unittest_params *ut_params = &unittest_params;
6007 /* Create AEAD session */
6008 retval = create_aead_session(ts_params->valid_devs[0],
6010 RTE_CRYPTO_AEAD_OP_DECRYPT,
6011 tdata->key.data, tdata->key.len,
6012 tdata->aad.len, tdata->auth_tag.len,
6017 /* alloc mbuf and set payload */
6018 if (tdata->aad.len > MBUF_SIZE) {
6019 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6020 /* Populate full size of add data */
6021 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6022 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6024 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6026 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6027 rte_pktmbuf_tailroom(ut_params->ibuf));
6029 /* Create AEAD operation */
6030 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6034 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6036 ut_params->op->sym->m_src = ut_params->ibuf;
6038 /* Process crypto operation */
6039 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6040 ut_params->op), "failed to process sym crypto op");
6042 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6043 "crypto op processing failed");
6045 if (ut_params->op->sym->m_dst)
6046 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6049 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6051 ut_params->op->sym->cipher.data.offset);
6053 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6056 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6058 tdata->plaintext.data,
6059 tdata->plaintext.len,
6060 "Plaintext data not as expected");
6062 TEST_ASSERT_EQUAL(ut_params->op->status,
6063 RTE_CRYPTO_OP_STATUS_SUCCESS,
6064 "Authentication failed");
6069 test_AES_GCM_authenticated_decryption_test_case_1(void)
6071 return test_authenticated_decryption(&gcm_test_case_1);
6075 test_AES_GCM_authenticated_decryption_test_case_2(void)
6077 return test_authenticated_decryption(&gcm_test_case_2);
6081 test_AES_GCM_authenticated_decryption_test_case_3(void)
6083 return test_authenticated_decryption(&gcm_test_case_3);
6087 test_AES_GCM_authenticated_decryption_test_case_4(void)
6089 return test_authenticated_decryption(&gcm_test_case_4);
6093 test_AES_GCM_authenticated_decryption_test_case_5(void)
6095 return test_authenticated_decryption(&gcm_test_case_5);
6099 test_AES_GCM_authenticated_decryption_test_case_6(void)
6101 return test_authenticated_decryption(&gcm_test_case_6);
6105 test_AES_GCM_authenticated_decryption_test_case_7(void)
6107 return test_authenticated_decryption(&gcm_test_case_7);
6111 test_AES_GCM_auth_decryption_test_case_192_1(void)
6113 return test_authenticated_decryption(&gcm_test_case_192_1);
6117 test_AES_GCM_auth_decryption_test_case_192_2(void)
6119 return test_authenticated_decryption(&gcm_test_case_192_2);
6123 test_AES_GCM_auth_decryption_test_case_192_3(void)
6125 return test_authenticated_decryption(&gcm_test_case_192_3);
6129 test_AES_GCM_auth_decryption_test_case_192_4(void)
6131 return test_authenticated_decryption(&gcm_test_case_192_4);
6135 test_AES_GCM_auth_decryption_test_case_192_5(void)
6137 return test_authenticated_decryption(&gcm_test_case_192_5);
6141 test_AES_GCM_auth_decryption_test_case_192_6(void)
6143 return test_authenticated_decryption(&gcm_test_case_192_6);
6147 test_AES_GCM_auth_decryption_test_case_192_7(void)
6149 return test_authenticated_decryption(&gcm_test_case_192_7);
6153 test_AES_GCM_auth_decryption_test_case_256_1(void)
6155 return test_authenticated_decryption(&gcm_test_case_256_1);
6159 test_AES_GCM_auth_decryption_test_case_256_2(void)
6161 return test_authenticated_decryption(&gcm_test_case_256_2);
6165 test_AES_GCM_auth_decryption_test_case_256_3(void)
6167 return test_authenticated_decryption(&gcm_test_case_256_3);
6171 test_AES_GCM_auth_decryption_test_case_256_4(void)
6173 return test_authenticated_decryption(&gcm_test_case_256_4);
6177 test_AES_GCM_auth_decryption_test_case_256_5(void)
6179 return test_authenticated_decryption(&gcm_test_case_256_5);
6183 test_AES_GCM_auth_decryption_test_case_256_6(void)
6185 return test_authenticated_decryption(&gcm_test_case_256_6);
6189 test_AES_GCM_auth_decryption_test_case_256_7(void)
6191 return test_authenticated_decryption(&gcm_test_case_256_7);
6195 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6197 return test_authenticated_decryption(&gcm_test_case_aad_1);
6201 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6203 return test_authenticated_decryption(&gcm_test_case_aad_2);
6207 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6209 struct crypto_testsuite_params *ts_params = &testsuite_params;
6210 struct crypto_unittest_params *ut_params = &unittest_params;
6213 uint8_t *ciphertext, *auth_tag;
6214 uint16_t plaintext_pad_len;
6216 /* Create AEAD session */
6217 retval = create_aead_session(ts_params->valid_devs[0],
6219 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6220 tdata->key.data, tdata->key.len,
6221 tdata->aad.len, tdata->auth_tag.len,
6226 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6227 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6229 /* clear mbuf payload */
6230 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6231 rte_pktmbuf_tailroom(ut_params->ibuf));
6232 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6233 rte_pktmbuf_tailroom(ut_params->obuf));
6235 /* Create AEAD operation */
6236 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6240 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6242 ut_params->op->sym->m_src = ut_params->ibuf;
6243 ut_params->op->sym->m_dst = ut_params->obuf;
6245 /* Process crypto operation */
6246 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6247 ut_params->op), "failed to process sym crypto op");
6249 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6250 "crypto op processing failed");
6252 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6254 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6255 ut_params->op->sym->cipher.data.offset);
6256 auth_tag = ciphertext + plaintext_pad_len;
6258 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6259 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6262 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6264 tdata->ciphertext.data,
6265 tdata->ciphertext.len,
6266 "Ciphertext data not as expected");
6268 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6270 tdata->auth_tag.data,
6271 tdata->auth_tag.len,
6272 "Generated auth tag not as expected");
6279 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6281 return test_authenticated_encryption_oop(&gcm_test_case_5);
6285 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6287 struct crypto_testsuite_params *ts_params = &testsuite_params;
6288 struct crypto_unittest_params *ut_params = &unittest_params;
6293 /* Create AEAD session */
6294 retval = create_aead_session(ts_params->valid_devs[0],
6296 RTE_CRYPTO_AEAD_OP_DECRYPT,
6297 tdata->key.data, tdata->key.len,
6298 tdata->aad.len, tdata->auth_tag.len,
6303 /* alloc mbuf and set payload */
6304 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6305 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6307 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6308 rte_pktmbuf_tailroom(ut_params->ibuf));
6309 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6310 rte_pktmbuf_tailroom(ut_params->obuf));
6312 /* Create AEAD operation */
6313 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6317 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6319 ut_params->op->sym->m_src = ut_params->ibuf;
6320 ut_params->op->sym->m_dst = ut_params->obuf;
6322 /* Process crypto operation */
6323 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6324 ut_params->op), "failed to process sym crypto op");
6326 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6327 "crypto op processing failed");
6329 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6330 ut_params->op->sym->cipher.data.offset);
6332 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6335 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6337 tdata->plaintext.data,
6338 tdata->plaintext.len,
6339 "Plaintext data not as expected");
6341 TEST_ASSERT_EQUAL(ut_params->op->status,
6342 RTE_CRYPTO_OP_STATUS_SUCCESS,
6343 "Authentication failed");
6348 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6350 return test_authenticated_decryption_oop(&gcm_test_case_5);
6354 test_authenticated_encryption_sessionless(
6355 const struct aead_test_data *tdata)
6357 struct crypto_testsuite_params *ts_params = &testsuite_params;
6358 struct crypto_unittest_params *ut_params = &unittest_params;
6361 uint8_t *ciphertext, *auth_tag;
6362 uint16_t plaintext_pad_len;
6363 uint8_t key[tdata->key.len + 1];
6365 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6367 /* clear mbuf payload */
6368 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6369 rte_pktmbuf_tailroom(ut_params->ibuf));
6371 /* Create AEAD operation */
6372 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6376 /* Create GCM xform */
6377 memcpy(key, tdata->key.data, tdata->key.len);
6378 retval = create_aead_xform(ut_params->op,
6380 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6381 key, tdata->key.len,
6382 tdata->aad.len, tdata->auth_tag.len,
6387 ut_params->op->sym->m_src = ut_params->ibuf;
6389 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6390 RTE_CRYPTO_OP_SESSIONLESS,
6391 "crypto op session type not sessionless");
6393 /* Process crypto operation */
6394 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6395 ut_params->op), "failed to process sym crypto op");
6397 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6399 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6400 "crypto op status not success");
6402 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6404 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6405 ut_params->op->sym->cipher.data.offset);
6406 auth_tag = ciphertext + plaintext_pad_len;
6408 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6409 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6412 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6414 tdata->ciphertext.data,
6415 tdata->ciphertext.len,
6416 "Ciphertext data not as expected");
6418 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6420 tdata->auth_tag.data,
6421 tdata->auth_tag.len,
6422 "Generated auth tag not as expected");
6429 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6431 return test_authenticated_encryption_sessionless(
6436 test_authenticated_decryption_sessionless(
6437 const struct aead_test_data *tdata)
6439 struct crypto_testsuite_params *ts_params = &testsuite_params;
6440 struct crypto_unittest_params *ut_params = &unittest_params;
6444 uint8_t key[tdata->key.len + 1];
6446 /* alloc mbuf and set payload */
6447 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6449 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6450 rte_pktmbuf_tailroom(ut_params->ibuf));
6452 /* Create AEAD operation */
6453 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6457 /* Create AEAD xform */
6458 memcpy(key, tdata->key.data, tdata->key.len);
6459 retval = create_aead_xform(ut_params->op,
6461 RTE_CRYPTO_AEAD_OP_DECRYPT,
6462 key, tdata->key.len,
6463 tdata->aad.len, tdata->auth_tag.len,
6468 ut_params->op->sym->m_src = ut_params->ibuf;
6470 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6471 RTE_CRYPTO_OP_SESSIONLESS,
6472 "crypto op session type not sessionless");
6474 /* Process crypto operation */
6475 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6476 ut_params->op), "failed to process sym crypto op");
6478 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6480 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6481 "crypto op status not success");
6483 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6484 ut_params->op->sym->cipher.data.offset);
6486 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6489 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6491 tdata->plaintext.data,
6492 tdata->plaintext.len,
6493 "Plaintext data not as expected");
6495 TEST_ASSERT_EQUAL(ut_params->op->status,
6496 RTE_CRYPTO_OP_STATUS_SUCCESS,
6497 "Authentication failed");
6502 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6504 return test_authenticated_decryption_sessionless(
6509 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6511 return test_authenticated_encryption(&ccm_test_case_128_1);
6515 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6517 return test_authenticated_encryption(&ccm_test_case_128_2);
6521 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6523 return test_authenticated_encryption(&ccm_test_case_128_3);
6527 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6529 return test_authenticated_decryption(&ccm_test_case_128_1);
6533 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6535 return test_authenticated_decryption(&ccm_test_case_128_2);
6539 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6541 return test_authenticated_decryption(&ccm_test_case_128_3);
6545 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6547 return test_authenticated_encryption(&ccm_test_case_192_1);
6551 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6553 return test_authenticated_encryption(&ccm_test_case_192_2);
6557 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6559 return test_authenticated_encryption(&ccm_test_case_192_3);
6563 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6565 return test_authenticated_decryption(&ccm_test_case_192_1);
6569 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6571 return test_authenticated_decryption(&ccm_test_case_192_2);
6575 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6577 return test_authenticated_decryption(&ccm_test_case_192_3);
6581 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6583 return test_authenticated_encryption(&ccm_test_case_256_1);
6587 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6589 return test_authenticated_encryption(&ccm_test_case_256_2);
6593 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6595 return test_authenticated_encryption(&ccm_test_case_256_3);
6599 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6601 return test_authenticated_decryption(&ccm_test_case_256_1);
6605 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6607 return test_authenticated_decryption(&ccm_test_case_256_2);
6611 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6613 return test_authenticated_decryption(&ccm_test_case_256_3);
6619 struct crypto_testsuite_params *ts_params = &testsuite_params;
6620 struct rte_cryptodev_stats stats;
6621 struct rte_cryptodev *dev;
6622 cryptodev_stats_get_t temp_pfn;
6624 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6625 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6626 &stats) == -ENODEV),
6627 "rte_cryptodev_stats_get invalid dev failed");
6628 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6629 "rte_cryptodev_stats_get invalid Param failed");
6630 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6631 temp_pfn = dev->dev_ops->stats_get;
6632 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6633 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6635 "rte_cryptodev_stats_get invalid Param failed");
6636 dev->dev_ops->stats_get = temp_pfn;
6638 /* Test expected values */
6640 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6642 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6644 "rte_cryptodev_stats_get failed");
6645 TEST_ASSERT((stats.enqueued_count == 1),
6646 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6647 TEST_ASSERT((stats.dequeued_count == 1),
6648 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6649 TEST_ASSERT((stats.enqueue_err_count == 0),
6650 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6651 TEST_ASSERT((stats.dequeue_err_count == 0),
6652 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6654 /* invalid device but should ignore and not reset device stats*/
6655 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6656 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6658 "rte_cryptodev_stats_get failed");
6659 TEST_ASSERT((stats.enqueued_count == 1),
6660 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6662 /* check that a valid reset clears stats */
6663 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6664 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6666 "rte_cryptodev_stats_get failed");
6667 TEST_ASSERT((stats.enqueued_count == 0),
6668 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6669 TEST_ASSERT((stats.dequeued_count == 0),
6670 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6672 return TEST_SUCCESS;
6675 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6676 struct crypto_unittest_params *ut_params,
6677 enum rte_crypto_auth_operation op,
6678 const struct HMAC_MD5_vector *test_case)
6682 memcpy(key, test_case->key.data, test_case->key.len);
6684 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6685 ut_params->auth_xform.next = NULL;
6686 ut_params->auth_xform.auth.op = op;
6688 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6690 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6691 ut_params->auth_xform.auth.key.length = test_case->key.len;
6692 ut_params->auth_xform.auth.key.data = key;
6694 ut_params->sess = rte_cryptodev_sym_session_create(
6695 ts_params->session_mpool);
6697 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6698 ut_params->sess, &ut_params->auth_xform,
6699 ts_params->session_priv_mpool);
6701 if (ut_params->sess == NULL)
6704 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6706 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6707 rte_pktmbuf_tailroom(ut_params->ibuf));
6712 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6713 const struct HMAC_MD5_vector *test_case,
6714 uint8_t **plaintext)
6716 uint16_t plaintext_pad_len;
6718 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6720 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6723 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6725 memcpy(*plaintext, test_case->plaintext.data,
6726 test_case->plaintext.len);
6728 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6729 ut_params->ibuf, MD5_DIGEST_LEN);
6730 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6731 "no room to append digest");
6732 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6733 ut_params->ibuf, plaintext_pad_len);
6735 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6736 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6737 test_case->auth_tag.len);
6740 sym_op->auth.data.offset = 0;
6741 sym_op->auth.data.length = test_case->plaintext.len;
6743 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6744 ut_params->op->sym->m_src = ut_params->ibuf;
6750 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6752 uint16_t plaintext_pad_len;
6753 uint8_t *plaintext, *auth_tag;
6755 struct crypto_testsuite_params *ts_params = &testsuite_params;
6756 struct crypto_unittest_params *ut_params = &unittest_params;
6758 if (MD5_HMAC_create_session(ts_params, ut_params,
6759 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6762 /* Generate Crypto op data structure */
6763 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6764 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6765 TEST_ASSERT_NOT_NULL(ut_params->op,
6766 "Failed to allocate symmetric crypto operation struct");
6768 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6771 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6774 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6775 ut_params->op), "failed to process sym crypto op");
6777 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6778 "crypto op processing failed");
6780 if (ut_params->op->sym->m_dst) {
6781 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6782 uint8_t *, plaintext_pad_len);
6784 auth_tag = plaintext + plaintext_pad_len;
6787 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6789 test_case->auth_tag.data,
6790 test_case->auth_tag.len,
6791 "HMAC_MD5 generated tag not as expected");
6793 return TEST_SUCCESS;
6797 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6801 struct crypto_testsuite_params *ts_params = &testsuite_params;
6802 struct crypto_unittest_params *ut_params = &unittest_params;
6804 if (MD5_HMAC_create_session(ts_params, ut_params,
6805 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6809 /* Generate Crypto op data structure */
6810 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6811 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6812 TEST_ASSERT_NOT_NULL(ut_params->op,
6813 "Failed to allocate symmetric crypto operation struct");
6815 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6818 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6819 ut_params->op), "failed to process sym crypto op");
6821 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6822 "HMAC_MD5 crypto op processing failed");
6824 return TEST_SUCCESS;
6828 test_MD5_HMAC_generate_case_1(void)
6830 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6834 test_MD5_HMAC_verify_case_1(void)
6836 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6840 test_MD5_HMAC_generate_case_2(void)
6842 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6846 test_MD5_HMAC_verify_case_2(void)
6848 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6852 test_multi_session(void)
6854 struct crypto_testsuite_params *ts_params = &testsuite_params;
6855 struct crypto_unittest_params *ut_params = &unittest_params;
6857 struct rte_cryptodev_info dev_info;
6858 struct rte_cryptodev_sym_session **sessions;
6862 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6863 aes_cbc_key, hmac_sha512_key);
6866 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6868 sessions = rte_malloc(NULL,
6869 (sizeof(struct rte_cryptodev_sym_session *) *
6870 MAX_NB_SESSIONS) + 1, 0);
6872 /* Create multiple crypto sessions*/
6873 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6875 sessions[i] = rte_cryptodev_sym_session_create(
6876 ts_params->session_mpool);
6878 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6879 sessions[i], &ut_params->auth_xform,
6880 ts_params->session_priv_mpool);
6881 TEST_ASSERT_NOT_NULL(sessions[i],
6882 "Session creation failed at session number %u",
6885 /* Attempt to send a request on each session */
6886 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6890 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6891 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6893 "Failed to perform decrypt on request number %u.", i);
6894 /* free crypto operation structure */
6896 rte_crypto_op_free(ut_params->op);
6899 * free mbuf - both obuf and ibuf are usually the same,
6900 * so check if they point at the same address is necessary,
6901 * to avoid freeing the mbuf twice.
6903 if (ut_params->obuf) {
6904 rte_pktmbuf_free(ut_params->obuf);
6905 if (ut_params->ibuf == ut_params->obuf)
6906 ut_params->ibuf = 0;
6907 ut_params->obuf = 0;
6909 if (ut_params->ibuf) {
6910 rte_pktmbuf_free(ut_params->ibuf);
6911 ut_params->ibuf = 0;
6915 /* Next session create should fail */
6916 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6917 sessions[i], &ut_params->auth_xform,
6918 ts_params->session_priv_mpool);
6919 TEST_ASSERT_NULL(sessions[i],
6920 "Session creation succeeded unexpectedly!");
6922 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6923 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6925 rte_cryptodev_sym_session_free(sessions[i]);
6930 return TEST_SUCCESS;
6933 struct multi_session_params {
6934 struct crypto_unittest_params ut_params;
6935 uint8_t *cipher_key;
6937 const uint8_t *cipher;
6938 const uint8_t *digest;
6942 #define MB_SESSION_NUMBER 3
6945 test_multi_session_random_usage(void)
6947 struct crypto_testsuite_params *ts_params = &testsuite_params;
6948 struct rte_cryptodev_info dev_info;
6949 struct rte_cryptodev_sym_session **sessions;
6951 struct multi_session_params ut_paramz[] = {
6954 .cipher_key = ms_aes_cbc_key0,
6955 .hmac_key = ms_hmac_key0,
6956 .cipher = ms_aes_cbc_cipher0,
6957 .digest = ms_hmac_digest0,
6958 .iv = ms_aes_cbc_iv0
6961 .cipher_key = ms_aes_cbc_key1,
6962 .hmac_key = ms_hmac_key1,
6963 .cipher = ms_aes_cbc_cipher1,
6964 .digest = ms_hmac_digest1,
6965 .iv = ms_aes_cbc_iv1
6968 .cipher_key = ms_aes_cbc_key2,
6969 .hmac_key = ms_hmac_key2,
6970 .cipher = ms_aes_cbc_cipher2,
6971 .digest = ms_hmac_digest2,
6972 .iv = ms_aes_cbc_iv2
6977 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6979 sessions = rte_malloc(NULL,
6980 (sizeof(struct rte_cryptodev_sym_session *)
6981 * MAX_NB_SESSIONS) + 1, 0);
6983 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6984 sessions[i] = rte_cryptodev_sym_session_create(
6985 ts_params->session_mpool);
6987 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6988 sizeof(struct crypto_unittest_params));
6990 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6991 &ut_paramz[i].ut_params,
6992 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6994 /* Create multiple crypto sessions*/
6995 rte_cryptodev_sym_session_init(
6996 ts_params->valid_devs[0],
6998 &ut_paramz[i].ut_params.auth_xform,
6999 ts_params->session_priv_mpool);
7001 TEST_ASSERT_NOT_NULL(sessions[i],
7002 "Session creation failed at session number %u",
7008 for (i = 0; i < 40000; i++) {
7010 j = rand() % MB_SESSION_NUMBER;
7012 TEST_ASSERT_SUCCESS(
7013 test_AES_CBC_HMAC_SHA512_decrypt_perform(
7015 &ut_paramz[j].ut_params,
7016 ts_params, ut_paramz[j].cipher,
7017 ut_paramz[j].digest,
7019 "Failed to perform decrypt on request number %u.", i);
7021 if (ut_paramz[j].ut_params.op)
7022 rte_crypto_op_free(ut_paramz[j].ut_params.op);
7025 * free mbuf - both obuf and ibuf are usually the same,
7026 * so check if they point at the same address is necessary,
7027 * to avoid freeing the mbuf twice.
7029 if (ut_paramz[j].ut_params.obuf) {
7030 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
7031 if (ut_paramz[j].ut_params.ibuf
7032 == ut_paramz[j].ut_params.obuf)
7033 ut_paramz[j].ut_params.ibuf = 0;
7034 ut_paramz[j].ut_params.obuf = 0;
7036 if (ut_paramz[j].ut_params.ibuf) {
7037 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
7038 ut_paramz[j].ut_params.ibuf = 0;
7042 for (i = 0; i < MB_SESSION_NUMBER; i++) {
7043 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
7045 rte_cryptodev_sym_session_free(sessions[i]);
7050 return TEST_SUCCESS;
7054 test_null_cipher_only_operation(void)
7056 struct crypto_testsuite_params *ts_params = &testsuite_params;
7057 struct crypto_unittest_params *ut_params = &unittest_params;
7059 /* Generate test mbuf data and space for digest */
7060 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7061 catch_22_quote, QUOTE_512_BYTES, 0);
7063 /* Setup Cipher Parameters */
7064 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7065 ut_params->cipher_xform.next = NULL;
7067 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7068 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7070 ut_params->sess = rte_cryptodev_sym_session_create(
7071 ts_params->session_mpool);
7073 /* Create Crypto session*/
7074 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7076 &ut_params->cipher_xform,
7077 ts_params->session_priv_mpool);
7078 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7080 /* Generate Crypto op data structure */
7081 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7082 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7083 TEST_ASSERT_NOT_NULL(ut_params->op,
7084 "Failed to allocate symmetric crypto operation struct");
7086 /* Set crypto operation data parameters */
7087 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7089 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7091 /* set crypto operation source mbuf */
7092 sym_op->m_src = ut_params->ibuf;
7094 sym_op->cipher.data.offset = 0;
7095 sym_op->cipher.data.length = QUOTE_512_BYTES;
7097 /* Process crypto operation */
7098 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7100 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7102 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7103 "crypto operation processing failed");
7106 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7107 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7110 "Ciphertext data not as expected");
7112 return TEST_SUCCESS;
7114 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
7115 0xab, 0xab, 0xab, 0xab,
7116 0xab, 0xab, 0xab, 0xab,
7117 0xab, 0xab, 0xab, 0xab};
7119 test_null_auth_only_operation(void)
7121 struct crypto_testsuite_params *ts_params = &testsuite_params;
7122 struct crypto_unittest_params *ut_params = &unittest_params;
7125 /* Generate test mbuf data and space for digest */
7126 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7127 catch_22_quote, QUOTE_512_BYTES, 0);
7129 /* create a pointer for digest, but don't expect anything to be written
7130 * here in a NULL auth algo so no mbuf append done.
7132 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7134 /* prefill the memory pointed to by digest */
7135 memcpy(digest, orig_data, sizeof(orig_data));
7137 /* Setup HMAC Parameters */
7138 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7139 ut_params->auth_xform.next = NULL;
7141 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7142 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7144 ut_params->sess = rte_cryptodev_sym_session_create(
7145 ts_params->session_mpool);
7147 /* Create Crypto session*/
7148 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7149 ut_params->sess, &ut_params->auth_xform,
7150 ts_params->session_priv_mpool);
7151 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7153 /* Generate Crypto op data structure */
7154 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7155 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7156 TEST_ASSERT_NOT_NULL(ut_params->op,
7157 "Failed to allocate symmetric crypto operation struct");
7159 /* Set crypto operation data parameters */
7160 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7162 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7164 sym_op->m_src = ut_params->ibuf;
7166 sym_op->auth.data.offset = 0;
7167 sym_op->auth.data.length = QUOTE_512_BYTES;
7168 sym_op->auth.digest.data = digest;
7169 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7172 /* Process crypto operation */
7173 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7175 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7177 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7178 "crypto operation processing failed");
7179 /* Make sure memory pointed to by digest hasn't been overwritten */
7180 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7184 "Memory at digest ptr overwritten unexpectedly");
7186 return TEST_SUCCESS;
7191 test_null_cipher_auth_operation(void)
7193 struct crypto_testsuite_params *ts_params = &testsuite_params;
7194 struct crypto_unittest_params *ut_params = &unittest_params;
7197 /* Generate test mbuf data and space for digest */
7198 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7199 catch_22_quote, QUOTE_512_BYTES, 0);
7201 /* create a pointer for digest, but don't expect anything to be written
7202 * here in a NULL auth algo so no mbuf append done.
7204 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7206 /* prefill the memory pointed to by digest */
7207 memcpy(digest, orig_data, sizeof(orig_data));
7209 /* Setup Cipher Parameters */
7210 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7211 ut_params->cipher_xform.next = &ut_params->auth_xform;
7213 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7214 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7216 /* Setup HMAC Parameters */
7217 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7218 ut_params->auth_xform.next = NULL;
7220 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7221 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7223 ut_params->sess = rte_cryptodev_sym_session_create(
7224 ts_params->session_mpool);
7226 /* Create Crypto session*/
7227 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7228 ut_params->sess, &ut_params->cipher_xform,
7229 ts_params->session_priv_mpool);
7230 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7232 /* Generate Crypto op data structure */
7233 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7234 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7235 TEST_ASSERT_NOT_NULL(ut_params->op,
7236 "Failed to allocate symmetric crypto operation struct");
7238 /* Set crypto operation data parameters */
7239 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7241 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7243 sym_op->m_src = ut_params->ibuf;
7245 sym_op->cipher.data.offset = 0;
7246 sym_op->cipher.data.length = QUOTE_512_BYTES;
7248 sym_op->auth.data.offset = 0;
7249 sym_op->auth.data.length = QUOTE_512_BYTES;
7250 sym_op->auth.digest.data = digest;
7251 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7254 /* Process crypto operation */
7255 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7257 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7259 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7260 "crypto operation processing failed");
7263 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7264 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7267 "Ciphertext data not as expected");
7268 /* Make sure memory pointed to by digest hasn't been overwritten */
7269 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7273 "Memory at digest ptr overwritten unexpectedly");
7275 return TEST_SUCCESS;
7279 test_null_auth_cipher_operation(void)
7281 struct crypto_testsuite_params *ts_params = &testsuite_params;
7282 struct crypto_unittest_params *ut_params = &unittest_params;
7285 /* Generate test mbuf data */
7286 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7287 catch_22_quote, QUOTE_512_BYTES, 0);
7289 /* create a pointer for digest, but don't expect anything to be written
7290 * here in a NULL auth algo so no mbuf append done.
7292 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7294 /* prefill the memory pointed to by digest */
7295 memcpy(digest, orig_data, sizeof(orig_data));
7297 /* Setup Cipher Parameters */
7298 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7299 ut_params->cipher_xform.next = NULL;
7301 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7302 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7304 /* Setup HMAC Parameters */
7305 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7306 ut_params->auth_xform.next = &ut_params->cipher_xform;
7308 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7309 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7311 ut_params->sess = rte_cryptodev_sym_session_create(
7312 ts_params->session_mpool);
7314 /* Create Crypto session*/
7315 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7316 ut_params->sess, &ut_params->cipher_xform,
7317 ts_params->session_priv_mpool);
7318 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7320 /* Generate Crypto op data structure */
7321 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7322 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7323 TEST_ASSERT_NOT_NULL(ut_params->op,
7324 "Failed to allocate symmetric crypto operation struct");
7326 /* Set crypto operation data parameters */
7327 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7329 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7331 sym_op->m_src = ut_params->ibuf;
7333 sym_op->cipher.data.offset = 0;
7334 sym_op->cipher.data.length = QUOTE_512_BYTES;
7336 sym_op->auth.data.offset = 0;
7337 sym_op->auth.data.length = QUOTE_512_BYTES;
7338 sym_op->auth.digest.data = digest;
7339 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7342 /* Process crypto operation */
7343 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7345 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7347 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7348 "crypto operation processing failed");
7351 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7352 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7355 "Ciphertext data not as expected");
7356 /* Make sure memory pointed to by digest hasn't been overwritten */
7357 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7361 "Memory at digest ptr overwritten unexpectedly");
7363 return TEST_SUCCESS;
7368 test_null_invalid_operation(void)
7370 struct crypto_testsuite_params *ts_params = &testsuite_params;
7371 struct crypto_unittest_params *ut_params = &unittest_params;
7374 /* Setup Cipher Parameters */
7375 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7376 ut_params->cipher_xform.next = NULL;
7378 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7379 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7381 ut_params->sess = rte_cryptodev_sym_session_create(
7382 ts_params->session_mpool);
7384 /* Create Crypto session*/
7385 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7386 ut_params->sess, &ut_params->cipher_xform,
7387 ts_params->session_priv_mpool);
7388 TEST_ASSERT(ret < 0,
7389 "Session creation succeeded unexpectedly");
7392 /* Setup HMAC Parameters */
7393 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7394 ut_params->auth_xform.next = NULL;
7396 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7397 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7399 ut_params->sess = rte_cryptodev_sym_session_create(
7400 ts_params->session_mpool);
7402 /* Create Crypto session*/
7403 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7404 ut_params->sess, &ut_params->auth_xform,
7405 ts_params->session_priv_mpool);
7406 TEST_ASSERT(ret < 0,
7407 "Session creation succeeded unexpectedly");
7409 return TEST_SUCCESS;
7413 #define NULL_BURST_LENGTH (32)
7416 test_null_burst_operation(void)
7418 struct crypto_testsuite_params *ts_params = &testsuite_params;
7419 struct crypto_unittest_params *ut_params = &unittest_params;
7421 unsigned i, burst_len = NULL_BURST_LENGTH;
7423 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7424 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7426 /* Setup Cipher Parameters */
7427 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7428 ut_params->cipher_xform.next = &ut_params->auth_xform;
7430 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7431 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7433 /* Setup HMAC Parameters */
7434 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7435 ut_params->auth_xform.next = NULL;
7437 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7438 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7440 ut_params->sess = rte_cryptodev_sym_session_create(
7441 ts_params->session_mpool);
7443 /* Create Crypto session*/
7444 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7445 ut_params->sess, &ut_params->cipher_xform,
7446 ts_params->session_priv_mpool);
7447 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7449 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7450 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7451 burst_len, "failed to generate burst of crypto ops");
7453 /* Generate an operation for each mbuf in burst */
7454 for (i = 0; i < burst_len; i++) {
7455 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7457 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7459 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7463 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7465 burst[i]->sym->m_src = m;
7468 /* Process crypto operation */
7469 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7470 0, burst, burst_len),
7472 "Error enqueuing burst");
7474 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7475 0, burst_dequeued, burst_len),
7477 "Error dequeuing burst");
7480 for (i = 0; i < burst_len; i++) {
7482 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7483 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7485 "data not as expected");
7487 rte_pktmbuf_free(burst[i]->sym->m_src);
7488 rte_crypto_op_free(burst[i]);
7491 return TEST_SUCCESS;
7495 generate_gmac_large_plaintext(uint8_t *data)
7499 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7500 memcpy(&data[i], &data[0], 32);
7504 create_gmac_operation(enum rte_crypto_auth_operation op,
7505 const struct gmac_test_data *tdata)
7507 struct crypto_testsuite_params *ts_params = &testsuite_params;
7508 struct crypto_unittest_params *ut_params = &unittest_params;
7509 struct rte_crypto_sym_op *sym_op;
7511 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7513 /* Generate Crypto op data structure */
7514 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7515 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7516 TEST_ASSERT_NOT_NULL(ut_params->op,
7517 "Failed to allocate symmetric crypto operation struct");
7519 sym_op = ut_params->op->sym;
7521 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7522 ut_params->ibuf, tdata->gmac_tag.len);
7523 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7524 "no room to append digest");
7526 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7527 ut_params->ibuf, plaintext_pad_len);
7529 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7530 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7531 tdata->gmac_tag.len);
7532 debug_hexdump(stdout, "digest:",
7533 sym_op->auth.digest.data,
7534 tdata->gmac_tag.len);
7537 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7538 uint8_t *, IV_OFFSET);
7540 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7542 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7544 sym_op->cipher.data.length = 0;
7545 sym_op->cipher.data.offset = 0;
7547 sym_op->auth.data.offset = 0;
7548 sym_op->auth.data.length = tdata->plaintext.len;
7553 static int create_gmac_session(uint8_t dev_id,
7554 const struct gmac_test_data *tdata,
7555 enum rte_crypto_auth_operation auth_op)
7557 uint8_t auth_key[tdata->key.len];
7559 struct crypto_testsuite_params *ts_params = &testsuite_params;
7560 struct crypto_unittest_params *ut_params = &unittest_params;
7562 memcpy(auth_key, tdata->key.data, tdata->key.len);
7564 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7565 ut_params->auth_xform.next = NULL;
7567 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7568 ut_params->auth_xform.auth.op = auth_op;
7569 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7570 ut_params->auth_xform.auth.key.length = tdata->key.len;
7571 ut_params->auth_xform.auth.key.data = auth_key;
7572 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7573 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7576 ut_params->sess = rte_cryptodev_sym_session_create(
7577 ts_params->session_mpool);
7579 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7580 &ut_params->auth_xform,
7581 ts_params->session_priv_mpool);
7583 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7589 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7591 struct crypto_testsuite_params *ts_params = &testsuite_params;
7592 struct crypto_unittest_params *ut_params = &unittest_params;
7596 uint8_t *auth_tag, *plaintext;
7597 uint16_t plaintext_pad_len;
7599 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7600 "No GMAC length in the source data");
7602 retval = create_gmac_session(ts_params->valid_devs[0],
7603 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7608 if (tdata->plaintext.len > MBUF_SIZE)
7609 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7611 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7612 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7613 "Failed to allocate input buffer in mempool");
7615 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7616 rte_pktmbuf_tailroom(ut_params->ibuf));
7618 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7620 * Runtime generate the large plain text instead of use hard code
7621 * plain text vector. It is done to avoid create huge source file
7622 * with the test vector.
7624 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7625 generate_gmac_large_plaintext(tdata->plaintext.data);
7627 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7629 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7631 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7632 debug_hexdump(stdout, "plaintext:", plaintext,
7633 tdata->plaintext.len);
7635 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7641 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7643 ut_params->op->sym->m_src = ut_params->ibuf;
7645 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7646 ut_params->op), "failed to process sym crypto op");
7648 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7649 "crypto op processing failed");
7651 if (ut_params->op->sym->m_dst) {
7652 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7653 uint8_t *, plaintext_pad_len);
7655 auth_tag = plaintext + plaintext_pad_len;
7658 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7660 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7662 tdata->gmac_tag.data,
7663 tdata->gmac_tag.len,
7664 "GMAC Generated auth tag not as expected");
7670 test_AES_GMAC_authentication_test_case_1(void)
7672 return test_AES_GMAC_authentication(&gmac_test_case_1);
7676 test_AES_GMAC_authentication_test_case_2(void)
7678 return test_AES_GMAC_authentication(&gmac_test_case_2);
7682 test_AES_GMAC_authentication_test_case_3(void)
7684 return test_AES_GMAC_authentication(&gmac_test_case_3);
7688 test_AES_GMAC_authentication_test_case_4(void)
7690 return test_AES_GMAC_authentication(&gmac_test_case_4);
7694 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7696 struct crypto_testsuite_params *ts_params = &testsuite_params;
7697 struct crypto_unittest_params *ut_params = &unittest_params;
7699 uint32_t plaintext_pad_len;
7702 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7703 "No GMAC length in the source data");
7705 retval = create_gmac_session(ts_params->valid_devs[0],
7706 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7711 if (tdata->plaintext.len > MBUF_SIZE)
7712 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7714 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7715 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7716 "Failed to allocate input buffer in mempool");
7718 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7719 rte_pktmbuf_tailroom(ut_params->ibuf));
7721 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7724 * Runtime generate the large plain text instead of use hard code
7725 * plain text vector. It is done to avoid create huge source file
7726 * with the test vector.
7728 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7729 generate_gmac_large_plaintext(tdata->plaintext.data);
7731 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7733 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7735 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7736 debug_hexdump(stdout, "plaintext:", plaintext,
7737 tdata->plaintext.len);
7739 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7745 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7747 ut_params->op->sym->m_src = ut_params->ibuf;
7749 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7750 ut_params->op), "failed to process sym crypto op");
7752 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7753 "crypto op processing failed");
7760 test_AES_GMAC_authentication_verify_test_case_1(void)
7762 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7766 test_AES_GMAC_authentication_verify_test_case_2(void)
7768 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7772 test_AES_GMAC_authentication_verify_test_case_3(void)
7774 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7778 test_AES_GMAC_authentication_verify_test_case_4(void)
7780 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7783 struct test_crypto_vector {
7784 enum rte_crypto_cipher_algorithm crypto_algo;
7797 const uint8_t *data;
7802 const uint8_t *data;
7806 enum rte_crypto_auth_algorithm auth_algo;
7814 const uint8_t *data;
7824 static const struct test_crypto_vector
7825 hmac_sha1_test_crypto_vector = {
7826 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7828 .data = plaintext_hash,
7833 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7834 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7835 0xDE, 0xF4, 0xDE, 0xAD
7841 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7842 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7843 0x3F, 0x91, 0x64, 0x59
7849 static const struct test_crypto_vector
7850 aes128_gmac_test_vector = {
7851 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7853 .data = plaintext_hash,
7858 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7859 0x08, 0x09, 0x0A, 0x0B
7865 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7866 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7872 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7873 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7879 static const struct test_crypto_vector
7880 aes128cbc_hmac_sha1_test_vector = {
7881 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7884 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7885 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7891 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7892 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7897 .data = plaintext_hash,
7901 .data = ciphertext512_aes128cbc,
7904 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7907 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7908 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7909 0xDE, 0xF4, 0xDE, 0xAD
7915 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7916 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7917 0x18, 0x8C, 0x1D, 0x32
7924 data_corruption(uint8_t *data)
7930 tag_corruption(uint8_t *data, unsigned int tag_offset)
7932 data[tag_offset] += 1;
7936 create_auth_session(struct crypto_unittest_params *ut_params,
7938 const struct test_crypto_vector *reference,
7939 enum rte_crypto_auth_operation auth_op)
7941 struct crypto_testsuite_params *ts_params = &testsuite_params;
7942 uint8_t auth_key[reference->auth_key.len + 1];
7944 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7946 /* Setup Authentication Parameters */
7947 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7948 ut_params->auth_xform.auth.op = auth_op;
7949 ut_params->auth_xform.next = NULL;
7950 ut_params->auth_xform.auth.algo = reference->auth_algo;
7951 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7952 ut_params->auth_xform.auth.key.data = auth_key;
7953 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7955 /* Create Crypto session*/
7956 ut_params->sess = rte_cryptodev_sym_session_create(
7957 ts_params->session_mpool);
7959 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7960 &ut_params->auth_xform,
7961 ts_params->session_priv_mpool);
7963 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7969 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7971 const struct test_crypto_vector *reference,
7972 enum rte_crypto_auth_operation auth_op,
7973 enum rte_crypto_cipher_operation cipher_op)
7975 struct crypto_testsuite_params *ts_params = &testsuite_params;
7976 uint8_t cipher_key[reference->cipher_key.len + 1];
7977 uint8_t auth_key[reference->auth_key.len + 1];
7979 memcpy(cipher_key, reference->cipher_key.data,
7980 reference->cipher_key.len);
7981 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7983 /* Setup Authentication Parameters */
7984 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7985 ut_params->auth_xform.auth.op = auth_op;
7986 ut_params->auth_xform.auth.algo = reference->auth_algo;
7987 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7988 ut_params->auth_xform.auth.key.data = auth_key;
7989 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7991 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7992 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7993 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7995 ut_params->auth_xform.next = &ut_params->cipher_xform;
7997 /* Setup Cipher Parameters */
7998 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7999 ut_params->cipher_xform.next = NULL;
8000 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
8001 ut_params->cipher_xform.cipher.op = cipher_op;
8002 ut_params->cipher_xform.cipher.key.data = cipher_key;
8003 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
8004 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8005 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
8008 /* Create Crypto session*/
8009 ut_params->sess = rte_cryptodev_sym_session_create(
8010 ts_params->session_mpool);
8012 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8013 &ut_params->auth_xform,
8014 ts_params->session_priv_mpool);
8016 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8022 create_auth_operation(struct crypto_testsuite_params *ts_params,
8023 struct crypto_unittest_params *ut_params,
8024 const struct test_crypto_vector *reference,
8025 unsigned int auth_generate)
8027 /* Generate Crypto op data structure */
8028 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8029 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8030 TEST_ASSERT_NOT_NULL(ut_params->op,
8031 "Failed to allocate pktmbuf offload");
8033 /* Set crypto operation data parameters */
8034 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8036 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8038 /* set crypto operation source mbuf */
8039 sym_op->m_src = ut_params->ibuf;
8042 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8043 ut_params->ibuf, reference->digest.len);
8045 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8046 "no room to append auth tag");
8048 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8049 ut_params->ibuf, reference->plaintext.len);
8052 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8054 memcpy(sym_op->auth.digest.data,
8055 reference->digest.data,
8056 reference->digest.len);
8058 debug_hexdump(stdout, "digest:",
8059 sym_op->auth.digest.data,
8060 reference->digest.len);
8062 sym_op->auth.data.length = reference->plaintext.len;
8063 sym_op->auth.data.offset = 0;
8069 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
8070 struct crypto_unittest_params *ut_params,
8071 const struct test_crypto_vector *reference,
8072 unsigned int auth_generate)
8074 /* Generate Crypto op data structure */
8075 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8076 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8077 TEST_ASSERT_NOT_NULL(ut_params->op,
8078 "Failed to allocate pktmbuf offload");
8080 /* Set crypto operation data parameters */
8081 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8083 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8085 /* set crypto operation source mbuf */
8086 sym_op->m_src = ut_params->ibuf;
8089 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8090 ut_params->ibuf, reference->digest.len);
8092 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8093 "no room to append auth tag");
8095 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8096 ut_params->ibuf, reference->ciphertext.len);
8099 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8101 memcpy(sym_op->auth.digest.data,
8102 reference->digest.data,
8103 reference->digest.len);
8105 debug_hexdump(stdout, "digest:",
8106 sym_op->auth.digest.data,
8107 reference->digest.len);
8109 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8110 reference->iv.data, reference->iv.len);
8112 sym_op->cipher.data.length = 0;
8113 sym_op->cipher.data.offset = 0;
8115 sym_op->auth.data.length = reference->plaintext.len;
8116 sym_op->auth.data.offset = 0;
8122 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8123 struct crypto_unittest_params *ut_params,
8124 const struct test_crypto_vector *reference,
8125 unsigned int auth_generate)
8127 /* Generate Crypto op data structure */
8128 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8129 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8130 TEST_ASSERT_NOT_NULL(ut_params->op,
8131 "Failed to allocate pktmbuf offload");
8133 /* Set crypto operation data parameters */
8134 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8136 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8138 /* set crypto operation source mbuf */
8139 sym_op->m_src = ut_params->ibuf;
8142 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8143 ut_params->ibuf, reference->digest.len);
8145 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8146 "no room to append auth tag");
8148 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8149 ut_params->ibuf, reference->ciphertext.len);
8152 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8154 memcpy(sym_op->auth.digest.data,
8155 reference->digest.data,
8156 reference->digest.len);
8158 debug_hexdump(stdout, "digest:",
8159 sym_op->auth.digest.data,
8160 reference->digest.len);
8162 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8163 reference->iv.data, reference->iv.len);
8165 sym_op->cipher.data.length = reference->ciphertext.len;
8166 sym_op->cipher.data.offset = 0;
8168 sym_op->auth.data.length = reference->ciphertext.len;
8169 sym_op->auth.data.offset = 0;
8175 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8176 struct crypto_unittest_params *ut_params,
8177 const struct test_crypto_vector *reference)
8179 return create_auth_operation(ts_params, ut_params, reference, 0);
8183 create_auth_verify_GMAC_operation(
8184 struct crypto_testsuite_params *ts_params,
8185 struct crypto_unittest_params *ut_params,
8186 const struct test_crypto_vector *reference)
8188 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8192 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8193 struct crypto_unittest_params *ut_params,
8194 const struct test_crypto_vector *reference)
8196 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8200 test_authentication_verify_fail_when_data_corruption(
8201 struct crypto_testsuite_params *ts_params,
8202 struct crypto_unittest_params *ut_params,
8203 const struct test_crypto_vector *reference,
8204 unsigned int data_corrupted)
8210 /* Create session */
8211 retval = create_auth_session(ut_params,
8212 ts_params->valid_devs[0],
8214 RTE_CRYPTO_AUTH_OP_VERIFY);
8218 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8219 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8220 "Failed to allocate input buffer in mempool");
8222 /* clear mbuf payload */
8223 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8224 rte_pktmbuf_tailroom(ut_params->ibuf));
8226 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8227 reference->plaintext.len);
8228 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8229 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8231 debug_hexdump(stdout, "plaintext:", plaintext,
8232 reference->plaintext.len);
8234 /* Create operation */
8235 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8241 data_corruption(plaintext);
8243 tag_corruption(plaintext, reference->plaintext.len);
8245 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8247 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8248 TEST_ASSERT_EQUAL(ut_params->op->status,
8249 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8250 "authentication not failed");
8252 ut_params->obuf = ut_params->op->sym->m_src;
8253 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8259 test_authentication_verify_GMAC_fail_when_corruption(
8260 struct crypto_testsuite_params *ts_params,
8261 struct crypto_unittest_params *ut_params,
8262 const struct test_crypto_vector *reference,
8263 unsigned int data_corrupted)
8268 /* Create session */
8269 retval = create_auth_cipher_session(ut_params,
8270 ts_params->valid_devs[0],
8272 RTE_CRYPTO_AUTH_OP_VERIFY,
8273 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8277 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8278 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8279 "Failed to allocate input buffer in mempool");
8281 /* clear mbuf payload */
8282 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8283 rte_pktmbuf_tailroom(ut_params->ibuf));
8285 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8286 reference->plaintext.len);
8287 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8288 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8290 debug_hexdump(stdout, "plaintext:", plaintext,
8291 reference->plaintext.len);
8293 /* Create operation */
8294 retval = create_auth_verify_GMAC_operation(ts_params,
8302 data_corruption(plaintext);
8304 tag_corruption(plaintext, reference->aad.len);
8306 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8308 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8309 TEST_ASSERT_EQUAL(ut_params->op->status,
8310 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8311 "authentication not failed");
8313 ut_params->obuf = ut_params->op->sym->m_src;
8314 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8320 test_authenticated_decryption_fail_when_corruption(
8321 struct crypto_testsuite_params *ts_params,
8322 struct crypto_unittest_params *ut_params,
8323 const struct test_crypto_vector *reference,
8324 unsigned int data_corrupted)
8328 uint8_t *ciphertext;
8330 /* Create session */
8331 retval = create_auth_cipher_session(ut_params,
8332 ts_params->valid_devs[0],
8334 RTE_CRYPTO_AUTH_OP_VERIFY,
8335 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8339 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8340 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8341 "Failed to allocate input buffer in mempool");
8343 /* clear mbuf payload */
8344 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8345 rte_pktmbuf_tailroom(ut_params->ibuf));
8347 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8348 reference->ciphertext.len);
8349 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8350 memcpy(ciphertext, reference->ciphertext.data,
8351 reference->ciphertext.len);
8353 /* Create operation */
8354 retval = create_cipher_auth_verify_operation(ts_params,
8362 data_corruption(ciphertext);
8364 tag_corruption(ciphertext, reference->ciphertext.len);
8366 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8369 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8370 TEST_ASSERT_EQUAL(ut_params->op->status,
8371 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8372 "authentication not failed");
8374 ut_params->obuf = ut_params->op->sym->m_src;
8375 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8381 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8382 const struct aead_test_data *tdata,
8383 void *digest_mem, uint64_t digest_phys)
8385 struct crypto_testsuite_params *ts_params = &testsuite_params;
8386 struct crypto_unittest_params *ut_params = &unittest_params;
8388 const unsigned int auth_tag_len = tdata->auth_tag.len;
8389 const unsigned int iv_len = tdata->iv.len;
8390 unsigned int aad_len = tdata->aad.len;
8392 /* Generate Crypto op data structure */
8393 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8394 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8395 TEST_ASSERT_NOT_NULL(ut_params->op,
8396 "Failed to allocate symmetric crypto operation struct");
8398 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8400 sym_op->aead.digest.data = digest_mem;
8402 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8403 "no room to append digest");
8405 sym_op->aead.digest.phys_addr = digest_phys;
8407 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8408 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8410 debug_hexdump(stdout, "digest:",
8411 sym_op->aead.digest.data,
8415 /* Append aad data */
8416 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8417 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8418 uint8_t *, IV_OFFSET);
8420 /* Copy IV 1 byte after the IV pointer, according to the API */
8421 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8423 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8425 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8426 ut_params->ibuf, aad_len);
8427 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8428 "no room to prepend aad");
8429 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8432 memset(sym_op->aead.aad.data, 0, aad_len);
8433 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8434 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8436 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8437 debug_hexdump(stdout, "aad:",
8438 sym_op->aead.aad.data, aad_len);
8440 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8441 uint8_t *, IV_OFFSET);
8443 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8445 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8446 ut_params->ibuf, aad_len);
8447 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8448 "no room to prepend aad");
8449 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8452 memset(sym_op->aead.aad.data, 0, aad_len);
8453 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8455 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8456 debug_hexdump(stdout, "aad:",
8457 sym_op->aead.aad.data, aad_len);
8460 sym_op->aead.data.length = tdata->plaintext.len;
8461 sym_op->aead.data.offset = aad_len;
8466 #define SGL_MAX_NO 16
8469 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8470 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8472 struct crypto_testsuite_params *ts_params = &testsuite_params;
8473 struct crypto_unittest_params *ut_params = &unittest_params;
8474 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8477 int to_trn_tbl[SGL_MAX_NO];
8479 unsigned int trn_data = 0;
8480 uint8_t *plaintext, *ciphertext, *auth_tag;
8482 if (fragsz > tdata->plaintext.len)
8483 fragsz = tdata->plaintext.len;
8485 uint16_t plaintext_len = fragsz;
8486 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8488 if (fragsz_oop > tdata->plaintext.len)
8489 frag_size_oop = tdata->plaintext.len;
8492 void *digest_mem = NULL;
8494 uint32_t prepend_len = tdata->aad.len;
8496 if (tdata->plaintext.len % fragsz != 0) {
8497 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8500 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8505 * For out-op-place we need to alloc another mbuf
8508 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8509 rte_pktmbuf_append(ut_params->obuf,
8510 frag_size_oop + prepend_len);
8511 buf_oop = ut_params->obuf;
8514 /* Create AEAD session */
8515 retval = create_aead_session(ts_params->valid_devs[0],
8517 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8518 tdata->key.data, tdata->key.len,
8519 tdata->aad.len, tdata->auth_tag.len,
8524 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8526 /* clear mbuf payload */
8527 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8528 rte_pktmbuf_tailroom(ut_params->ibuf));
8530 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8533 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8535 trn_data += plaintext_len;
8537 buf = ut_params->ibuf;
8540 * Loop until no more fragments
8543 while (trn_data < tdata->plaintext.len) {
8545 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8546 (tdata->plaintext.len - trn_data) : fragsz;
8548 to_trn_tbl[ecx++] = to_trn;
8550 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8553 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8554 rte_pktmbuf_tailroom(buf));
8557 if (oop && !fragsz_oop) {
8558 buf_last_oop = buf_oop->next =
8559 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8560 buf_oop = buf_oop->next;
8561 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8562 0, rte_pktmbuf_tailroom(buf_oop));
8563 rte_pktmbuf_append(buf_oop, to_trn);
8566 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8569 memcpy(plaintext, tdata->plaintext.data + trn_data,
8572 if (trn_data == tdata->plaintext.len) {
8575 digest_mem = rte_pktmbuf_append(buf_oop,
8576 tdata->auth_tag.len);
8578 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8579 tdata->auth_tag.len);
8583 uint64_t digest_phys = 0;
8585 ut_params->ibuf->nb_segs = segs;
8588 if (fragsz_oop && oop) {
8592 if (frag_size_oop == tdata->plaintext.len) {
8593 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8594 tdata->auth_tag.len);
8596 digest_phys = rte_pktmbuf_iova_offset(
8598 tdata->plaintext.len + prepend_len);
8601 trn_data = frag_size_oop;
8602 while (trn_data < tdata->plaintext.len) {
8605 (tdata->plaintext.len - trn_data <
8607 (tdata->plaintext.len - trn_data) :
8610 to_trn_tbl[ecx++] = to_trn;
8612 buf_last_oop = buf_oop->next =
8613 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8614 buf_oop = buf_oop->next;
8615 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8616 0, rte_pktmbuf_tailroom(buf_oop));
8617 rte_pktmbuf_append(buf_oop, to_trn);
8621 if (trn_data == tdata->plaintext.len) {
8622 digest_mem = rte_pktmbuf_append(buf_oop,
8623 tdata->auth_tag.len);
8627 ut_params->obuf->nb_segs = segs;
8631 * Place digest at the end of the last buffer
8634 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8635 if (oop && buf_last_oop)
8636 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8638 if (!digest_mem && !oop) {
8639 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8640 + tdata->auth_tag.len);
8641 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8642 tdata->plaintext.len);
8645 /* Create AEAD operation */
8646 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8647 tdata, digest_mem, digest_phys);
8652 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8654 ut_params->op->sym->m_src = ut_params->ibuf;
8656 ut_params->op->sym->m_dst = ut_params->obuf;
8658 /* Process crypto operation */
8659 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8660 ut_params->op), "failed to process sym crypto op");
8662 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8663 "crypto op processing failed");
8666 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8667 uint8_t *, prepend_len);
8669 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8670 uint8_t *, prepend_len);
8674 fragsz = fragsz_oop;
8676 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8678 tdata->ciphertext.data,
8680 "Ciphertext data not as expected");
8682 buf = ut_params->op->sym->m_src->next;
8684 buf = ut_params->op->sym->m_dst->next;
8686 unsigned int off = fragsz;
8690 ciphertext = rte_pktmbuf_mtod(buf,
8693 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8695 tdata->ciphertext.data + off,
8697 "Ciphertext data not as expected");
8699 off += to_trn_tbl[ecx++];
8703 auth_tag = digest_mem;
8704 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8706 tdata->auth_tag.data,
8707 tdata->auth_tag.len,
8708 "Generated auth tag not as expected");
8714 #define OUT_OF_PLACE 1
8717 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8719 return test_authenticated_encryption_SGL(
8720 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8724 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8726 return test_authenticated_encryption_SGL(
8727 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8731 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8733 return test_authenticated_encryption_SGL(
8734 &gcm_test_case_8, OUT_OF_PLACE, 400,
8735 gcm_test_case_8.plaintext.len);
8739 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8742 return test_authenticated_encryption_SGL(
8743 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8747 test_authentication_verify_fail_when_data_corrupted(
8748 struct crypto_testsuite_params *ts_params,
8749 struct crypto_unittest_params *ut_params,
8750 const struct test_crypto_vector *reference)
8752 return test_authentication_verify_fail_when_data_corruption(
8753 ts_params, ut_params, reference, 1);
8757 test_authentication_verify_fail_when_tag_corrupted(
8758 struct crypto_testsuite_params *ts_params,
8759 struct crypto_unittest_params *ut_params,
8760 const struct test_crypto_vector *reference)
8762 return test_authentication_verify_fail_when_data_corruption(
8763 ts_params, ut_params, reference, 0);
8767 test_authentication_verify_GMAC_fail_when_data_corrupted(
8768 struct crypto_testsuite_params *ts_params,
8769 struct crypto_unittest_params *ut_params,
8770 const struct test_crypto_vector *reference)
8772 return test_authentication_verify_GMAC_fail_when_corruption(
8773 ts_params, ut_params, reference, 1);
8777 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8778 struct crypto_testsuite_params *ts_params,
8779 struct crypto_unittest_params *ut_params,
8780 const struct test_crypto_vector *reference)
8782 return test_authentication_verify_GMAC_fail_when_corruption(
8783 ts_params, ut_params, reference, 0);
8787 test_authenticated_decryption_fail_when_data_corrupted(
8788 struct crypto_testsuite_params *ts_params,
8789 struct crypto_unittest_params *ut_params,
8790 const struct test_crypto_vector *reference)
8792 return test_authenticated_decryption_fail_when_corruption(
8793 ts_params, ut_params, reference, 1);
8797 test_authenticated_decryption_fail_when_tag_corrupted(
8798 struct crypto_testsuite_params *ts_params,
8799 struct crypto_unittest_params *ut_params,
8800 const struct test_crypto_vector *reference)
8802 return test_authenticated_decryption_fail_when_corruption(
8803 ts_params, ut_params, reference, 0);
8807 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8809 return test_authentication_verify_fail_when_data_corrupted(
8810 &testsuite_params, &unittest_params,
8811 &hmac_sha1_test_crypto_vector);
8815 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8817 return test_authentication_verify_fail_when_tag_corrupted(
8818 &testsuite_params, &unittest_params,
8819 &hmac_sha1_test_crypto_vector);
8823 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8825 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8826 &testsuite_params, &unittest_params,
8827 &aes128_gmac_test_vector);
8831 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8833 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8834 &testsuite_params, &unittest_params,
8835 &aes128_gmac_test_vector);
8839 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8841 return test_authenticated_decryption_fail_when_data_corrupted(
8844 &aes128cbc_hmac_sha1_test_vector);
8848 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8850 return test_authenticated_decryption_fail_when_tag_corrupted(
8853 &aes128cbc_hmac_sha1_test_vector);
8856 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8858 /* global AESNI slave IDs for the scheduler test */
8859 uint8_t aesni_ids[2];
8862 test_scheduler_attach_slave_op(void)
8864 struct crypto_testsuite_params *ts_params = &testsuite_params;
8865 uint8_t sched_id = ts_params->valid_devs[0];
8866 uint32_t nb_devs, i, nb_devs_attached = 0;
8870 /* create 2 AESNI_MB if necessary */
8871 nb_devs = rte_cryptodev_device_count_by_driver(
8872 rte_cryptodev_driver_id_get(
8873 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8875 for (i = nb_devs; i < 2; i++) {
8876 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8877 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8879 ret = rte_vdev_init(vdev_name, NULL);
8881 TEST_ASSERT(ret == 0,
8882 "Failed to create instance %u of"
8884 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8888 /* attach 2 AESNI_MB cdevs */
8889 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8891 struct rte_cryptodev_info info;
8892 unsigned int session_size;
8894 rte_cryptodev_info_get(i, &info);
8895 if (info.driver_id != rte_cryptodev_driver_id_get(
8896 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8899 session_size = rte_cryptodev_sym_get_private_session_size(i);
8901 * Create the session mempool again, since now there are new devices
8902 * to use the mempool.
8904 if (ts_params->session_mpool) {
8905 rte_mempool_free(ts_params->session_mpool);
8906 ts_params->session_mpool = NULL;
8908 if (ts_params->session_priv_mpool) {
8909 rte_mempool_free(ts_params->session_priv_mpool);
8910 ts_params->session_priv_mpool = NULL;
8913 if (info.sym.max_nb_sessions != 0 &&
8914 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8916 "Device does not support "
8917 "at least %u sessions\n",
8922 * Create mempool with maximum number of sessions,
8923 * to include the session headers
8925 if (ts_params->session_mpool == NULL) {
8926 ts_params->session_mpool =
8927 rte_cryptodev_sym_session_pool_create(
8929 MAX_NB_SESSIONS, 0, 0, 0,
8931 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8932 "session mempool allocation failed");
8936 * Create mempool with maximum number of sessions,
8937 * to include device specific session private data
8939 if (ts_params->session_priv_mpool == NULL) {
8940 ts_params->session_priv_mpool = rte_mempool_create(
8941 "test_sess_mp_priv",
8944 0, 0, NULL, NULL, NULL,
8945 NULL, SOCKET_ID_ANY,
8948 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
8949 "session mempool allocation failed");
8952 ts_params->qp_conf.mp_session = ts_params->session_mpool;
8953 ts_params->qp_conf.mp_session_private =
8954 ts_params->session_priv_mpool;
8956 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8959 TEST_ASSERT(ret == 0,
8960 "Failed to attach device %u of pmd : %s", i,
8961 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8963 aesni_ids[nb_devs_attached] = (uint8_t)i;
8972 test_scheduler_detach_slave_op(void)
8974 struct crypto_testsuite_params *ts_params = &testsuite_params;
8975 uint8_t sched_id = ts_params->valid_devs[0];
8979 for (i = 0; i < 2; i++) {
8980 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8982 TEST_ASSERT(ret == 0,
8983 "Failed to detach device %u", aesni_ids[i]);
8990 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8992 struct crypto_testsuite_params *ts_params = &testsuite_params;
8993 uint8_t sched_id = ts_params->valid_devs[0];
8995 return rte_cryptodev_scheduler_mode_set(sched_id,
9000 test_scheduler_mode_roundrobin_op(void)
9002 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
9003 0, "Failed to set roundrobin mode");
9009 test_scheduler_mode_multicore_op(void)
9011 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
9012 0, "Failed to set multicore mode");
9018 test_scheduler_mode_failover_op(void)
9020 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
9021 0, "Failed to set failover mode");
9027 test_scheduler_mode_pkt_size_distr_op(void)
9029 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
9030 0, "Failed to set pktsize mode");
9035 static struct unit_test_suite cryptodev_scheduler_testsuite = {
9036 .suite_name = "Crypto Device Scheduler Unit Test Suite",
9037 .setup = testsuite_setup,
9038 .teardown = testsuite_teardown,
9039 .unit_test_cases = {
9041 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9042 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_AES_chain_scheduler_all),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_cipheronly_scheduler_all),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_authonly_scheduler_all),
9049 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9052 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9053 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_chain_scheduler_all),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_cipheronly_scheduler_all),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_authonly_scheduler_all),
9060 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9063 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9064 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_AES_chain_scheduler_all),
9067 TEST_CASE_ST(ut_setup, ut_teardown,
9068 test_AES_cipheronly_scheduler_all),
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_authonly_scheduler_all),
9071 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9074 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9075 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_AES_chain_scheduler_all),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_cipheronly_scheduler_all),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_authonly_scheduler_all),
9082 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9084 TEST_CASES_END() /**< NULL terminate unit test array */
9088 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
9090 static struct unit_test_suite cryptodev_qat_testsuite = {
9091 .suite_name = "Crypto QAT Unit Test Suite",
9092 .setup = testsuite_setup,
9093 .teardown = testsuite_teardown,
9094 .unit_test_cases = {
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_device_configure_invalid_dev_id),
9097 TEST_CASE_ST(ut_setup, ut_teardown,
9098 test_device_configure_invalid_queue_pair_ids),
9099 TEST_CASE_ST(ut_setup, ut_teardown,
9100 test_queue_pair_descriptor_setup),
9101 TEST_CASE_ST(ut_setup, ut_teardown,
9102 test_multi_session),
9104 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
9105 TEST_CASE_ST(ut_setup, ut_teardown,
9106 test_AES_cipheronly_qat_all),
9107 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_3DES_cipheronly_qat_all),
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_DES_cipheronly_qat_all),
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_AES_docsis_qat_all),
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_DES_docsis_qat_all),
9116 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
9117 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
9119 /** AES CCM Authenticated Encryption 128 bits key */
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_AES_CCM_authenticated_encryption_test_case_128_1),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_AES_CCM_authenticated_encryption_test_case_128_2),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_AES_CCM_authenticated_encryption_test_case_128_3),
9127 /** AES CCM Authenticated Decryption 128 bits key*/
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_AES_CCM_authenticated_decryption_test_case_128_1),
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_AES_CCM_authenticated_decryption_test_case_128_2),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_AES_CCM_authenticated_decryption_test_case_128_3),
9135 /** AES GCM Authenticated Encryption */
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_AES_GCM_authenticated_encryption_test_case_1),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_AES_GCM_authenticated_encryption_test_case_2),
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_AES_GCM_authenticated_encryption_test_case_3),
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_AES_GCM_authenticated_encryption_test_case_4),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_AES_GCM_authenticated_encryption_test_case_5),
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_AES_GCM_authenticated_encryption_test_case_6),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_AES_GCM_authenticated_encryption_test_case_7),
9157 /** AES GCM Authenticated Decryption */
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_AES_GCM_authenticated_decryption_test_case_1),
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_AES_GCM_authenticated_decryption_test_case_2),
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_AES_GCM_authenticated_decryption_test_case_3),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_AES_GCM_authenticated_decryption_test_case_4),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_AES_GCM_authenticated_decryption_test_case_5),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_AES_GCM_authenticated_decryption_test_case_6),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_AES_GCM_authenticated_decryption_test_case_7),
9173 /** AES GCM Authenticated Encryption 192 bits key */
9174 TEST_CASE_ST(ut_setup, ut_teardown,
9175 test_AES_GCM_auth_encryption_test_case_192_1),
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_AES_GCM_auth_encryption_test_case_192_2),
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_AES_GCM_auth_encryption_test_case_192_3),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_AES_GCM_auth_encryption_test_case_192_4),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_AES_GCM_auth_encryption_test_case_192_5),
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_AES_GCM_auth_encryption_test_case_192_6),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_AES_GCM_auth_encryption_test_case_192_7),
9189 /** AES GCM Authenticated Decryption 192 bits key */
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 test_AES_GCM_auth_decryption_test_case_192_1),
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_AES_GCM_auth_decryption_test_case_192_2),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_AES_GCM_auth_decryption_test_case_192_3),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_AES_GCM_auth_decryption_test_case_192_4),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 test_AES_GCM_auth_decryption_test_case_192_5),
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 test_AES_GCM_auth_decryption_test_case_192_6),
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 test_AES_GCM_auth_decryption_test_case_192_7),
9205 /** AES GCM Authenticated Encryption 256 bits key */
9206 TEST_CASE_ST(ut_setup, ut_teardown,
9207 test_AES_GCM_auth_encryption_test_case_256_1),
9208 TEST_CASE_ST(ut_setup, ut_teardown,
9209 test_AES_GCM_auth_encryption_test_case_256_2),
9210 TEST_CASE_ST(ut_setup, ut_teardown,
9211 test_AES_GCM_auth_encryption_test_case_256_3),
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_AES_GCM_auth_encryption_test_case_256_4),
9214 TEST_CASE_ST(ut_setup, ut_teardown,
9215 test_AES_GCM_auth_encryption_test_case_256_5),
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_AES_GCM_auth_encryption_test_case_256_6),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_AES_GCM_auth_encryption_test_case_256_7),
9221 /** AES GMAC Authentication */
9222 TEST_CASE_ST(ut_setup, ut_teardown,
9223 test_AES_GMAC_authentication_test_case_1),
9224 TEST_CASE_ST(ut_setup, ut_teardown,
9225 test_AES_GMAC_authentication_verify_test_case_1),
9226 TEST_CASE_ST(ut_setup, ut_teardown,
9227 test_AES_GMAC_authentication_test_case_2),
9228 TEST_CASE_ST(ut_setup, ut_teardown,
9229 test_AES_GMAC_authentication_verify_test_case_2),
9230 TEST_CASE_ST(ut_setup, ut_teardown,
9231 test_AES_GMAC_authentication_test_case_3),
9232 TEST_CASE_ST(ut_setup, ut_teardown,
9233 test_AES_GMAC_authentication_verify_test_case_3),
9235 /** SNOW 3G encrypt only (UEA2) */
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_snow3g_encryption_test_case_1),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_snow3g_encryption_test_case_2),
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 test_snow3g_encryption_test_case_3),
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 test_snow3g_encryption_test_case_4),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_snow3g_encryption_test_case_5),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_snow3g_encryption_test_case_1_oop),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_snow3g_decryption_test_case_1_oop),
9252 /** SNOW 3G decrypt only (UEA2) */
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_snow3g_decryption_test_case_1),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_snow3g_decryption_test_case_2),
9257 TEST_CASE_ST(ut_setup, ut_teardown,
9258 test_snow3g_decryption_test_case_3),
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_snow3g_decryption_test_case_4),
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_snow3g_decryption_test_case_5),
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_snow3g_decryption_with_digest_test_case_1),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_snow3g_hash_generate_test_case_1),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_snow3g_hash_generate_test_case_2),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_snow3g_hash_generate_test_case_3),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_snow3g_hash_verify_test_case_1),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_snow3g_hash_verify_test_case_2),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_snow3g_hash_verify_test_case_3),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_snow3g_cipher_auth_test_case_1),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_snow3g_auth_cipher_test_case_1),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_snow3g_auth_cipher_with_digest_test_case_1),
9284 /** ZUC encrypt only (EEA3) */
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_zuc_encryption_test_case_1),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_zuc_encryption_test_case_2),
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_zuc_encryption_test_case_3),
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_zuc_encryption_test_case_4),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_zuc_encryption_test_case_5),
9296 /** ZUC authenticate (EIA3) */
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_zuc_hash_generate_test_case_6),
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_zuc_hash_generate_test_case_7),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_zuc_hash_generate_test_case_8),
9304 /** ZUC alg-chain (EEA3/EIA3) */
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_zuc_cipher_auth_test_case_1),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_zuc_cipher_auth_test_case_2),
9310 /** HMAC_MD5 Authentication */
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_MD5_HMAC_generate_case_1),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_MD5_HMAC_verify_case_1),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_MD5_HMAC_generate_case_2),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_MD5_HMAC_verify_case_2),
9320 /** NULL algo tests done in chain_all,
9321 * cipheronly and authonly suites
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_kasumi_hash_generate_test_case_1),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_kasumi_hash_generate_test_case_2),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_kasumi_hash_generate_test_case_3),
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_kasumi_hash_generate_test_case_4),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_kasumi_hash_generate_test_case_5),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_kasumi_hash_generate_test_case_6),
9338 TEST_CASE_ST(ut_setup, ut_teardown,
9339 test_kasumi_hash_verify_test_case_1),
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_kasumi_hash_verify_test_case_2),
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_kasumi_hash_verify_test_case_3),
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_kasumi_hash_verify_test_case_4),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_kasumi_hash_verify_test_case_5),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_kasumi_encryption_test_case_1),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_kasumi_encryption_test_case_3),
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_kasumi_auth_cipher_test_case_1),
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_kasumi_cipher_auth_test_case_1),
9358 /** Negative tests */
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 authentication_verify_AES128_GMAC_fail_data_corrupt),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9369 TEST_CASE_ST(ut_setup, ut_teardown,
9370 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9372 TEST_CASES_END() /**< NULL terminate unit test array */
9376 static struct unit_test_suite cryptodev_virtio_testsuite = {
9377 .suite_name = "Crypto VIRTIO Unit Test Suite",
9378 .setup = testsuite_setup,
9379 .teardown = testsuite_teardown,
9380 .unit_test_cases = {
9381 TEST_CASE_ST(ut_setup, ut_teardown,
9382 test_AES_cipheronly_virtio_all),
9384 TEST_CASES_END() /**< NULL terminate unit test array */
9388 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9389 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9390 .setup = testsuite_setup,
9391 .teardown = testsuite_teardown,
9392 .unit_test_cases = {
9393 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_GCM_authenticated_encryption_test_case_1),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GCM_authenticated_encryption_test_case_2),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_GCM_authenticated_encryption_test_case_3),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_GCM_authenticated_encryption_test_case_4),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_AES_GCM_authenticated_encryption_test_case_5),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_AES_GCM_authenticated_encryption_test_case_6),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_authenticated_encryption_test_case_7),
9409 /** AES GCM Authenticated Decryption */
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_AES_GCM_authenticated_decryption_test_case_1),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_authenticated_decryption_test_case_2),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_authenticated_decryption_test_case_3),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_authenticated_decryption_test_case_4),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_AES_GCM_authenticated_decryption_test_case_5),
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_GCM_authenticated_decryption_test_case_6),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_authenticated_decryption_test_case_7),
9425 /** AES GCM Authenticated Encryption 192 bits key */
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_auth_encryption_test_case_192_1),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_AES_GCM_auth_encryption_test_case_192_2),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_auth_encryption_test_case_192_3),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_auth_encryption_test_case_192_4),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_AES_GCM_auth_encryption_test_case_192_5),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_AES_GCM_auth_encryption_test_case_192_6),
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_AES_GCM_auth_encryption_test_case_192_7),
9441 /** AES GCM Authenticated Decryption 192 bits key */
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_AES_GCM_auth_decryption_test_case_192_1),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_AES_GCM_auth_decryption_test_case_192_2),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_AES_GCM_auth_decryption_test_case_192_3),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_AES_GCM_auth_decryption_test_case_192_4),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_GCM_auth_decryption_test_case_192_5),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_AES_GCM_auth_decryption_test_case_192_6),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_AES_GCM_auth_decryption_test_case_192_7),
9457 /** AES GCM Authenticated Encryption 256 bits key */
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GCM_auth_encryption_test_case_256_1),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_AES_GCM_auth_encryption_test_case_256_2),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GCM_auth_encryption_test_case_256_3),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GCM_auth_encryption_test_case_256_4),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GCM_auth_encryption_test_case_256_5),
9468 TEST_CASE_ST(ut_setup, ut_teardown,
9469 test_AES_GCM_auth_encryption_test_case_256_6),
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_AES_GCM_auth_encryption_test_case_256_7),
9473 /** AES GCM Authenticated Decryption 256 bits key */
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_AES_GCM_auth_decryption_test_case_256_1),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_AES_GCM_auth_decryption_test_case_256_2),
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_AES_GCM_auth_decryption_test_case_256_3),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_GCM_auth_decryption_test_case_256_4),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_GCM_auth_decryption_test_case_256_5),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_AES_GCM_auth_decryption_test_case_256_6),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_AES_GCM_auth_decryption_test_case_256_7),
9489 /** AES GCM Authenticated Encryption big aad size */
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_AES_GCM_auth_encryption_test_case_aad_1),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_AES_GCM_auth_encryption_test_case_aad_2),
9495 /** AES GCM Authenticated Decryption big aad size */
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_AES_GCM_auth_decryption_test_case_aad_1),
9498 TEST_CASE_ST(ut_setup, ut_teardown,
9499 test_AES_GCM_auth_decryption_test_case_aad_2),
9501 /** Session-less tests */
9502 TEST_CASE_ST(ut_setup, ut_teardown,
9503 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9507 /** AES GMAC Authentication */
9508 TEST_CASE_ST(ut_setup, ut_teardown,
9509 test_AES_GMAC_authentication_test_case_1),
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_AES_GMAC_authentication_verify_test_case_1),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_AES_GMAC_authentication_test_case_2),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_AES_GMAC_authentication_verify_test_case_2),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_AES_GMAC_authentication_test_case_3),
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_AES_GMAC_authentication_verify_test_case_3),
9520 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
9522 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9523 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9524 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9525 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9526 TEST_CASE_ST(ut_setup, ut_teardown,
9527 test_DES_cipheronly_mb_all),
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 test_DES_docsis_mb_all),
9530 TEST_CASE_ST(ut_setup, ut_teardown,
9531 test_3DES_cipheronly_mb_all),
9532 TEST_CASE_ST(ut_setup, ut_teardown,
9533 test_AES_CCM_authenticated_encryption_test_case_128_1),
9534 TEST_CASE_ST(ut_setup, ut_teardown,
9535 test_AES_CCM_authenticated_decryption_test_case_128_1),
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 test_AES_CCM_authenticated_encryption_test_case_128_2),
9538 TEST_CASE_ST(ut_setup, ut_teardown,
9539 test_AES_CCM_authenticated_decryption_test_case_128_2),
9540 TEST_CASE_ST(ut_setup, ut_teardown,
9541 test_AES_CCM_authenticated_encryption_test_case_128_3),
9542 TEST_CASE_ST(ut_setup, ut_teardown,
9543 test_AES_CCM_authenticated_decryption_test_case_128_3),
9545 TEST_CASES_END() /**< NULL terminate unit test array */
9549 static struct unit_test_suite cryptodev_openssl_testsuite = {
9550 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9551 .setup = testsuite_setup,
9552 .teardown = testsuite_teardown,
9553 .unit_test_cases = {
9554 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9555 TEST_CASE_ST(ut_setup, ut_teardown,
9556 test_multi_session_random_usage),
9557 TEST_CASE_ST(ut_setup, ut_teardown,
9558 test_AES_chain_openssl_all),
9559 TEST_CASE_ST(ut_setup, ut_teardown,
9560 test_AES_cipheronly_openssl_all),
9561 TEST_CASE_ST(ut_setup, ut_teardown,
9562 test_3DES_chain_openssl_all),
9563 TEST_CASE_ST(ut_setup, ut_teardown,
9564 test_3DES_cipheronly_openssl_all),
9565 TEST_CASE_ST(ut_setup, ut_teardown,
9566 test_DES_cipheronly_openssl_all),
9567 TEST_CASE_ST(ut_setup, ut_teardown,
9568 test_DES_docsis_openssl_all),
9569 TEST_CASE_ST(ut_setup, ut_teardown,
9570 test_authonly_openssl_all),
9572 /** AES GCM Authenticated Encryption */
9573 TEST_CASE_ST(ut_setup, ut_teardown,
9574 test_AES_GCM_authenticated_encryption_test_case_1),
9575 TEST_CASE_ST(ut_setup, ut_teardown,
9576 test_AES_GCM_authenticated_encryption_test_case_2),
9577 TEST_CASE_ST(ut_setup, ut_teardown,
9578 test_AES_GCM_authenticated_encryption_test_case_3),
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 test_AES_GCM_authenticated_encryption_test_case_4),
9581 TEST_CASE_ST(ut_setup, ut_teardown,
9582 test_AES_GCM_authenticated_encryption_test_case_5),
9583 TEST_CASE_ST(ut_setup, ut_teardown,
9584 test_AES_GCM_authenticated_encryption_test_case_6),
9585 TEST_CASE_ST(ut_setup, ut_teardown,
9586 test_AES_GCM_authenticated_encryption_test_case_7),
9588 /** AES GCM Authenticated Decryption */
9589 TEST_CASE_ST(ut_setup, ut_teardown,
9590 test_AES_GCM_authenticated_decryption_test_case_1),
9591 TEST_CASE_ST(ut_setup, ut_teardown,
9592 test_AES_GCM_authenticated_decryption_test_case_2),
9593 TEST_CASE_ST(ut_setup, ut_teardown,
9594 test_AES_GCM_authenticated_decryption_test_case_3),
9595 TEST_CASE_ST(ut_setup, ut_teardown,
9596 test_AES_GCM_authenticated_decryption_test_case_4),
9597 TEST_CASE_ST(ut_setup, ut_teardown,
9598 test_AES_GCM_authenticated_decryption_test_case_5),
9599 TEST_CASE_ST(ut_setup, ut_teardown,
9600 test_AES_GCM_authenticated_decryption_test_case_6),
9601 TEST_CASE_ST(ut_setup, ut_teardown,
9602 test_AES_GCM_authenticated_decryption_test_case_7),
9605 /** AES GCM Authenticated Encryption 192 bits key */
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_auth_encryption_test_case_192_1),
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_GCM_auth_encryption_test_case_192_2),
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_auth_encryption_test_case_192_3),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_auth_encryption_test_case_192_4),
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_AES_GCM_auth_encryption_test_case_192_5),
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GCM_auth_encryption_test_case_192_6),
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GCM_auth_encryption_test_case_192_7),
9621 /** AES GCM Authenticated Decryption 192 bits key */
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GCM_auth_decryption_test_case_192_1),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_GCM_auth_decryption_test_case_192_2),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GCM_auth_decryption_test_case_192_3),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GCM_auth_decryption_test_case_192_4),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GCM_auth_decryption_test_case_192_5),
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_AES_GCM_auth_decryption_test_case_192_6),
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_GCM_auth_decryption_test_case_192_7),
9637 /** AES GCM Authenticated Encryption 256 bits key */
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_GCM_auth_encryption_test_case_256_1),
9640 TEST_CASE_ST(ut_setup, ut_teardown,
9641 test_AES_GCM_auth_encryption_test_case_256_2),
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 test_AES_GCM_auth_encryption_test_case_256_3),
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_GCM_auth_encryption_test_case_256_4),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_GCM_auth_encryption_test_case_256_5),
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_GCM_auth_encryption_test_case_256_6),
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_auth_encryption_test_case_256_7),
9653 /** AES GCM Authenticated Decryption 256 bits key */
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_auth_decryption_test_case_256_1),
9656 TEST_CASE_ST(ut_setup, ut_teardown,
9657 test_AES_GCM_auth_decryption_test_case_256_2),
9658 TEST_CASE_ST(ut_setup, ut_teardown,
9659 test_AES_GCM_auth_decryption_test_case_256_3),
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_GCM_auth_decryption_test_case_256_4),
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_GCM_auth_decryption_test_case_256_5),
9664 TEST_CASE_ST(ut_setup, ut_teardown,
9665 test_AES_GCM_auth_decryption_test_case_256_6),
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_auth_decryption_test_case_256_7),
9669 /** AES GMAC Authentication */
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GMAC_authentication_test_case_1),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_GMAC_authentication_verify_test_case_1),
9674 TEST_CASE_ST(ut_setup, ut_teardown,
9675 test_AES_GMAC_authentication_test_case_2),
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_GMAC_authentication_verify_test_case_2),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_AES_GMAC_authentication_test_case_3),
9680 TEST_CASE_ST(ut_setup, ut_teardown,
9681 test_AES_GMAC_authentication_verify_test_case_3),
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GMAC_authentication_test_case_4),
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GMAC_authentication_verify_test_case_4),
9687 /** AES CCM Authenticated Encryption 128 bits key */
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 test_AES_CCM_authenticated_encryption_test_case_128_1),
9690 TEST_CASE_ST(ut_setup, ut_teardown,
9691 test_AES_CCM_authenticated_encryption_test_case_128_2),
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 test_AES_CCM_authenticated_encryption_test_case_128_3),
9695 /** AES CCM Authenticated Decryption 128 bits key*/
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 test_AES_CCM_authenticated_decryption_test_case_128_1),
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 test_AES_CCM_authenticated_decryption_test_case_128_2),
9700 TEST_CASE_ST(ut_setup, ut_teardown,
9701 test_AES_CCM_authenticated_decryption_test_case_128_3),
9703 /** AES CCM Authenticated Encryption 192 bits key */
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_AES_CCM_authenticated_encryption_test_case_192_1),
9706 TEST_CASE_ST(ut_setup, ut_teardown,
9707 test_AES_CCM_authenticated_encryption_test_case_192_2),
9708 TEST_CASE_ST(ut_setup, ut_teardown,
9709 test_AES_CCM_authenticated_encryption_test_case_192_3),
9711 /** AES CCM Authenticated Decryption 192 bits key*/
9712 TEST_CASE_ST(ut_setup, ut_teardown,
9713 test_AES_CCM_authenticated_decryption_test_case_192_1),
9714 TEST_CASE_ST(ut_setup, ut_teardown,
9715 test_AES_CCM_authenticated_decryption_test_case_192_2),
9716 TEST_CASE_ST(ut_setup, ut_teardown,
9717 test_AES_CCM_authenticated_decryption_test_case_192_3),
9719 /** AES CCM Authenticated Encryption 256 bits key */
9720 TEST_CASE_ST(ut_setup, ut_teardown,
9721 test_AES_CCM_authenticated_encryption_test_case_256_1),
9722 TEST_CASE_ST(ut_setup, ut_teardown,
9723 test_AES_CCM_authenticated_encryption_test_case_256_2),
9724 TEST_CASE_ST(ut_setup, ut_teardown,
9725 test_AES_CCM_authenticated_encryption_test_case_256_3),
9727 /** AES CCM Authenticated Decryption 256 bits key*/
9728 TEST_CASE_ST(ut_setup, ut_teardown,
9729 test_AES_CCM_authenticated_decryption_test_case_256_1),
9730 TEST_CASE_ST(ut_setup, ut_teardown,
9731 test_AES_CCM_authenticated_decryption_test_case_256_2),
9732 TEST_CASE_ST(ut_setup, ut_teardown,
9733 test_AES_CCM_authenticated_decryption_test_case_256_3),
9735 /** Scatter-Gather */
9736 TEST_CASE_ST(ut_setup, ut_teardown,
9737 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9739 /** Negative tests */
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9744 TEST_CASE_ST(ut_setup, ut_teardown,
9745 authentication_verify_AES128_GMAC_fail_data_corrupt),
9746 TEST_CASE_ST(ut_setup, ut_teardown,
9747 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9748 TEST_CASE_ST(ut_setup, ut_teardown,
9749 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9753 TEST_CASES_END() /**< NULL terminate unit test array */
9757 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9758 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9759 .setup = testsuite_setup,
9760 .teardown = testsuite_teardown,
9761 .unit_test_cases = {
9762 /** AES GCM Authenticated Encryption */
9763 TEST_CASE_ST(ut_setup, ut_teardown,
9764 test_AES_GCM_authenticated_encryption_test_case_1),
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 test_AES_GCM_authenticated_encryption_test_case_2),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 test_AES_GCM_authenticated_encryption_test_case_3),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_AES_GCM_authenticated_encryption_test_case_4),
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_AES_GCM_authenticated_encryption_test_case_5),
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_AES_GCM_authenticated_encryption_test_case_6),
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_AES_GCM_authenticated_encryption_test_case_7),
9778 /** AES GCM Authenticated Decryption */
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 test_AES_GCM_authenticated_decryption_test_case_1),
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 test_AES_GCM_authenticated_decryption_test_case_2),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_AES_GCM_authenticated_decryption_test_case_3),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_AES_GCM_authenticated_decryption_test_case_4),
9787 TEST_CASE_ST(ut_setup, ut_teardown,
9788 test_AES_GCM_authenticated_decryption_test_case_5),
9789 TEST_CASE_ST(ut_setup, ut_teardown,
9790 test_AES_GCM_authenticated_decryption_test_case_6),
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_AES_GCM_authenticated_decryption_test_case_7),
9794 /** AES GCM Authenticated Encryption 192 bits key */
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_AES_GCM_auth_encryption_test_case_192_1),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_AES_GCM_auth_encryption_test_case_192_2),
9799 TEST_CASE_ST(ut_setup, ut_teardown,
9800 test_AES_GCM_auth_encryption_test_case_192_3),
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_AES_GCM_auth_encryption_test_case_192_4),
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_AES_GCM_auth_encryption_test_case_192_5),
9805 TEST_CASE_ST(ut_setup, ut_teardown,
9806 test_AES_GCM_auth_encryption_test_case_192_6),
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 test_AES_GCM_auth_encryption_test_case_192_7),
9810 /** AES GCM Authenticated Decryption 192 bits key */
9811 TEST_CASE_ST(ut_setup, ut_teardown,
9812 test_AES_GCM_auth_decryption_test_case_192_1),
9813 TEST_CASE_ST(ut_setup, ut_teardown,
9814 test_AES_GCM_auth_decryption_test_case_192_2),
9815 TEST_CASE_ST(ut_setup, ut_teardown,
9816 test_AES_GCM_auth_decryption_test_case_192_3),
9817 TEST_CASE_ST(ut_setup, ut_teardown,
9818 test_AES_GCM_auth_decryption_test_case_192_4),
9819 TEST_CASE_ST(ut_setup, ut_teardown,
9820 test_AES_GCM_auth_decryption_test_case_192_5),
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_AES_GCM_auth_decryption_test_case_192_6),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_AES_GCM_auth_decryption_test_case_192_7),
9826 /** AES GCM Authenticated Encryption 256 bits key */
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_AES_GCM_auth_encryption_test_case_256_1),
9829 TEST_CASE_ST(ut_setup, ut_teardown,
9830 test_AES_GCM_auth_encryption_test_case_256_2),
9831 TEST_CASE_ST(ut_setup, ut_teardown,
9832 test_AES_GCM_auth_encryption_test_case_256_3),
9833 TEST_CASE_ST(ut_setup, ut_teardown,
9834 test_AES_GCM_auth_encryption_test_case_256_4),
9835 TEST_CASE_ST(ut_setup, ut_teardown,
9836 test_AES_GCM_auth_encryption_test_case_256_5),
9837 TEST_CASE_ST(ut_setup, ut_teardown,
9838 test_AES_GCM_auth_encryption_test_case_256_6),
9839 TEST_CASE_ST(ut_setup, ut_teardown,
9840 test_AES_GCM_auth_encryption_test_case_256_7),
9842 /** AES GCM Authenticated Decryption 256 bits key */
9843 TEST_CASE_ST(ut_setup, ut_teardown,
9844 test_AES_GCM_auth_decryption_test_case_256_1),
9845 TEST_CASE_ST(ut_setup, ut_teardown,
9846 test_AES_GCM_auth_decryption_test_case_256_2),
9847 TEST_CASE_ST(ut_setup, ut_teardown,
9848 test_AES_GCM_auth_decryption_test_case_256_3),
9849 TEST_CASE_ST(ut_setup, ut_teardown,
9850 test_AES_GCM_auth_decryption_test_case_256_4),
9851 TEST_CASE_ST(ut_setup, ut_teardown,
9852 test_AES_GCM_auth_decryption_test_case_256_5),
9853 TEST_CASE_ST(ut_setup, ut_teardown,
9854 test_AES_GCM_auth_decryption_test_case_256_6),
9855 TEST_CASE_ST(ut_setup, ut_teardown,
9856 test_AES_GCM_auth_decryption_test_case_256_7),
9858 /** AES GCM Authenticated Encryption big aad size */
9859 TEST_CASE_ST(ut_setup, ut_teardown,
9860 test_AES_GCM_auth_encryption_test_case_aad_1),
9861 TEST_CASE_ST(ut_setup, ut_teardown,
9862 test_AES_GCM_auth_encryption_test_case_aad_2),
9864 /** AES GCM Authenticated Decryption big aad size */
9865 TEST_CASE_ST(ut_setup, ut_teardown,
9866 test_AES_GCM_auth_decryption_test_case_aad_1),
9867 TEST_CASE_ST(ut_setup, ut_teardown,
9868 test_AES_GCM_auth_decryption_test_case_aad_2),
9870 /** AES GMAC Authentication */
9871 TEST_CASE_ST(ut_setup, ut_teardown,
9872 test_AES_GMAC_authentication_test_case_1),
9873 TEST_CASE_ST(ut_setup, ut_teardown,
9874 test_AES_GMAC_authentication_verify_test_case_1),
9875 TEST_CASE_ST(ut_setup, ut_teardown,
9876 test_AES_GMAC_authentication_test_case_3),
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 test_AES_GMAC_authentication_verify_test_case_3),
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 test_AES_GMAC_authentication_test_case_4),
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 test_AES_GMAC_authentication_verify_test_case_4),
9884 /** Negative tests */
9885 TEST_CASE_ST(ut_setup, ut_teardown,
9886 authentication_verify_AES128_GMAC_fail_data_corrupt),
9887 TEST_CASE_ST(ut_setup, ut_teardown,
9888 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9890 /** Out of place tests */
9891 TEST_CASE_ST(ut_setup, ut_teardown,
9892 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9893 TEST_CASE_ST(ut_setup, ut_teardown,
9894 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9896 /** Session-less tests */
9897 TEST_CASE_ST(ut_setup, ut_teardown,
9898 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9899 TEST_CASE_ST(ut_setup, ut_teardown,
9900 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9902 /** Scatter-Gather */
9903 TEST_CASE_ST(ut_setup, ut_teardown,
9904 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9906 TEST_CASES_END() /**< NULL terminate unit test array */
9910 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9911 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9912 .setup = testsuite_setup,
9913 .teardown = testsuite_teardown,
9914 .unit_test_cases = {
9915 /** KASUMI encrypt only (UEA1) */
9916 TEST_CASE_ST(ut_setup, ut_teardown,
9917 test_kasumi_encryption_test_case_1),
9918 TEST_CASE_ST(ut_setup, ut_teardown,
9919 test_kasumi_encryption_test_case_1_sgl),
9920 TEST_CASE_ST(ut_setup, ut_teardown,
9921 test_kasumi_encryption_test_case_2),
9922 TEST_CASE_ST(ut_setup, ut_teardown,
9923 test_kasumi_encryption_test_case_3),
9924 TEST_CASE_ST(ut_setup, ut_teardown,
9925 test_kasumi_encryption_test_case_4),
9926 TEST_CASE_ST(ut_setup, ut_teardown,
9927 test_kasumi_encryption_test_case_5),
9928 /** KASUMI decrypt only (UEA1) */
9929 TEST_CASE_ST(ut_setup, ut_teardown,
9930 test_kasumi_decryption_test_case_1),
9931 TEST_CASE_ST(ut_setup, ut_teardown,
9932 test_kasumi_decryption_test_case_2),
9933 TEST_CASE_ST(ut_setup, ut_teardown,
9934 test_kasumi_decryption_test_case_3),
9935 TEST_CASE_ST(ut_setup, ut_teardown,
9936 test_kasumi_decryption_test_case_4),
9937 TEST_CASE_ST(ut_setup, ut_teardown,
9938 test_kasumi_decryption_test_case_5),
9940 TEST_CASE_ST(ut_setup, ut_teardown,
9941 test_kasumi_encryption_test_case_1_oop),
9942 TEST_CASE_ST(ut_setup, ut_teardown,
9943 test_kasumi_encryption_test_case_1_oop_sgl),
9946 TEST_CASE_ST(ut_setup, ut_teardown,
9947 test_kasumi_decryption_test_case_1_oop),
9949 /** KASUMI hash only (UIA1) */
9950 TEST_CASE_ST(ut_setup, ut_teardown,
9951 test_kasumi_hash_generate_test_case_1),
9952 TEST_CASE_ST(ut_setup, ut_teardown,
9953 test_kasumi_hash_generate_test_case_2),
9954 TEST_CASE_ST(ut_setup, ut_teardown,
9955 test_kasumi_hash_generate_test_case_3),
9956 TEST_CASE_ST(ut_setup, ut_teardown,
9957 test_kasumi_hash_generate_test_case_4),
9958 TEST_CASE_ST(ut_setup, ut_teardown,
9959 test_kasumi_hash_generate_test_case_5),
9960 TEST_CASE_ST(ut_setup, ut_teardown,
9961 test_kasumi_hash_generate_test_case_6),
9962 TEST_CASE_ST(ut_setup, ut_teardown,
9963 test_kasumi_hash_verify_test_case_1),
9964 TEST_CASE_ST(ut_setup, ut_teardown,
9965 test_kasumi_hash_verify_test_case_2),
9966 TEST_CASE_ST(ut_setup, ut_teardown,
9967 test_kasumi_hash_verify_test_case_3),
9968 TEST_CASE_ST(ut_setup, ut_teardown,
9969 test_kasumi_hash_verify_test_case_4),
9970 TEST_CASE_ST(ut_setup, ut_teardown,
9971 test_kasumi_hash_verify_test_case_5),
9972 TEST_CASE_ST(ut_setup, ut_teardown,
9973 test_kasumi_auth_cipher_test_case_1),
9974 TEST_CASE_ST(ut_setup, ut_teardown,
9975 test_kasumi_cipher_auth_test_case_1),
9976 TEST_CASES_END() /**< NULL terminate unit test array */
9979 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9980 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9981 .setup = testsuite_setup,
9982 .teardown = testsuite_teardown,
9983 .unit_test_cases = {
9984 /** SNOW 3G encrypt only (UEA2) */
9985 TEST_CASE_ST(ut_setup, ut_teardown,
9986 test_snow3g_encryption_test_case_1),
9987 TEST_CASE_ST(ut_setup, ut_teardown,
9988 test_snow3g_encryption_test_case_2),
9989 TEST_CASE_ST(ut_setup, ut_teardown,
9990 test_snow3g_encryption_test_case_3),
9991 TEST_CASE_ST(ut_setup, ut_teardown,
9992 test_snow3g_encryption_test_case_4),
9993 TEST_CASE_ST(ut_setup, ut_teardown,
9994 test_snow3g_encryption_test_case_5),
9995 TEST_CASE_ST(ut_setup, ut_teardown,
9996 test_snow3g_auth_cipher_with_digest_test_case_1),
9998 TEST_CASE_ST(ut_setup, ut_teardown,
9999 test_snow3g_encryption_test_case_1_oop),
10000 TEST_CASE_ST(ut_setup, ut_teardown,
10001 test_snow3g_encryption_test_case_1_oop_sgl),
10002 TEST_CASE_ST(ut_setup, ut_teardown,
10003 test_snow3g_decryption_test_case_1_oop),
10005 TEST_CASE_ST(ut_setup, ut_teardown,
10006 test_snow3g_encryption_test_case_1_offset_oop),
10008 /** SNOW 3G decrypt only (UEA2) */
10009 TEST_CASE_ST(ut_setup, ut_teardown,
10010 test_snow3g_decryption_test_case_1),
10011 TEST_CASE_ST(ut_setup, ut_teardown,
10012 test_snow3g_decryption_test_case_2),
10013 TEST_CASE_ST(ut_setup, ut_teardown,
10014 test_snow3g_decryption_test_case_3),
10015 TEST_CASE_ST(ut_setup, ut_teardown,
10016 test_snow3g_decryption_test_case_4),
10017 TEST_CASE_ST(ut_setup, ut_teardown,
10018 test_snow3g_decryption_test_case_5),
10019 TEST_CASE_ST(ut_setup, ut_teardown,
10020 test_snow3g_decryption_with_digest_test_case_1),
10021 TEST_CASE_ST(ut_setup, ut_teardown,
10022 test_snow3g_hash_generate_test_case_1),
10023 TEST_CASE_ST(ut_setup, ut_teardown,
10024 test_snow3g_hash_generate_test_case_2),
10025 TEST_CASE_ST(ut_setup, ut_teardown,
10026 test_snow3g_hash_generate_test_case_3),
10027 /* Tests with buffers which length is not byte-aligned */
10028 TEST_CASE_ST(ut_setup, ut_teardown,
10029 test_snow3g_hash_generate_test_case_4),
10030 TEST_CASE_ST(ut_setup, ut_teardown,
10031 test_snow3g_hash_generate_test_case_5),
10032 TEST_CASE_ST(ut_setup, ut_teardown,
10033 test_snow3g_hash_generate_test_case_6),
10034 TEST_CASE_ST(ut_setup, ut_teardown,
10035 test_snow3g_hash_verify_test_case_1),
10036 TEST_CASE_ST(ut_setup, ut_teardown,
10037 test_snow3g_hash_verify_test_case_2),
10038 TEST_CASE_ST(ut_setup, ut_teardown,
10039 test_snow3g_hash_verify_test_case_3),
10040 /* Tests with buffers which length is not byte-aligned */
10041 TEST_CASE_ST(ut_setup, ut_teardown,
10042 test_snow3g_hash_verify_test_case_4),
10043 TEST_CASE_ST(ut_setup, ut_teardown,
10044 test_snow3g_hash_verify_test_case_5),
10045 TEST_CASE_ST(ut_setup, ut_teardown,
10046 test_snow3g_hash_verify_test_case_6),
10047 TEST_CASE_ST(ut_setup, ut_teardown,
10048 test_snow3g_cipher_auth_test_case_1),
10049 TEST_CASE_ST(ut_setup, ut_teardown,
10050 test_snow3g_auth_cipher_test_case_1),
10052 TEST_CASES_END() /**< NULL terminate unit test array */
10056 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
10057 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
10058 .setup = testsuite_setup,
10059 .teardown = testsuite_teardown,
10060 .unit_test_cases = {
10061 /** ZUC encrypt only (EEA3) */
10062 TEST_CASE_ST(ut_setup, ut_teardown,
10063 test_zuc_encryption_test_case_1),
10064 TEST_CASE_ST(ut_setup, ut_teardown,
10065 test_zuc_encryption_test_case_2),
10066 TEST_CASE_ST(ut_setup, ut_teardown,
10067 test_zuc_encryption_test_case_3),
10068 TEST_CASE_ST(ut_setup, ut_teardown,
10069 test_zuc_encryption_test_case_4),
10070 TEST_CASE_ST(ut_setup, ut_teardown,
10071 test_zuc_encryption_test_case_5),
10072 TEST_CASE_ST(ut_setup, ut_teardown,
10073 test_zuc_hash_generate_test_case_1),
10074 TEST_CASE_ST(ut_setup, ut_teardown,
10075 test_zuc_hash_generate_test_case_2),
10076 TEST_CASE_ST(ut_setup, ut_teardown,
10077 test_zuc_hash_generate_test_case_3),
10078 TEST_CASE_ST(ut_setup, ut_teardown,
10079 test_zuc_hash_generate_test_case_4),
10080 TEST_CASE_ST(ut_setup, ut_teardown,
10081 test_zuc_hash_generate_test_case_5),
10082 TEST_CASE_ST(ut_setup, ut_teardown,
10083 test_zuc_encryption_test_case_6_sgl),
10084 TEST_CASES_END() /**< NULL terminate unit test array */
10088 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
10089 .suite_name = "Crypto CAAM JR Unit Test Suite",
10090 .setup = testsuite_setup,
10091 .teardown = testsuite_teardown,
10092 .unit_test_cases = {
10093 TEST_CASE_ST(ut_setup, ut_teardown,
10094 test_device_configure_invalid_dev_id),
10095 TEST_CASE_ST(ut_setup, ut_teardown,
10096 test_multi_session),
10098 TEST_CASE_ST(ut_setup, ut_teardown,
10099 test_AES_chain_caam_jr_all),
10100 TEST_CASE_ST(ut_setup, ut_teardown,
10101 test_3DES_chain_caam_jr_all),
10102 TEST_CASE_ST(ut_setup, ut_teardown,
10103 test_AES_cipheronly_caam_jr_all),
10104 TEST_CASE_ST(ut_setup, ut_teardown,
10105 test_3DES_cipheronly_caam_jr_all),
10106 TEST_CASE_ST(ut_setup, ut_teardown,
10107 test_authonly_caam_jr_all),
10109 TEST_CASES_END() /**< NULL terminate unit test array */
10113 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
10114 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
10115 .setup = testsuite_setup,
10116 .teardown = testsuite_teardown,
10117 .unit_test_cases = {
10118 TEST_CASE_ST(ut_setup, ut_teardown,
10119 test_device_configure_invalid_dev_id),
10120 TEST_CASE_ST(ut_setup, ut_teardown,
10121 test_multi_session),
10123 TEST_CASE_ST(ut_setup, ut_teardown,
10124 test_AES_chain_dpaa_sec_all),
10125 TEST_CASE_ST(ut_setup, ut_teardown,
10126 test_3DES_chain_dpaa_sec_all),
10127 TEST_CASE_ST(ut_setup, ut_teardown,
10128 test_AES_cipheronly_dpaa_sec_all),
10129 TEST_CASE_ST(ut_setup, ut_teardown,
10130 test_3DES_cipheronly_dpaa_sec_all),
10131 TEST_CASE_ST(ut_setup, ut_teardown,
10132 test_authonly_dpaa_sec_all),
10134 /** AES GCM Authenticated Encryption */
10135 TEST_CASE_ST(ut_setup, ut_teardown,
10136 test_AES_GCM_authenticated_encryption_test_case_1),
10137 TEST_CASE_ST(ut_setup, ut_teardown,
10138 test_AES_GCM_authenticated_encryption_test_case_2),
10139 TEST_CASE_ST(ut_setup, ut_teardown,
10140 test_AES_GCM_authenticated_encryption_test_case_3),
10141 TEST_CASE_ST(ut_setup, ut_teardown,
10142 test_AES_GCM_authenticated_encryption_test_case_4),
10143 TEST_CASE_ST(ut_setup, ut_teardown,
10144 test_AES_GCM_authenticated_encryption_test_case_5),
10145 TEST_CASE_ST(ut_setup, ut_teardown,
10146 test_AES_GCM_authenticated_encryption_test_case_6),
10147 TEST_CASE_ST(ut_setup, ut_teardown,
10148 test_AES_GCM_authenticated_encryption_test_case_7),
10150 /** AES GCM Authenticated Decryption */
10151 TEST_CASE_ST(ut_setup, ut_teardown,
10152 test_AES_GCM_authenticated_decryption_test_case_1),
10153 TEST_CASE_ST(ut_setup, ut_teardown,
10154 test_AES_GCM_authenticated_decryption_test_case_2),
10155 TEST_CASE_ST(ut_setup, ut_teardown,
10156 test_AES_GCM_authenticated_decryption_test_case_3),
10157 TEST_CASE_ST(ut_setup, ut_teardown,
10158 test_AES_GCM_authenticated_decryption_test_case_4),
10159 TEST_CASE_ST(ut_setup, ut_teardown,
10160 test_AES_GCM_authenticated_decryption_test_case_5),
10161 TEST_CASE_ST(ut_setup, ut_teardown,
10162 test_AES_GCM_authenticated_decryption_test_case_6),
10163 TEST_CASE_ST(ut_setup, ut_teardown,
10164 test_AES_GCM_authenticated_decryption_test_case_7),
10166 /** AES GCM Authenticated Encryption 256 bits key */
10167 TEST_CASE_ST(ut_setup, ut_teardown,
10168 test_AES_GCM_auth_encryption_test_case_256_1),
10169 TEST_CASE_ST(ut_setup, ut_teardown,
10170 test_AES_GCM_auth_encryption_test_case_256_2),
10171 TEST_CASE_ST(ut_setup, ut_teardown,
10172 test_AES_GCM_auth_encryption_test_case_256_3),
10173 TEST_CASE_ST(ut_setup, ut_teardown,
10174 test_AES_GCM_auth_encryption_test_case_256_4),
10175 TEST_CASE_ST(ut_setup, ut_teardown,
10176 test_AES_GCM_auth_encryption_test_case_256_5),
10177 TEST_CASE_ST(ut_setup, ut_teardown,
10178 test_AES_GCM_auth_encryption_test_case_256_6),
10179 TEST_CASE_ST(ut_setup, ut_teardown,
10180 test_AES_GCM_auth_encryption_test_case_256_7),
10182 /** AES GCM Authenticated Decryption 256 bits key */
10183 TEST_CASE_ST(ut_setup, ut_teardown,
10184 test_AES_GCM_auth_decryption_test_case_256_1),
10185 TEST_CASE_ST(ut_setup, ut_teardown,
10186 test_AES_GCM_auth_decryption_test_case_256_2),
10187 TEST_CASE_ST(ut_setup, ut_teardown,
10188 test_AES_GCM_auth_decryption_test_case_256_3),
10189 TEST_CASE_ST(ut_setup, ut_teardown,
10190 test_AES_GCM_auth_decryption_test_case_256_4),
10191 TEST_CASE_ST(ut_setup, ut_teardown,
10192 test_AES_GCM_auth_decryption_test_case_256_5),
10193 TEST_CASE_ST(ut_setup, ut_teardown,
10194 test_AES_GCM_auth_decryption_test_case_256_6),
10195 TEST_CASE_ST(ut_setup, ut_teardown,
10196 test_AES_GCM_auth_decryption_test_case_256_7),
10198 /** Out of place tests */
10199 TEST_CASE_ST(ut_setup, ut_teardown,
10200 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10201 TEST_CASE_ST(ut_setup, ut_teardown,
10202 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10204 /** Scatter-Gather */
10205 TEST_CASE_ST(ut_setup, ut_teardown,
10206 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10207 TEST_CASE_ST(ut_setup, ut_teardown,
10208 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10209 TEST_CASE_ST(ut_setup, ut_teardown,
10210 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10211 TEST_CASE_ST(ut_setup, ut_teardown,
10212 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10214 TEST_CASES_END() /**< NULL terminate unit test array */
10218 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10219 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10220 .setup = testsuite_setup,
10221 .teardown = testsuite_teardown,
10222 .unit_test_cases = {
10223 TEST_CASE_ST(ut_setup, ut_teardown,
10224 test_device_configure_invalid_dev_id),
10225 TEST_CASE_ST(ut_setup, ut_teardown,
10226 test_multi_session),
10228 TEST_CASE_ST(ut_setup, ut_teardown,
10229 test_AES_chain_dpaa2_sec_all),
10230 TEST_CASE_ST(ut_setup, ut_teardown,
10231 test_3DES_chain_dpaa2_sec_all),
10232 TEST_CASE_ST(ut_setup, ut_teardown,
10233 test_AES_cipheronly_dpaa2_sec_all),
10234 TEST_CASE_ST(ut_setup, ut_teardown,
10235 test_3DES_cipheronly_dpaa2_sec_all),
10236 TEST_CASE_ST(ut_setup, ut_teardown,
10237 test_authonly_dpaa2_sec_all),
10239 /** AES GCM Authenticated Encryption */
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 test_AES_GCM_authenticated_encryption_test_case_1),
10242 TEST_CASE_ST(ut_setup, ut_teardown,
10243 test_AES_GCM_authenticated_encryption_test_case_2),
10244 TEST_CASE_ST(ut_setup, ut_teardown,
10245 test_AES_GCM_authenticated_encryption_test_case_3),
10246 TEST_CASE_ST(ut_setup, ut_teardown,
10247 test_AES_GCM_authenticated_encryption_test_case_4),
10248 TEST_CASE_ST(ut_setup, ut_teardown,
10249 test_AES_GCM_authenticated_encryption_test_case_5),
10250 TEST_CASE_ST(ut_setup, ut_teardown,
10251 test_AES_GCM_authenticated_encryption_test_case_6),
10252 TEST_CASE_ST(ut_setup, ut_teardown,
10253 test_AES_GCM_authenticated_encryption_test_case_7),
10255 /** AES GCM Authenticated Decryption */
10256 TEST_CASE_ST(ut_setup, ut_teardown,
10257 test_AES_GCM_authenticated_decryption_test_case_1),
10258 TEST_CASE_ST(ut_setup, ut_teardown,
10259 test_AES_GCM_authenticated_decryption_test_case_2),
10260 TEST_CASE_ST(ut_setup, ut_teardown,
10261 test_AES_GCM_authenticated_decryption_test_case_3),
10262 TEST_CASE_ST(ut_setup, ut_teardown,
10263 test_AES_GCM_authenticated_decryption_test_case_4),
10264 TEST_CASE_ST(ut_setup, ut_teardown,
10265 test_AES_GCM_authenticated_decryption_test_case_5),
10266 TEST_CASE_ST(ut_setup, ut_teardown,
10267 test_AES_GCM_authenticated_decryption_test_case_6),
10268 TEST_CASE_ST(ut_setup, ut_teardown,
10269 test_AES_GCM_authenticated_decryption_test_case_7),
10271 /** AES GCM Authenticated Encryption 192 bits key */
10272 TEST_CASE_ST(ut_setup, ut_teardown,
10273 test_AES_GCM_auth_encryption_test_case_192_1),
10274 TEST_CASE_ST(ut_setup, ut_teardown,
10275 test_AES_GCM_auth_encryption_test_case_192_2),
10276 TEST_CASE_ST(ut_setup, ut_teardown,
10277 test_AES_GCM_auth_encryption_test_case_192_3),
10278 TEST_CASE_ST(ut_setup, ut_teardown,
10279 test_AES_GCM_auth_encryption_test_case_192_4),
10280 TEST_CASE_ST(ut_setup, ut_teardown,
10281 test_AES_GCM_auth_encryption_test_case_192_5),
10282 TEST_CASE_ST(ut_setup, ut_teardown,
10283 test_AES_GCM_auth_encryption_test_case_192_6),
10284 TEST_CASE_ST(ut_setup, ut_teardown,
10285 test_AES_GCM_auth_encryption_test_case_192_7),
10287 /** AES GCM Authenticated Decryption 192 bits key */
10288 TEST_CASE_ST(ut_setup, ut_teardown,
10289 test_AES_GCM_auth_decryption_test_case_192_1),
10290 TEST_CASE_ST(ut_setup, ut_teardown,
10291 test_AES_GCM_auth_decryption_test_case_192_2),
10292 TEST_CASE_ST(ut_setup, ut_teardown,
10293 test_AES_GCM_auth_decryption_test_case_192_3),
10294 TEST_CASE_ST(ut_setup, ut_teardown,
10295 test_AES_GCM_auth_decryption_test_case_192_4),
10296 TEST_CASE_ST(ut_setup, ut_teardown,
10297 test_AES_GCM_auth_decryption_test_case_192_5),
10298 TEST_CASE_ST(ut_setup, ut_teardown,
10299 test_AES_GCM_auth_decryption_test_case_192_6),
10300 TEST_CASE_ST(ut_setup, ut_teardown,
10301 test_AES_GCM_auth_decryption_test_case_192_7),
10303 /** AES GCM Authenticated Encryption 256 bits key */
10304 TEST_CASE_ST(ut_setup, ut_teardown,
10305 test_AES_GCM_auth_encryption_test_case_256_1),
10306 TEST_CASE_ST(ut_setup, ut_teardown,
10307 test_AES_GCM_auth_encryption_test_case_256_2),
10308 TEST_CASE_ST(ut_setup, ut_teardown,
10309 test_AES_GCM_auth_encryption_test_case_256_3),
10310 TEST_CASE_ST(ut_setup, ut_teardown,
10311 test_AES_GCM_auth_encryption_test_case_256_4),
10312 TEST_CASE_ST(ut_setup, ut_teardown,
10313 test_AES_GCM_auth_encryption_test_case_256_5),
10314 TEST_CASE_ST(ut_setup, ut_teardown,
10315 test_AES_GCM_auth_encryption_test_case_256_6),
10316 TEST_CASE_ST(ut_setup, ut_teardown,
10317 test_AES_GCM_auth_encryption_test_case_256_7),
10319 /** AES GCM Authenticated Decryption 256 bits key */
10320 TEST_CASE_ST(ut_setup, ut_teardown,
10321 test_AES_GCM_auth_decryption_test_case_256_1),
10322 TEST_CASE_ST(ut_setup, ut_teardown,
10323 test_AES_GCM_auth_decryption_test_case_256_2),
10324 TEST_CASE_ST(ut_setup, ut_teardown,
10325 test_AES_GCM_auth_decryption_test_case_256_3),
10326 TEST_CASE_ST(ut_setup, ut_teardown,
10327 test_AES_GCM_auth_decryption_test_case_256_4),
10328 TEST_CASE_ST(ut_setup, ut_teardown,
10329 test_AES_GCM_auth_decryption_test_case_256_5),
10330 TEST_CASE_ST(ut_setup, ut_teardown,
10331 test_AES_GCM_auth_decryption_test_case_256_6),
10332 TEST_CASE_ST(ut_setup, ut_teardown,
10333 test_AES_GCM_auth_decryption_test_case_256_7),
10335 /** Out of place tests */
10336 TEST_CASE_ST(ut_setup, ut_teardown,
10337 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10338 TEST_CASE_ST(ut_setup, ut_teardown,
10339 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10341 /** Scatter-Gather */
10342 TEST_CASE_ST(ut_setup, ut_teardown,
10343 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10344 TEST_CASE_ST(ut_setup, ut_teardown,
10345 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10346 TEST_CASE_ST(ut_setup, ut_teardown,
10347 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10348 TEST_CASE_ST(ut_setup, ut_teardown,
10349 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10351 TEST_CASES_END() /**< NULL terminate unit test array */
10355 static struct unit_test_suite cryptodev_null_testsuite = {
10356 .suite_name = "Crypto Device NULL Unit Test Suite",
10357 .setup = testsuite_setup,
10358 .teardown = testsuite_teardown,
10359 .unit_test_cases = {
10360 TEST_CASE_ST(ut_setup, ut_teardown,
10361 test_null_invalid_operation),
10362 TEST_CASE_ST(ut_setup, ut_teardown,
10363 test_null_burst_operation),
10364 TEST_CASE_ST(ut_setup, ut_teardown,
10365 test_AES_chain_null_all),
10366 TEST_CASE_ST(ut_setup, ut_teardown,
10367 test_AES_cipheronly_null_all),
10368 TEST_CASE_ST(ut_setup, ut_teardown,
10369 test_authonly_null_all),
10371 TEST_CASES_END() /**< NULL terminate unit test array */
10375 static struct unit_test_suite cryptodev_armv8_testsuite = {
10376 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10377 .setup = testsuite_setup,
10378 .teardown = testsuite_teardown,
10379 .unit_test_cases = {
10380 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10382 /** Negative tests */
10383 TEST_CASE_ST(ut_setup, ut_teardown,
10384 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10388 TEST_CASES_END() /**< NULL terminate unit test array */
10392 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10393 .suite_name = "Crypto Device Marvell Component Test Suite",
10394 .setup = testsuite_setup,
10395 .teardown = testsuite_teardown,
10396 .unit_test_cases = {
10397 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10398 TEST_CASE_ST(ut_setup, ut_teardown,
10399 test_multi_session_random_usage),
10400 TEST_CASE_ST(ut_setup, ut_teardown,
10401 test_AES_chain_mrvl_all),
10402 TEST_CASE_ST(ut_setup, ut_teardown,
10403 test_AES_cipheronly_mrvl_all),
10404 TEST_CASE_ST(ut_setup, ut_teardown,
10405 test_authonly_mrvl_all),
10406 TEST_CASE_ST(ut_setup, ut_teardown,
10407 test_3DES_chain_mrvl_all),
10408 TEST_CASE_ST(ut_setup, ut_teardown,
10409 test_3DES_cipheronly_mrvl_all),
10411 /** Negative tests */
10412 TEST_CASE_ST(ut_setup, ut_teardown,
10413 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10414 TEST_CASE_ST(ut_setup, ut_teardown,
10415 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10416 TEST_CASE_ST(ut_setup, ut_teardown,
10417 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10418 TEST_CASE_ST(ut_setup, ut_teardown,
10419 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10421 TEST_CASES_END() /**< NULL terminate unit test array */
10425 static struct unit_test_suite cryptodev_ccp_testsuite = {
10426 .suite_name = "Crypto Device CCP Unit Test Suite",
10427 .setup = testsuite_setup,
10428 .teardown = testsuite_teardown,
10429 .unit_test_cases = {
10430 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10431 TEST_CASE_ST(ut_setup, ut_teardown,
10432 test_multi_session_random_usage),
10433 TEST_CASE_ST(ut_setup, ut_teardown,
10434 test_AES_chain_ccp_all),
10435 TEST_CASE_ST(ut_setup, ut_teardown,
10436 test_AES_cipheronly_ccp_all),
10437 TEST_CASE_ST(ut_setup, ut_teardown,
10438 test_3DES_chain_ccp_all),
10439 TEST_CASE_ST(ut_setup, ut_teardown,
10440 test_3DES_cipheronly_ccp_all),
10441 TEST_CASE_ST(ut_setup, ut_teardown,
10442 test_authonly_ccp_all),
10444 /** Negative tests */
10445 TEST_CASE_ST(ut_setup, ut_teardown,
10446 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10447 TEST_CASE_ST(ut_setup, ut_teardown,
10448 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10449 TEST_CASE_ST(ut_setup, ut_teardown,
10450 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10451 TEST_CASE_ST(ut_setup, ut_teardown,
10452 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10454 TEST_CASES_END() /**< NULL terminate unit test array */
10458 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10459 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10460 .setup = testsuite_setup,
10461 .teardown = testsuite_teardown,
10462 .unit_test_cases = {
10463 TEST_CASE_ST(ut_setup, ut_teardown,
10464 test_AES_chain_octeontx_all),
10465 TEST_CASE_ST(ut_setup, ut_teardown,
10466 test_AES_cipheronly_octeontx_all),
10467 TEST_CASE_ST(ut_setup, ut_teardown,
10468 test_3DES_chain_octeontx_all),
10469 TEST_CASE_ST(ut_setup, ut_teardown,
10470 test_3DES_cipheronly_octeontx_all),
10471 TEST_CASE_ST(ut_setup, ut_teardown,
10472 test_authonly_octeontx_all),
10474 /** AES GCM Authenticated Encryption */
10475 TEST_CASE_ST(ut_setup, ut_teardown,
10476 test_AES_GCM_authenticated_encryption_test_case_1),
10477 TEST_CASE_ST(ut_setup, ut_teardown,
10478 test_AES_GCM_authenticated_encryption_test_case_2),
10479 TEST_CASE_ST(ut_setup, ut_teardown,
10480 test_AES_GCM_authenticated_encryption_test_case_3),
10481 TEST_CASE_ST(ut_setup, ut_teardown,
10482 test_AES_GCM_authenticated_encryption_test_case_4),
10483 TEST_CASE_ST(ut_setup, ut_teardown,
10484 test_AES_GCM_authenticated_encryption_test_case_5),
10485 TEST_CASE_ST(ut_setup, ut_teardown,
10486 test_AES_GCM_authenticated_encryption_test_case_6),
10487 TEST_CASE_ST(ut_setup, ut_teardown,
10488 test_AES_GCM_authenticated_encryption_test_case_7),
10490 /** AES GCM Authenticated Decryption */
10491 TEST_CASE_ST(ut_setup, ut_teardown,
10492 test_AES_GCM_authenticated_decryption_test_case_1),
10493 TEST_CASE_ST(ut_setup, ut_teardown,
10494 test_AES_GCM_authenticated_decryption_test_case_2),
10495 TEST_CASE_ST(ut_setup, ut_teardown,
10496 test_AES_GCM_authenticated_decryption_test_case_3),
10497 TEST_CASE_ST(ut_setup, ut_teardown,
10498 test_AES_GCM_authenticated_decryption_test_case_4),
10499 TEST_CASE_ST(ut_setup, ut_teardown,
10500 test_AES_GCM_authenticated_decryption_test_case_5),
10501 TEST_CASE_ST(ut_setup, ut_teardown,
10502 test_AES_GCM_authenticated_decryption_test_case_6),
10503 TEST_CASE_ST(ut_setup, ut_teardown,
10504 test_AES_GCM_authenticated_decryption_test_case_7),
10505 /** AES GMAC Authentication */
10506 TEST_CASE_ST(ut_setup, ut_teardown,
10507 test_AES_GMAC_authentication_test_case_1),
10508 TEST_CASE_ST(ut_setup, ut_teardown,
10509 test_AES_GMAC_authentication_verify_test_case_1),
10510 TEST_CASE_ST(ut_setup, ut_teardown,
10511 test_AES_GMAC_authentication_test_case_2),
10512 TEST_CASE_ST(ut_setup, ut_teardown,
10513 test_AES_GMAC_authentication_verify_test_case_2),
10514 TEST_CASE_ST(ut_setup, ut_teardown,
10515 test_AES_GMAC_authentication_test_case_3),
10516 TEST_CASE_ST(ut_setup, ut_teardown,
10517 test_AES_GMAC_authentication_verify_test_case_3),
10519 /** SNOW 3G encrypt only (UEA2) */
10520 TEST_CASE_ST(ut_setup, ut_teardown,
10521 test_snow3g_encryption_test_case_1),
10522 TEST_CASE_ST(ut_setup, ut_teardown,
10523 test_snow3g_encryption_test_case_2),
10524 TEST_CASE_ST(ut_setup, ut_teardown,
10525 test_snow3g_encryption_test_case_3),
10526 TEST_CASE_ST(ut_setup, ut_teardown,
10527 test_snow3g_encryption_test_case_4),
10528 TEST_CASE_ST(ut_setup, ut_teardown,
10529 test_snow3g_encryption_test_case_5),
10531 TEST_CASE_ST(ut_setup, ut_teardown,
10532 test_snow3g_encryption_test_case_1_oop),
10533 TEST_CASE_ST(ut_setup, ut_teardown,
10534 test_snow3g_decryption_test_case_1_oop),
10535 TEST_CASE_ST(ut_setup, ut_teardown,
10536 test_snow3g_encryption_test_case_1_oop_sgl),
10538 /** SNOW 3G decrypt only (UEA2) */
10539 TEST_CASE_ST(ut_setup, ut_teardown,
10540 test_snow3g_decryption_test_case_1),
10541 TEST_CASE_ST(ut_setup, ut_teardown,
10542 test_snow3g_decryption_test_case_2),
10543 TEST_CASE_ST(ut_setup, ut_teardown,
10544 test_snow3g_decryption_test_case_3),
10545 TEST_CASE_ST(ut_setup, ut_teardown,
10546 test_snow3g_decryption_test_case_4),
10547 TEST_CASE_ST(ut_setup, ut_teardown,
10548 test_snow3g_decryption_test_case_5),
10550 TEST_CASE_ST(ut_setup, ut_teardown,
10551 test_snow3g_hash_generate_test_case_1),
10552 TEST_CASE_ST(ut_setup, ut_teardown,
10553 test_snow3g_hash_generate_test_case_2),
10554 TEST_CASE_ST(ut_setup, ut_teardown,
10555 test_snow3g_hash_generate_test_case_3),
10556 TEST_CASE_ST(ut_setup, ut_teardown,
10557 test_snow3g_hash_verify_test_case_1),
10558 TEST_CASE_ST(ut_setup, ut_teardown,
10559 test_snow3g_hash_verify_test_case_2),
10560 TEST_CASE_ST(ut_setup, ut_teardown,
10561 test_snow3g_hash_verify_test_case_3),
10563 /** ZUC encrypt only (EEA3) */
10564 TEST_CASE_ST(ut_setup, ut_teardown,
10565 test_zuc_encryption_test_case_1),
10566 TEST_CASE_ST(ut_setup, ut_teardown,
10567 test_zuc_encryption_test_case_2),
10568 TEST_CASE_ST(ut_setup, ut_teardown,
10569 test_zuc_encryption_test_case_3),
10570 TEST_CASE_ST(ut_setup, ut_teardown,
10571 test_zuc_encryption_test_case_4),
10572 TEST_CASE_ST(ut_setup, ut_teardown,
10573 test_zuc_encryption_test_case_5),
10574 TEST_CASE_ST(ut_setup, ut_teardown,
10575 test_zuc_hash_generate_test_case_1),
10576 TEST_CASE_ST(ut_setup, ut_teardown,
10577 test_zuc_hash_generate_test_case_2),
10578 TEST_CASE_ST(ut_setup, ut_teardown,
10579 test_zuc_hash_generate_test_case_3),
10580 TEST_CASE_ST(ut_setup, ut_teardown,
10581 test_zuc_hash_generate_test_case_4),
10582 TEST_CASE_ST(ut_setup, ut_teardown,
10583 test_zuc_hash_generate_test_case_5),
10584 TEST_CASE_ST(ut_setup, ut_teardown,
10585 test_zuc_encryption_test_case_6_sgl),
10587 /** KASUMI encrypt only (UEA1) */
10588 TEST_CASE_ST(ut_setup, ut_teardown,
10589 test_kasumi_encryption_test_case_1),
10590 TEST_CASE_ST(ut_setup, ut_teardown,
10591 test_kasumi_encryption_test_case_2),
10592 TEST_CASE_ST(ut_setup, ut_teardown,
10593 test_kasumi_encryption_test_case_3),
10594 TEST_CASE_ST(ut_setup, ut_teardown,
10595 test_kasumi_encryption_test_case_4),
10596 TEST_CASE_ST(ut_setup, ut_teardown,
10597 test_kasumi_encryption_test_case_5),
10598 TEST_CASE_ST(ut_setup, ut_teardown,
10599 test_kasumi_encryption_test_case_1_sgl),
10600 TEST_CASE_ST(ut_setup, ut_teardown,
10601 test_kasumi_encryption_test_case_1_oop_sgl),
10602 /** KASUMI decrypt only (UEA1) */
10603 TEST_CASE_ST(ut_setup, ut_teardown,
10604 test_kasumi_decryption_test_case_1),
10605 TEST_CASE_ST(ut_setup, ut_teardown,
10606 test_kasumi_decryption_test_case_2),
10607 TEST_CASE_ST(ut_setup, ut_teardown,
10608 test_kasumi_decryption_test_case_3),
10609 TEST_CASE_ST(ut_setup, ut_teardown,
10610 test_kasumi_decryption_test_case_4),
10611 TEST_CASE_ST(ut_setup, ut_teardown,
10612 test_kasumi_decryption_test_case_5),
10614 TEST_CASE_ST(ut_setup, ut_teardown,
10615 test_kasumi_encryption_test_case_1_oop),
10616 TEST_CASE_ST(ut_setup, ut_teardown,
10617 test_kasumi_decryption_test_case_1_oop),
10619 /** KASUMI hash only (UIA1) */
10620 TEST_CASE_ST(ut_setup, ut_teardown,
10621 test_kasumi_hash_generate_test_case_1),
10622 TEST_CASE_ST(ut_setup, ut_teardown,
10623 test_kasumi_hash_generate_test_case_2),
10624 TEST_CASE_ST(ut_setup, ut_teardown,
10625 test_kasumi_hash_generate_test_case_3),
10626 TEST_CASE_ST(ut_setup, ut_teardown,
10627 test_kasumi_hash_generate_test_case_4),
10628 TEST_CASE_ST(ut_setup, ut_teardown,
10629 test_kasumi_hash_generate_test_case_5),
10630 TEST_CASE_ST(ut_setup, ut_teardown,
10631 test_kasumi_hash_generate_test_case_6),
10632 TEST_CASE_ST(ut_setup, ut_teardown,
10633 test_kasumi_hash_verify_test_case_1),
10634 TEST_CASE_ST(ut_setup, ut_teardown,
10635 test_kasumi_hash_verify_test_case_2),
10636 TEST_CASE_ST(ut_setup, ut_teardown,
10637 test_kasumi_hash_verify_test_case_3),
10638 TEST_CASE_ST(ut_setup, ut_teardown,
10639 test_kasumi_hash_verify_test_case_4),
10640 TEST_CASE_ST(ut_setup, ut_teardown,
10641 test_kasumi_hash_verify_test_case_5),
10644 TEST_CASE_ST(ut_setup, ut_teardown,
10645 test_null_cipher_only_operation),
10646 TEST_CASE_ST(ut_setup, ut_teardown,
10647 test_null_auth_only_operation),
10648 TEST_CASE_ST(ut_setup, ut_teardown,
10649 test_null_cipher_auth_operation),
10650 TEST_CASE_ST(ut_setup, ut_teardown,
10651 test_null_auth_cipher_operation),
10653 /** Negative tests */
10654 TEST_CASE_ST(ut_setup, ut_teardown,
10655 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10656 TEST_CASE_ST(ut_setup, ut_teardown,
10657 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10658 TEST_CASE_ST(ut_setup, ut_teardown,
10659 authentication_verify_AES128_GMAC_fail_data_corrupt),
10660 TEST_CASE_ST(ut_setup, ut_teardown,
10661 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10662 TEST_CASE_ST(ut_setup, ut_teardown,
10663 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10664 TEST_CASE_ST(ut_setup, ut_teardown,
10665 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10666 TEST_CASES_END() /**< NULL terminate unit test array */
10671 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10673 gbl_driver_id = rte_cryptodev_driver_id_get(
10674 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10676 if (gbl_driver_id == -1) {
10677 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10678 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10679 "are enabled in config file to run this testsuite.\n");
10680 return TEST_SKIPPED;
10683 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10687 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10689 gbl_driver_id = rte_cryptodev_driver_id_get(
10690 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10692 if (gbl_driver_id == -1) {
10693 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10694 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10695 "in config file to run this testsuite.\n");
10696 return TEST_FAILED;
10699 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10703 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10705 gbl_driver_id = rte_cryptodev_driver_id_get(
10706 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10708 if (gbl_driver_id == -1) {
10709 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10710 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10711 "in config file to run this testsuite.\n");
10712 return TEST_SKIPPED;
10715 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10719 test_cryptodev_openssl(void)
10721 gbl_driver_id = rte_cryptodev_driver_id_get(
10722 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10724 if (gbl_driver_id == -1) {
10725 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10726 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10727 "in config file to run this testsuite.\n");
10728 return TEST_SKIPPED;
10731 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10735 test_cryptodev_aesni_gcm(void)
10737 gbl_driver_id = rte_cryptodev_driver_id_get(
10738 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10740 if (gbl_driver_id == -1) {
10741 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10742 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10743 "in config file to run this testsuite.\n");
10744 return TEST_SKIPPED;
10747 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10751 test_cryptodev_null(void)
10753 gbl_driver_id = rte_cryptodev_driver_id_get(
10754 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10756 if (gbl_driver_id == -1) {
10757 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10758 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10759 "in config file to run this testsuite.\n");
10760 return TEST_SKIPPED;
10763 return unit_test_suite_runner(&cryptodev_null_testsuite);
10767 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10769 gbl_driver_id = rte_cryptodev_driver_id_get(
10770 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10772 if (gbl_driver_id == -1) {
10773 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10774 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10775 "in config file to run this testsuite.\n");
10776 return TEST_SKIPPED;
10779 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10783 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10785 gbl_driver_id = rte_cryptodev_driver_id_get(
10786 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10788 if (gbl_driver_id == -1) {
10789 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10790 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10791 "in config file to run this testsuite.\n");
10792 return TEST_SKIPPED;
10795 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10799 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10801 gbl_driver_id = rte_cryptodev_driver_id_get(
10802 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10804 if (gbl_driver_id == -1) {
10805 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10806 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10807 "in config file to run this testsuite.\n");
10808 return TEST_SKIPPED;
10811 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10815 test_cryptodev_armv8(void)
10817 gbl_driver_id = rte_cryptodev_driver_id_get(
10818 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10820 if (gbl_driver_id == -1) {
10821 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10822 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10823 "in config file to run this testsuite.\n");
10824 return TEST_SKIPPED;
10827 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10831 test_cryptodev_mrvl(void)
10833 gbl_driver_id = rte_cryptodev_driver_id_get(
10834 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10836 if (gbl_driver_id == -1) {
10837 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10838 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10839 "in config file to run this testsuite.\n");
10840 return TEST_SKIPPED;
10843 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10846 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10849 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10851 gbl_driver_id = rte_cryptodev_driver_id_get(
10852 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10854 if (gbl_driver_id == -1) {
10855 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10856 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10857 "in config file to run this testsuite.\n");
10858 return TEST_SKIPPED;
10861 if (rte_cryptodev_driver_id_get(
10862 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10863 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10864 " enabled in config file to run this testsuite.\n");
10865 return TEST_SKIPPED;
10867 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10870 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10875 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10877 gbl_driver_id = rte_cryptodev_driver_id_get(
10878 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10880 if (gbl_driver_id == -1) {
10881 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10882 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10883 "in config file to run this testsuite.\n");
10884 return TEST_SKIPPED;
10887 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10891 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10893 gbl_driver_id = rte_cryptodev_driver_id_get(
10894 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10896 if (gbl_driver_id == -1) {
10897 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10898 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10899 "in config file to run this testsuite.\n");
10900 return TEST_SKIPPED;
10903 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10907 test_cryptodev_ccp(void)
10909 gbl_driver_id = rte_cryptodev_driver_id_get(
10910 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10912 if (gbl_driver_id == -1) {
10913 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10914 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10915 "in config file to run this testsuite.\n");
10916 return TEST_FAILED;
10919 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10923 test_cryptodev_octeontx(void)
10925 gbl_driver_id = rte_cryptodev_driver_id_get(
10926 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10927 if (gbl_driver_id == -1) {
10928 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10929 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10930 "enabled in config file to run this "
10932 return TEST_FAILED;
10934 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10938 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10940 gbl_driver_id = rte_cryptodev_driver_id_get(
10941 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10943 if (gbl_driver_id == -1) {
10944 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10945 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10946 "in config file to run this testsuite.\n");
10947 return TEST_FAILED;
10950 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10953 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10954 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10955 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10956 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10957 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10958 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10959 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10960 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10961 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10962 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10963 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10964 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10965 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10966 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10967 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10968 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);