1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2019 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
46 #define OUT_OF_PLACE 1
48 static int gbl_driver_id;
50 struct crypto_testsuite_params {
51 struct rte_mempool *mbuf_pool;
52 struct rte_mempool *large_mbuf_pool;
53 struct rte_mempool *op_mpool;
54 struct rte_mempool *session_mpool;
55 struct rte_mempool *session_priv_mpool;
56 struct rte_cryptodev_config conf;
57 struct rte_cryptodev_qp_conf qp_conf;
59 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
60 uint8_t valid_dev_count;
63 struct crypto_unittest_params {
64 struct rte_crypto_sym_xform cipher_xform;
65 struct rte_crypto_sym_xform auth_xform;
66 struct rte_crypto_sym_xform aead_xform;
68 struct rte_cryptodev_sym_session *sess;
70 struct rte_crypto_op *op;
72 struct rte_mbuf *obuf, *ibuf;
77 #define ALIGN_POW2_ROUNDUP(num, align) \
78 (((num) + (align) - 1) & ~((align) - 1))
81 * Forward declarations.
84 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
85 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
89 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
90 struct crypto_unittest_params *ut_params,
91 struct crypto_testsuite_params *ts_param,
92 const uint8_t *cipher,
93 const uint8_t *digest,
96 static struct rte_mbuf *
97 setup_test_string(struct rte_mempool *mpool,
98 const char *string, size_t len, uint8_t blocksize)
100 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
101 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
103 memset(m->buf_addr, 0, m->buf_len);
105 char *dst = rte_pktmbuf_append(m, t_len);
112 rte_memcpy(dst, string, t_len);
114 memset(dst, 0, t_len);
120 /* Get number of bytes in X bits (rounding up) */
122 ceil_byte_length(uint32_t num_bits)
125 return ((num_bits >> 3) + 1);
127 return (num_bits >> 3);
130 static struct rte_crypto_op *
131 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
133 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
134 printf("Error sending packet for encryption");
140 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
146 static struct crypto_testsuite_params testsuite_params = { NULL };
147 static struct crypto_unittest_params unittest_params;
150 testsuite_setup(void)
152 struct crypto_testsuite_params *ts_params = &testsuite_params;
153 struct rte_cryptodev_info info;
154 uint32_t i = 0, nb_devs, dev_id;
158 memset(ts_params, 0, sizeof(*ts_params));
160 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
161 if (ts_params->mbuf_pool == NULL) {
162 /* Not already created so create */
163 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
165 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
167 if (ts_params->mbuf_pool == NULL) {
168 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
173 ts_params->large_mbuf_pool = rte_mempool_lookup(
174 "CRYPTO_LARGE_MBUFPOOL");
175 if (ts_params->large_mbuf_pool == NULL) {
176 /* Not already created so create */
177 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
178 "CRYPTO_LARGE_MBUFPOOL",
181 if (ts_params->large_mbuf_pool == NULL) {
183 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
188 ts_params->op_mpool = rte_crypto_op_pool_create(
189 "MBUF_CRYPTO_SYM_OP_POOL",
190 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
191 NUM_MBUFS, MBUF_CACHE_SIZE,
193 sizeof(struct rte_crypto_sym_xform) +
196 if (ts_params->op_mpool == NULL) {
197 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
201 /* Create an AESNI MB device if required */
202 if (gbl_driver_id == rte_cryptodev_driver_id_get(
203 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
204 nb_devs = rte_cryptodev_device_count_by_driver(
205 rte_cryptodev_driver_id_get(
206 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
209 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
211 TEST_ASSERT(ret == 0,
212 "Failed to create instance of"
214 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
218 /* Create an AESNI GCM device if required */
219 if (gbl_driver_id == rte_cryptodev_driver_id_get(
220 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
221 nb_devs = rte_cryptodev_device_count_by_driver(
222 rte_cryptodev_driver_id_get(
223 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
225 TEST_ASSERT_SUCCESS(rte_vdev_init(
226 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
227 "Failed to create instance of"
229 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
233 /* Create a SNOW 3G device if required */
234 if (gbl_driver_id == rte_cryptodev_driver_id_get(
235 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
236 nb_devs = rte_cryptodev_device_count_by_driver(
237 rte_cryptodev_driver_id_get(
238 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
240 TEST_ASSERT_SUCCESS(rte_vdev_init(
241 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
242 "Failed to create instance of"
244 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
248 /* Create a KASUMI device if required */
249 if (gbl_driver_id == rte_cryptodev_driver_id_get(
250 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
251 nb_devs = rte_cryptodev_device_count_by_driver(
252 rte_cryptodev_driver_id_get(
253 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
255 TEST_ASSERT_SUCCESS(rte_vdev_init(
256 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
257 "Failed to create instance of"
259 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
263 /* Create a ZUC device if required */
264 if (gbl_driver_id == rte_cryptodev_driver_id_get(
265 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
266 nb_devs = rte_cryptodev_device_count_by_driver(
267 rte_cryptodev_driver_id_get(
268 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
270 TEST_ASSERT_SUCCESS(rte_vdev_init(
271 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
272 "Failed to create instance of"
274 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
278 /* Create a NULL device if required */
279 if (gbl_driver_id == rte_cryptodev_driver_id_get(
280 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
281 nb_devs = rte_cryptodev_device_count_by_driver(
282 rte_cryptodev_driver_id_get(
283 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
286 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
288 TEST_ASSERT(ret == 0,
289 "Failed to create instance of"
291 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
295 /* Create an OPENSSL device if required */
296 if (gbl_driver_id == rte_cryptodev_driver_id_get(
297 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
298 nb_devs = rte_cryptodev_device_count_by_driver(
299 rte_cryptodev_driver_id_get(
300 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
303 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
306 TEST_ASSERT(ret == 0, "Failed to create "
307 "instance of pmd : %s",
308 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
312 /* Create a ARMv8 device if required */
313 if (gbl_driver_id == rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
315 nb_devs = rte_cryptodev_device_count_by_driver(
316 rte_cryptodev_driver_id_get(
317 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
320 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
323 TEST_ASSERT(ret == 0, "Failed to create "
324 "instance of pmd : %s",
325 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
329 /* Create a MVSAM device if required */
330 if (gbl_driver_id == rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
332 nb_devs = rte_cryptodev_device_count_by_driver(
333 rte_cryptodev_driver_id_get(
334 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
337 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
340 TEST_ASSERT(ret == 0, "Failed to create "
341 "instance of pmd : %s",
342 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
346 /* Create an CCP device if required */
347 if (gbl_driver_id == rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
349 nb_devs = rte_cryptodev_device_count_by_driver(
350 rte_cryptodev_driver_id_get(
351 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
354 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
363 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
364 char vdev_args[VDEV_ARGS_SIZE] = {""};
365 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
366 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
367 uint16_t slave_core_count = 0;
368 uint16_t socket_id = 0;
370 if (gbl_driver_id == rte_cryptodev_driver_id_get(
371 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
373 /* Identify the Slave Cores
374 * Use 2 slave cores for the device args
376 RTE_LCORE_FOREACH_SLAVE(i) {
377 if (slave_core_count > 1)
379 snprintf(vdev_args, sizeof(vdev_args),
380 "%s%d", temp_str, i);
381 strcpy(temp_str, vdev_args);
382 strlcat(temp_str, ";", sizeof(temp_str));
384 socket_id = rte_lcore_to_socket_id(i);
386 if (slave_core_count != 2) {
388 "Cryptodev scheduler test require at least "
389 "two slave cores to run. "
390 "Please use the correct coremask.\n");
393 strcpy(temp_str, vdev_args);
394 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
395 temp_str, socket_id);
396 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
397 nb_devs = rte_cryptodev_device_count_by_driver(
398 rte_cryptodev_driver_id_get(
399 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
402 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
404 TEST_ASSERT(ret == 0,
405 "Failed to create instance %u of"
407 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
410 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
412 nb_devs = rte_cryptodev_count();
414 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
418 /* Create list of valid crypto devs */
419 for (i = 0; i < nb_devs; i++) {
420 rte_cryptodev_info_get(i, &info);
421 if (info.driver_id == gbl_driver_id)
422 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
425 if (ts_params->valid_dev_count < 1)
428 /* Set up all the qps on the first of the valid devices found */
430 dev_id = ts_params->valid_devs[0];
432 rte_cryptodev_info_get(dev_id, &info);
434 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
435 ts_params->conf.socket_id = SOCKET_ID_ANY;
436 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
438 unsigned int session_size =
439 rte_cryptodev_sym_get_private_session_size(dev_id);
442 * Create mempool with maximum number of sessions * 2,
443 * to include the session headers
445 if (info.sym.max_nb_sessions != 0 &&
446 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
447 RTE_LOG(ERR, USER1, "Device does not support "
448 "at least %u sessions\n",
453 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
454 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
456 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
457 "session mempool allocation failed");
459 ts_params->session_priv_mpool = rte_mempool_create(
463 0, 0, NULL, NULL, NULL,
466 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
467 "session mempool allocation failed");
471 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
473 "Failed to configure cryptodev %u with %u qps",
474 dev_id, ts_params->conf.nb_queue_pairs);
476 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
477 ts_params->qp_conf.mp_session = ts_params->session_mpool;
478 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
480 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
481 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
482 dev_id, qp_id, &ts_params->qp_conf,
483 rte_cryptodev_socket_id(dev_id)),
484 "Failed to setup queue pair %u on cryptodev %u",
492 testsuite_teardown(void)
494 struct crypto_testsuite_params *ts_params = &testsuite_params;
496 if (ts_params->mbuf_pool != NULL) {
497 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
498 rte_mempool_avail_count(ts_params->mbuf_pool));
501 if (ts_params->op_mpool != NULL) {
502 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
503 rte_mempool_avail_count(ts_params->op_mpool));
506 /* Free session mempools */
507 if (ts_params->session_priv_mpool != NULL) {
508 rte_mempool_free(ts_params->session_priv_mpool);
509 ts_params->session_priv_mpool = NULL;
512 if (ts_params->session_mpool != NULL) {
513 rte_mempool_free(ts_params->session_mpool);
514 ts_params->session_mpool = NULL;
521 struct crypto_testsuite_params *ts_params = &testsuite_params;
522 struct crypto_unittest_params *ut_params = &unittest_params;
526 /* Clear unit test parameters before running test */
527 memset(ut_params, 0, sizeof(*ut_params));
529 /* Reconfigure device to default parameters */
530 ts_params->conf.socket_id = SOCKET_ID_ANY;
531 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
532 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
533 ts_params->qp_conf.mp_session = ts_params->session_mpool;
534 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
536 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
538 "Failed to configure cryptodev %u",
539 ts_params->valid_devs[0]);
541 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
542 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
543 ts_params->valid_devs[0], qp_id,
545 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
546 "Failed to setup queue pair %u on cryptodev %u",
547 qp_id, ts_params->valid_devs[0]);
551 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
553 /* Start the device */
554 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
555 "Failed to start cryptodev %u",
556 ts_params->valid_devs[0]);
564 struct crypto_testsuite_params *ts_params = &testsuite_params;
565 struct crypto_unittest_params *ut_params = &unittest_params;
566 struct rte_cryptodev_stats stats;
568 /* free crypto session structure */
569 if (ut_params->sess) {
570 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
572 rte_cryptodev_sym_session_free(ut_params->sess);
573 ut_params->sess = NULL;
576 /* free crypto operation structure */
578 rte_crypto_op_free(ut_params->op);
581 * free mbuf - both obuf and ibuf are usually the same,
582 * so check if they point at the same address is necessary,
583 * to avoid freeing the mbuf twice.
585 if (ut_params->obuf) {
586 rte_pktmbuf_free(ut_params->obuf);
587 if (ut_params->ibuf == ut_params->obuf)
591 if (ut_params->ibuf) {
592 rte_pktmbuf_free(ut_params->ibuf);
596 if (ts_params->mbuf_pool != NULL)
597 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
598 rte_mempool_avail_count(ts_params->mbuf_pool));
600 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
602 /* Stop the device */
603 rte_cryptodev_stop(ts_params->valid_devs[0]);
607 test_device_configure_invalid_dev_id(void)
609 struct crypto_testsuite_params *ts_params = &testsuite_params;
610 uint16_t dev_id, num_devs = 0;
612 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
613 "Need at least %d devices for test", 1);
615 /* valid dev_id values */
616 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
618 /* Stop the device in case it's started so it can be configured */
619 rte_cryptodev_stop(dev_id);
621 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
622 "Failed test for rte_cryptodev_configure: "
623 "invalid dev_num %u", dev_id);
625 /* invalid dev_id values */
628 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
629 "Failed test for rte_cryptodev_configure: "
630 "invalid dev_num %u", dev_id);
634 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
635 "Failed test for rte_cryptodev_configure:"
636 "invalid dev_num %u", dev_id);
642 test_device_configure_invalid_queue_pair_ids(void)
644 struct crypto_testsuite_params *ts_params = &testsuite_params;
645 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
647 /* Stop the device in case it's started so it can be configured */
648 rte_cryptodev_stop(ts_params->valid_devs[0]);
650 /* valid - one queue pairs */
651 ts_params->conf.nb_queue_pairs = 1;
653 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
655 "Failed to configure cryptodev: dev_id %u, qp_id %u",
656 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
659 /* valid - max value queue pairs */
660 ts_params->conf.nb_queue_pairs = orig_nb_qps;
662 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
664 "Failed to configure cryptodev: dev_id %u, qp_id %u",
665 ts_params->valid_devs[0],
666 ts_params->conf.nb_queue_pairs);
669 /* invalid - zero queue pairs */
670 ts_params->conf.nb_queue_pairs = 0;
672 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
674 "Failed test for rte_cryptodev_configure, dev_id %u,"
676 ts_params->valid_devs[0],
677 ts_params->conf.nb_queue_pairs);
680 /* invalid - max value supported by field queue pairs */
681 ts_params->conf.nb_queue_pairs = UINT16_MAX;
683 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
685 "Failed test for rte_cryptodev_configure, dev_id %u,"
687 ts_params->valid_devs[0],
688 ts_params->conf.nb_queue_pairs);
691 /* invalid - max value + 1 queue pairs */
692 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
694 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
696 "Failed test for rte_cryptodev_configure, dev_id %u,"
698 ts_params->valid_devs[0],
699 ts_params->conf.nb_queue_pairs);
701 /* revert to original testsuite value */
702 ts_params->conf.nb_queue_pairs = orig_nb_qps;
708 test_queue_pair_descriptor_setup(void)
710 struct crypto_testsuite_params *ts_params = &testsuite_params;
711 struct rte_cryptodev_info dev_info;
712 struct rte_cryptodev_qp_conf qp_conf = {
713 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
718 /* Stop the device in case it's started so it can be configured */
719 rte_cryptodev_stop(ts_params->valid_devs[0]);
722 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
724 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
726 "Failed to configure cryptodev %u",
727 ts_params->valid_devs[0]);
730 * Test various ring sizes on this device. memzones can't be
731 * freed so are re-used if ring is released and re-created.
733 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
734 qp_conf.mp_session = ts_params->session_mpool;
735 qp_conf.mp_session_private = ts_params->session_priv_mpool;
737 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
738 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
739 ts_params->valid_devs[0], qp_id, &qp_conf,
740 rte_cryptodev_socket_id(
741 ts_params->valid_devs[0])),
743 "rte_cryptodev_queue_pair_setup: num_inflights "
744 "%u on qp %u on cryptodev %u",
745 qp_conf.nb_descriptors, qp_id,
746 ts_params->valid_devs[0]);
749 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
751 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
752 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
753 ts_params->valid_devs[0], qp_id, &qp_conf,
754 rte_cryptodev_socket_id(
755 ts_params->valid_devs[0])),
757 " rte_cryptodev_queue_pair_setup: num_inflights"
758 " %u on qp %u on cryptodev %u",
759 qp_conf.nb_descriptors, qp_id,
760 ts_params->valid_devs[0]);
763 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
765 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
766 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
767 ts_params->valid_devs[0], qp_id, &qp_conf,
768 rte_cryptodev_socket_id(
769 ts_params->valid_devs[0])),
771 "rte_cryptodev_queue_pair_setup: num_inflights"
772 " %u on qp %u on cryptodev %u",
773 qp_conf.nb_descriptors, qp_id,
774 ts_params->valid_devs[0]);
777 /* invalid number of descriptors - max supported + 2 */
778 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
780 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
781 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
782 ts_params->valid_devs[0], qp_id, &qp_conf,
783 rte_cryptodev_socket_id(
784 ts_params->valid_devs[0])),
785 "Unexpectedly passed test for "
786 "rte_cryptodev_queue_pair_setup:"
787 "num_inflights %u on qp %u on cryptodev %u",
788 qp_conf.nb_descriptors, qp_id,
789 ts_params->valid_devs[0]);
792 /* invalid number of descriptors - max value of parameter */
793 qp_conf.nb_descriptors = UINT32_MAX-1;
795 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
796 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
797 ts_params->valid_devs[0], qp_id, &qp_conf,
798 rte_cryptodev_socket_id(
799 ts_params->valid_devs[0])),
800 "Unexpectedly passed test for "
801 "rte_cryptodev_queue_pair_setup:"
802 "num_inflights %u on qp %u on cryptodev %u",
803 qp_conf.nb_descriptors, qp_id,
804 ts_params->valid_devs[0]);
807 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
809 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
810 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
811 ts_params->valid_devs[0], qp_id, &qp_conf,
812 rte_cryptodev_socket_id(
813 ts_params->valid_devs[0])),
815 " rte_cryptodev_queue_pair_setup:"
816 "num_inflights %u on qp %u on cryptodev %u",
817 qp_conf.nb_descriptors, qp_id,
818 ts_params->valid_devs[0]);
821 /* invalid number of descriptors - max supported + 1 */
822 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
824 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
825 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
826 ts_params->valid_devs[0], qp_id, &qp_conf,
827 rte_cryptodev_socket_id(
828 ts_params->valid_devs[0])),
829 "Unexpectedly passed test for "
830 "rte_cryptodev_queue_pair_setup:"
831 "num_inflights %u on qp %u on cryptodev %u",
832 qp_conf.nb_descriptors, qp_id,
833 ts_params->valid_devs[0]);
836 /* test invalid queue pair id */
837 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
839 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
841 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
842 ts_params->valid_devs[0],
844 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
845 "Failed test for rte_cryptodev_queue_pair_setup:"
846 "invalid qp %u on cryptodev %u",
847 qp_id, ts_params->valid_devs[0]);
849 qp_id = 0xffff; /*invalid*/
851 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
852 ts_params->valid_devs[0],
854 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
855 "Failed test for rte_cryptodev_queue_pair_setup:"
856 "invalid qp %u on cryptodev %u",
857 qp_id, ts_params->valid_devs[0]);
862 /* ***** Plaintext data for tests ***** */
864 const char catch_22_quote_1[] =
865 "There was only one catch and that was Catch-22, which "
866 "specified that a concern for one's safety in the face of "
867 "dangers that were real and immediate was the process of a "
868 "rational mind. Orr was crazy and could be grounded. All he "
869 "had to do was ask; and as soon as he did, he would no longer "
870 "be crazy and would have to fly more missions. Orr would be "
871 "crazy to fly more missions and sane if he didn't, but if he "
872 "was sane he had to fly them. If he flew them he was crazy "
873 "and didn't have to; but if he didn't want to he was sane and "
874 "had to. Yossarian was moved very deeply by the absolute "
875 "simplicity of this clause of Catch-22 and let out a "
876 "respectful whistle. \"That's some catch, that Catch-22\", he "
877 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
879 const char catch_22_quote[] =
880 "What a lousy earth! He wondered how many people were "
881 "destitute that same night even in his own prosperous country, "
882 "how many homes were shanties, how many husbands were drunk "
883 "and wives socked, and how many children were bullied, abused, "
884 "or abandoned. How many families hungered for food they could "
885 "not afford to buy? How many hearts were broken? How many "
886 "suicides would take place that same night, how many people "
887 "would go insane? How many cockroaches and landlords would "
888 "triumph? How many winners were losers, successes failures, "
889 "and rich men poor men? How many wise guys were stupid? How "
890 "many happy endings were unhappy endings? How many honest men "
891 "were liars, brave men cowards, loyal men traitors, how many "
892 "sainted men were corrupt, how many people in positions of "
893 "trust had sold their souls to bodyguards, how many had never "
894 "had souls? How many straight-and-narrow paths were crooked "
895 "paths? How many best families were worst families and how "
896 "many good people were bad people? When you added them all up "
897 "and then subtracted, you might be left with only the children, "
898 "and perhaps with Albert Einstein and an old violinist or "
899 "sculptor somewhere.";
901 #define QUOTE_480_BYTES (480)
902 #define QUOTE_512_BYTES (512)
903 #define QUOTE_768_BYTES (768)
904 #define QUOTE_1024_BYTES (1024)
908 /* ***** SHA1 Hash Tests ***** */
910 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
912 static uint8_t hmac_sha1_key[] = {
913 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
914 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
915 0xDE, 0xF4, 0xDE, 0xAD };
917 /* ***** SHA224 Hash Tests ***** */
919 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
922 /* ***** AES-CBC Cipher Tests ***** */
924 #define CIPHER_KEY_LENGTH_AES_CBC (16)
925 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
927 static uint8_t aes_cbc_key[] = {
928 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
929 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
931 static uint8_t aes_cbc_iv[] = {
932 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
933 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
936 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
938 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
939 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
940 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
941 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
942 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
943 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
944 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
945 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
946 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
947 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
948 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
949 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
950 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
951 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
952 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
953 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
954 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
955 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
956 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
957 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
958 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
959 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
960 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
961 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
962 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
963 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
964 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
965 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
966 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
967 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
968 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
969 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
970 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
971 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
972 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
973 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
974 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
975 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
976 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
977 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
978 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
979 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
980 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
981 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
982 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
983 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
984 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
985 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
986 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
987 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
988 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
989 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
990 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
991 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
992 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
993 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
994 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
995 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
996 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
997 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
998 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
999 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1000 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1001 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1002 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1005 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1006 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1007 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1008 0x18, 0x8c, 0x1d, 0x32
1012 /* Multisession Vector context Test */
1013 /*Begin Session 0 */
1014 static uint8_t ms_aes_cbc_key0[] = {
1015 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1016 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1019 static uint8_t ms_aes_cbc_iv0[] = {
1020 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1021 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1024 static const uint8_t ms_aes_cbc_cipher0[] = {
1025 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1026 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1027 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1028 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1029 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1030 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1031 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1032 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1033 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1034 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1035 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1036 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1037 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1038 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1039 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1040 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1041 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1042 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1043 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1044 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1045 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1046 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1047 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1048 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1049 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1050 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1051 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1052 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1053 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1054 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1055 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1056 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1057 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1058 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1059 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1060 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1061 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1062 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1063 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1064 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1065 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1066 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1067 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1068 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1069 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1070 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1071 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1072 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1073 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1074 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1075 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1076 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1077 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1078 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1079 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1080 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1081 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1082 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1083 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1084 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1085 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1086 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1087 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1088 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1092 static uint8_t ms_hmac_key0[] = {
1093 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1094 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1095 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1096 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1097 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1098 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1099 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1100 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1103 static const uint8_t ms_hmac_digest0[] = {
1104 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1105 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1106 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1107 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1108 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1109 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1110 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1111 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1115 /* Begin session 1 */
1117 static uint8_t ms_aes_cbc_key1[] = {
1118 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1119 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1122 static uint8_t ms_aes_cbc_iv1[] = {
1123 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1124 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1127 static const uint8_t ms_aes_cbc_cipher1[] = {
1128 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1129 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1130 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1131 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1132 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1133 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1134 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1135 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1136 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1137 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1138 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1139 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1140 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1141 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1142 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1143 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1144 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1145 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1146 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1147 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1148 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1149 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1150 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1151 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1152 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1153 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1154 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1155 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1156 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1157 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1158 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1159 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1160 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1161 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1162 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1163 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1164 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1165 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1166 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1167 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1168 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1169 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1170 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1171 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1172 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1173 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1174 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1175 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1176 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1177 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1178 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1179 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1180 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1181 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1182 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1183 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1184 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1185 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1186 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1187 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1188 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1189 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1190 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1191 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1195 static uint8_t ms_hmac_key1[] = {
1196 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1197 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1198 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1199 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1200 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1201 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1202 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1203 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1206 static const uint8_t ms_hmac_digest1[] = {
1207 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1208 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1209 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1210 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1211 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1212 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1213 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1214 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1217 /* Begin Session 2 */
1218 static uint8_t ms_aes_cbc_key2[] = {
1219 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1220 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1223 static uint8_t ms_aes_cbc_iv2[] = {
1224 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1225 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1228 static const uint8_t ms_aes_cbc_cipher2[] = {
1229 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1230 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1231 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1232 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1233 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1234 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1235 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1236 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1237 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1238 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1239 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1240 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1241 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1242 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1243 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1244 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1245 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1246 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1247 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1248 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1249 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1250 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1251 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1252 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1253 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1254 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1255 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1256 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1257 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1258 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1259 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1260 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1261 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1262 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1263 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1264 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1265 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1266 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1267 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1268 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1269 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1270 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1271 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1272 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1273 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1274 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1275 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1276 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1277 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1278 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1279 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1280 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1281 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1282 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1283 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1284 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1285 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1286 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1287 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1288 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1289 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1290 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1291 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1292 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1295 static uint8_t ms_hmac_key2[] = {
1296 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1297 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1298 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1299 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1300 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1301 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1302 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1303 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1306 static const uint8_t ms_hmac_digest2[] = {
1307 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1308 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1309 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1310 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1311 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1312 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1313 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1314 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1321 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1323 struct crypto_testsuite_params *ts_params = &testsuite_params;
1324 struct crypto_unittest_params *ut_params = &unittest_params;
1326 /* Generate test mbuf data and space for digest */
1327 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1328 catch_22_quote, QUOTE_512_BYTES, 0);
1330 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1331 DIGEST_BYTE_LENGTH_SHA1);
1332 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1334 /* Setup Cipher Parameters */
1335 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1336 ut_params->cipher_xform.next = &ut_params->auth_xform;
1338 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1339 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1340 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1341 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1342 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1343 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1345 /* Setup HMAC Parameters */
1346 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1348 ut_params->auth_xform.next = NULL;
1350 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1351 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1352 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1353 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1354 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1356 ut_params->sess = rte_cryptodev_sym_session_create(
1357 ts_params->session_mpool);
1359 /* Create crypto session*/
1360 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1361 ut_params->sess, &ut_params->cipher_xform,
1362 ts_params->session_priv_mpool);
1363 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1365 /* Generate crypto op data structure */
1366 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1367 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1368 TEST_ASSERT_NOT_NULL(ut_params->op,
1369 "Failed to allocate symmetric crypto operation struct");
1371 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1373 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1375 /* set crypto operation source mbuf */
1376 sym_op->m_src = ut_params->ibuf;
1378 /* Set crypto operation authentication parameters */
1379 sym_op->auth.digest.data = ut_params->digest;
1380 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1381 ut_params->ibuf, QUOTE_512_BYTES);
1383 sym_op->auth.data.offset = 0;
1384 sym_op->auth.data.length = QUOTE_512_BYTES;
1386 /* Copy IV at the end of the crypto operation */
1387 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1388 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1390 /* Set crypto operation cipher parameters */
1391 sym_op->cipher.data.offset = 0;
1392 sym_op->cipher.data.length = QUOTE_512_BYTES;
1394 /* Process crypto operation */
1395 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1396 ut_params->op), "failed to process sym crypto op");
1398 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1399 "crypto op processing failed");
1402 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1405 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1406 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1408 "ciphertext data not as expected");
1410 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1412 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1413 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1414 gbl_driver_id == rte_cryptodev_driver_id_get(
1415 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1416 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1417 DIGEST_BYTE_LENGTH_SHA1,
1418 "Generated digest data not as expected");
1420 return TEST_SUCCESS;
1423 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1425 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1427 static uint8_t hmac_sha512_key[] = {
1428 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1429 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1430 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1431 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1432 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1433 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1434 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1435 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1437 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1438 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1439 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1440 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1441 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1442 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1443 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1444 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1445 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1450 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1451 struct crypto_unittest_params *ut_params,
1452 uint8_t *cipher_key,
1456 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1457 struct crypto_unittest_params *ut_params,
1458 struct crypto_testsuite_params *ts_params,
1459 const uint8_t *cipher,
1460 const uint8_t *digest,
1465 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1466 struct crypto_unittest_params *ut_params,
1467 uint8_t *cipher_key,
1471 /* Setup Cipher Parameters */
1472 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1473 ut_params->cipher_xform.next = NULL;
1475 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1476 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1477 ut_params->cipher_xform.cipher.key.data = cipher_key;
1478 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1479 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1480 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1482 /* Setup HMAC Parameters */
1483 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1484 ut_params->auth_xform.next = &ut_params->cipher_xform;
1486 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1487 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1488 ut_params->auth_xform.auth.key.data = hmac_key;
1489 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1490 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1492 return TEST_SUCCESS;
1497 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1498 struct crypto_unittest_params *ut_params,
1499 struct crypto_testsuite_params *ts_params,
1500 const uint8_t *cipher,
1501 const uint8_t *digest,
1504 /* Generate test mbuf data and digest */
1505 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1508 QUOTE_512_BYTES, 0);
1510 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1511 DIGEST_BYTE_LENGTH_SHA512);
1512 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1514 rte_memcpy(ut_params->digest,
1516 DIGEST_BYTE_LENGTH_SHA512);
1518 /* Generate Crypto op data structure */
1519 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1520 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1521 TEST_ASSERT_NOT_NULL(ut_params->op,
1522 "Failed to allocate symmetric crypto operation struct");
1524 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1526 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1528 /* set crypto operation source mbuf */
1529 sym_op->m_src = ut_params->ibuf;
1531 sym_op->auth.digest.data = ut_params->digest;
1532 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1533 ut_params->ibuf, QUOTE_512_BYTES);
1535 sym_op->auth.data.offset = 0;
1536 sym_op->auth.data.length = QUOTE_512_BYTES;
1538 /* Copy IV at the end of the crypto operation */
1539 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1540 iv, CIPHER_IV_LENGTH_AES_CBC);
1542 sym_op->cipher.data.offset = 0;
1543 sym_op->cipher.data.length = QUOTE_512_BYTES;
1545 /* Process crypto operation */
1546 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1547 ut_params->op), "failed to process sym crypto op");
1549 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1550 "crypto op processing failed");
1552 ut_params->obuf = ut_params->op->sym->m_src;
1555 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1556 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1559 "Plaintext data not as expected");
1562 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1563 "Digest verification failed");
1565 return TEST_SUCCESS;
1569 test_AES_cipheronly_mb_all(void)
1571 struct crypto_testsuite_params *ts_params = &testsuite_params;
1574 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1575 ts_params->op_mpool,
1576 ts_params->session_mpool, ts_params->session_priv_mpool,
1577 ts_params->valid_devs[0],
1578 rte_cryptodev_driver_id_get(
1579 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1580 BLKCIPHER_AES_CIPHERONLY_TYPE);
1582 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1584 return TEST_SUCCESS;
1588 test_AES_docsis_mb_all(void)
1590 struct crypto_testsuite_params *ts_params = &testsuite_params;
1593 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1594 ts_params->op_mpool,
1595 ts_params->session_mpool, ts_params->session_priv_mpool,
1596 ts_params->valid_devs[0],
1597 rte_cryptodev_driver_id_get(
1598 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1599 BLKCIPHER_AES_DOCSIS_TYPE);
1601 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1603 return TEST_SUCCESS;
1607 test_AES_docsis_qat_all(void)
1609 struct crypto_testsuite_params *ts_params = &testsuite_params;
1612 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1613 ts_params->op_mpool,
1614 ts_params->session_mpool, ts_params->session_priv_mpool,
1615 ts_params->valid_devs[0],
1616 rte_cryptodev_driver_id_get(
1617 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1618 BLKCIPHER_AES_DOCSIS_TYPE);
1620 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1622 return TEST_SUCCESS;
1626 test_DES_docsis_qat_all(void)
1628 struct crypto_testsuite_params *ts_params = &testsuite_params;
1631 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1632 ts_params->op_mpool,
1633 ts_params->session_mpool, ts_params->session_priv_mpool,
1634 ts_params->valid_devs[0],
1635 rte_cryptodev_driver_id_get(
1636 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1637 BLKCIPHER_DES_DOCSIS_TYPE);
1639 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1641 return TEST_SUCCESS;
1645 test_authonly_mb_all(void)
1647 struct crypto_testsuite_params *ts_params = &testsuite_params;
1650 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1651 ts_params->op_mpool,
1652 ts_params->session_mpool, ts_params->session_priv_mpool,
1653 ts_params->valid_devs[0],
1654 rte_cryptodev_driver_id_get(
1655 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1656 BLKCIPHER_AUTHONLY_TYPE);
1658 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1660 return TEST_SUCCESS;
1664 test_authonly_qat_all(void)
1666 struct crypto_testsuite_params *ts_params = &testsuite_params;
1669 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1670 ts_params->op_mpool,
1671 ts_params->session_mpool, ts_params->session_priv_mpool,
1672 ts_params->valid_devs[0],
1673 rte_cryptodev_driver_id_get(
1674 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1675 BLKCIPHER_AUTHONLY_TYPE);
1677 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1679 return TEST_SUCCESS;
1683 test_AES_chain_null_all(void)
1685 struct crypto_testsuite_params *ts_params = &testsuite_params;
1688 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1689 ts_params->op_mpool,
1690 ts_params->session_mpool, ts_params->session_priv_mpool,
1691 ts_params->valid_devs[0],
1692 rte_cryptodev_driver_id_get(
1693 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1694 BLKCIPHER_AES_CHAIN_TYPE);
1696 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1698 return TEST_SUCCESS;
1702 test_AES_cipheronly_null_all(void)
1704 struct crypto_testsuite_params *ts_params = &testsuite_params;
1707 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1708 ts_params->op_mpool,
1709 ts_params->session_mpool, ts_params->session_priv_mpool,
1710 ts_params->valid_devs[0],
1711 rte_cryptodev_driver_id_get(
1712 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1713 BLKCIPHER_AES_CIPHERONLY_TYPE);
1715 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1717 return TEST_SUCCESS;
1721 test_authonly_null_all(void)
1723 struct crypto_testsuite_params *ts_params = &testsuite_params;
1726 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1727 ts_params->op_mpool,
1728 ts_params->session_mpool, ts_params->session_priv_mpool,
1729 ts_params->valid_devs[0],
1730 rte_cryptodev_driver_id_get(
1731 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1732 BLKCIPHER_AUTHONLY_TYPE);
1734 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1736 return TEST_SUCCESS;
1740 test_AES_chain_mb_all(void)
1742 struct crypto_testsuite_params *ts_params = &testsuite_params;
1745 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1746 ts_params->op_mpool,
1747 ts_params->session_mpool, ts_params->session_priv_mpool,
1748 ts_params->valid_devs[0],
1749 rte_cryptodev_driver_id_get(
1750 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1751 BLKCIPHER_AES_CHAIN_TYPE);
1753 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1755 return TEST_SUCCESS;
1758 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1761 test_AES_cipheronly_scheduler_all(void)
1763 struct crypto_testsuite_params *ts_params = &testsuite_params;
1766 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1767 ts_params->op_mpool,
1768 ts_params->session_mpool, ts_params->session_priv_mpool,
1769 ts_params->valid_devs[0],
1770 rte_cryptodev_driver_id_get(
1771 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1772 BLKCIPHER_AES_CIPHERONLY_TYPE);
1774 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1776 return TEST_SUCCESS;
1780 test_AES_chain_scheduler_all(void)
1782 struct crypto_testsuite_params *ts_params = &testsuite_params;
1785 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1786 ts_params->op_mpool,
1787 ts_params->session_mpool, ts_params->session_priv_mpool,
1788 ts_params->valid_devs[0],
1789 rte_cryptodev_driver_id_get(
1790 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1791 BLKCIPHER_AES_CHAIN_TYPE);
1793 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1795 return TEST_SUCCESS;
1799 test_authonly_scheduler_all(void)
1801 struct crypto_testsuite_params *ts_params = &testsuite_params;
1804 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1805 ts_params->op_mpool,
1806 ts_params->session_mpool, ts_params->session_priv_mpool,
1807 ts_params->valid_devs[0],
1808 rte_cryptodev_driver_id_get(
1809 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1810 BLKCIPHER_AUTHONLY_TYPE);
1812 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1814 return TEST_SUCCESS;
1817 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1820 test_AES_chain_openssl_all(void)
1822 struct crypto_testsuite_params *ts_params = &testsuite_params;
1825 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1826 ts_params->op_mpool,
1827 ts_params->session_mpool, ts_params->session_priv_mpool,
1828 ts_params->valid_devs[0],
1829 rte_cryptodev_driver_id_get(
1830 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1831 BLKCIPHER_AES_CHAIN_TYPE);
1833 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1835 return TEST_SUCCESS;
1839 test_AES_cipheronly_openssl_all(void)
1841 struct crypto_testsuite_params *ts_params = &testsuite_params;
1844 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1845 ts_params->op_mpool,
1846 ts_params->session_mpool, ts_params->session_priv_mpool,
1847 ts_params->valid_devs[0],
1848 rte_cryptodev_driver_id_get(
1849 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1850 BLKCIPHER_AES_CIPHERONLY_TYPE);
1852 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1854 return TEST_SUCCESS;
1858 test_AES_chain_ccp_all(void)
1860 struct crypto_testsuite_params *ts_params = &testsuite_params;
1863 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1864 ts_params->op_mpool,
1865 ts_params->session_mpool, ts_params->session_priv_mpool,
1866 ts_params->valid_devs[0],
1867 rte_cryptodev_driver_id_get(
1868 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1869 BLKCIPHER_AES_CHAIN_TYPE);
1871 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1873 return TEST_SUCCESS;
1877 test_AES_cipheronly_ccp_all(void)
1879 struct crypto_testsuite_params *ts_params = &testsuite_params;
1882 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1883 ts_params->op_mpool,
1884 ts_params->session_mpool, ts_params->session_priv_mpool,
1885 ts_params->valid_devs[0],
1886 rte_cryptodev_driver_id_get(
1887 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1888 BLKCIPHER_AES_CIPHERONLY_TYPE);
1890 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1892 return TEST_SUCCESS;
1896 test_AES_chain_qat_all(void)
1898 struct crypto_testsuite_params *ts_params = &testsuite_params;
1901 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1902 ts_params->op_mpool,
1903 ts_params->session_mpool, ts_params->session_priv_mpool,
1904 ts_params->valid_devs[0],
1905 rte_cryptodev_driver_id_get(
1906 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1907 BLKCIPHER_AES_CHAIN_TYPE);
1909 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1911 return TEST_SUCCESS;
1915 test_AES_cipheronly_qat_all(void)
1917 struct crypto_testsuite_params *ts_params = &testsuite_params;
1920 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1921 ts_params->op_mpool,
1922 ts_params->session_mpool, ts_params->session_priv_mpool,
1923 ts_params->valid_devs[0],
1924 rte_cryptodev_driver_id_get(
1925 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1926 BLKCIPHER_AES_CIPHERONLY_TYPE);
1928 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1930 return TEST_SUCCESS;
1934 test_AES_cipheronly_virtio_all(void)
1936 struct crypto_testsuite_params *ts_params = &testsuite_params;
1939 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1940 ts_params->op_mpool,
1941 ts_params->session_mpool, ts_params->session_priv_mpool,
1942 ts_params->valid_devs[0],
1943 rte_cryptodev_driver_id_get(
1944 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1945 BLKCIPHER_AES_CIPHERONLY_TYPE);
1947 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1949 return TEST_SUCCESS;
1953 test_AES_chain_caam_jr_all(void)
1955 struct crypto_testsuite_params *ts_params = &testsuite_params;
1958 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1959 ts_params->op_mpool,
1960 ts_params->session_mpool, ts_params->session_priv_mpool,
1961 ts_params->valid_devs[0],
1962 rte_cryptodev_driver_id_get(
1963 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1964 BLKCIPHER_AES_CHAIN_TYPE);
1966 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1968 return TEST_SUCCESS;
1972 test_AES_cipheronly_caam_jr_all(void)
1974 struct crypto_testsuite_params *ts_params = &testsuite_params;
1977 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1978 ts_params->op_mpool,
1979 ts_params->session_mpool, ts_params->session_priv_mpool,
1980 ts_params->valid_devs[0],
1981 rte_cryptodev_driver_id_get(
1982 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1983 BLKCIPHER_AES_CIPHERONLY_TYPE);
1985 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1987 return TEST_SUCCESS;
1991 test_authonly_caam_jr_all(void)
1993 struct crypto_testsuite_params *ts_params = &testsuite_params;
1996 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1997 ts_params->op_mpool,
1998 ts_params->session_mpool, ts_params->session_priv_mpool,
1999 ts_params->valid_devs[0],
2000 rte_cryptodev_driver_id_get(
2001 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2002 BLKCIPHER_AUTHONLY_TYPE);
2004 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2006 return TEST_SUCCESS;
2011 test_AES_chain_dpaa_sec_all(void)
2013 struct crypto_testsuite_params *ts_params = &testsuite_params;
2016 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2017 ts_params->op_mpool,
2018 ts_params->session_mpool, ts_params->session_priv_mpool,
2019 ts_params->valid_devs[0],
2020 rte_cryptodev_driver_id_get(
2021 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2022 BLKCIPHER_AES_CHAIN_TYPE);
2024 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2026 return TEST_SUCCESS;
2030 test_AES_cipheronly_dpaa_sec_all(void)
2032 struct crypto_testsuite_params *ts_params = &testsuite_params;
2035 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2036 ts_params->op_mpool,
2037 ts_params->session_mpool, ts_params->session_priv_mpool,
2038 ts_params->valid_devs[0],
2039 rte_cryptodev_driver_id_get(
2040 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2041 BLKCIPHER_AES_CIPHERONLY_TYPE);
2043 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2045 return TEST_SUCCESS;
2049 test_authonly_dpaa_sec_all(void)
2051 struct crypto_testsuite_params *ts_params = &testsuite_params;
2054 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2055 ts_params->op_mpool,
2056 ts_params->session_mpool, ts_params->session_priv_mpool,
2057 ts_params->valid_devs[0],
2058 rte_cryptodev_driver_id_get(
2059 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2060 BLKCIPHER_AUTHONLY_TYPE);
2062 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2064 return TEST_SUCCESS;
2068 test_AES_chain_dpaa2_sec_all(void)
2070 struct crypto_testsuite_params *ts_params = &testsuite_params;
2073 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2074 ts_params->op_mpool,
2075 ts_params->session_mpool, ts_params->session_priv_mpool,
2076 ts_params->valid_devs[0],
2077 rte_cryptodev_driver_id_get(
2078 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2079 BLKCIPHER_AES_CHAIN_TYPE);
2081 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2083 return TEST_SUCCESS;
2087 test_AES_cipheronly_dpaa2_sec_all(void)
2089 struct crypto_testsuite_params *ts_params = &testsuite_params;
2092 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2093 ts_params->op_mpool,
2094 ts_params->session_mpool, ts_params->session_priv_mpool,
2095 ts_params->valid_devs[0],
2096 rte_cryptodev_driver_id_get(
2097 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2098 BLKCIPHER_AES_CIPHERONLY_TYPE);
2100 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2102 return TEST_SUCCESS;
2106 test_authonly_dpaa2_sec_all(void)
2108 struct crypto_testsuite_params *ts_params = &testsuite_params;
2111 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2112 ts_params->op_mpool,
2113 ts_params->session_mpool, ts_params->session_priv_mpool,
2114 ts_params->valid_devs[0],
2115 rte_cryptodev_driver_id_get(
2116 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2117 BLKCIPHER_AUTHONLY_TYPE);
2119 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2121 return TEST_SUCCESS;
2125 test_authonly_openssl_all(void)
2127 struct crypto_testsuite_params *ts_params = &testsuite_params;
2130 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2131 ts_params->op_mpool,
2132 ts_params->session_mpool, ts_params->session_priv_mpool,
2133 ts_params->valid_devs[0],
2134 rte_cryptodev_driver_id_get(
2135 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2136 BLKCIPHER_AUTHONLY_TYPE);
2138 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2140 return TEST_SUCCESS;
2144 test_authonly_ccp_all(void)
2146 struct crypto_testsuite_params *ts_params = &testsuite_params;
2149 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2150 ts_params->op_mpool,
2151 ts_params->session_mpool, ts_params->session_priv_mpool,
2152 ts_params->valid_devs[0],
2153 rte_cryptodev_driver_id_get(
2154 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2155 BLKCIPHER_AUTHONLY_TYPE);
2157 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2159 return TEST_SUCCESS;
2163 test_AES_chain_armv8_all(void)
2165 struct crypto_testsuite_params *ts_params = &testsuite_params;
2168 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2169 ts_params->op_mpool,
2170 ts_params->session_mpool, ts_params->session_priv_mpool,
2171 ts_params->valid_devs[0],
2172 rte_cryptodev_driver_id_get(
2173 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2174 BLKCIPHER_AES_CHAIN_TYPE);
2176 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2178 return TEST_SUCCESS;
2182 test_AES_chain_mrvl_all(void)
2184 struct crypto_testsuite_params *ts_params = &testsuite_params;
2187 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2188 ts_params->op_mpool,
2189 ts_params->session_mpool, ts_params->session_priv_mpool,
2190 ts_params->valid_devs[0],
2191 rte_cryptodev_driver_id_get(
2192 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2193 BLKCIPHER_AES_CHAIN_TYPE);
2195 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2197 return TEST_SUCCESS;
2201 test_AES_cipheronly_mrvl_all(void)
2203 struct crypto_testsuite_params *ts_params = &testsuite_params;
2206 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2207 ts_params->op_mpool,
2208 ts_params->session_mpool, ts_params->session_priv_mpool,
2209 ts_params->valid_devs[0],
2210 rte_cryptodev_driver_id_get(
2211 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2212 BLKCIPHER_AES_CIPHERONLY_TYPE);
2214 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2216 return TEST_SUCCESS;
2220 test_authonly_mrvl_all(void)
2222 struct crypto_testsuite_params *ts_params = &testsuite_params;
2225 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2226 ts_params->op_mpool,
2227 ts_params->session_mpool, ts_params->session_priv_mpool,
2228 ts_params->valid_devs[0],
2229 rte_cryptodev_driver_id_get(
2230 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2231 BLKCIPHER_AUTHONLY_TYPE);
2233 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2235 return TEST_SUCCESS;
2239 test_3DES_chain_mrvl_all(void)
2241 struct crypto_testsuite_params *ts_params = &testsuite_params;
2244 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2245 ts_params->op_mpool,
2246 ts_params->session_mpool, ts_params->session_priv_mpool,
2247 ts_params->valid_devs[0],
2248 rte_cryptodev_driver_id_get(
2249 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2250 BLKCIPHER_3DES_CHAIN_TYPE);
2252 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2254 return TEST_SUCCESS;
2258 test_3DES_cipheronly_mrvl_all(void)
2260 struct crypto_testsuite_params *ts_params = &testsuite_params;
2263 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2264 ts_params->op_mpool,
2265 ts_params->session_mpool, ts_params->session_priv_mpool,
2266 ts_params->valid_devs[0],
2267 rte_cryptodev_driver_id_get(
2268 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2269 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2271 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2273 return TEST_SUCCESS;
2277 test_AES_chain_octeontx_all(void)
2279 struct crypto_testsuite_params *ts_params = &testsuite_params;
2282 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2283 ts_params->op_mpool, ts_params->session_mpool,
2284 ts_params->session_priv_mpool,
2285 ts_params->valid_devs[0],
2286 rte_cryptodev_driver_id_get(
2287 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2288 BLKCIPHER_AES_CHAIN_TYPE);
2290 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2292 return TEST_SUCCESS;
2296 test_AES_cipheronly_octeontx_all(void)
2298 struct crypto_testsuite_params *ts_params = &testsuite_params;
2301 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2302 ts_params->op_mpool, ts_params->session_mpool,
2303 ts_params->session_priv_mpool,
2304 ts_params->valid_devs[0],
2305 rte_cryptodev_driver_id_get(
2306 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2307 BLKCIPHER_AES_CIPHERONLY_TYPE);
2309 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2311 return TEST_SUCCESS;
2315 test_3DES_chain_octeontx_all(void)
2317 struct crypto_testsuite_params *ts_params = &testsuite_params;
2320 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2321 ts_params->op_mpool, ts_params->session_mpool,
2322 ts_params->session_priv_mpool,
2323 ts_params->valid_devs[0],
2324 rte_cryptodev_driver_id_get(
2325 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2326 BLKCIPHER_3DES_CHAIN_TYPE);
2328 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2330 return TEST_SUCCESS;
2334 test_3DES_cipheronly_octeontx_all(void)
2336 struct crypto_testsuite_params *ts_params = &testsuite_params;
2339 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2340 ts_params->op_mpool, ts_params->session_mpool,
2341 ts_params->session_priv_mpool,
2342 ts_params->valid_devs[0],
2343 rte_cryptodev_driver_id_get(
2344 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2345 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2347 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2349 return TEST_SUCCESS;
2353 test_authonly_octeontx_all(void)
2355 struct crypto_testsuite_params *ts_params = &testsuite_params;
2358 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2359 ts_params->op_mpool, ts_params->session_mpool,
2360 ts_params->session_priv_mpool,
2361 ts_params->valid_devs[0],
2362 rte_cryptodev_driver_id_get(
2363 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2364 BLKCIPHER_AUTHONLY_TYPE);
2366 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2368 return TEST_SUCCESS;
2371 /* ***** SNOW 3G Tests ***** */
2373 create_wireless_algo_hash_session(uint8_t dev_id,
2374 const uint8_t *key, const uint8_t key_len,
2375 const uint8_t iv_len, const uint8_t auth_len,
2376 enum rte_crypto_auth_operation op,
2377 enum rte_crypto_auth_algorithm algo)
2379 uint8_t hash_key[key_len];
2381 struct crypto_testsuite_params *ts_params = &testsuite_params;
2382 struct crypto_unittest_params *ut_params = &unittest_params;
2384 memcpy(hash_key, key, key_len);
2386 debug_hexdump(stdout, "key:", key, key_len);
2388 /* Setup Authentication Parameters */
2389 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2390 ut_params->auth_xform.next = NULL;
2392 ut_params->auth_xform.auth.op = op;
2393 ut_params->auth_xform.auth.algo = algo;
2394 ut_params->auth_xform.auth.key.length = key_len;
2395 ut_params->auth_xform.auth.key.data = hash_key;
2396 ut_params->auth_xform.auth.digest_length = auth_len;
2397 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2398 ut_params->auth_xform.auth.iv.length = iv_len;
2399 ut_params->sess = rte_cryptodev_sym_session_create(
2400 ts_params->session_mpool);
2402 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2403 &ut_params->auth_xform,
2404 ts_params->session_priv_mpool);
2405 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2410 create_wireless_algo_cipher_session(uint8_t dev_id,
2411 enum rte_crypto_cipher_operation op,
2412 enum rte_crypto_cipher_algorithm algo,
2413 const uint8_t *key, const uint8_t key_len,
2416 uint8_t cipher_key[key_len];
2418 struct crypto_testsuite_params *ts_params = &testsuite_params;
2419 struct crypto_unittest_params *ut_params = &unittest_params;
2421 memcpy(cipher_key, key, key_len);
2423 /* Setup Cipher Parameters */
2424 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2425 ut_params->cipher_xform.next = NULL;
2427 ut_params->cipher_xform.cipher.algo = algo;
2428 ut_params->cipher_xform.cipher.op = op;
2429 ut_params->cipher_xform.cipher.key.data = cipher_key;
2430 ut_params->cipher_xform.cipher.key.length = key_len;
2431 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2432 ut_params->cipher_xform.cipher.iv.length = iv_len;
2434 debug_hexdump(stdout, "key:", key, key_len);
2436 /* Create Crypto session */
2437 ut_params->sess = rte_cryptodev_sym_session_create(
2438 ts_params->session_mpool);
2440 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2441 &ut_params->cipher_xform,
2442 ts_params->session_priv_mpool);
2443 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2448 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2449 unsigned int cipher_len,
2450 unsigned int cipher_offset)
2452 struct crypto_testsuite_params *ts_params = &testsuite_params;
2453 struct crypto_unittest_params *ut_params = &unittest_params;
2455 /* Generate Crypto op data structure */
2456 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2457 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2458 TEST_ASSERT_NOT_NULL(ut_params->op,
2459 "Failed to allocate pktmbuf offload");
2461 /* Set crypto operation data parameters */
2462 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2464 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2466 /* set crypto operation source mbuf */
2467 sym_op->m_src = ut_params->ibuf;
2470 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2472 sym_op->cipher.data.length = cipher_len;
2473 sym_op->cipher.data.offset = cipher_offset;
2478 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2479 unsigned int cipher_len,
2480 unsigned int cipher_offset)
2482 struct crypto_testsuite_params *ts_params = &testsuite_params;
2483 struct crypto_unittest_params *ut_params = &unittest_params;
2485 /* Generate Crypto op data structure */
2486 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2487 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2488 TEST_ASSERT_NOT_NULL(ut_params->op,
2489 "Failed to allocate pktmbuf offload");
2491 /* Set crypto operation data parameters */
2492 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2494 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2496 /* set crypto operation source mbuf */
2497 sym_op->m_src = ut_params->ibuf;
2498 sym_op->m_dst = ut_params->obuf;
2501 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2503 sym_op->cipher.data.length = cipher_len;
2504 sym_op->cipher.data.offset = cipher_offset;
2509 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2510 enum rte_crypto_cipher_operation cipher_op,
2511 enum rte_crypto_auth_operation auth_op,
2512 enum rte_crypto_auth_algorithm auth_algo,
2513 enum rte_crypto_cipher_algorithm cipher_algo,
2514 const uint8_t *key, uint8_t key_len,
2515 uint8_t auth_iv_len, uint8_t auth_len,
2516 uint8_t cipher_iv_len)
2519 uint8_t cipher_auth_key[key_len];
2521 struct crypto_testsuite_params *ts_params = &testsuite_params;
2522 struct crypto_unittest_params *ut_params = &unittest_params;
2524 memcpy(cipher_auth_key, key, key_len);
2526 /* Setup Authentication Parameters */
2527 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2528 ut_params->auth_xform.next = NULL;
2530 ut_params->auth_xform.auth.op = auth_op;
2531 ut_params->auth_xform.auth.algo = auth_algo;
2532 ut_params->auth_xform.auth.key.length = key_len;
2533 /* Hash key = cipher key */
2534 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2535 ut_params->auth_xform.auth.digest_length = auth_len;
2536 /* Auth IV will be after cipher IV */
2537 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2538 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2540 /* Setup Cipher Parameters */
2541 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2542 ut_params->cipher_xform.next = &ut_params->auth_xform;
2544 ut_params->cipher_xform.cipher.algo = cipher_algo;
2545 ut_params->cipher_xform.cipher.op = cipher_op;
2546 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2547 ut_params->cipher_xform.cipher.key.length = key_len;
2548 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2549 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2551 debug_hexdump(stdout, "key:", key, key_len);
2553 /* Create Crypto session*/
2554 ut_params->sess = rte_cryptodev_sym_session_create(
2555 ts_params->session_mpool);
2557 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2558 &ut_params->cipher_xform,
2559 ts_params->session_priv_mpool);
2561 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2566 create_wireless_cipher_auth_session(uint8_t dev_id,
2567 enum rte_crypto_cipher_operation cipher_op,
2568 enum rte_crypto_auth_operation auth_op,
2569 enum rte_crypto_auth_algorithm auth_algo,
2570 enum rte_crypto_cipher_algorithm cipher_algo,
2571 const struct wireless_test_data *tdata)
2573 const uint8_t key_len = tdata->key.len;
2574 uint8_t cipher_auth_key[key_len];
2576 struct crypto_testsuite_params *ts_params = &testsuite_params;
2577 struct crypto_unittest_params *ut_params = &unittest_params;
2578 const uint8_t *key = tdata->key.data;
2579 const uint8_t auth_len = tdata->digest.len;
2580 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2581 uint8_t auth_iv_len = tdata->auth_iv.len;
2583 memcpy(cipher_auth_key, key, key_len);
2585 /* Setup Authentication Parameters */
2586 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2587 ut_params->auth_xform.next = NULL;
2589 ut_params->auth_xform.auth.op = auth_op;
2590 ut_params->auth_xform.auth.algo = auth_algo;
2591 ut_params->auth_xform.auth.key.length = key_len;
2592 /* Hash key = cipher key */
2593 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2594 ut_params->auth_xform.auth.digest_length = auth_len;
2595 /* Auth IV will be after cipher IV */
2596 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2597 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2599 /* Setup Cipher Parameters */
2600 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2601 ut_params->cipher_xform.next = &ut_params->auth_xform;
2603 ut_params->cipher_xform.cipher.algo = cipher_algo;
2604 ut_params->cipher_xform.cipher.op = cipher_op;
2605 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2606 ut_params->cipher_xform.cipher.key.length = key_len;
2607 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2608 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2611 debug_hexdump(stdout, "key:", key, key_len);
2613 /* Create Crypto session*/
2614 ut_params->sess = rte_cryptodev_sym_session_create(
2615 ts_params->session_mpool);
2617 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2618 &ut_params->cipher_xform,
2619 ts_params->session_priv_mpool);
2621 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2626 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2627 const struct wireless_test_data *tdata)
2629 return create_wireless_cipher_auth_session(dev_id,
2630 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2631 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2632 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2636 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2637 enum rte_crypto_cipher_operation cipher_op,
2638 enum rte_crypto_auth_operation auth_op,
2639 enum rte_crypto_auth_algorithm auth_algo,
2640 enum rte_crypto_cipher_algorithm cipher_algo,
2641 const uint8_t *key, const uint8_t key_len,
2642 uint8_t auth_iv_len, uint8_t auth_len,
2643 uint8_t cipher_iv_len)
2645 uint8_t auth_cipher_key[key_len];
2647 struct crypto_testsuite_params *ts_params = &testsuite_params;
2648 struct crypto_unittest_params *ut_params = &unittest_params;
2650 memcpy(auth_cipher_key, key, key_len);
2652 /* Setup Authentication Parameters */
2653 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2654 ut_params->auth_xform.auth.op = auth_op;
2655 ut_params->auth_xform.next = &ut_params->cipher_xform;
2656 ut_params->auth_xform.auth.algo = auth_algo;
2657 ut_params->auth_xform.auth.key.length = key_len;
2658 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2659 ut_params->auth_xform.auth.digest_length = auth_len;
2660 /* Auth IV will be after cipher IV */
2661 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2662 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2664 /* Setup Cipher Parameters */
2665 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2666 ut_params->cipher_xform.next = NULL;
2667 ut_params->cipher_xform.cipher.algo = cipher_algo;
2668 ut_params->cipher_xform.cipher.op = cipher_op;
2669 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2670 ut_params->cipher_xform.cipher.key.length = key_len;
2671 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2672 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2674 debug_hexdump(stdout, "key:", key, key_len);
2676 /* Create Crypto session*/
2677 ut_params->sess = rte_cryptodev_sym_session_create(
2678 ts_params->session_mpool);
2680 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2681 &ut_params->auth_xform,
2682 ts_params->session_priv_mpool);
2684 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2690 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2691 unsigned int auth_tag_len,
2692 const uint8_t *iv, unsigned int iv_len,
2693 unsigned int data_pad_len,
2694 enum rte_crypto_auth_operation op,
2695 unsigned int auth_len, unsigned int auth_offset)
2697 struct crypto_testsuite_params *ts_params = &testsuite_params;
2699 struct crypto_unittest_params *ut_params = &unittest_params;
2701 /* Generate Crypto op data structure */
2702 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2703 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2704 TEST_ASSERT_NOT_NULL(ut_params->op,
2705 "Failed to allocate pktmbuf offload");
2707 /* Set crypto operation data parameters */
2708 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2710 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2712 /* set crypto operation source mbuf */
2713 sym_op->m_src = ut_params->ibuf;
2716 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2719 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2720 ut_params->ibuf, auth_tag_len);
2722 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2723 "no room to append auth tag");
2724 ut_params->digest = sym_op->auth.digest.data;
2725 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2726 ut_params->ibuf, data_pad_len);
2727 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2728 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2730 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2732 debug_hexdump(stdout, "digest:",
2733 sym_op->auth.digest.data,
2736 sym_op->auth.data.length = auth_len;
2737 sym_op->auth.data.offset = auth_offset;
2743 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2744 enum rte_crypto_auth_operation op)
2746 struct crypto_testsuite_params *ts_params = &testsuite_params;
2747 struct crypto_unittest_params *ut_params = &unittest_params;
2749 const uint8_t *auth_tag = tdata->digest.data;
2750 const unsigned int auth_tag_len = tdata->digest.len;
2751 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2752 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2754 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2755 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2756 const uint8_t *auth_iv = tdata->auth_iv.data;
2757 const uint8_t auth_iv_len = tdata->auth_iv.len;
2758 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2759 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2761 /* Generate Crypto op data structure */
2762 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2763 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2764 TEST_ASSERT_NOT_NULL(ut_params->op,
2765 "Failed to allocate pktmbuf offload");
2766 /* Set crypto operation data parameters */
2767 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2769 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2771 /* set crypto operation source mbuf */
2772 sym_op->m_src = ut_params->ibuf;
2775 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2776 ut_params->ibuf, auth_tag_len);
2778 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2779 "no room to append auth tag");
2780 ut_params->digest = sym_op->auth.digest.data;
2781 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2782 ut_params->ibuf, data_pad_len);
2783 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2784 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2786 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2788 debug_hexdump(stdout, "digest:",
2789 sym_op->auth.digest.data,
2792 /* Copy cipher and auth IVs at the end of the crypto operation */
2793 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2795 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2796 iv_ptr += cipher_iv_len;
2797 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2799 sym_op->cipher.data.length = cipher_len;
2800 sym_op->cipher.data.offset = 0;
2801 sym_op->auth.data.length = auth_len;
2802 sym_op->auth.data.offset = 0;
2808 create_zuc_cipher_hash_generate_operation(
2809 const struct wireless_test_data *tdata)
2811 return create_wireless_cipher_hash_operation(tdata,
2812 RTE_CRYPTO_AUTH_OP_GENERATE);
2816 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2817 const unsigned auth_tag_len,
2818 const uint8_t *auth_iv, uint8_t auth_iv_len,
2819 unsigned data_pad_len,
2820 enum rte_crypto_auth_operation op,
2821 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2822 const unsigned cipher_len, const unsigned cipher_offset,
2823 const unsigned auth_len, const unsigned auth_offset)
2825 struct crypto_testsuite_params *ts_params = &testsuite_params;
2826 struct crypto_unittest_params *ut_params = &unittest_params;
2828 /* Generate Crypto op data structure */
2829 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2830 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2831 TEST_ASSERT_NOT_NULL(ut_params->op,
2832 "Failed to allocate pktmbuf offload");
2833 /* Set crypto operation data parameters */
2834 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2836 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2838 /* set crypto operation source mbuf */
2839 sym_op->m_src = ut_params->ibuf;
2842 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2843 ut_params->ibuf, auth_tag_len);
2845 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2846 "no room to append auth tag");
2847 ut_params->digest = sym_op->auth.digest.data;
2848 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2849 ut_params->ibuf, data_pad_len);
2850 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2851 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2853 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2855 debug_hexdump(stdout, "digest:",
2856 sym_op->auth.digest.data,
2859 /* Copy cipher and auth IVs at the end of the crypto operation */
2860 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2862 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2863 iv_ptr += cipher_iv_len;
2864 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2866 sym_op->cipher.data.length = cipher_len;
2867 sym_op->cipher.data.offset = cipher_offset;
2868 sym_op->auth.data.length = auth_len;
2869 sym_op->auth.data.offset = auth_offset;
2875 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2876 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2877 const uint8_t *auth_iv, uint8_t auth_iv_len,
2878 unsigned int data_pad_len,
2879 unsigned int cipher_len, unsigned int cipher_offset,
2880 unsigned int auth_len, unsigned int auth_offset,
2883 struct crypto_testsuite_params *ts_params = &testsuite_params;
2884 struct crypto_unittest_params *ut_params = &unittest_params;
2886 /* Generate Crypto op data structure */
2887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2889 TEST_ASSERT_NOT_NULL(ut_params->op,
2890 "Failed to allocate pktmbuf offload");
2892 /* Set crypto operation data parameters */
2893 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2897 /* set crypto operation mbufs */
2898 sym_op->m_src = ut_params->ibuf;
2899 if (op_mode == OUT_OF_PLACE)
2900 sym_op->m_dst = ut_params->obuf;
2903 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2904 (op_mode == IN_PLACE ?
2905 ut_params->ibuf : ut_params->obuf),
2906 uint8_t *, data_pad_len);
2908 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2909 "no room to append auth tag");
2911 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2912 (op_mode == IN_PLACE ?
2913 ut_params->ibuf : ut_params->obuf),
2916 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2918 /* Copy cipher and auth IVs at the end of the crypto operation */
2919 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2920 ut_params->op, uint8_t *, IV_OFFSET);
2922 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2923 iv_ptr += cipher_iv_len;
2924 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2926 sym_op->cipher.data.length = cipher_len;
2927 sym_op->cipher.data.offset = cipher_offset;
2929 sym_op->auth.data.length = auth_len;
2930 sym_op->auth.data.offset = auth_offset;
2936 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2938 struct crypto_testsuite_params *ts_params = &testsuite_params;
2939 struct crypto_unittest_params *ut_params = &unittest_params;
2942 unsigned plaintext_pad_len;
2943 unsigned plaintext_len;
2946 /* Create SNOW 3G session */
2947 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2948 tdata->key.data, tdata->key.len,
2949 tdata->auth_iv.len, tdata->digest.len,
2950 RTE_CRYPTO_AUTH_OP_GENERATE,
2951 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2955 /* alloc mbuf and set payload */
2956 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2958 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2959 rte_pktmbuf_tailroom(ut_params->ibuf));
2961 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2962 /* Append data which is padded to a multiple of */
2963 /* the algorithms block size */
2964 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2965 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2967 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2969 /* Create SNOW 3G operation */
2970 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2971 tdata->auth_iv.data, tdata->auth_iv.len,
2972 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2973 tdata->validAuthLenInBits.len,
2978 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2980 ut_params->obuf = ut_params->op->sym->m_src;
2981 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2982 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2983 + plaintext_pad_len;
2986 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2989 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2990 "SNOW 3G Generated auth tag not as expected");
2996 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2998 struct crypto_testsuite_params *ts_params = &testsuite_params;
2999 struct crypto_unittest_params *ut_params = &unittest_params;
3002 unsigned plaintext_pad_len;
3003 unsigned plaintext_len;
3006 /* Create SNOW 3G session */
3007 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3008 tdata->key.data, tdata->key.len,
3009 tdata->auth_iv.len, tdata->digest.len,
3010 RTE_CRYPTO_AUTH_OP_VERIFY,
3011 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3014 /* alloc mbuf and set payload */
3015 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3017 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3018 rte_pktmbuf_tailroom(ut_params->ibuf));
3020 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3021 /* Append data which is padded to a multiple of */
3022 /* the algorithms block size */
3023 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3024 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3026 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3028 /* Create SNOW 3G operation */
3029 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3031 tdata->auth_iv.data, tdata->auth_iv.len,
3033 RTE_CRYPTO_AUTH_OP_VERIFY,
3034 tdata->validAuthLenInBits.len,
3039 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3041 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3042 ut_params->obuf = ut_params->op->sym->m_src;
3043 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3044 + plaintext_pad_len;
3047 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3056 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3058 struct crypto_testsuite_params *ts_params = &testsuite_params;
3059 struct crypto_unittest_params *ut_params = &unittest_params;
3062 unsigned plaintext_pad_len;
3063 unsigned plaintext_len;
3066 /* Create KASUMI session */
3067 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3068 tdata->key.data, tdata->key.len,
3069 0, tdata->digest.len,
3070 RTE_CRYPTO_AUTH_OP_GENERATE,
3071 RTE_CRYPTO_AUTH_KASUMI_F9);
3075 /* alloc mbuf and set payload */
3076 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3078 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3079 rte_pktmbuf_tailroom(ut_params->ibuf));
3081 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3082 /* Append data which is padded to a multiple of */
3083 /* the algorithms block size */
3084 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3085 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3087 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3089 /* Create KASUMI operation */
3090 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3092 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3093 tdata->plaintext.len,
3098 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3100 ut_params->obuf = ut_params->op->sym->m_src;
3101 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3102 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3103 + plaintext_pad_len;
3106 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3109 DIGEST_BYTE_LENGTH_KASUMI_F9,
3110 "KASUMI Generated auth tag not as expected");
3116 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3118 struct crypto_testsuite_params *ts_params = &testsuite_params;
3119 struct crypto_unittest_params *ut_params = &unittest_params;
3122 unsigned plaintext_pad_len;
3123 unsigned plaintext_len;
3126 /* Create KASUMI session */
3127 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3128 tdata->key.data, tdata->key.len,
3129 0, tdata->digest.len,
3130 RTE_CRYPTO_AUTH_OP_VERIFY,
3131 RTE_CRYPTO_AUTH_KASUMI_F9);
3134 /* alloc mbuf and set payload */
3135 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3137 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3138 rte_pktmbuf_tailroom(ut_params->ibuf));
3140 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3141 /* Append data which is padded to a multiple */
3142 /* of the algorithms block size */
3143 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3144 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3146 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3148 /* Create KASUMI operation */
3149 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3153 RTE_CRYPTO_AUTH_OP_VERIFY,
3154 tdata->plaintext.len,
3159 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3161 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3162 ut_params->obuf = ut_params->op->sym->m_src;
3163 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3164 + plaintext_pad_len;
3167 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3176 test_snow3g_hash_generate_test_case_1(void)
3178 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3182 test_snow3g_hash_generate_test_case_2(void)
3184 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3188 test_snow3g_hash_generate_test_case_3(void)
3190 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3194 test_snow3g_hash_generate_test_case_4(void)
3196 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3200 test_snow3g_hash_generate_test_case_5(void)
3202 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3206 test_snow3g_hash_generate_test_case_6(void)
3208 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3212 test_snow3g_hash_verify_test_case_1(void)
3214 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3219 test_snow3g_hash_verify_test_case_2(void)
3221 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3225 test_snow3g_hash_verify_test_case_3(void)
3227 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3231 test_snow3g_hash_verify_test_case_4(void)
3233 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3237 test_snow3g_hash_verify_test_case_5(void)
3239 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3243 test_snow3g_hash_verify_test_case_6(void)
3245 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3249 test_kasumi_hash_generate_test_case_1(void)
3251 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3255 test_kasumi_hash_generate_test_case_2(void)
3257 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3261 test_kasumi_hash_generate_test_case_3(void)
3263 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3267 test_kasumi_hash_generate_test_case_4(void)
3269 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3273 test_kasumi_hash_generate_test_case_5(void)
3275 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3279 test_kasumi_hash_generate_test_case_6(void)
3281 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3285 test_kasumi_hash_verify_test_case_1(void)
3287 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3291 test_kasumi_hash_verify_test_case_2(void)
3293 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3297 test_kasumi_hash_verify_test_case_3(void)
3299 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3303 test_kasumi_hash_verify_test_case_4(void)
3305 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3309 test_kasumi_hash_verify_test_case_5(void)
3311 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3315 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3317 struct crypto_testsuite_params *ts_params = &testsuite_params;
3318 struct crypto_unittest_params *ut_params = &unittest_params;
3321 uint8_t *plaintext, *ciphertext;
3322 unsigned plaintext_pad_len;
3323 unsigned plaintext_len;
3325 /* Create KASUMI session */
3326 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3327 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3328 RTE_CRYPTO_CIPHER_KASUMI_F8,
3329 tdata->key.data, tdata->key.len,
3330 tdata->cipher_iv.len);
3334 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3336 /* Clear mbuf payload */
3337 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3338 rte_pktmbuf_tailroom(ut_params->ibuf));
3340 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3341 /* Append data which is padded to a multiple */
3342 /* of the algorithms block size */
3343 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3344 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3346 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3348 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3350 /* Create KASUMI operation */
3351 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3352 tdata->cipher_iv.len,
3353 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3354 tdata->validCipherOffsetInBits.len);
3358 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3360 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3362 ut_params->obuf = ut_params->op->sym->m_dst;
3363 if (ut_params->obuf)
3364 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3366 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3368 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3370 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3371 (tdata->validCipherOffsetInBits.len >> 3);
3373 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3375 reference_ciphertext,
3376 tdata->validCipherLenInBits.len,
3377 "KASUMI Ciphertext data not as expected");
3382 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3384 struct crypto_testsuite_params *ts_params = &testsuite_params;
3385 struct crypto_unittest_params *ut_params = &unittest_params;
3389 unsigned int plaintext_pad_len;
3390 unsigned int plaintext_len;
3392 uint8_t buffer[10000];
3393 const uint8_t *ciphertext;
3395 struct rte_cryptodev_info dev_info;
3397 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3399 uint64_t feat_flags = dev_info.feature_flags;
3401 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3402 printf("Device doesn't support in-place scatter-gather. "
3407 /* Create KASUMI session */
3408 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3409 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3410 RTE_CRYPTO_CIPHER_KASUMI_F8,
3411 tdata->key.data, tdata->key.len,
3412 tdata->cipher_iv.len);
3416 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3419 /* Append data which is padded to a multiple */
3420 /* of the algorithms block size */
3421 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3423 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3424 plaintext_pad_len, 10, 0);
3426 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3428 /* Create KASUMI operation */
3429 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3430 tdata->cipher_iv.len,
3431 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3432 tdata->validCipherOffsetInBits.len);
3436 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3438 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3440 ut_params->obuf = ut_params->op->sym->m_dst;
3442 if (ut_params->obuf)
3443 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3444 plaintext_len, buffer);
3446 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3447 tdata->validCipherOffsetInBits.len >> 3,
3448 plaintext_len, buffer);
3451 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3453 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3454 (tdata->validCipherOffsetInBits.len >> 3);
3456 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3458 reference_ciphertext,
3459 tdata->validCipherLenInBits.len,
3460 "KASUMI Ciphertext data not as expected");
3465 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3467 struct crypto_testsuite_params *ts_params = &testsuite_params;
3468 struct crypto_unittest_params *ut_params = &unittest_params;
3471 uint8_t *plaintext, *ciphertext;
3472 unsigned plaintext_pad_len;
3473 unsigned plaintext_len;
3475 /* Create KASUMI session */
3476 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3477 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3478 RTE_CRYPTO_CIPHER_KASUMI_F8,
3479 tdata->key.data, tdata->key.len,
3480 tdata->cipher_iv.len);
3484 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3485 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3487 /* Clear mbuf payload */
3488 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3489 rte_pktmbuf_tailroom(ut_params->ibuf));
3491 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3492 /* Append data which is padded to a multiple */
3493 /* of the algorithms block size */
3494 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3495 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3497 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3498 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3500 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3502 /* Create KASUMI operation */
3503 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3504 tdata->cipher_iv.len,
3505 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3506 tdata->validCipherOffsetInBits.len);
3510 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3512 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3514 ut_params->obuf = ut_params->op->sym->m_dst;
3515 if (ut_params->obuf)
3516 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3518 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3520 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3522 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3523 (tdata->validCipherOffsetInBits.len >> 3);
3525 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3527 reference_ciphertext,
3528 tdata->validCipherLenInBits.len,
3529 "KASUMI Ciphertext data not as expected");
3534 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3536 struct crypto_testsuite_params *ts_params = &testsuite_params;
3537 struct crypto_unittest_params *ut_params = &unittest_params;
3540 unsigned int plaintext_pad_len;
3541 unsigned int plaintext_len;
3543 const uint8_t *ciphertext;
3544 uint8_t buffer[2048];
3546 struct rte_cryptodev_info dev_info;
3548 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3550 uint64_t feat_flags = dev_info.feature_flags;
3551 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3552 printf("Device doesn't support out-of-place scatter-gather "
3553 "in both input and output mbufs. "
3558 /* Create KASUMI session */
3559 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3560 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3561 RTE_CRYPTO_CIPHER_KASUMI_F8,
3562 tdata->key.data, tdata->key.len,
3563 tdata->cipher_iv.len);
3567 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3568 /* Append data which is padded to a multiple */
3569 /* of the algorithms block size */
3570 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3572 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3573 plaintext_pad_len, 10, 0);
3574 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3575 plaintext_pad_len, 3, 0);
3577 /* Append data which is padded to a multiple */
3578 /* of the algorithms block size */
3579 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3581 /* Create KASUMI operation */
3582 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3583 tdata->cipher_iv.len,
3584 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3585 tdata->validCipherOffsetInBits.len);
3589 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3591 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3593 ut_params->obuf = ut_params->op->sym->m_dst;
3594 if (ut_params->obuf)
3595 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3596 plaintext_pad_len, buffer);
3598 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3599 tdata->validCipherOffsetInBits.len >> 3,
3600 plaintext_pad_len, buffer);
3602 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3603 (tdata->validCipherOffsetInBits.len >> 3);
3605 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3607 reference_ciphertext,
3608 tdata->validCipherLenInBits.len,
3609 "KASUMI Ciphertext data not as expected");
3615 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3617 struct crypto_testsuite_params *ts_params = &testsuite_params;
3618 struct crypto_unittest_params *ut_params = &unittest_params;
3621 uint8_t *ciphertext, *plaintext;
3622 unsigned ciphertext_pad_len;
3623 unsigned ciphertext_len;
3625 /* Create KASUMI session */
3626 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3627 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3628 RTE_CRYPTO_CIPHER_KASUMI_F8,
3629 tdata->key.data, tdata->key.len,
3630 tdata->cipher_iv.len);
3634 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3635 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3637 /* Clear mbuf payload */
3638 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3639 rte_pktmbuf_tailroom(ut_params->ibuf));
3641 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3642 /* Append data which is padded to a multiple */
3643 /* of the algorithms block size */
3644 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3645 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3646 ciphertext_pad_len);
3647 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3648 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3650 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3652 /* Create KASUMI operation */
3653 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3654 tdata->cipher_iv.len,
3655 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3656 tdata->validCipherOffsetInBits.len);
3660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3662 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3664 ut_params->obuf = ut_params->op->sym->m_dst;
3665 if (ut_params->obuf)
3666 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3668 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3670 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3672 const uint8_t *reference_plaintext = tdata->plaintext.data +
3673 (tdata->validCipherOffsetInBits.len >> 3);
3675 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3677 reference_plaintext,
3678 tdata->validCipherLenInBits.len,
3679 "KASUMI Plaintext data not as expected");
3684 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3686 struct crypto_testsuite_params *ts_params = &testsuite_params;
3687 struct crypto_unittest_params *ut_params = &unittest_params;
3690 uint8_t *ciphertext, *plaintext;
3691 unsigned ciphertext_pad_len;
3692 unsigned ciphertext_len;
3694 /* Create KASUMI session */
3695 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3696 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3697 RTE_CRYPTO_CIPHER_KASUMI_F8,
3698 tdata->key.data, tdata->key.len,
3699 tdata->cipher_iv.len);
3703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3705 /* Clear mbuf payload */
3706 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3707 rte_pktmbuf_tailroom(ut_params->ibuf));
3709 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3710 /* Append data which is padded to a multiple */
3711 /* of the algorithms block size */
3712 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3713 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3714 ciphertext_pad_len);
3715 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3717 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3719 /* Create KASUMI operation */
3720 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3721 tdata->cipher_iv.len,
3722 tdata->ciphertext.len,
3723 tdata->validCipherOffsetInBits.len);
3727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3729 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3731 ut_params->obuf = ut_params->op->sym->m_dst;
3732 if (ut_params->obuf)
3733 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3735 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3737 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3739 const uint8_t *reference_plaintext = tdata->plaintext.data +
3740 (tdata->validCipherOffsetInBits.len >> 3);
3742 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3744 reference_plaintext,
3745 tdata->validCipherLenInBits.len,
3746 "KASUMI Plaintext data not as expected");
3751 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3753 struct crypto_testsuite_params *ts_params = &testsuite_params;
3754 struct crypto_unittest_params *ut_params = &unittest_params;
3757 uint8_t *plaintext, *ciphertext;
3758 unsigned plaintext_pad_len;
3759 unsigned plaintext_len;
3761 /* Create SNOW 3G session */
3762 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3763 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3764 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3765 tdata->key.data, tdata->key.len,
3766 tdata->cipher_iv.len);
3770 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3772 /* Clear mbuf payload */
3773 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3774 rte_pktmbuf_tailroom(ut_params->ibuf));
3776 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3777 /* Append data which is padded to a multiple of */
3778 /* the algorithms block size */
3779 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3780 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3782 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3784 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3786 /* Create SNOW 3G operation */
3787 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3788 tdata->cipher_iv.len,
3789 tdata->validCipherLenInBits.len,
3794 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3796 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3798 ut_params->obuf = ut_params->op->sym->m_dst;
3799 if (ut_params->obuf)
3800 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3802 ciphertext = plaintext;
3804 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3807 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3809 tdata->ciphertext.data,
3810 tdata->validDataLenInBits.len,
3811 "SNOW 3G Ciphertext data not as expected");
3817 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3819 struct crypto_testsuite_params *ts_params = &testsuite_params;
3820 struct crypto_unittest_params *ut_params = &unittest_params;
3821 uint8_t *plaintext, *ciphertext;
3824 unsigned plaintext_pad_len;
3825 unsigned plaintext_len;
3827 /* Create SNOW 3G session */
3828 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3829 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3830 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3831 tdata->key.data, tdata->key.len,
3832 tdata->cipher_iv.len);
3836 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3837 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3839 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3840 "Failed to allocate input buffer in mempool");
3841 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3842 "Failed to allocate output buffer in mempool");
3844 /* Clear mbuf payload */
3845 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3846 rte_pktmbuf_tailroom(ut_params->ibuf));
3848 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3849 /* Append data which is padded to a multiple of */
3850 /* the algorithms block size */
3851 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3852 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3854 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3855 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3857 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3859 /* Create SNOW 3G operation */
3860 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3861 tdata->cipher_iv.len,
3862 tdata->validCipherLenInBits.len,
3867 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3869 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3871 ut_params->obuf = ut_params->op->sym->m_dst;
3872 if (ut_params->obuf)
3873 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3875 ciphertext = plaintext;
3877 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3880 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3882 tdata->ciphertext.data,
3883 tdata->validDataLenInBits.len,
3884 "SNOW 3G Ciphertext data not as expected");
3889 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3891 struct crypto_testsuite_params *ts_params = &testsuite_params;
3892 struct crypto_unittest_params *ut_params = &unittest_params;
3895 unsigned int plaintext_pad_len;
3896 unsigned int plaintext_len;
3897 uint8_t buffer[10000];
3898 const uint8_t *ciphertext;
3900 struct rte_cryptodev_info dev_info;
3902 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3904 uint64_t feat_flags = dev_info.feature_flags;
3906 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3907 printf("Device doesn't support out-of-place scatter-gather "
3908 "in both input and output mbufs. "
3913 /* Create SNOW 3G session */
3914 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3915 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3916 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3917 tdata->key.data, tdata->key.len,
3918 tdata->cipher_iv.len);
3922 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3923 /* Append data which is padded to a multiple of */
3924 /* the algorithms block size */
3925 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3927 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3928 plaintext_pad_len, 10, 0);
3929 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3930 plaintext_pad_len, 3, 0);
3932 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3933 "Failed to allocate input buffer in mempool");
3934 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3935 "Failed to allocate output buffer in mempool");
3937 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3939 /* Create SNOW 3G operation */
3940 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3941 tdata->cipher_iv.len,
3942 tdata->validCipherLenInBits.len,
3947 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3951 ut_params->obuf = ut_params->op->sym->m_dst;
3952 if (ut_params->obuf)
3953 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3954 plaintext_len, buffer);
3956 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3957 plaintext_len, buffer);
3959 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3962 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3964 tdata->ciphertext.data,
3965 tdata->validDataLenInBits.len,
3966 "SNOW 3G Ciphertext data not as expected");
3971 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3973 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3975 uint8_t curr_byte, prev_byte;
3976 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3977 uint8_t lower_byte_mask = (1 << offset) - 1;
3980 prev_byte = buffer[0];
3981 buffer[0] >>= offset;
3983 for (i = 1; i < length_in_bytes; i++) {
3984 curr_byte = buffer[i];
3985 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3986 (curr_byte >> offset);
3987 prev_byte = curr_byte;
3992 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3994 struct crypto_testsuite_params *ts_params = &testsuite_params;
3995 struct crypto_unittest_params *ut_params = &unittest_params;
3996 uint8_t *plaintext, *ciphertext;
3998 uint32_t plaintext_len;
3999 uint32_t plaintext_pad_len;
4000 uint8_t extra_offset = 4;
4001 uint8_t *expected_ciphertext_shifted;
4003 /* Create SNOW 3G session */
4004 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4005 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4006 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4007 tdata->key.data, tdata->key.len,
4008 tdata->cipher_iv.len);
4012 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4013 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4015 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4016 "Failed to allocate input buffer in mempool");
4017 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4018 "Failed to allocate output buffer in mempool");
4020 /* Clear mbuf payload */
4021 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4022 rte_pktmbuf_tailroom(ut_params->ibuf));
4024 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4026 * Append data which is padded to a
4027 * multiple of the algorithms block size
4029 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4031 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4034 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4036 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4037 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4039 #ifdef RTE_APP_TEST_DEBUG
4040 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4042 /* Create SNOW 3G operation */
4043 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4044 tdata->cipher_iv.len,
4045 tdata->validCipherLenInBits.len,
4050 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4052 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4054 ut_params->obuf = ut_params->op->sym->m_dst;
4055 if (ut_params->obuf)
4056 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4058 ciphertext = plaintext;
4060 #ifdef RTE_APP_TEST_DEBUG
4061 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4064 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4066 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4067 "failed to reserve memory for ciphertext shifted\n");
4069 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4070 ceil_byte_length(tdata->ciphertext.len));
4071 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4074 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4076 expected_ciphertext_shifted,
4077 tdata->validDataLenInBits.len,
4079 "SNOW 3G Ciphertext data not as expected");
4083 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4085 struct crypto_testsuite_params *ts_params = &testsuite_params;
4086 struct crypto_unittest_params *ut_params = &unittest_params;
4090 uint8_t *plaintext, *ciphertext;
4091 unsigned ciphertext_pad_len;
4092 unsigned ciphertext_len;
4094 /* Create SNOW 3G session */
4095 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4096 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4097 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4098 tdata->key.data, tdata->key.len,
4099 tdata->cipher_iv.len);
4103 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4105 /* Clear mbuf payload */
4106 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4107 rte_pktmbuf_tailroom(ut_params->ibuf));
4109 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4110 /* Append data which is padded to a multiple of */
4111 /* the algorithms block size */
4112 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4113 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4114 ciphertext_pad_len);
4115 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4117 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4119 /* Create SNOW 3G operation */
4120 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4121 tdata->cipher_iv.len,
4122 tdata->validCipherLenInBits.len,
4123 tdata->cipher.offset_bits);
4127 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4129 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4130 ut_params->obuf = ut_params->op->sym->m_dst;
4131 if (ut_params->obuf)
4132 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4134 plaintext = ciphertext;
4136 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4139 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4140 tdata->plaintext.data,
4141 tdata->validDataLenInBits.len,
4142 "SNOW 3G Plaintext data not as expected");
4146 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4148 struct crypto_testsuite_params *ts_params = &testsuite_params;
4149 struct crypto_unittest_params *ut_params = &unittest_params;
4153 uint8_t *plaintext, *ciphertext;
4154 unsigned ciphertext_pad_len;
4155 unsigned ciphertext_len;
4157 /* Create SNOW 3G session */
4158 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4159 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4160 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4161 tdata->key.data, tdata->key.len,
4162 tdata->cipher_iv.len);
4166 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4167 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4169 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4170 "Failed to allocate input buffer");
4171 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4172 "Failed to allocate output buffer");
4174 /* Clear mbuf payload */
4175 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4176 rte_pktmbuf_tailroom(ut_params->ibuf));
4178 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4179 rte_pktmbuf_tailroom(ut_params->obuf));
4181 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4182 /* Append data which is padded to a multiple of */
4183 /* the algorithms block size */
4184 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4185 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4186 ciphertext_pad_len);
4187 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4188 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4190 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4192 /* Create SNOW 3G operation */
4193 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4194 tdata->cipher_iv.len,
4195 tdata->validCipherLenInBits.len,
4200 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4202 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4203 ut_params->obuf = ut_params->op->sym->m_dst;
4204 if (ut_params->obuf)
4205 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4207 plaintext = ciphertext;
4209 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4212 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4213 tdata->plaintext.data,
4214 tdata->validDataLenInBits.len,
4215 "SNOW 3G Plaintext data not as expected");
4220 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4222 struct crypto_testsuite_params *ts_params = &testsuite_params;
4223 struct crypto_unittest_params *ut_params = &unittest_params;
4227 uint8_t *plaintext, *ciphertext;
4228 unsigned int plaintext_pad_len;
4229 unsigned int plaintext_len;
4231 struct rte_cryptodev_sym_capability_idx cap_idx;
4233 /* Check if device supports ZUC EEA3 */
4234 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4235 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4237 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4241 /* Check if device supports ZUC EIA3 */
4242 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4243 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4245 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4249 /* Create ZUC session */
4250 retval = create_zuc_cipher_auth_encrypt_generate_session(
4251 ts_params->valid_devs[0],
4255 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4257 /* clear mbuf payload */
4258 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4259 rte_pktmbuf_tailroom(ut_params->ibuf));
4261 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4262 /* Append data which is padded to a multiple of */
4263 /* the algorithms block size */
4264 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4265 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4267 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4269 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4271 /* Create ZUC operation */
4272 retval = create_zuc_cipher_hash_generate_operation(tdata);
4276 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4278 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4279 ut_params->obuf = ut_params->op->sym->m_src;
4280 if (ut_params->obuf)
4281 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4283 ciphertext = plaintext;
4285 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4289 tdata->ciphertext.data,
4290 tdata->validDataLenInBits.len,
4291 "ZUC Ciphertext data not as expected");
4293 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4294 + plaintext_pad_len;
4297 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4301 "ZUC Generated auth tag not as expected");
4306 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4308 struct crypto_testsuite_params *ts_params = &testsuite_params;
4309 struct crypto_unittest_params *ut_params = &unittest_params;
4313 uint8_t *plaintext, *ciphertext;
4314 unsigned plaintext_pad_len;
4315 unsigned plaintext_len;
4317 /* Create SNOW 3G session */
4318 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4319 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4320 RTE_CRYPTO_AUTH_OP_GENERATE,
4321 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4322 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4323 tdata->key.data, tdata->key.len,
4324 tdata->auth_iv.len, tdata->digest.len,
4325 tdata->cipher_iv.len);
4328 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4330 /* clear mbuf payload */
4331 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4332 rte_pktmbuf_tailroom(ut_params->ibuf));
4334 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4335 /* Append data which is padded to a multiple of */
4336 /* the algorithms block size */
4337 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4338 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4340 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4342 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4344 /* Create SNOW 3G operation */
4345 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4346 tdata->digest.len, tdata->auth_iv.data,
4348 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4349 tdata->cipher_iv.data, tdata->cipher_iv.len,
4350 tdata->validCipherLenInBits.len,
4352 tdata->validAuthLenInBits.len,
4358 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4360 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4361 ut_params->obuf = ut_params->op->sym->m_src;
4362 if (ut_params->obuf)
4363 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4365 ciphertext = plaintext;
4367 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4369 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4371 tdata->ciphertext.data,
4372 tdata->validDataLenInBits.len,
4373 "SNOW 3G Ciphertext data not as expected");
4375 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4376 + plaintext_pad_len;
4379 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4382 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4383 "SNOW 3G Generated auth tag not as expected");
4388 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4389 uint8_t op_mode, uint8_t verify)
4391 struct crypto_testsuite_params *ts_params = &testsuite_params;
4392 struct crypto_unittest_params *ut_params = &unittest_params;
4396 uint8_t *plaintext = NULL, *ciphertext = NULL;
4397 unsigned int plaintext_pad_len;
4398 unsigned int plaintext_len;
4399 unsigned int ciphertext_pad_len;
4400 unsigned int ciphertext_len;
4402 struct rte_cryptodev_info dev_info;
4404 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4406 uint64_t feat_flags = dev_info.feature_flags;
4408 if (op_mode == OUT_OF_PLACE) {
4409 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4410 printf("Device doesn't support digest encrypted.\n");
4415 /* Create SNOW 3G session */
4416 retval = create_wireless_algo_auth_cipher_session(
4417 ts_params->valid_devs[0],
4418 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4419 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4420 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4421 : RTE_CRYPTO_AUTH_OP_GENERATE),
4422 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4423 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4424 tdata->key.data, tdata->key.len,
4425 tdata->auth_iv.len, tdata->digest.len,
4426 tdata->cipher_iv.len);
4431 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4432 if (op_mode == OUT_OF_PLACE)
4433 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4435 /* clear mbuf payload */
4436 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4437 rte_pktmbuf_tailroom(ut_params->ibuf));
4438 if (op_mode == OUT_OF_PLACE)
4439 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4440 rte_pktmbuf_tailroom(ut_params->obuf));
4442 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4443 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4444 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4445 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4448 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4449 ciphertext_pad_len);
4450 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4451 if (op_mode == OUT_OF_PLACE)
4452 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4453 debug_hexdump(stdout, "ciphertext:", ciphertext,
4456 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4458 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4459 if (op_mode == OUT_OF_PLACE)
4460 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4461 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4464 /* Create SNOW 3G operation */
4465 retval = create_wireless_algo_auth_cipher_operation(
4467 tdata->cipher_iv.data, tdata->cipher_iv.len,
4468 tdata->auth_iv.data, tdata->auth_iv.len,
4469 (tdata->digest.offset_bytes == 0 ?
4470 (verify ? ciphertext_pad_len : plaintext_pad_len)
4471 : tdata->digest.offset_bytes),
4472 tdata->validCipherLenInBits.len,
4473 tdata->cipher.offset_bits,
4474 tdata->validAuthLenInBits.len,
4475 tdata->auth.offset_bits,
4481 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4484 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4486 ut_params->obuf = (op_mode == IN_PLACE ?
4487 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4490 if (ut_params->obuf)
4491 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4494 plaintext = ciphertext +
4495 (tdata->cipher.offset_bits >> 3);
4497 debug_hexdump(stdout, "plaintext:", plaintext,
4498 (tdata->plaintext.len >> 3) - tdata->digest.len);
4499 debug_hexdump(stdout, "plaintext expected:",
4500 tdata->plaintext.data,
4501 (tdata->plaintext.len >> 3) - tdata->digest.len);
4503 if (ut_params->obuf)
4504 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4507 ciphertext = plaintext;
4509 debug_hexdump(stdout, "ciphertext:", ciphertext,
4511 debug_hexdump(stdout, "ciphertext expected:",
4512 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4514 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4515 + (tdata->digest.offset_bytes == 0 ?
4516 plaintext_pad_len : tdata->digest.offset_bytes);
4518 debug_hexdump(stdout, "digest:", ut_params->digest,
4520 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4526 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4528 tdata->plaintext.data,
4529 tdata->plaintext.len >> 3,
4530 "SNOW 3G Plaintext data not as expected");
4532 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4534 tdata->ciphertext.data,
4535 tdata->validDataLenInBits.len,
4536 "SNOW 3G Ciphertext data not as expected");
4538 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4541 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4542 "SNOW 3G Generated auth tag not as expected");
4548 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4549 uint8_t op_mode, uint8_t verify)
4551 struct crypto_testsuite_params *ts_params = &testsuite_params;
4552 struct crypto_unittest_params *ut_params = &unittest_params;
4556 uint8_t *plaintext = NULL, *ciphertext = NULL;
4557 unsigned int plaintext_pad_len;
4558 unsigned int plaintext_len;
4559 unsigned int ciphertext_pad_len;
4560 unsigned int ciphertext_len;
4562 struct rte_cryptodev_info dev_info;
4564 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4566 uint64_t feat_flags = dev_info.feature_flags;
4568 if (op_mode == OUT_OF_PLACE) {
4569 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4570 printf("Device doesn't support digest encrypted.\n");
4575 /* Create KASUMI session */
4576 retval = create_wireless_algo_auth_cipher_session(
4577 ts_params->valid_devs[0],
4578 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4579 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4580 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4581 : RTE_CRYPTO_AUTH_OP_GENERATE),
4582 RTE_CRYPTO_AUTH_KASUMI_F9,
4583 RTE_CRYPTO_CIPHER_KASUMI_F8,
4584 tdata->key.data, tdata->key.len,
4585 0, tdata->digest.len,
4586 tdata->cipher_iv.len);
4591 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4592 if (op_mode == OUT_OF_PLACE)
4593 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4595 /* clear mbuf payload */
4596 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4597 rte_pktmbuf_tailroom(ut_params->ibuf));
4598 if (op_mode == OUT_OF_PLACE)
4599 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4600 rte_pktmbuf_tailroom(ut_params->obuf));
4602 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4603 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4604 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4605 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4608 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4609 ciphertext_pad_len);
4610 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4611 if (op_mode == OUT_OF_PLACE)
4612 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4613 debug_hexdump(stdout, "ciphertext:", ciphertext,
4616 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4618 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4619 if (op_mode == OUT_OF_PLACE)
4620 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4621 debug_hexdump(stdout, "plaintext:", plaintext,
4625 /* Create KASUMI operation */
4626 retval = create_wireless_algo_auth_cipher_operation(
4628 tdata->cipher_iv.data, tdata->cipher_iv.len,
4630 (tdata->digest.offset_bytes == 0 ?
4631 (verify ? ciphertext_pad_len : plaintext_pad_len)
4632 : tdata->digest.offset_bytes),
4633 tdata->validCipherLenInBits.len,
4634 tdata->validCipherOffsetInBits.len,
4635 tdata->validAuthLenInBits.len,
4642 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4645 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4647 ut_params->obuf = (op_mode == IN_PLACE ?
4648 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4652 if (ut_params->obuf)
4653 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4656 plaintext = ciphertext;
4658 debug_hexdump(stdout, "plaintext:", plaintext,
4659 (tdata->plaintext.len >> 3) - tdata->digest.len);
4660 debug_hexdump(stdout, "plaintext expected:",
4661 tdata->plaintext.data,
4662 (tdata->plaintext.len >> 3) - tdata->digest.len);
4664 if (ut_params->obuf)
4665 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4668 ciphertext = plaintext;
4670 debug_hexdump(stdout, "ciphertext:", ciphertext,
4672 debug_hexdump(stdout, "ciphertext expected:",
4673 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4675 ut_params->digest = rte_pktmbuf_mtod(
4676 ut_params->obuf, uint8_t *) +
4677 (tdata->digest.offset_bytes == 0 ?
4678 plaintext_pad_len : tdata->digest.offset_bytes);
4680 debug_hexdump(stdout, "digest:", ut_params->digest,
4682 debug_hexdump(stdout, "digest expected:",
4683 tdata->digest.data, tdata->digest.len);
4688 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4690 tdata->plaintext.data,
4691 tdata->plaintext.len >> 3,
4692 "KASUMI Plaintext data not as expected");
4694 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4696 tdata->ciphertext.data,
4697 tdata->ciphertext.len >> 3,
4698 "KASUMI Ciphertext data not as expected");
4700 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4703 DIGEST_BYTE_LENGTH_KASUMI_F9,
4704 "KASUMI Generated auth tag not as expected");
4710 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4712 struct crypto_testsuite_params *ts_params = &testsuite_params;
4713 struct crypto_unittest_params *ut_params = &unittest_params;
4717 uint8_t *plaintext, *ciphertext;
4718 unsigned plaintext_pad_len;
4719 unsigned plaintext_len;
4721 /* Create KASUMI session */
4722 retval = create_wireless_algo_cipher_auth_session(
4723 ts_params->valid_devs[0],
4724 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4725 RTE_CRYPTO_AUTH_OP_GENERATE,
4726 RTE_CRYPTO_AUTH_KASUMI_F9,
4727 RTE_CRYPTO_CIPHER_KASUMI_F8,
4728 tdata->key.data, tdata->key.len,
4729 0, tdata->digest.len,
4730 tdata->cipher_iv.len);
4734 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4736 /* clear mbuf payload */
4737 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4738 rte_pktmbuf_tailroom(ut_params->ibuf));
4740 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4741 /* Append data which is padded to a multiple of */
4742 /* the algorithms block size */
4743 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4744 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4746 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4748 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4750 /* Create KASUMI operation */
4751 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4752 tdata->digest.len, NULL, 0,
4753 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4754 tdata->cipher_iv.data, tdata->cipher_iv.len,
4755 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4756 tdata->validCipherOffsetInBits.len,
4757 tdata->validAuthLenInBits.len,
4763 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4765 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4767 if (ut_params->op->sym->m_dst)
4768 ut_params->obuf = ut_params->op->sym->m_dst;
4770 ut_params->obuf = ut_params->op->sym->m_src;
4772 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4773 tdata->validCipherOffsetInBits.len >> 3);
4775 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4776 + plaintext_pad_len;
4778 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4779 (tdata->validCipherOffsetInBits.len >> 3);
4781 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4783 reference_ciphertext,
4784 tdata->validCipherLenInBits.len,
4785 "KASUMI Ciphertext data not as expected");
4788 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4791 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4792 "KASUMI Generated auth tag not as expected");
4797 test_zuc_encryption(const struct wireless_test_data *tdata)
4799 struct crypto_testsuite_params *ts_params = &testsuite_params;
4800 struct crypto_unittest_params *ut_params = &unittest_params;
4803 uint8_t *plaintext, *ciphertext;
4804 unsigned plaintext_pad_len;
4805 unsigned plaintext_len;
4807 struct rte_cryptodev_sym_capability_idx cap_idx;
4809 /* Check if device supports ZUC EEA3 */
4810 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4811 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4813 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4817 /* Create ZUC session */
4818 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4819 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4820 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4821 tdata->key.data, tdata->key.len,
4822 tdata->cipher_iv.len);
4826 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4828 /* Clear mbuf payload */
4829 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4830 rte_pktmbuf_tailroom(ut_params->ibuf));
4832 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4833 /* Append data which is padded to a multiple */
4834 /* of the algorithms block size */
4835 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4836 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4838 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4840 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4842 /* Create ZUC operation */
4843 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4844 tdata->cipher_iv.len,
4845 tdata->plaintext.len,
4850 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4852 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4854 ut_params->obuf = ut_params->op->sym->m_dst;
4855 if (ut_params->obuf)
4856 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4858 ciphertext = plaintext;
4860 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4863 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4865 tdata->ciphertext.data,
4866 tdata->validCipherLenInBits.len,
4867 "ZUC Ciphertext data not as expected");
4872 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4874 struct crypto_testsuite_params *ts_params = &testsuite_params;
4875 struct crypto_unittest_params *ut_params = &unittest_params;
4879 unsigned int plaintext_pad_len;
4880 unsigned int plaintext_len;
4881 const uint8_t *ciphertext;
4882 uint8_t ciphertext_buffer[2048];
4883 struct rte_cryptodev_info dev_info;
4885 struct rte_cryptodev_sym_capability_idx cap_idx;
4887 /* Check if device supports ZUC EEA3 */
4888 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4889 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4891 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4895 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4897 uint64_t feat_flags = dev_info.feature_flags;
4899 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4900 printf("Device doesn't support in-place scatter-gather. "
4905 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4907 /* Append data which is padded to a multiple */
4908 /* of the algorithms block size */
4909 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4911 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4912 plaintext_pad_len, 10, 0);
4914 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4915 tdata->plaintext.data);
4917 /* Create ZUC session */
4918 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4919 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4920 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4921 tdata->key.data, tdata->key.len,
4922 tdata->cipher_iv.len);
4926 /* Clear mbuf payload */
4928 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4930 /* Create ZUC operation */
4931 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4932 tdata->cipher_iv.len, tdata->plaintext.len,
4937 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4939 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4941 ut_params->obuf = ut_params->op->sym->m_dst;
4942 if (ut_params->obuf)
4943 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4944 0, plaintext_len, ciphertext_buffer);
4946 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4947 0, plaintext_len, ciphertext_buffer);
4950 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4953 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4955 tdata->ciphertext.data,
4956 tdata->validCipherLenInBits.len,
4957 "ZUC Ciphertext data not as expected");
4963 test_zuc_authentication(const struct wireless_test_data *tdata)
4965 struct crypto_testsuite_params *ts_params = &testsuite_params;
4966 struct crypto_unittest_params *ut_params = &unittest_params;
4969 unsigned plaintext_pad_len;
4970 unsigned plaintext_len;
4973 struct rte_cryptodev_sym_capability_idx cap_idx;
4975 /* Check if device supports ZUC EIA3 */
4976 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4977 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4979 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4983 /* Create ZUC session */
4984 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4985 tdata->key.data, tdata->key.len,
4986 tdata->auth_iv.len, tdata->digest.len,
4987 RTE_CRYPTO_AUTH_OP_GENERATE,
4988 RTE_CRYPTO_AUTH_ZUC_EIA3);
4992 /* alloc mbuf and set payload */
4993 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4995 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4996 rte_pktmbuf_tailroom(ut_params->ibuf));
4998 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4999 /* Append data which is padded to a multiple of */
5000 /* the algorithms block size */
5001 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5002 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5004 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5006 /* Create ZUC operation */
5007 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5008 tdata->auth_iv.data, tdata->auth_iv.len,
5009 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5010 tdata->validAuthLenInBits.len,
5015 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5017 ut_params->obuf = ut_params->op->sym->m_src;
5018 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5019 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5020 + plaintext_pad_len;
5023 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5026 DIGEST_BYTE_LENGTH_KASUMI_F9,
5027 "ZUC Generated auth tag not as expected");
5033 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5034 uint8_t op_mode, uint8_t verify)
5036 struct crypto_testsuite_params *ts_params = &testsuite_params;
5037 struct crypto_unittest_params *ut_params = &unittest_params;
5041 uint8_t *plaintext = NULL, *ciphertext = NULL;
5042 unsigned int plaintext_pad_len;
5043 unsigned int plaintext_len;
5044 unsigned int ciphertext_pad_len;
5045 unsigned int ciphertext_len;
5047 struct rte_cryptodev_info dev_info;
5049 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5051 uint64_t feat_flags = dev_info.feature_flags;
5053 if (op_mode == OUT_OF_PLACE) {
5054 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5055 printf("Device doesn't support digest encrypted.\n");
5060 /* Create KASUMI session */
5061 retval = create_wireless_algo_auth_cipher_session(
5062 ts_params->valid_devs[0],
5063 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5064 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5065 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5066 : RTE_CRYPTO_AUTH_OP_GENERATE),
5067 RTE_CRYPTO_AUTH_ZUC_EIA3,
5068 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5069 tdata->key.data, tdata->key.len,
5070 tdata->auth_iv.len, tdata->digest.len,
5071 tdata->cipher_iv.len);
5076 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5077 if (op_mode == OUT_OF_PLACE)
5078 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5080 /* clear mbuf payload */
5081 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5082 rte_pktmbuf_tailroom(ut_params->ibuf));
5083 if (op_mode == OUT_OF_PLACE)
5084 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5085 rte_pktmbuf_tailroom(ut_params->obuf));
5087 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5088 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5089 /* Append data which is padded to a multiple of */
5090 /* the algorithms block size */
5091 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5092 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5095 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5096 ciphertext_pad_len);
5097 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5098 if (op_mode == OUT_OF_PLACE)
5099 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5100 debug_hexdump(stdout, "ciphertext:", ciphertext,
5103 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5105 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5106 if (op_mode == OUT_OF_PLACE)
5107 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5108 debug_hexdump(stdout, "plaintext:", plaintext,
5112 /* Create ZUC operation */
5113 retval = create_wireless_algo_auth_cipher_operation(
5115 tdata->cipher_iv.data, tdata->cipher_iv.len,
5116 tdata->auth_iv.data, tdata->auth_iv.len,
5117 (tdata->digest.offset_bytes == 0 ?
5118 (verify ? ciphertext_pad_len : plaintext_pad_len)
5119 : tdata->digest.offset_bytes),
5120 tdata->validCipherLenInBits.len,
5121 tdata->validCipherOffsetInBits.len,
5122 tdata->validAuthLenInBits.len,
5129 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5132 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5134 ut_params->obuf = (op_mode == IN_PLACE ?
5135 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5139 if (ut_params->obuf)
5140 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5143 plaintext = ciphertext;
5145 debug_hexdump(stdout, "plaintext:", plaintext,
5146 (tdata->plaintext.len >> 3) - tdata->digest.len);
5147 debug_hexdump(stdout, "plaintext expected:",
5148 tdata->plaintext.data,
5149 (tdata->plaintext.len >> 3) - tdata->digest.len);
5151 if (ut_params->obuf)
5152 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5155 ciphertext = plaintext;
5157 debug_hexdump(stdout, "ciphertext:", ciphertext,
5159 debug_hexdump(stdout, "ciphertext expected:",
5160 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5162 ut_params->digest = rte_pktmbuf_mtod(
5163 ut_params->obuf, uint8_t *) +
5164 (tdata->digest.offset_bytes == 0 ?
5165 plaintext_pad_len : tdata->digest.offset_bytes);
5167 debug_hexdump(stdout, "digest:", ut_params->digest,
5169 debug_hexdump(stdout, "digest expected:",
5170 tdata->digest.data, tdata->digest.len);
5175 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5177 tdata->plaintext.data,
5178 tdata->plaintext.len >> 3,
5179 "ZUC Plaintext data not as expected");
5181 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5183 tdata->ciphertext.data,
5184 tdata->ciphertext.len >> 3,
5185 "ZUC Ciphertext data not as expected");
5187 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5190 DIGEST_BYTE_LENGTH_KASUMI_F9,
5191 "ZUC Generated auth tag not as expected");
5197 test_kasumi_encryption_test_case_1(void)
5199 return test_kasumi_encryption(&kasumi_test_case_1);
5203 test_kasumi_encryption_test_case_1_sgl(void)
5205 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5209 test_kasumi_encryption_test_case_1_oop(void)
5211 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5215 test_kasumi_encryption_test_case_1_oop_sgl(void)
5217 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5221 test_kasumi_encryption_test_case_2(void)
5223 return test_kasumi_encryption(&kasumi_test_case_2);
5227 test_kasumi_encryption_test_case_3(void)
5229 return test_kasumi_encryption(&kasumi_test_case_3);
5233 test_kasumi_encryption_test_case_4(void)
5235 return test_kasumi_encryption(&kasumi_test_case_4);
5239 test_kasumi_encryption_test_case_5(void)
5241 return test_kasumi_encryption(&kasumi_test_case_5);
5245 test_kasumi_decryption_test_case_1(void)
5247 return test_kasumi_decryption(&kasumi_test_case_1);
5251 test_kasumi_decryption_test_case_1_oop(void)
5253 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5257 test_kasumi_decryption_test_case_2(void)
5259 return test_kasumi_decryption(&kasumi_test_case_2);
5263 test_kasumi_decryption_test_case_3(void)
5265 return test_kasumi_decryption(&kasumi_test_case_3);
5269 test_kasumi_decryption_test_case_4(void)
5271 return test_kasumi_decryption(&kasumi_test_case_4);
5275 test_kasumi_decryption_test_case_5(void)
5277 return test_kasumi_decryption(&kasumi_test_case_5);
5280 test_snow3g_encryption_test_case_1(void)
5282 return test_snow3g_encryption(&snow3g_test_case_1);
5286 test_snow3g_encryption_test_case_1_oop(void)
5288 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5292 test_snow3g_encryption_test_case_1_oop_sgl(void)
5294 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5299 test_snow3g_encryption_test_case_1_offset_oop(void)
5301 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5305 test_snow3g_encryption_test_case_2(void)
5307 return test_snow3g_encryption(&snow3g_test_case_2);
5311 test_snow3g_encryption_test_case_3(void)
5313 return test_snow3g_encryption(&snow3g_test_case_3);
5317 test_snow3g_encryption_test_case_4(void)
5319 return test_snow3g_encryption(&snow3g_test_case_4);
5323 test_snow3g_encryption_test_case_5(void)
5325 return test_snow3g_encryption(&snow3g_test_case_5);
5329 test_snow3g_decryption_test_case_1(void)
5331 return test_snow3g_decryption(&snow3g_test_case_1);
5335 test_snow3g_decryption_test_case_1_oop(void)
5337 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5341 test_snow3g_decryption_test_case_2(void)
5343 return test_snow3g_decryption(&snow3g_test_case_2);
5347 test_snow3g_decryption_test_case_3(void)
5349 return test_snow3g_decryption(&snow3g_test_case_3);
5353 test_snow3g_decryption_test_case_4(void)
5355 return test_snow3g_decryption(&snow3g_test_case_4);
5359 test_snow3g_decryption_test_case_5(void)
5361 return test_snow3g_decryption(&snow3g_test_case_5);
5365 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5366 * Pattern digest from snow3g_test_data must be allocated as
5367 * 4 last bytes in plaintext.
5370 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5371 struct snow3g_hash_test_data *output)
5373 if ((pattern != NULL) && (output != NULL)) {
5374 output->key.len = pattern->key.len;
5376 memcpy(output->key.data,
5377 pattern->key.data, pattern->key.len);
5379 output->auth_iv.len = pattern->auth_iv.len;
5381 memcpy(output->auth_iv.data,
5382 pattern->auth_iv.data, pattern->auth_iv.len);
5384 output->plaintext.len = pattern->plaintext.len;
5386 memcpy(output->plaintext.data,
5387 pattern->plaintext.data, pattern->plaintext.len >> 3);
5389 output->digest.len = pattern->digest.len;
5391 memcpy(output->digest.data,
5392 &pattern->plaintext.data[pattern->digest.offset_bytes],
5393 pattern->digest.len);
5395 output->validAuthLenInBits.len =
5396 pattern->validAuthLenInBits.len;
5401 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5404 test_snow3g_decryption_with_digest_test_case_1(void)
5406 struct snow3g_hash_test_data snow3g_hash_data;
5409 * Function prepare data for hash veryfication test case.
5410 * Digest is allocated in 4 last bytes in plaintext, pattern.
5412 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5414 return test_snow3g_decryption(&snow3g_test_case_7) &
5415 test_snow3g_authentication_verify(&snow3g_hash_data);
5419 test_snow3g_cipher_auth_test_case_1(void)
5421 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5425 test_snow3g_auth_cipher_test_case_1(void)
5427 return test_snow3g_auth_cipher(
5428 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5432 test_snow3g_auth_cipher_test_case_2(void)
5434 return test_snow3g_auth_cipher(
5435 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5439 test_snow3g_auth_cipher_test_case_2_oop(void)
5441 return test_snow3g_auth_cipher(
5442 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5446 test_snow3g_auth_cipher_part_digest_enc(void)
5448 return test_snow3g_auth_cipher(
5449 &snow3g_auth_cipher_partial_digest_encryption,
5454 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5456 return test_snow3g_auth_cipher(
5457 &snow3g_auth_cipher_partial_digest_encryption,
5462 test_snow3g_auth_cipher_verify_test_case_1(void)
5464 return test_snow3g_auth_cipher(
5465 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5469 test_snow3g_auth_cipher_verify_test_case_2(void)
5471 return test_snow3g_auth_cipher(
5472 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5476 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5478 return test_snow3g_auth_cipher(
5479 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5483 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5485 return test_snow3g_auth_cipher(
5486 &snow3g_auth_cipher_partial_digest_encryption,
5491 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5493 return test_snow3g_auth_cipher(
5494 &snow3g_auth_cipher_partial_digest_encryption,
5499 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5501 return test_snow3g_auth_cipher(
5502 &snow3g_test_case_7, IN_PLACE, 0);
5506 test_kasumi_auth_cipher_test_case_1(void)
5508 return test_kasumi_auth_cipher(
5509 &kasumi_test_case_3, IN_PLACE, 0);
5513 test_kasumi_auth_cipher_test_case_2(void)
5515 return test_kasumi_auth_cipher(
5516 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5520 test_kasumi_auth_cipher_test_case_2_oop(void)
5522 return test_kasumi_auth_cipher(
5523 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5527 test_kasumi_auth_cipher_verify_test_case_1(void)
5529 return test_kasumi_auth_cipher(
5530 &kasumi_test_case_3, IN_PLACE, 1);
5534 test_kasumi_auth_cipher_verify_test_case_2(void)
5536 return test_kasumi_auth_cipher(
5537 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5541 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5543 return test_kasumi_auth_cipher(
5544 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5548 test_kasumi_cipher_auth_test_case_1(void)
5550 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5554 test_zuc_encryption_test_case_1(void)
5556 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5560 test_zuc_encryption_test_case_2(void)
5562 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5566 test_zuc_encryption_test_case_3(void)
5568 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5572 test_zuc_encryption_test_case_4(void)
5574 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5578 test_zuc_encryption_test_case_5(void)
5580 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5584 test_zuc_encryption_test_case_6_sgl(void)
5586 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5590 test_zuc_hash_generate_test_case_1(void)
5592 return test_zuc_authentication(&zuc_test_case_auth_1b);
5596 test_zuc_hash_generate_test_case_2(void)
5598 return test_zuc_authentication(&zuc_test_case_auth_90b);
5602 test_zuc_hash_generate_test_case_3(void)
5604 return test_zuc_authentication(&zuc_test_case_auth_577b);
5608 test_zuc_hash_generate_test_case_4(void)
5610 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5614 test_zuc_hash_generate_test_case_5(void)
5616 return test_zuc_authentication(&zuc_test_auth_5670b);
5620 test_zuc_hash_generate_test_case_6(void)
5622 return test_zuc_authentication(&zuc_test_case_auth_128b);
5626 test_zuc_hash_generate_test_case_7(void)
5628 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5632 test_zuc_hash_generate_test_case_8(void)
5634 return test_zuc_authentication(&zuc_test_case_auth_584b);
5638 test_zuc_cipher_auth_test_case_1(void)
5640 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5644 test_zuc_cipher_auth_test_case_2(void)
5646 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5650 test_zuc_auth_cipher_test_case_1(void)
5652 return test_zuc_auth_cipher(
5653 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
5657 test_zuc_auth_cipher_test_case_1_oop(void)
5659 return test_zuc_auth_cipher(
5660 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
5664 test_zuc_auth_cipher_verify_test_case_1(void)
5666 return test_zuc_auth_cipher(
5667 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
5671 test_zuc_auth_cipher_verify_test_case_1_oop(void)
5673 return test_zuc_auth_cipher(
5674 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
5678 test_3DES_chain_qat_all(void)
5680 struct crypto_testsuite_params *ts_params = &testsuite_params;
5683 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5684 ts_params->op_mpool,
5685 ts_params->session_mpool, ts_params->session_priv_mpool,
5686 ts_params->valid_devs[0],
5687 rte_cryptodev_driver_id_get(
5688 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5689 BLKCIPHER_3DES_CHAIN_TYPE);
5691 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5693 return TEST_SUCCESS;
5697 test_DES_cipheronly_qat_all(void)
5699 struct crypto_testsuite_params *ts_params = &testsuite_params;
5702 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5703 ts_params->op_mpool,
5704 ts_params->session_mpool, ts_params->session_priv_mpool,
5705 ts_params->valid_devs[0],
5706 rte_cryptodev_driver_id_get(
5707 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5708 BLKCIPHER_DES_CIPHERONLY_TYPE);
5710 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5712 return TEST_SUCCESS;
5716 test_DES_cipheronly_openssl_all(void)
5718 struct crypto_testsuite_params *ts_params = &testsuite_params;
5721 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5722 ts_params->op_mpool,
5723 ts_params->session_mpool, ts_params->session_priv_mpool,
5724 ts_params->valid_devs[0],
5725 rte_cryptodev_driver_id_get(
5726 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5727 BLKCIPHER_DES_CIPHERONLY_TYPE);
5729 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5731 return TEST_SUCCESS;
5735 test_DES_docsis_openssl_all(void)
5737 struct crypto_testsuite_params *ts_params = &testsuite_params;
5740 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5741 ts_params->op_mpool,
5742 ts_params->session_mpool, ts_params->session_priv_mpool,
5743 ts_params->valid_devs[0],
5744 rte_cryptodev_driver_id_get(
5745 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5746 BLKCIPHER_DES_DOCSIS_TYPE);
5748 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5750 return TEST_SUCCESS;
5754 test_DES_cipheronly_mb_all(void)
5756 struct crypto_testsuite_params *ts_params = &testsuite_params;
5759 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5760 ts_params->op_mpool,
5761 ts_params->session_mpool, ts_params->session_priv_mpool,
5762 ts_params->valid_devs[0],
5763 rte_cryptodev_driver_id_get(
5764 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5765 BLKCIPHER_DES_CIPHERONLY_TYPE);
5767 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5769 return TEST_SUCCESS;
5772 test_3DES_cipheronly_mb_all(void)
5774 struct crypto_testsuite_params *ts_params = &testsuite_params;
5777 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5778 ts_params->op_mpool,
5779 ts_params->session_mpool, ts_params->session_priv_mpool,
5780 ts_params->valid_devs[0],
5781 rte_cryptodev_driver_id_get(
5782 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5783 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5785 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5787 return TEST_SUCCESS;
5791 test_DES_docsis_mb_all(void)
5793 struct crypto_testsuite_params *ts_params = &testsuite_params;
5796 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5797 ts_params->op_mpool,
5798 ts_params->session_mpool, ts_params->session_priv_mpool,
5799 ts_params->valid_devs[0],
5800 rte_cryptodev_driver_id_get(
5801 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5802 BLKCIPHER_DES_DOCSIS_TYPE);
5804 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5806 return TEST_SUCCESS;
5810 test_3DES_chain_caam_jr_all(void)
5812 struct crypto_testsuite_params *ts_params = &testsuite_params;
5815 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5816 ts_params->op_mpool,
5817 ts_params->session_mpool, ts_params->session_priv_mpool,
5818 ts_params->valid_devs[0],
5819 rte_cryptodev_driver_id_get(
5820 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5821 BLKCIPHER_3DES_CHAIN_TYPE);
5823 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5825 return TEST_SUCCESS;
5829 test_3DES_cipheronly_caam_jr_all(void)
5831 struct crypto_testsuite_params *ts_params = &testsuite_params;
5834 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5835 ts_params->op_mpool,
5836 ts_params->session_mpool, ts_params->session_priv_mpool,
5837 ts_params->valid_devs[0],
5838 rte_cryptodev_driver_id_get(
5839 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5840 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5842 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5844 return TEST_SUCCESS;
5848 test_3DES_chain_dpaa_sec_all(void)
5850 struct crypto_testsuite_params *ts_params = &testsuite_params;
5853 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5854 ts_params->op_mpool,
5855 ts_params->session_mpool, ts_params->session_priv_mpool,
5856 ts_params->valid_devs[0],
5857 rte_cryptodev_driver_id_get(
5858 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5859 BLKCIPHER_3DES_CHAIN_TYPE);
5861 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5863 return TEST_SUCCESS;
5867 test_3DES_cipheronly_dpaa_sec_all(void)
5869 struct crypto_testsuite_params *ts_params = &testsuite_params;
5872 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5873 ts_params->op_mpool,
5874 ts_params->session_mpool, ts_params->session_priv_mpool,
5875 ts_params->valid_devs[0],
5876 rte_cryptodev_driver_id_get(
5877 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5878 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5880 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5882 return TEST_SUCCESS;
5886 test_3DES_chain_dpaa2_sec_all(void)
5888 struct crypto_testsuite_params *ts_params = &testsuite_params;
5891 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5892 ts_params->op_mpool,
5893 ts_params->session_mpool, ts_params->session_priv_mpool,
5894 ts_params->valid_devs[0],
5895 rte_cryptodev_driver_id_get(
5896 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5897 BLKCIPHER_3DES_CHAIN_TYPE);
5899 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5901 return TEST_SUCCESS;
5905 test_3DES_cipheronly_dpaa2_sec_all(void)
5907 struct crypto_testsuite_params *ts_params = &testsuite_params;
5910 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5911 ts_params->op_mpool,
5912 ts_params->session_mpool, ts_params->session_priv_mpool,
5913 ts_params->valid_devs[0],
5914 rte_cryptodev_driver_id_get(
5915 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5916 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5918 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5920 return TEST_SUCCESS;
5924 test_3DES_chain_ccp_all(void)
5926 struct crypto_testsuite_params *ts_params = &testsuite_params;
5929 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5930 ts_params->op_mpool,
5931 ts_params->session_mpool, ts_params->session_priv_mpool,
5932 ts_params->valid_devs[0],
5933 rte_cryptodev_driver_id_get(
5934 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5935 BLKCIPHER_3DES_CHAIN_TYPE);
5937 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5939 return TEST_SUCCESS;
5943 test_3DES_cipheronly_ccp_all(void)
5945 struct crypto_testsuite_params *ts_params = &testsuite_params;
5948 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5949 ts_params->op_mpool,
5950 ts_params->session_mpool, ts_params->session_priv_mpool,
5951 ts_params->valid_devs[0],
5952 rte_cryptodev_driver_id_get(
5953 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5954 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5956 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5958 return TEST_SUCCESS;
5962 test_3DES_cipheronly_qat_all(void)
5964 struct crypto_testsuite_params *ts_params = &testsuite_params;
5967 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5968 ts_params->op_mpool,
5969 ts_params->session_mpool, ts_params->session_priv_mpool,
5970 ts_params->valid_devs[0],
5971 rte_cryptodev_driver_id_get(
5972 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5973 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5975 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5977 return TEST_SUCCESS;
5981 test_3DES_chain_openssl_all(void)
5983 struct crypto_testsuite_params *ts_params = &testsuite_params;
5986 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5987 ts_params->op_mpool,
5988 ts_params->session_mpool, ts_params->session_priv_mpool,
5989 ts_params->valid_devs[0],
5990 rte_cryptodev_driver_id_get(
5991 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5992 BLKCIPHER_3DES_CHAIN_TYPE);
5994 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5996 return TEST_SUCCESS;
6000 test_3DES_cipheronly_openssl_all(void)
6002 struct crypto_testsuite_params *ts_params = &testsuite_params;
6005 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6006 ts_params->op_mpool,
6007 ts_params->session_mpool, ts_params->session_priv_mpool,
6008 ts_params->valid_devs[0],
6009 rte_cryptodev_driver_id_get(
6010 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6011 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6013 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6015 return TEST_SUCCESS;
6018 /* ***** AEAD algorithm Tests ***** */
6021 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6022 enum rte_crypto_aead_operation op,
6023 const uint8_t *key, const uint8_t key_len,
6024 const uint16_t aad_len, const uint8_t auth_len,
6027 uint8_t aead_key[key_len];
6029 struct crypto_testsuite_params *ts_params = &testsuite_params;
6030 struct crypto_unittest_params *ut_params = &unittest_params;
6032 memcpy(aead_key, key, key_len);
6034 /* Setup AEAD Parameters */
6035 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6036 ut_params->aead_xform.next = NULL;
6037 ut_params->aead_xform.aead.algo = algo;
6038 ut_params->aead_xform.aead.op = op;
6039 ut_params->aead_xform.aead.key.data = aead_key;
6040 ut_params->aead_xform.aead.key.length = key_len;
6041 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6042 ut_params->aead_xform.aead.iv.length = iv_len;
6043 ut_params->aead_xform.aead.digest_length = auth_len;
6044 ut_params->aead_xform.aead.aad_length = aad_len;
6046 debug_hexdump(stdout, "key:", key, key_len);
6048 /* Create Crypto session*/
6049 ut_params->sess = rte_cryptodev_sym_session_create(
6050 ts_params->session_mpool);
6052 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6053 &ut_params->aead_xform,
6054 ts_params->session_priv_mpool);
6056 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6062 create_aead_xform(struct rte_crypto_op *op,
6063 enum rte_crypto_aead_algorithm algo,
6064 enum rte_crypto_aead_operation aead_op,
6065 uint8_t *key, const uint8_t key_len,
6066 const uint8_t aad_len, const uint8_t auth_len,
6069 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6070 "failed to allocate space for crypto transform");
6072 struct rte_crypto_sym_op *sym_op = op->sym;
6074 /* Setup AEAD Parameters */
6075 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6076 sym_op->xform->next = NULL;
6077 sym_op->xform->aead.algo = algo;
6078 sym_op->xform->aead.op = aead_op;
6079 sym_op->xform->aead.key.data = key;
6080 sym_op->xform->aead.key.length = key_len;
6081 sym_op->xform->aead.iv.offset = IV_OFFSET;
6082 sym_op->xform->aead.iv.length = iv_len;
6083 sym_op->xform->aead.digest_length = auth_len;
6084 sym_op->xform->aead.aad_length = aad_len;
6086 debug_hexdump(stdout, "key:", key, key_len);
6092 create_aead_operation(enum rte_crypto_aead_operation op,
6093 const struct aead_test_data *tdata)
6095 struct crypto_testsuite_params *ts_params = &testsuite_params;
6096 struct crypto_unittest_params *ut_params = &unittest_params;
6098 uint8_t *plaintext, *ciphertext;
6099 unsigned int aad_pad_len, plaintext_pad_len;
6101 /* Generate Crypto op data structure */
6102 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6103 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6104 TEST_ASSERT_NOT_NULL(ut_params->op,
6105 "Failed to allocate symmetric crypto operation struct");
6107 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6109 /* Append aad data */
6110 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6111 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6112 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6114 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6115 "no room to append aad");
6117 sym_op->aead.aad.phys_addr =
6118 rte_pktmbuf_iova(ut_params->ibuf);
6119 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6120 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6121 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6124 /* Append IV at the end of the crypto operation*/
6125 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6126 uint8_t *, IV_OFFSET);
6128 /* Copy IV 1 byte after the IV pointer, according to the API */
6129 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6130 debug_hexdump(stdout, "iv:", iv_ptr,
6133 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6134 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6136 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6137 "no room to append aad");
6139 sym_op->aead.aad.phys_addr =
6140 rte_pktmbuf_iova(ut_params->ibuf);
6141 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6142 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6145 /* Append IV at the end of the crypto operation*/
6146 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6147 uint8_t *, IV_OFFSET);
6149 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6150 debug_hexdump(stdout, "iv:", iv_ptr,
6154 /* Append plaintext/ciphertext */
6155 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6156 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6157 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6159 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6161 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6162 debug_hexdump(stdout, "plaintext:", plaintext,
6163 tdata->plaintext.len);
6165 if (ut_params->obuf) {
6166 ciphertext = (uint8_t *)rte_pktmbuf_append(
6168 plaintext_pad_len + aad_pad_len);
6169 TEST_ASSERT_NOT_NULL(ciphertext,
6170 "no room to append ciphertext");
6172 memset(ciphertext + aad_pad_len, 0,
6173 tdata->ciphertext.len);
6176 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6177 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6179 TEST_ASSERT_NOT_NULL(ciphertext,
6180 "no room to append ciphertext");
6182 memcpy(ciphertext, tdata->ciphertext.data,
6183 tdata->ciphertext.len);
6184 debug_hexdump(stdout, "ciphertext:", ciphertext,
6185 tdata->ciphertext.len);
6187 if (ut_params->obuf) {
6188 plaintext = (uint8_t *)rte_pktmbuf_append(
6190 plaintext_pad_len + aad_pad_len);
6191 TEST_ASSERT_NOT_NULL(plaintext,
6192 "no room to append plaintext");
6194 memset(plaintext + aad_pad_len, 0,
6195 tdata->plaintext.len);
6199 /* Append digest data */
6200 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6201 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6202 ut_params->obuf ? ut_params->obuf :
6204 tdata->auth_tag.len);
6205 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6206 "no room to append digest");
6207 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6208 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6209 ut_params->obuf ? ut_params->obuf :
6214 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6215 ut_params->ibuf, tdata->auth_tag.len);
6216 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6217 "no room to append digest");
6218 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6220 plaintext_pad_len + aad_pad_len);
6222 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6223 tdata->auth_tag.len);
6224 debug_hexdump(stdout, "digest:",
6225 sym_op->aead.digest.data,
6226 tdata->auth_tag.len);
6229 sym_op->aead.data.length = tdata->plaintext.len;
6230 sym_op->aead.data.offset = aad_pad_len;
6236 test_authenticated_encryption(const struct aead_test_data *tdata)
6238 struct crypto_testsuite_params *ts_params = &testsuite_params;
6239 struct crypto_unittest_params *ut_params = &unittest_params;
6242 uint8_t *ciphertext, *auth_tag;
6243 uint16_t plaintext_pad_len;
6246 /* Create AEAD session */
6247 retval = create_aead_session(ts_params->valid_devs[0],
6249 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6250 tdata->key.data, tdata->key.len,
6251 tdata->aad.len, tdata->auth_tag.len,
6256 if (tdata->aad.len > MBUF_SIZE) {
6257 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6258 /* Populate full size of add data */
6259 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6260 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6262 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6264 /* clear mbuf payload */
6265 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6266 rte_pktmbuf_tailroom(ut_params->ibuf));
6268 /* Create AEAD operation */
6269 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6273 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6275 ut_params->op->sym->m_src = ut_params->ibuf;
6277 /* Process crypto operation */
6278 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6279 ut_params->op), "failed to process sym crypto op");
6281 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6282 "crypto op processing failed");
6284 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6286 if (ut_params->op->sym->m_dst) {
6287 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6289 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6290 uint8_t *, plaintext_pad_len);
6292 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6294 ut_params->op->sym->cipher.data.offset);
6295 auth_tag = ciphertext + plaintext_pad_len;
6298 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6299 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6302 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6304 tdata->ciphertext.data,
6305 tdata->ciphertext.len,
6306 "Ciphertext data not as expected");
6308 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6310 tdata->auth_tag.data,
6311 tdata->auth_tag.len,
6312 "Generated auth tag not as expected");
6319 test_AES_GCM_authenticated_encryption_test_case_1(void)
6321 return test_authenticated_encryption(&gcm_test_case_1);
6325 test_AES_GCM_authenticated_encryption_test_case_2(void)
6327 return test_authenticated_encryption(&gcm_test_case_2);
6331 test_AES_GCM_authenticated_encryption_test_case_3(void)
6333 return test_authenticated_encryption(&gcm_test_case_3);
6337 test_AES_GCM_authenticated_encryption_test_case_4(void)
6339 return test_authenticated_encryption(&gcm_test_case_4);
6343 test_AES_GCM_authenticated_encryption_test_case_5(void)
6345 return test_authenticated_encryption(&gcm_test_case_5);
6349 test_AES_GCM_authenticated_encryption_test_case_6(void)
6351 return test_authenticated_encryption(&gcm_test_case_6);
6355 test_AES_GCM_authenticated_encryption_test_case_7(void)
6357 return test_authenticated_encryption(&gcm_test_case_7);
6361 test_AES_GCM_auth_encryption_test_case_192_1(void)
6363 return test_authenticated_encryption(&gcm_test_case_192_1);
6367 test_AES_GCM_auth_encryption_test_case_192_2(void)
6369 return test_authenticated_encryption(&gcm_test_case_192_2);
6373 test_AES_GCM_auth_encryption_test_case_192_3(void)
6375 return test_authenticated_encryption(&gcm_test_case_192_3);
6379 test_AES_GCM_auth_encryption_test_case_192_4(void)
6381 return test_authenticated_encryption(&gcm_test_case_192_4);
6385 test_AES_GCM_auth_encryption_test_case_192_5(void)
6387 return test_authenticated_encryption(&gcm_test_case_192_5);
6391 test_AES_GCM_auth_encryption_test_case_192_6(void)
6393 return test_authenticated_encryption(&gcm_test_case_192_6);
6397 test_AES_GCM_auth_encryption_test_case_192_7(void)
6399 return test_authenticated_encryption(&gcm_test_case_192_7);
6403 test_AES_GCM_auth_encryption_test_case_256_1(void)
6405 return test_authenticated_encryption(&gcm_test_case_256_1);
6409 test_AES_GCM_auth_encryption_test_case_256_2(void)
6411 return test_authenticated_encryption(&gcm_test_case_256_2);
6415 test_AES_GCM_auth_encryption_test_case_256_3(void)
6417 return test_authenticated_encryption(&gcm_test_case_256_3);
6421 test_AES_GCM_auth_encryption_test_case_256_4(void)
6423 return test_authenticated_encryption(&gcm_test_case_256_4);
6427 test_AES_GCM_auth_encryption_test_case_256_5(void)
6429 return test_authenticated_encryption(&gcm_test_case_256_5);
6433 test_AES_GCM_auth_encryption_test_case_256_6(void)
6435 return test_authenticated_encryption(&gcm_test_case_256_6);
6439 test_AES_GCM_auth_encryption_test_case_256_7(void)
6441 return test_authenticated_encryption(&gcm_test_case_256_7);
6445 test_AES_GCM_auth_encryption_test_case_aad_1(void)
6447 return test_authenticated_encryption(&gcm_test_case_aad_1);
6451 test_AES_GCM_auth_encryption_test_case_aad_2(void)
6453 return test_authenticated_encryption(&gcm_test_case_aad_2);
6457 test_authenticated_decryption(const struct aead_test_data *tdata)
6459 struct crypto_testsuite_params *ts_params = &testsuite_params;
6460 struct crypto_unittest_params *ut_params = &unittest_params;
6466 /* Create AEAD session */
6467 retval = create_aead_session(ts_params->valid_devs[0],
6469 RTE_CRYPTO_AEAD_OP_DECRYPT,
6470 tdata->key.data, tdata->key.len,
6471 tdata->aad.len, tdata->auth_tag.len,
6476 /* alloc mbuf and set payload */
6477 if (tdata->aad.len > MBUF_SIZE) {
6478 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6479 /* Populate full size of add data */
6480 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6481 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6483 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6485 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6486 rte_pktmbuf_tailroom(ut_params->ibuf));
6488 /* Create AEAD operation */
6489 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6493 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6495 ut_params->op->sym->m_src = ut_params->ibuf;
6497 /* Process crypto operation */
6498 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6499 ut_params->op), "failed to process sym crypto op");
6501 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6502 "crypto op processing failed");
6504 if (ut_params->op->sym->m_dst)
6505 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6508 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6510 ut_params->op->sym->cipher.data.offset);
6512 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6515 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6517 tdata->plaintext.data,
6518 tdata->plaintext.len,
6519 "Plaintext data not as expected");
6521 TEST_ASSERT_EQUAL(ut_params->op->status,
6522 RTE_CRYPTO_OP_STATUS_SUCCESS,
6523 "Authentication failed");
6528 test_AES_GCM_authenticated_decryption_test_case_1(void)
6530 return test_authenticated_decryption(&gcm_test_case_1);
6534 test_AES_GCM_authenticated_decryption_test_case_2(void)
6536 return test_authenticated_decryption(&gcm_test_case_2);
6540 test_AES_GCM_authenticated_decryption_test_case_3(void)
6542 return test_authenticated_decryption(&gcm_test_case_3);
6546 test_AES_GCM_authenticated_decryption_test_case_4(void)
6548 return test_authenticated_decryption(&gcm_test_case_4);
6552 test_AES_GCM_authenticated_decryption_test_case_5(void)
6554 return test_authenticated_decryption(&gcm_test_case_5);
6558 test_AES_GCM_authenticated_decryption_test_case_6(void)
6560 return test_authenticated_decryption(&gcm_test_case_6);
6564 test_AES_GCM_authenticated_decryption_test_case_7(void)
6566 return test_authenticated_decryption(&gcm_test_case_7);
6570 test_AES_GCM_auth_decryption_test_case_192_1(void)
6572 return test_authenticated_decryption(&gcm_test_case_192_1);
6576 test_AES_GCM_auth_decryption_test_case_192_2(void)
6578 return test_authenticated_decryption(&gcm_test_case_192_2);
6582 test_AES_GCM_auth_decryption_test_case_192_3(void)
6584 return test_authenticated_decryption(&gcm_test_case_192_3);
6588 test_AES_GCM_auth_decryption_test_case_192_4(void)
6590 return test_authenticated_decryption(&gcm_test_case_192_4);
6594 test_AES_GCM_auth_decryption_test_case_192_5(void)
6596 return test_authenticated_decryption(&gcm_test_case_192_5);
6600 test_AES_GCM_auth_decryption_test_case_192_6(void)
6602 return test_authenticated_decryption(&gcm_test_case_192_6);
6606 test_AES_GCM_auth_decryption_test_case_192_7(void)
6608 return test_authenticated_decryption(&gcm_test_case_192_7);
6612 test_AES_GCM_auth_decryption_test_case_256_1(void)
6614 return test_authenticated_decryption(&gcm_test_case_256_1);
6618 test_AES_GCM_auth_decryption_test_case_256_2(void)
6620 return test_authenticated_decryption(&gcm_test_case_256_2);
6624 test_AES_GCM_auth_decryption_test_case_256_3(void)
6626 return test_authenticated_decryption(&gcm_test_case_256_3);
6630 test_AES_GCM_auth_decryption_test_case_256_4(void)
6632 return test_authenticated_decryption(&gcm_test_case_256_4);
6636 test_AES_GCM_auth_decryption_test_case_256_5(void)
6638 return test_authenticated_decryption(&gcm_test_case_256_5);
6642 test_AES_GCM_auth_decryption_test_case_256_6(void)
6644 return test_authenticated_decryption(&gcm_test_case_256_6);
6648 test_AES_GCM_auth_decryption_test_case_256_7(void)
6650 return test_authenticated_decryption(&gcm_test_case_256_7);
6654 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6656 return test_authenticated_decryption(&gcm_test_case_aad_1);
6660 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6662 return test_authenticated_decryption(&gcm_test_case_aad_2);
6666 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6668 struct crypto_testsuite_params *ts_params = &testsuite_params;
6669 struct crypto_unittest_params *ut_params = &unittest_params;
6672 uint8_t *ciphertext, *auth_tag;
6673 uint16_t plaintext_pad_len;
6675 /* Create AEAD session */
6676 retval = create_aead_session(ts_params->valid_devs[0],
6678 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6679 tdata->key.data, tdata->key.len,
6680 tdata->aad.len, tdata->auth_tag.len,
6685 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6686 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6688 /* clear mbuf payload */
6689 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6690 rte_pktmbuf_tailroom(ut_params->ibuf));
6691 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6692 rte_pktmbuf_tailroom(ut_params->obuf));
6694 /* Create AEAD operation */
6695 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6699 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6701 ut_params->op->sym->m_src = ut_params->ibuf;
6702 ut_params->op->sym->m_dst = ut_params->obuf;
6704 /* Process crypto operation */
6705 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6706 ut_params->op), "failed to process sym crypto op");
6708 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6709 "crypto op processing failed");
6711 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6713 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6714 ut_params->op->sym->cipher.data.offset);
6715 auth_tag = ciphertext + plaintext_pad_len;
6717 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6718 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6721 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6723 tdata->ciphertext.data,
6724 tdata->ciphertext.len,
6725 "Ciphertext data not as expected");
6727 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6729 tdata->auth_tag.data,
6730 tdata->auth_tag.len,
6731 "Generated auth tag not as expected");
6738 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6740 return test_authenticated_encryption_oop(&gcm_test_case_5);
6744 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6746 struct crypto_testsuite_params *ts_params = &testsuite_params;
6747 struct crypto_unittest_params *ut_params = &unittest_params;
6752 /* Create AEAD session */
6753 retval = create_aead_session(ts_params->valid_devs[0],
6755 RTE_CRYPTO_AEAD_OP_DECRYPT,
6756 tdata->key.data, tdata->key.len,
6757 tdata->aad.len, tdata->auth_tag.len,
6762 /* alloc mbuf and set payload */
6763 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6764 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6766 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6767 rte_pktmbuf_tailroom(ut_params->ibuf));
6768 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6769 rte_pktmbuf_tailroom(ut_params->obuf));
6771 /* Create AEAD operation */
6772 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6776 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6778 ut_params->op->sym->m_src = ut_params->ibuf;
6779 ut_params->op->sym->m_dst = ut_params->obuf;
6781 /* Process crypto operation */
6782 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6783 ut_params->op), "failed to process sym crypto op");
6785 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6786 "crypto op processing failed");
6788 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6789 ut_params->op->sym->cipher.data.offset);
6791 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6794 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6796 tdata->plaintext.data,
6797 tdata->plaintext.len,
6798 "Plaintext data not as expected");
6800 TEST_ASSERT_EQUAL(ut_params->op->status,
6801 RTE_CRYPTO_OP_STATUS_SUCCESS,
6802 "Authentication failed");
6807 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6809 return test_authenticated_decryption_oop(&gcm_test_case_5);
6813 test_authenticated_encryption_sessionless(
6814 const struct aead_test_data *tdata)
6816 struct crypto_testsuite_params *ts_params = &testsuite_params;
6817 struct crypto_unittest_params *ut_params = &unittest_params;
6820 uint8_t *ciphertext, *auth_tag;
6821 uint16_t plaintext_pad_len;
6822 uint8_t key[tdata->key.len + 1];
6824 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6826 /* clear mbuf payload */
6827 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6828 rte_pktmbuf_tailroom(ut_params->ibuf));
6830 /* Create AEAD operation */
6831 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6835 /* Create GCM xform */
6836 memcpy(key, tdata->key.data, tdata->key.len);
6837 retval = create_aead_xform(ut_params->op,
6839 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6840 key, tdata->key.len,
6841 tdata->aad.len, tdata->auth_tag.len,
6846 ut_params->op->sym->m_src = ut_params->ibuf;
6848 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6849 RTE_CRYPTO_OP_SESSIONLESS,
6850 "crypto op session type not sessionless");
6852 /* Process crypto operation */
6853 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6854 ut_params->op), "failed to process sym crypto op");
6856 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6858 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6859 "crypto op status not success");
6861 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6863 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6864 ut_params->op->sym->cipher.data.offset);
6865 auth_tag = ciphertext + plaintext_pad_len;
6867 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6868 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6871 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6873 tdata->ciphertext.data,
6874 tdata->ciphertext.len,
6875 "Ciphertext data not as expected");
6877 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6879 tdata->auth_tag.data,
6880 tdata->auth_tag.len,
6881 "Generated auth tag not as expected");
6888 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6890 return test_authenticated_encryption_sessionless(
6895 test_authenticated_decryption_sessionless(
6896 const struct aead_test_data *tdata)
6898 struct crypto_testsuite_params *ts_params = &testsuite_params;
6899 struct crypto_unittest_params *ut_params = &unittest_params;
6903 uint8_t key[tdata->key.len + 1];
6905 /* alloc mbuf and set payload */
6906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6908 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6909 rte_pktmbuf_tailroom(ut_params->ibuf));
6911 /* Create AEAD operation */
6912 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6916 /* Create AEAD xform */
6917 memcpy(key, tdata->key.data, tdata->key.len);
6918 retval = create_aead_xform(ut_params->op,
6920 RTE_CRYPTO_AEAD_OP_DECRYPT,
6921 key, tdata->key.len,
6922 tdata->aad.len, tdata->auth_tag.len,
6927 ut_params->op->sym->m_src = ut_params->ibuf;
6929 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6930 RTE_CRYPTO_OP_SESSIONLESS,
6931 "crypto op session type not sessionless");
6933 /* Process crypto operation */
6934 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6935 ut_params->op), "failed to process sym crypto op");
6937 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6939 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6940 "crypto op status not success");
6942 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6943 ut_params->op->sym->cipher.data.offset);
6945 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6948 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6950 tdata->plaintext.data,
6951 tdata->plaintext.len,
6952 "Plaintext data not as expected");
6954 TEST_ASSERT_EQUAL(ut_params->op->status,
6955 RTE_CRYPTO_OP_STATUS_SUCCESS,
6956 "Authentication failed");
6961 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6963 return test_authenticated_decryption_sessionless(
6968 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6970 return test_authenticated_encryption(&ccm_test_case_128_1);
6974 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6976 return test_authenticated_encryption(&ccm_test_case_128_2);
6980 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6982 return test_authenticated_encryption(&ccm_test_case_128_3);
6986 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6988 return test_authenticated_decryption(&ccm_test_case_128_1);
6992 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6994 return test_authenticated_decryption(&ccm_test_case_128_2);
6998 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
7000 return test_authenticated_decryption(&ccm_test_case_128_3);
7004 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
7006 return test_authenticated_encryption(&ccm_test_case_192_1);
7010 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
7012 return test_authenticated_encryption(&ccm_test_case_192_2);
7016 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
7018 return test_authenticated_encryption(&ccm_test_case_192_3);
7022 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
7024 return test_authenticated_decryption(&ccm_test_case_192_1);
7028 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
7030 return test_authenticated_decryption(&ccm_test_case_192_2);
7034 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
7036 return test_authenticated_decryption(&ccm_test_case_192_3);
7040 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
7042 return test_authenticated_encryption(&ccm_test_case_256_1);
7046 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
7048 return test_authenticated_encryption(&ccm_test_case_256_2);
7052 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
7054 return test_authenticated_encryption(&ccm_test_case_256_3);
7058 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
7060 return test_authenticated_decryption(&ccm_test_case_256_1);
7064 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
7066 return test_authenticated_decryption(&ccm_test_case_256_2);
7070 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
7072 return test_authenticated_decryption(&ccm_test_case_256_3);
7078 struct crypto_testsuite_params *ts_params = &testsuite_params;
7079 struct rte_cryptodev_stats stats;
7080 struct rte_cryptodev *dev;
7081 cryptodev_stats_get_t temp_pfn;
7083 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7084 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
7085 &stats) == -ENODEV),
7086 "rte_cryptodev_stats_get invalid dev failed");
7087 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
7088 "rte_cryptodev_stats_get invalid Param failed");
7089 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
7090 temp_pfn = dev->dev_ops->stats_get;
7091 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
7092 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
7094 "rte_cryptodev_stats_get invalid Param failed");
7095 dev->dev_ops->stats_get = temp_pfn;
7097 /* Test expected values */
7099 test_AES_CBC_HMAC_SHA1_encrypt_digest();
7101 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7103 "rte_cryptodev_stats_get failed");
7104 TEST_ASSERT((stats.enqueued_count == 1),
7105 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7106 TEST_ASSERT((stats.dequeued_count == 1),
7107 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7108 TEST_ASSERT((stats.enqueue_err_count == 0),
7109 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7110 TEST_ASSERT((stats.dequeue_err_count == 0),
7111 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7113 /* invalid device but should ignore and not reset device stats*/
7114 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
7115 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7117 "rte_cryptodev_stats_get failed");
7118 TEST_ASSERT((stats.enqueued_count == 1),
7119 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7121 /* check that a valid reset clears stats */
7122 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7123 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7125 "rte_cryptodev_stats_get failed");
7126 TEST_ASSERT((stats.enqueued_count == 0),
7127 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7128 TEST_ASSERT((stats.dequeued_count == 0),
7129 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7131 return TEST_SUCCESS;
7134 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
7135 struct crypto_unittest_params *ut_params,
7136 enum rte_crypto_auth_operation op,
7137 const struct HMAC_MD5_vector *test_case)
7141 memcpy(key, test_case->key.data, test_case->key.len);
7143 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7144 ut_params->auth_xform.next = NULL;
7145 ut_params->auth_xform.auth.op = op;
7147 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
7149 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
7150 ut_params->auth_xform.auth.key.length = test_case->key.len;
7151 ut_params->auth_xform.auth.key.data = key;
7153 ut_params->sess = rte_cryptodev_sym_session_create(
7154 ts_params->session_mpool);
7156 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7157 ut_params->sess, &ut_params->auth_xform,
7158 ts_params->session_priv_mpool);
7160 if (ut_params->sess == NULL)
7163 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7165 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7166 rte_pktmbuf_tailroom(ut_params->ibuf));
7171 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
7172 const struct HMAC_MD5_vector *test_case,
7173 uint8_t **plaintext)
7175 uint16_t plaintext_pad_len;
7177 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7179 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7182 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7184 memcpy(*plaintext, test_case->plaintext.data,
7185 test_case->plaintext.len);
7187 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7188 ut_params->ibuf, MD5_DIGEST_LEN);
7189 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7190 "no room to append digest");
7191 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7192 ut_params->ibuf, plaintext_pad_len);
7194 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7195 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
7196 test_case->auth_tag.len);
7199 sym_op->auth.data.offset = 0;
7200 sym_op->auth.data.length = test_case->plaintext.len;
7202 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7203 ut_params->op->sym->m_src = ut_params->ibuf;
7209 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
7211 uint16_t plaintext_pad_len;
7212 uint8_t *plaintext, *auth_tag;
7214 struct crypto_testsuite_params *ts_params = &testsuite_params;
7215 struct crypto_unittest_params *ut_params = &unittest_params;
7217 if (MD5_HMAC_create_session(ts_params, ut_params,
7218 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
7221 /* Generate Crypto op data structure */
7222 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7223 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7224 TEST_ASSERT_NOT_NULL(ut_params->op,
7225 "Failed to allocate symmetric crypto operation struct");
7227 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7230 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7233 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7234 ut_params->op), "failed to process sym crypto op");
7236 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7237 "crypto op processing failed");
7239 if (ut_params->op->sym->m_dst) {
7240 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7241 uint8_t *, plaintext_pad_len);
7243 auth_tag = plaintext + plaintext_pad_len;
7246 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7248 test_case->auth_tag.data,
7249 test_case->auth_tag.len,
7250 "HMAC_MD5 generated tag not as expected");
7252 return TEST_SUCCESS;
7256 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
7260 struct crypto_testsuite_params *ts_params = &testsuite_params;
7261 struct crypto_unittest_params *ut_params = &unittest_params;
7263 if (MD5_HMAC_create_session(ts_params, ut_params,
7264 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
7268 /* Generate Crypto op data structure */
7269 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7270 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7271 TEST_ASSERT_NOT_NULL(ut_params->op,
7272 "Failed to allocate symmetric crypto operation struct");
7274 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7277 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7278 ut_params->op), "failed to process sym crypto op");
7280 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7281 "HMAC_MD5 crypto op processing failed");
7283 return TEST_SUCCESS;
7287 test_MD5_HMAC_generate_case_1(void)
7289 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
7293 test_MD5_HMAC_verify_case_1(void)
7295 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
7299 test_MD5_HMAC_generate_case_2(void)
7301 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
7305 test_MD5_HMAC_verify_case_2(void)
7307 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
7311 test_multi_session(void)
7313 struct crypto_testsuite_params *ts_params = &testsuite_params;
7314 struct crypto_unittest_params *ut_params = &unittest_params;
7316 struct rte_cryptodev_info dev_info;
7317 struct rte_cryptodev_sym_session **sessions;
7321 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
7322 aes_cbc_key, hmac_sha512_key);
7325 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7327 sessions = rte_malloc(NULL,
7328 (sizeof(struct rte_cryptodev_sym_session *) *
7329 MAX_NB_SESSIONS) + 1, 0);
7331 /* Create multiple crypto sessions*/
7332 for (i = 0; i < MAX_NB_SESSIONS; i++) {
7334 sessions[i] = rte_cryptodev_sym_session_create(
7335 ts_params->session_mpool);
7337 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7338 sessions[i], &ut_params->auth_xform,
7339 ts_params->session_priv_mpool);
7340 TEST_ASSERT_NOT_NULL(sessions[i],
7341 "Session creation failed at session number %u",
7344 /* Attempt to send a request on each session */
7345 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
7349 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
7350 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
7352 "Failed to perform decrypt on request number %u.", i);
7353 /* free crypto operation structure */
7355 rte_crypto_op_free(ut_params->op);
7358 * free mbuf - both obuf and ibuf are usually the same,
7359 * so check if they point at the same address is necessary,
7360 * to avoid freeing the mbuf twice.
7362 if (ut_params->obuf) {
7363 rte_pktmbuf_free(ut_params->obuf);
7364 if (ut_params->ibuf == ut_params->obuf)
7365 ut_params->ibuf = 0;
7366 ut_params->obuf = 0;
7368 if (ut_params->ibuf) {
7369 rte_pktmbuf_free(ut_params->ibuf);
7370 ut_params->ibuf = 0;
7374 /* Next session create should fail */
7375 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7376 sessions[i], &ut_params->auth_xform,
7377 ts_params->session_priv_mpool);
7378 TEST_ASSERT_NULL(sessions[i],
7379 "Session creation succeeded unexpectedly!");
7381 for (i = 0; i < MAX_NB_SESSIONS; i++) {
7382 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
7384 rte_cryptodev_sym_session_free(sessions[i]);
7389 return TEST_SUCCESS;
7392 struct multi_session_params {
7393 struct crypto_unittest_params ut_params;
7394 uint8_t *cipher_key;
7396 const uint8_t *cipher;
7397 const uint8_t *digest;
7401 #define MB_SESSION_NUMBER 3
7404 test_multi_session_random_usage(void)
7406 struct crypto_testsuite_params *ts_params = &testsuite_params;
7407 struct rte_cryptodev_info dev_info;
7408 struct rte_cryptodev_sym_session **sessions;
7410 struct multi_session_params ut_paramz[] = {
7413 .cipher_key = ms_aes_cbc_key0,
7414 .hmac_key = ms_hmac_key0,
7415 .cipher = ms_aes_cbc_cipher0,
7416 .digest = ms_hmac_digest0,
7417 .iv = ms_aes_cbc_iv0
7420 .cipher_key = ms_aes_cbc_key1,
7421 .hmac_key = ms_hmac_key1,
7422 .cipher = ms_aes_cbc_cipher1,
7423 .digest = ms_hmac_digest1,
7424 .iv = ms_aes_cbc_iv1
7427 .cipher_key = ms_aes_cbc_key2,
7428 .hmac_key = ms_hmac_key2,
7429 .cipher = ms_aes_cbc_cipher2,
7430 .digest = ms_hmac_digest2,
7431 .iv = ms_aes_cbc_iv2
7436 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7438 sessions = rte_malloc(NULL,
7439 (sizeof(struct rte_cryptodev_sym_session *)
7440 * MAX_NB_SESSIONS) + 1, 0);
7442 for (i = 0; i < MB_SESSION_NUMBER; i++) {
7443 sessions[i] = rte_cryptodev_sym_session_create(
7444 ts_params->session_mpool);
7446 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
7447 sizeof(struct crypto_unittest_params));
7449 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
7450 &ut_paramz[i].ut_params,
7451 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
7453 /* Create multiple crypto sessions*/
7454 rte_cryptodev_sym_session_init(
7455 ts_params->valid_devs[0],
7457 &ut_paramz[i].ut_params.auth_xform,
7458 ts_params->session_priv_mpool);
7460 TEST_ASSERT_NOT_NULL(sessions[i],
7461 "Session creation failed at session number %u",
7467 for (i = 0; i < 40000; i++) {
7469 j = rand() % MB_SESSION_NUMBER;
7471 TEST_ASSERT_SUCCESS(
7472 test_AES_CBC_HMAC_SHA512_decrypt_perform(
7474 &ut_paramz[j].ut_params,
7475 ts_params, ut_paramz[j].cipher,
7476 ut_paramz[j].digest,
7478 "Failed to perform decrypt on request number %u.", i);
7480 if (ut_paramz[j].ut_params.op)
7481 rte_crypto_op_free(ut_paramz[j].ut_params.op);
7484 * free mbuf - both obuf and ibuf are usually the same,
7485 * so check if they point at the same address is necessary,
7486 * to avoid freeing the mbuf twice.
7488 if (ut_paramz[j].ut_params.obuf) {
7489 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
7490 if (ut_paramz[j].ut_params.ibuf
7491 == ut_paramz[j].ut_params.obuf)
7492 ut_paramz[j].ut_params.ibuf = 0;
7493 ut_paramz[j].ut_params.obuf = 0;
7495 if (ut_paramz[j].ut_params.ibuf) {
7496 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
7497 ut_paramz[j].ut_params.ibuf = 0;
7501 for (i = 0; i < MB_SESSION_NUMBER; i++) {
7502 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
7504 rte_cryptodev_sym_session_free(sessions[i]);
7509 return TEST_SUCCESS;
7513 test_null_cipher_only_operation(void)
7515 struct crypto_testsuite_params *ts_params = &testsuite_params;
7516 struct crypto_unittest_params *ut_params = &unittest_params;
7518 /* Generate test mbuf data and space for digest */
7519 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7520 catch_22_quote, QUOTE_512_BYTES, 0);
7522 /* Setup Cipher Parameters */
7523 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7524 ut_params->cipher_xform.next = NULL;
7526 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7527 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7529 ut_params->sess = rte_cryptodev_sym_session_create(
7530 ts_params->session_mpool);
7532 /* Create Crypto session*/
7533 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7535 &ut_params->cipher_xform,
7536 ts_params->session_priv_mpool);
7537 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7539 /* Generate Crypto op data structure */
7540 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7541 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7542 TEST_ASSERT_NOT_NULL(ut_params->op,
7543 "Failed to allocate symmetric crypto operation struct");
7545 /* Set crypto operation data parameters */
7546 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7548 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7550 /* set crypto operation source mbuf */
7551 sym_op->m_src = ut_params->ibuf;
7553 sym_op->cipher.data.offset = 0;
7554 sym_op->cipher.data.length = QUOTE_512_BYTES;
7556 /* Process crypto operation */
7557 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7559 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7561 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7562 "crypto operation processing failed");
7565 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7566 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7569 "Ciphertext data not as expected");
7571 return TEST_SUCCESS;
7573 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
7574 0xab, 0xab, 0xab, 0xab,
7575 0xab, 0xab, 0xab, 0xab,
7576 0xab, 0xab, 0xab, 0xab};
7578 test_null_auth_only_operation(void)
7580 struct crypto_testsuite_params *ts_params = &testsuite_params;
7581 struct crypto_unittest_params *ut_params = &unittest_params;
7584 /* Generate test mbuf data and space for digest */
7585 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7586 catch_22_quote, QUOTE_512_BYTES, 0);
7588 /* create a pointer for digest, but don't expect anything to be written
7589 * here in a NULL auth algo so no mbuf append done.
7591 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7593 /* prefill the memory pointed to by digest */
7594 memcpy(digest, orig_data, sizeof(orig_data));
7596 /* Setup HMAC Parameters */
7597 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7598 ut_params->auth_xform.next = NULL;
7600 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7601 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7603 ut_params->sess = rte_cryptodev_sym_session_create(
7604 ts_params->session_mpool);
7606 /* Create Crypto session*/
7607 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7608 ut_params->sess, &ut_params->auth_xform,
7609 ts_params->session_priv_mpool);
7610 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7612 /* Generate Crypto op data structure */
7613 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7614 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7615 TEST_ASSERT_NOT_NULL(ut_params->op,
7616 "Failed to allocate symmetric crypto operation struct");
7618 /* Set crypto operation data parameters */
7619 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7621 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7623 sym_op->m_src = ut_params->ibuf;
7625 sym_op->auth.data.offset = 0;
7626 sym_op->auth.data.length = QUOTE_512_BYTES;
7627 sym_op->auth.digest.data = digest;
7628 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7631 /* Process crypto operation */
7632 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7634 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7636 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7637 "crypto operation processing failed");
7638 /* Make sure memory pointed to by digest hasn't been overwritten */
7639 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7643 "Memory at digest ptr overwritten unexpectedly");
7645 return TEST_SUCCESS;
7650 test_null_cipher_auth_operation(void)
7652 struct crypto_testsuite_params *ts_params = &testsuite_params;
7653 struct crypto_unittest_params *ut_params = &unittest_params;
7656 /* Generate test mbuf data and space for digest */
7657 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7658 catch_22_quote, QUOTE_512_BYTES, 0);
7660 /* create a pointer for digest, but don't expect anything to be written
7661 * here in a NULL auth algo so no mbuf append done.
7663 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7665 /* prefill the memory pointed to by digest */
7666 memcpy(digest, orig_data, sizeof(orig_data));
7668 /* Setup Cipher Parameters */
7669 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7670 ut_params->cipher_xform.next = &ut_params->auth_xform;
7672 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7673 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7675 /* Setup HMAC Parameters */
7676 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7677 ut_params->auth_xform.next = NULL;
7679 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7680 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7682 ut_params->sess = rte_cryptodev_sym_session_create(
7683 ts_params->session_mpool);
7685 /* Create Crypto session*/
7686 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7687 ut_params->sess, &ut_params->cipher_xform,
7688 ts_params->session_priv_mpool);
7689 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7691 /* Generate Crypto op data structure */
7692 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7693 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7694 TEST_ASSERT_NOT_NULL(ut_params->op,
7695 "Failed to allocate symmetric crypto operation struct");
7697 /* Set crypto operation data parameters */
7698 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7700 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7702 sym_op->m_src = ut_params->ibuf;
7704 sym_op->cipher.data.offset = 0;
7705 sym_op->cipher.data.length = QUOTE_512_BYTES;
7707 sym_op->auth.data.offset = 0;
7708 sym_op->auth.data.length = QUOTE_512_BYTES;
7709 sym_op->auth.digest.data = digest;
7710 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7713 /* Process crypto operation */
7714 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7716 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7718 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7719 "crypto operation processing failed");
7722 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7723 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7726 "Ciphertext data not as expected");
7727 /* Make sure memory pointed to by digest hasn't been overwritten */
7728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7732 "Memory at digest ptr overwritten unexpectedly");
7734 return TEST_SUCCESS;
7738 test_null_auth_cipher_operation(void)
7740 struct crypto_testsuite_params *ts_params = &testsuite_params;
7741 struct crypto_unittest_params *ut_params = &unittest_params;
7744 /* Generate test mbuf data */
7745 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7746 catch_22_quote, QUOTE_512_BYTES, 0);
7748 /* create a pointer for digest, but don't expect anything to be written
7749 * here in a NULL auth algo so no mbuf append done.
7751 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7753 /* prefill the memory pointed to by digest */
7754 memcpy(digest, orig_data, sizeof(orig_data));
7756 /* Setup Cipher Parameters */
7757 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7758 ut_params->cipher_xform.next = NULL;
7760 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7761 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7763 /* Setup HMAC Parameters */
7764 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7765 ut_params->auth_xform.next = &ut_params->cipher_xform;
7767 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7768 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7770 ut_params->sess = rte_cryptodev_sym_session_create(
7771 ts_params->session_mpool);
7773 /* Create Crypto session*/
7774 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7775 ut_params->sess, &ut_params->cipher_xform,
7776 ts_params->session_priv_mpool);
7777 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7779 /* Generate Crypto op data structure */
7780 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7781 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7782 TEST_ASSERT_NOT_NULL(ut_params->op,
7783 "Failed to allocate symmetric crypto operation struct");
7785 /* Set crypto operation data parameters */
7786 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7788 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7790 sym_op->m_src = ut_params->ibuf;
7792 sym_op->cipher.data.offset = 0;
7793 sym_op->cipher.data.length = QUOTE_512_BYTES;
7795 sym_op->auth.data.offset = 0;
7796 sym_op->auth.data.length = QUOTE_512_BYTES;
7797 sym_op->auth.digest.data = digest;
7798 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7801 /* Process crypto operation */
7802 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7804 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7806 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7807 "crypto operation processing failed");
7810 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7811 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7814 "Ciphertext data not as expected");
7815 /* Make sure memory pointed to by digest hasn't been overwritten */
7816 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7820 "Memory at digest ptr overwritten unexpectedly");
7822 return TEST_SUCCESS;
7827 test_null_invalid_operation(void)
7829 struct crypto_testsuite_params *ts_params = &testsuite_params;
7830 struct crypto_unittest_params *ut_params = &unittest_params;
7833 /* Setup Cipher Parameters */
7834 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7835 ut_params->cipher_xform.next = NULL;
7837 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7838 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7840 ut_params->sess = rte_cryptodev_sym_session_create(
7841 ts_params->session_mpool);
7843 /* Create Crypto session*/
7844 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7845 ut_params->sess, &ut_params->cipher_xform,
7846 ts_params->session_priv_mpool);
7847 TEST_ASSERT(ret < 0,
7848 "Session creation succeeded unexpectedly");
7851 /* Setup HMAC Parameters */
7852 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7853 ut_params->auth_xform.next = NULL;
7855 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7856 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7858 ut_params->sess = rte_cryptodev_sym_session_create(
7859 ts_params->session_mpool);
7861 /* Create Crypto session*/
7862 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7863 ut_params->sess, &ut_params->auth_xform,
7864 ts_params->session_priv_mpool);
7865 TEST_ASSERT(ret < 0,
7866 "Session creation succeeded unexpectedly");
7868 return TEST_SUCCESS;
7872 #define NULL_BURST_LENGTH (32)
7875 test_null_burst_operation(void)
7877 struct crypto_testsuite_params *ts_params = &testsuite_params;
7878 struct crypto_unittest_params *ut_params = &unittest_params;
7880 unsigned i, burst_len = NULL_BURST_LENGTH;
7882 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7883 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7885 /* Setup Cipher Parameters */
7886 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7887 ut_params->cipher_xform.next = &ut_params->auth_xform;
7889 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7890 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7892 /* Setup HMAC Parameters */
7893 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7894 ut_params->auth_xform.next = NULL;
7896 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7897 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7899 ut_params->sess = rte_cryptodev_sym_session_create(
7900 ts_params->session_mpool);
7902 /* Create Crypto session*/
7903 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7904 ut_params->sess, &ut_params->cipher_xform,
7905 ts_params->session_priv_mpool);
7906 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7908 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7909 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7910 burst_len, "failed to generate burst of crypto ops");
7912 /* Generate an operation for each mbuf in burst */
7913 for (i = 0; i < burst_len; i++) {
7914 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7916 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7918 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7922 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7924 burst[i]->sym->m_src = m;
7927 /* Process crypto operation */
7928 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7929 0, burst, burst_len),
7931 "Error enqueuing burst");
7933 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7934 0, burst_dequeued, burst_len),
7936 "Error dequeuing burst");
7939 for (i = 0; i < burst_len; i++) {
7941 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7942 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7944 "data not as expected");
7946 rte_pktmbuf_free(burst[i]->sym->m_src);
7947 rte_crypto_op_free(burst[i]);
7950 return TEST_SUCCESS;
7954 generate_gmac_large_plaintext(uint8_t *data)
7958 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7959 memcpy(&data[i], &data[0], 32);
7963 create_gmac_operation(enum rte_crypto_auth_operation op,
7964 const struct gmac_test_data *tdata)
7966 struct crypto_testsuite_params *ts_params = &testsuite_params;
7967 struct crypto_unittest_params *ut_params = &unittest_params;
7968 struct rte_crypto_sym_op *sym_op;
7970 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7972 /* Generate Crypto op data structure */
7973 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7974 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7975 TEST_ASSERT_NOT_NULL(ut_params->op,
7976 "Failed to allocate symmetric crypto operation struct");
7978 sym_op = ut_params->op->sym;
7980 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7981 ut_params->ibuf, tdata->gmac_tag.len);
7982 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7983 "no room to append digest");
7985 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7986 ut_params->ibuf, plaintext_pad_len);
7988 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7989 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7990 tdata->gmac_tag.len);
7991 debug_hexdump(stdout, "digest:",
7992 sym_op->auth.digest.data,
7993 tdata->gmac_tag.len);
7996 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7997 uint8_t *, IV_OFFSET);
7999 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8001 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
8003 sym_op->cipher.data.length = 0;
8004 sym_op->cipher.data.offset = 0;
8006 sym_op->auth.data.offset = 0;
8007 sym_op->auth.data.length = tdata->plaintext.len;
8012 static int create_gmac_session(uint8_t dev_id,
8013 const struct gmac_test_data *tdata,
8014 enum rte_crypto_auth_operation auth_op)
8016 uint8_t auth_key[tdata->key.len];
8018 struct crypto_testsuite_params *ts_params = &testsuite_params;
8019 struct crypto_unittest_params *ut_params = &unittest_params;
8021 memcpy(auth_key, tdata->key.data, tdata->key.len);
8023 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8024 ut_params->auth_xform.next = NULL;
8026 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
8027 ut_params->auth_xform.auth.op = auth_op;
8028 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
8029 ut_params->auth_xform.auth.key.length = tdata->key.len;
8030 ut_params->auth_xform.auth.key.data = auth_key;
8031 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
8032 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
8035 ut_params->sess = rte_cryptodev_sym_session_create(
8036 ts_params->session_mpool);
8038 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8039 &ut_params->auth_xform,
8040 ts_params->session_priv_mpool);
8042 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8048 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
8050 struct crypto_testsuite_params *ts_params = &testsuite_params;
8051 struct crypto_unittest_params *ut_params = &unittest_params;
8055 uint8_t *auth_tag, *plaintext;
8056 uint16_t plaintext_pad_len;
8058 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8059 "No GMAC length in the source data");
8061 retval = create_gmac_session(ts_params->valid_devs[0],
8062 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
8067 if (tdata->plaintext.len > MBUF_SIZE)
8068 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8070 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8071 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8072 "Failed to allocate input buffer in mempool");
8074 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8075 rte_pktmbuf_tailroom(ut_params->ibuf));
8077 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8079 * Runtime generate the large plain text instead of use hard code
8080 * plain text vector. It is done to avoid create huge source file
8081 * with the test vector.
8083 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8084 generate_gmac_large_plaintext(tdata->plaintext.data);
8086 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8088 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8090 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8091 debug_hexdump(stdout, "plaintext:", plaintext,
8092 tdata->plaintext.len);
8094 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
8100 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8102 ut_params->op->sym->m_src = ut_params->ibuf;
8104 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8105 ut_params->op), "failed to process sym crypto op");
8107 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8108 "crypto op processing failed");
8110 if (ut_params->op->sym->m_dst) {
8111 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8112 uint8_t *, plaintext_pad_len);
8114 auth_tag = plaintext + plaintext_pad_len;
8117 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
8119 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8121 tdata->gmac_tag.data,
8122 tdata->gmac_tag.len,
8123 "GMAC Generated auth tag not as expected");
8129 test_AES_GMAC_authentication_test_case_1(void)
8131 return test_AES_GMAC_authentication(&gmac_test_case_1);
8135 test_AES_GMAC_authentication_test_case_2(void)
8137 return test_AES_GMAC_authentication(&gmac_test_case_2);
8141 test_AES_GMAC_authentication_test_case_3(void)
8143 return test_AES_GMAC_authentication(&gmac_test_case_3);
8147 test_AES_GMAC_authentication_test_case_4(void)
8149 return test_AES_GMAC_authentication(&gmac_test_case_4);
8153 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
8155 struct crypto_testsuite_params *ts_params = &testsuite_params;
8156 struct crypto_unittest_params *ut_params = &unittest_params;
8158 uint32_t plaintext_pad_len;
8161 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8162 "No GMAC length in the source data");
8164 retval = create_gmac_session(ts_params->valid_devs[0],
8165 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
8170 if (tdata->plaintext.len > MBUF_SIZE)
8171 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8173 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8174 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8175 "Failed to allocate input buffer in mempool");
8177 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8178 rte_pktmbuf_tailroom(ut_params->ibuf));
8180 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8183 * Runtime generate the large plain text instead of use hard code
8184 * plain text vector. It is done to avoid create huge source file
8185 * with the test vector.
8187 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8188 generate_gmac_large_plaintext(tdata->plaintext.data);
8190 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8192 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8194 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8195 debug_hexdump(stdout, "plaintext:", plaintext,
8196 tdata->plaintext.len);
8198 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
8204 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8206 ut_params->op->sym->m_src = ut_params->ibuf;
8208 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8209 ut_params->op), "failed to process sym crypto op");
8211 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8212 "crypto op processing failed");
8219 test_AES_GMAC_authentication_verify_test_case_1(void)
8221 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
8225 test_AES_GMAC_authentication_verify_test_case_2(void)
8227 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
8231 test_AES_GMAC_authentication_verify_test_case_3(void)
8233 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
8237 test_AES_GMAC_authentication_verify_test_case_4(void)
8239 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
8242 struct test_crypto_vector {
8243 enum rte_crypto_cipher_algorithm crypto_algo;
8256 const uint8_t *data;
8261 const uint8_t *data;
8265 enum rte_crypto_auth_algorithm auth_algo;
8273 const uint8_t *data;
8283 static const struct test_crypto_vector
8284 hmac_sha1_test_crypto_vector = {
8285 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
8287 .data = plaintext_hash,
8292 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
8293 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
8294 0xDE, 0xF4, 0xDE, 0xAD
8300 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
8301 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
8302 0x3F, 0x91, 0x64, 0x59
8308 static const struct test_crypto_vector
8309 aes128_gmac_test_vector = {
8310 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
8312 .data = plaintext_hash,
8317 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
8318 0x08, 0x09, 0x0A, 0x0B
8324 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
8325 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
8331 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
8332 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
8338 static const struct test_crypto_vector
8339 aes128cbc_hmac_sha1_test_vector = {
8340 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
8343 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
8344 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
8350 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
8351 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
8356 .data = plaintext_hash,
8360 .data = ciphertext512_aes128cbc,
8363 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
8366 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
8367 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
8368 0xDE, 0xF4, 0xDE, 0xAD
8374 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
8375 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
8376 0x18, 0x8C, 0x1D, 0x32
8383 data_corruption(uint8_t *data)
8389 tag_corruption(uint8_t *data, unsigned int tag_offset)
8391 data[tag_offset] += 1;
8395 create_auth_session(struct crypto_unittest_params *ut_params,
8397 const struct test_crypto_vector *reference,
8398 enum rte_crypto_auth_operation auth_op)
8400 struct crypto_testsuite_params *ts_params = &testsuite_params;
8401 uint8_t auth_key[reference->auth_key.len + 1];
8403 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
8405 /* Setup Authentication Parameters */
8406 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8407 ut_params->auth_xform.auth.op = auth_op;
8408 ut_params->auth_xform.next = NULL;
8409 ut_params->auth_xform.auth.algo = reference->auth_algo;
8410 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
8411 ut_params->auth_xform.auth.key.data = auth_key;
8412 ut_params->auth_xform.auth.digest_length = reference->digest.len;
8414 /* Create Crypto session*/
8415 ut_params->sess = rte_cryptodev_sym_session_create(
8416 ts_params->session_mpool);
8418 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8419 &ut_params->auth_xform,
8420 ts_params->session_priv_mpool);
8422 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8428 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
8430 const struct test_crypto_vector *reference,
8431 enum rte_crypto_auth_operation auth_op,
8432 enum rte_crypto_cipher_operation cipher_op)
8434 struct crypto_testsuite_params *ts_params = &testsuite_params;
8435 uint8_t cipher_key[reference->cipher_key.len + 1];
8436 uint8_t auth_key[reference->auth_key.len + 1];
8438 memcpy(cipher_key, reference->cipher_key.data,
8439 reference->cipher_key.len);
8440 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
8442 /* Setup Authentication Parameters */
8443 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8444 ut_params->auth_xform.auth.op = auth_op;
8445 ut_params->auth_xform.auth.algo = reference->auth_algo;
8446 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
8447 ut_params->auth_xform.auth.key.data = auth_key;
8448 ut_params->auth_xform.auth.digest_length = reference->digest.len;
8450 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
8451 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
8452 ut_params->auth_xform.auth.iv.length = reference->iv.len;
8454 ut_params->auth_xform.next = &ut_params->cipher_xform;
8456 /* Setup Cipher Parameters */
8457 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8458 ut_params->cipher_xform.next = NULL;
8459 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
8460 ut_params->cipher_xform.cipher.op = cipher_op;
8461 ut_params->cipher_xform.cipher.key.data = cipher_key;
8462 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
8463 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8464 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
8467 /* Create Crypto session*/
8468 ut_params->sess = rte_cryptodev_sym_session_create(
8469 ts_params->session_mpool);
8471 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8472 &ut_params->auth_xform,
8473 ts_params->session_priv_mpool);
8475 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8481 create_auth_operation(struct crypto_testsuite_params *ts_params,
8482 struct crypto_unittest_params *ut_params,
8483 const struct test_crypto_vector *reference,
8484 unsigned int auth_generate)
8486 /* Generate Crypto op data structure */
8487 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8488 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8489 TEST_ASSERT_NOT_NULL(ut_params->op,
8490 "Failed to allocate pktmbuf offload");
8492 /* Set crypto operation data parameters */
8493 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8495 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8497 /* set crypto operation source mbuf */
8498 sym_op->m_src = ut_params->ibuf;
8501 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8502 ut_params->ibuf, reference->digest.len);
8504 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8505 "no room to append auth tag");
8507 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8508 ut_params->ibuf, reference->plaintext.len);
8511 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8513 memcpy(sym_op->auth.digest.data,
8514 reference->digest.data,
8515 reference->digest.len);
8517 debug_hexdump(stdout, "digest:",
8518 sym_op->auth.digest.data,
8519 reference->digest.len);
8521 sym_op->auth.data.length = reference->plaintext.len;
8522 sym_op->auth.data.offset = 0;
8528 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
8529 struct crypto_unittest_params *ut_params,
8530 const struct test_crypto_vector *reference,
8531 unsigned int auth_generate)
8533 /* Generate Crypto op data structure */
8534 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8535 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8536 TEST_ASSERT_NOT_NULL(ut_params->op,
8537 "Failed to allocate pktmbuf offload");
8539 /* Set crypto operation data parameters */
8540 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8542 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8544 /* set crypto operation source mbuf */
8545 sym_op->m_src = ut_params->ibuf;
8548 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8549 ut_params->ibuf, reference->digest.len);
8551 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8552 "no room to append auth tag");
8554 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8555 ut_params->ibuf, reference->ciphertext.len);
8558 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8560 memcpy(sym_op->auth.digest.data,
8561 reference->digest.data,
8562 reference->digest.len);
8564 debug_hexdump(stdout, "digest:",
8565 sym_op->auth.digest.data,
8566 reference->digest.len);
8568 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8569 reference->iv.data, reference->iv.len);
8571 sym_op->cipher.data.length = 0;
8572 sym_op->cipher.data.offset = 0;
8574 sym_op->auth.data.length = reference->plaintext.len;
8575 sym_op->auth.data.offset = 0;
8581 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8582 struct crypto_unittest_params *ut_params,
8583 const struct test_crypto_vector *reference,
8584 unsigned int auth_generate)
8586 /* Generate Crypto op data structure */
8587 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8588 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8589 TEST_ASSERT_NOT_NULL(ut_params->op,
8590 "Failed to allocate pktmbuf offload");
8592 /* Set crypto operation data parameters */
8593 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8595 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8597 /* set crypto operation source mbuf */
8598 sym_op->m_src = ut_params->ibuf;
8601 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8602 ut_params->ibuf, reference->digest.len);
8604 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8605 "no room to append auth tag");
8607 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8608 ut_params->ibuf, reference->ciphertext.len);
8611 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8613 memcpy(sym_op->auth.digest.data,
8614 reference->digest.data,
8615 reference->digest.len);
8617 debug_hexdump(stdout, "digest:",
8618 sym_op->auth.digest.data,
8619 reference->digest.len);
8621 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8622 reference->iv.data, reference->iv.len);
8624 sym_op->cipher.data.length = reference->ciphertext.len;
8625 sym_op->cipher.data.offset = 0;
8627 sym_op->auth.data.length = reference->ciphertext.len;
8628 sym_op->auth.data.offset = 0;
8634 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8635 struct crypto_unittest_params *ut_params,
8636 const struct test_crypto_vector *reference)
8638 return create_auth_operation(ts_params, ut_params, reference, 0);
8642 create_auth_verify_GMAC_operation(
8643 struct crypto_testsuite_params *ts_params,
8644 struct crypto_unittest_params *ut_params,
8645 const struct test_crypto_vector *reference)
8647 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8651 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8652 struct crypto_unittest_params *ut_params,
8653 const struct test_crypto_vector *reference)
8655 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8659 test_authentication_verify_fail_when_data_corruption(
8660 struct crypto_testsuite_params *ts_params,
8661 struct crypto_unittest_params *ut_params,
8662 const struct test_crypto_vector *reference,
8663 unsigned int data_corrupted)
8669 /* Create session */
8670 retval = create_auth_session(ut_params,
8671 ts_params->valid_devs[0],
8673 RTE_CRYPTO_AUTH_OP_VERIFY);
8677 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8678 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8679 "Failed to allocate input buffer in mempool");
8681 /* clear mbuf payload */
8682 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8683 rte_pktmbuf_tailroom(ut_params->ibuf));
8685 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8686 reference->plaintext.len);
8687 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8688 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8690 debug_hexdump(stdout, "plaintext:", plaintext,
8691 reference->plaintext.len);
8693 /* Create operation */
8694 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8700 data_corruption(plaintext);
8702 tag_corruption(plaintext, reference->plaintext.len);
8704 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8706 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8707 TEST_ASSERT_EQUAL(ut_params->op->status,
8708 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8709 "authentication not failed");
8711 ut_params->obuf = ut_params->op->sym->m_src;
8712 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8718 test_authentication_verify_GMAC_fail_when_corruption(
8719 struct crypto_testsuite_params *ts_params,
8720 struct crypto_unittest_params *ut_params,
8721 const struct test_crypto_vector *reference,
8722 unsigned int data_corrupted)
8727 /* Create session */
8728 retval = create_auth_cipher_session(ut_params,
8729 ts_params->valid_devs[0],
8731 RTE_CRYPTO_AUTH_OP_VERIFY,
8732 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8736 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8737 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8738 "Failed to allocate input buffer in mempool");
8740 /* clear mbuf payload */
8741 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8742 rte_pktmbuf_tailroom(ut_params->ibuf));
8744 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8745 reference->plaintext.len);
8746 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8747 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8749 debug_hexdump(stdout, "plaintext:", plaintext,
8750 reference->plaintext.len);
8752 /* Create operation */
8753 retval = create_auth_verify_GMAC_operation(ts_params,
8761 data_corruption(plaintext);
8763 tag_corruption(plaintext, reference->aad.len);
8765 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8767 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8768 TEST_ASSERT_EQUAL(ut_params->op->status,
8769 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8770 "authentication not failed");
8772 ut_params->obuf = ut_params->op->sym->m_src;
8773 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8779 test_authenticated_decryption_fail_when_corruption(
8780 struct crypto_testsuite_params *ts_params,
8781 struct crypto_unittest_params *ut_params,
8782 const struct test_crypto_vector *reference,
8783 unsigned int data_corrupted)
8787 uint8_t *ciphertext;
8789 /* Create session */
8790 retval = create_auth_cipher_session(ut_params,
8791 ts_params->valid_devs[0],
8793 RTE_CRYPTO_AUTH_OP_VERIFY,
8794 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8798 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8799 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8800 "Failed to allocate input buffer in mempool");
8802 /* clear mbuf payload */
8803 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8804 rte_pktmbuf_tailroom(ut_params->ibuf));
8806 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8807 reference->ciphertext.len);
8808 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8809 memcpy(ciphertext, reference->ciphertext.data,
8810 reference->ciphertext.len);
8812 /* Create operation */
8813 retval = create_cipher_auth_verify_operation(ts_params,
8821 data_corruption(ciphertext);
8823 tag_corruption(ciphertext, reference->ciphertext.len);
8825 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8828 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8829 TEST_ASSERT_EQUAL(ut_params->op->status,
8830 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8831 "authentication not failed");
8833 ut_params->obuf = ut_params->op->sym->m_src;
8834 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8840 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8841 const struct aead_test_data *tdata,
8842 void *digest_mem, uint64_t digest_phys)
8844 struct crypto_testsuite_params *ts_params = &testsuite_params;
8845 struct crypto_unittest_params *ut_params = &unittest_params;
8847 const unsigned int auth_tag_len = tdata->auth_tag.len;
8848 const unsigned int iv_len = tdata->iv.len;
8849 unsigned int aad_len = tdata->aad.len;
8851 /* Generate Crypto op data structure */
8852 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8853 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8854 TEST_ASSERT_NOT_NULL(ut_params->op,
8855 "Failed to allocate symmetric crypto operation struct");
8857 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8859 sym_op->aead.digest.data = digest_mem;
8861 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8862 "no room to append digest");
8864 sym_op->aead.digest.phys_addr = digest_phys;
8866 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8867 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8869 debug_hexdump(stdout, "digest:",
8870 sym_op->aead.digest.data,
8874 /* Append aad data */
8875 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8876 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8877 uint8_t *, IV_OFFSET);
8879 /* Copy IV 1 byte after the IV pointer, according to the API */
8880 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8882 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8884 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8885 ut_params->ibuf, aad_len);
8886 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8887 "no room to prepend aad");
8888 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8891 memset(sym_op->aead.aad.data, 0, aad_len);
8892 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8893 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8895 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8896 debug_hexdump(stdout, "aad:",
8897 sym_op->aead.aad.data, aad_len);
8899 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8900 uint8_t *, IV_OFFSET);
8902 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8904 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8905 ut_params->ibuf, aad_len);
8906 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8907 "no room to prepend aad");
8908 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8911 memset(sym_op->aead.aad.data, 0, aad_len);
8912 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8914 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8915 debug_hexdump(stdout, "aad:",
8916 sym_op->aead.aad.data, aad_len);
8919 sym_op->aead.data.length = tdata->plaintext.len;
8920 sym_op->aead.data.offset = aad_len;
8925 #define SGL_MAX_NO 16
8928 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8929 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8931 struct crypto_testsuite_params *ts_params = &testsuite_params;
8932 struct crypto_unittest_params *ut_params = &unittest_params;
8933 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8936 int to_trn_tbl[SGL_MAX_NO];
8938 unsigned int trn_data = 0;
8939 uint8_t *plaintext, *ciphertext, *auth_tag;
8941 if (fragsz > tdata->plaintext.len)
8942 fragsz = tdata->plaintext.len;
8944 uint16_t plaintext_len = fragsz;
8945 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8947 if (fragsz_oop > tdata->plaintext.len)
8948 frag_size_oop = tdata->plaintext.len;
8951 void *digest_mem = NULL;
8953 uint32_t prepend_len = tdata->aad.len;
8955 if (tdata->plaintext.len % fragsz != 0) {
8956 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8959 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8964 * For out-op-place we need to alloc another mbuf
8967 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8968 rte_pktmbuf_append(ut_params->obuf,
8969 frag_size_oop + prepend_len);
8970 buf_oop = ut_params->obuf;
8973 /* Create AEAD session */
8974 retval = create_aead_session(ts_params->valid_devs[0],
8976 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8977 tdata->key.data, tdata->key.len,
8978 tdata->aad.len, tdata->auth_tag.len,
8983 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8985 /* clear mbuf payload */
8986 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8987 rte_pktmbuf_tailroom(ut_params->ibuf));
8989 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8992 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8994 trn_data += plaintext_len;
8996 buf = ut_params->ibuf;
8999 * Loop until no more fragments
9002 while (trn_data < tdata->plaintext.len) {
9004 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
9005 (tdata->plaintext.len - trn_data) : fragsz;
9007 to_trn_tbl[ecx++] = to_trn;
9009 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9012 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9013 rte_pktmbuf_tailroom(buf));
9016 if (oop && !fragsz_oop) {
9017 buf_last_oop = buf_oop->next =
9018 rte_pktmbuf_alloc(ts_params->mbuf_pool);
9019 buf_oop = buf_oop->next;
9020 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9021 0, rte_pktmbuf_tailroom(buf_oop));
9022 rte_pktmbuf_append(buf_oop, to_trn);
9025 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9028 memcpy(plaintext, tdata->plaintext.data + trn_data,
9031 if (trn_data == tdata->plaintext.len) {
9034 digest_mem = rte_pktmbuf_append(buf_oop,
9035 tdata->auth_tag.len);
9037 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
9038 tdata->auth_tag.len);
9042 uint64_t digest_phys = 0;
9044 ut_params->ibuf->nb_segs = segs;
9047 if (fragsz_oop && oop) {
9051 if (frag_size_oop == tdata->plaintext.len) {
9052 digest_mem = rte_pktmbuf_append(ut_params->obuf,
9053 tdata->auth_tag.len);
9055 digest_phys = rte_pktmbuf_iova_offset(
9057 tdata->plaintext.len + prepend_len);
9060 trn_data = frag_size_oop;
9061 while (trn_data < tdata->plaintext.len) {
9064 (tdata->plaintext.len - trn_data <
9066 (tdata->plaintext.len - trn_data) :
9069 to_trn_tbl[ecx++] = to_trn;
9071 buf_last_oop = buf_oop->next =
9072 rte_pktmbuf_alloc(ts_params->mbuf_pool);
9073 buf_oop = buf_oop->next;
9074 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9075 0, rte_pktmbuf_tailroom(buf_oop));
9076 rte_pktmbuf_append(buf_oop, to_trn);
9080 if (trn_data == tdata->plaintext.len) {
9081 digest_mem = rte_pktmbuf_append(buf_oop,
9082 tdata->auth_tag.len);
9086 ut_params->obuf->nb_segs = segs;
9090 * Place digest at the end of the last buffer
9093 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
9094 if (oop && buf_last_oop)
9095 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
9097 if (!digest_mem && !oop) {
9098 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9099 + tdata->auth_tag.len);
9100 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
9101 tdata->plaintext.len);
9104 /* Create AEAD operation */
9105 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
9106 tdata, digest_mem, digest_phys);
9111 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9113 ut_params->op->sym->m_src = ut_params->ibuf;
9115 ut_params->op->sym->m_dst = ut_params->obuf;
9117 /* Process crypto operation */
9118 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9119 ut_params->op), "failed to process sym crypto op");
9121 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9122 "crypto op processing failed");
9125 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9126 uint8_t *, prepend_len);
9128 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9129 uint8_t *, prepend_len);
9133 fragsz = fragsz_oop;
9135 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9137 tdata->ciphertext.data,
9139 "Ciphertext data not as expected");
9141 buf = ut_params->op->sym->m_src->next;
9143 buf = ut_params->op->sym->m_dst->next;
9145 unsigned int off = fragsz;
9149 ciphertext = rte_pktmbuf_mtod(buf,
9152 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9154 tdata->ciphertext.data + off,
9156 "Ciphertext data not as expected");
9158 off += to_trn_tbl[ecx++];
9162 auth_tag = digest_mem;
9163 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9165 tdata->auth_tag.data,
9166 tdata->auth_tag.len,
9167 "Generated auth tag not as expected");
9173 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
9175 return test_authenticated_encryption_SGL(
9176 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
9180 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
9182 return test_authenticated_encryption_SGL(
9183 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
9187 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
9189 return test_authenticated_encryption_SGL(
9190 &gcm_test_case_8, OUT_OF_PLACE, 400,
9191 gcm_test_case_8.plaintext.len);
9195 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
9198 return test_authenticated_encryption_SGL(
9199 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
9203 test_authentication_verify_fail_when_data_corrupted(
9204 struct crypto_testsuite_params *ts_params,
9205 struct crypto_unittest_params *ut_params,
9206 const struct test_crypto_vector *reference)
9208 return test_authentication_verify_fail_when_data_corruption(
9209 ts_params, ut_params, reference, 1);
9213 test_authentication_verify_fail_when_tag_corrupted(
9214 struct crypto_testsuite_params *ts_params,
9215 struct crypto_unittest_params *ut_params,
9216 const struct test_crypto_vector *reference)
9218 return test_authentication_verify_fail_when_data_corruption(
9219 ts_params, ut_params, reference, 0);
9223 test_authentication_verify_GMAC_fail_when_data_corrupted(
9224 struct crypto_testsuite_params *ts_params,
9225 struct crypto_unittest_params *ut_params,
9226 const struct test_crypto_vector *reference)
9228 return test_authentication_verify_GMAC_fail_when_corruption(
9229 ts_params, ut_params, reference, 1);
9233 test_authentication_verify_GMAC_fail_when_tag_corrupted(
9234 struct crypto_testsuite_params *ts_params,
9235 struct crypto_unittest_params *ut_params,
9236 const struct test_crypto_vector *reference)
9238 return test_authentication_verify_GMAC_fail_when_corruption(
9239 ts_params, ut_params, reference, 0);
9243 test_authenticated_decryption_fail_when_data_corrupted(
9244 struct crypto_testsuite_params *ts_params,
9245 struct crypto_unittest_params *ut_params,
9246 const struct test_crypto_vector *reference)
9248 return test_authenticated_decryption_fail_when_corruption(
9249 ts_params, ut_params, reference, 1);
9253 test_authenticated_decryption_fail_when_tag_corrupted(
9254 struct crypto_testsuite_params *ts_params,
9255 struct crypto_unittest_params *ut_params,
9256 const struct test_crypto_vector *reference)
9258 return test_authenticated_decryption_fail_when_corruption(
9259 ts_params, ut_params, reference, 0);
9263 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
9265 return test_authentication_verify_fail_when_data_corrupted(
9266 &testsuite_params, &unittest_params,
9267 &hmac_sha1_test_crypto_vector);
9271 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
9273 return test_authentication_verify_fail_when_tag_corrupted(
9274 &testsuite_params, &unittest_params,
9275 &hmac_sha1_test_crypto_vector);
9279 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
9281 return test_authentication_verify_GMAC_fail_when_data_corrupted(
9282 &testsuite_params, &unittest_params,
9283 &aes128_gmac_test_vector);
9287 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
9289 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
9290 &testsuite_params, &unittest_params,
9291 &aes128_gmac_test_vector);
9295 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
9297 return test_authenticated_decryption_fail_when_data_corrupted(
9300 &aes128cbc_hmac_sha1_test_vector);
9304 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
9306 return test_authenticated_decryption_fail_when_tag_corrupted(
9309 &aes128cbc_hmac_sha1_test_vector);
9312 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9314 /* global AESNI slave IDs for the scheduler test */
9315 uint8_t aesni_ids[2];
9318 test_scheduler_attach_slave_op(void)
9320 struct crypto_testsuite_params *ts_params = &testsuite_params;
9321 uint8_t sched_id = ts_params->valid_devs[0];
9322 uint32_t nb_devs, i, nb_devs_attached = 0;
9326 /* create 2 AESNI_MB if necessary */
9327 nb_devs = rte_cryptodev_device_count_by_driver(
9328 rte_cryptodev_driver_id_get(
9329 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
9331 for (i = nb_devs; i < 2; i++) {
9332 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
9333 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
9335 ret = rte_vdev_init(vdev_name, NULL);
9337 TEST_ASSERT(ret == 0,
9338 "Failed to create instance %u of"
9340 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9344 /* attach 2 AESNI_MB cdevs */
9345 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
9347 struct rte_cryptodev_info info;
9348 unsigned int session_size;
9350 rte_cryptodev_info_get(i, &info);
9351 if (info.driver_id != rte_cryptodev_driver_id_get(
9352 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
9355 session_size = rte_cryptodev_sym_get_private_session_size(i);
9357 * Create the session mempool again, since now there are new devices
9358 * to use the mempool.
9360 if (ts_params->session_mpool) {
9361 rte_mempool_free(ts_params->session_mpool);
9362 ts_params->session_mpool = NULL;
9364 if (ts_params->session_priv_mpool) {
9365 rte_mempool_free(ts_params->session_priv_mpool);
9366 ts_params->session_priv_mpool = NULL;
9369 if (info.sym.max_nb_sessions != 0 &&
9370 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
9372 "Device does not support "
9373 "at least %u sessions\n",
9378 * Create mempool with maximum number of sessions,
9379 * to include the session headers
9381 if (ts_params->session_mpool == NULL) {
9382 ts_params->session_mpool =
9383 rte_cryptodev_sym_session_pool_create(
9385 MAX_NB_SESSIONS, 0, 0, 0,
9387 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
9388 "session mempool allocation failed");
9392 * Create mempool with maximum number of sessions,
9393 * to include device specific session private data
9395 if (ts_params->session_priv_mpool == NULL) {
9396 ts_params->session_priv_mpool = rte_mempool_create(
9397 "test_sess_mp_priv",
9400 0, 0, NULL, NULL, NULL,
9401 NULL, SOCKET_ID_ANY,
9404 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
9405 "session mempool allocation failed");
9408 ts_params->qp_conf.mp_session = ts_params->session_mpool;
9409 ts_params->qp_conf.mp_session_private =
9410 ts_params->session_priv_mpool;
9412 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
9415 TEST_ASSERT(ret == 0,
9416 "Failed to attach device %u of pmd : %s", i,
9417 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9419 aesni_ids[nb_devs_attached] = (uint8_t)i;
9428 test_scheduler_detach_slave_op(void)
9430 struct crypto_testsuite_params *ts_params = &testsuite_params;
9431 uint8_t sched_id = ts_params->valid_devs[0];
9435 for (i = 0; i < 2; i++) {
9436 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
9438 TEST_ASSERT(ret == 0,
9439 "Failed to detach device %u", aesni_ids[i]);
9446 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
9448 struct crypto_testsuite_params *ts_params = &testsuite_params;
9449 uint8_t sched_id = ts_params->valid_devs[0];
9451 return rte_cryptodev_scheduler_mode_set(sched_id,
9456 test_scheduler_mode_roundrobin_op(void)
9458 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
9459 0, "Failed to set roundrobin mode");
9465 test_scheduler_mode_multicore_op(void)
9467 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
9468 0, "Failed to set multicore mode");
9474 test_scheduler_mode_failover_op(void)
9476 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
9477 0, "Failed to set failover mode");
9483 test_scheduler_mode_pkt_size_distr_op(void)
9485 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
9486 0, "Failed to set pktsize mode");
9491 static struct unit_test_suite cryptodev_scheduler_testsuite = {
9492 .suite_name = "Crypto Device Scheduler Unit Test Suite",
9493 .setup = testsuite_setup,
9494 .teardown = testsuite_teardown,
9495 .unit_test_cases = {
9497 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9498 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_AES_chain_scheduler_all),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_AES_cipheronly_scheduler_all),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_authonly_scheduler_all),
9505 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9508 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9509 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_AES_chain_scheduler_all),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_AES_cipheronly_scheduler_all),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_authonly_scheduler_all),
9516 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9519 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9520 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_AES_chain_scheduler_all),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_AES_cipheronly_scheduler_all),
9525 TEST_CASE_ST(ut_setup, ut_teardown,
9526 test_authonly_scheduler_all),
9527 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9530 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9531 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
9532 TEST_CASE_ST(ut_setup, ut_teardown,
9533 test_AES_chain_scheduler_all),
9534 TEST_CASE_ST(ut_setup, ut_teardown,
9535 test_AES_cipheronly_scheduler_all),
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 test_authonly_scheduler_all),
9538 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9540 TEST_CASES_END() /**< NULL terminate unit test array */
9544 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
9546 static struct unit_test_suite cryptodev_qat_testsuite = {
9547 .suite_name = "Crypto QAT Unit Test Suite",
9548 .setup = testsuite_setup,
9549 .teardown = testsuite_teardown,
9550 .unit_test_cases = {
9551 TEST_CASE_ST(ut_setup, ut_teardown,
9552 test_device_configure_invalid_dev_id),
9553 TEST_CASE_ST(ut_setup, ut_teardown,
9554 test_device_configure_invalid_queue_pair_ids),
9555 TEST_CASE_ST(ut_setup, ut_teardown,
9556 test_queue_pair_descriptor_setup),
9557 TEST_CASE_ST(ut_setup, ut_teardown,
9558 test_multi_session),
9560 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
9561 TEST_CASE_ST(ut_setup, ut_teardown,
9562 test_AES_cipheronly_qat_all),
9563 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_3DES_cipheronly_qat_all),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_DES_cipheronly_qat_all),
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 test_AES_docsis_qat_all),
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 test_DES_docsis_qat_all),
9572 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
9573 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
9575 /** AES CCM Authenticated Encryption 128 bits key */
9576 TEST_CASE_ST(ut_setup, ut_teardown,
9577 test_AES_CCM_authenticated_encryption_test_case_128_1),
9578 TEST_CASE_ST(ut_setup, ut_teardown,
9579 test_AES_CCM_authenticated_encryption_test_case_128_2),
9580 TEST_CASE_ST(ut_setup, ut_teardown,
9581 test_AES_CCM_authenticated_encryption_test_case_128_3),
9583 /** AES CCM Authenticated Decryption 128 bits key*/
9584 TEST_CASE_ST(ut_setup, ut_teardown,
9585 test_AES_CCM_authenticated_decryption_test_case_128_1),
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_AES_CCM_authenticated_decryption_test_case_128_2),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_AES_CCM_authenticated_decryption_test_case_128_3),
9591 /** AES GCM Authenticated Encryption */
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9598 TEST_CASE_ST(ut_setup, ut_teardown,
9599 test_AES_GCM_authenticated_encryption_test_case_1),
9600 TEST_CASE_ST(ut_setup, ut_teardown,
9601 test_AES_GCM_authenticated_encryption_test_case_2),
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_authenticated_encryption_test_case_3),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_GCM_authenticated_encryption_test_case_4),
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_authenticated_encryption_test_case_5),
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_GCM_authenticated_encryption_test_case_6),
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_authenticated_encryption_test_case_7),
9613 /** AES GCM Authenticated Decryption */
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_AES_GCM_authenticated_decryption_test_case_1),
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GCM_authenticated_decryption_test_case_2),
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GCM_authenticated_decryption_test_case_3),
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 test_AES_GCM_authenticated_decryption_test_case_4),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GCM_authenticated_decryption_test_case_5),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_GCM_authenticated_decryption_test_case_6),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GCM_authenticated_decryption_test_case_7),
9629 /** AES GCM Authenticated Encryption 192 bits key */
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GCM_auth_encryption_test_case_192_1),
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_AES_GCM_auth_encryption_test_case_192_2),
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_GCM_auth_encryption_test_case_192_3),
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 test_AES_GCM_auth_encryption_test_case_192_4),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_GCM_auth_encryption_test_case_192_5),
9640 TEST_CASE_ST(ut_setup, ut_teardown,
9641 test_AES_GCM_auth_encryption_test_case_192_6),
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 test_AES_GCM_auth_encryption_test_case_192_7),
9645 /** AES GCM Authenticated Decryption 192 bits key */
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_GCM_auth_decryption_test_case_192_1),
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_GCM_auth_decryption_test_case_192_2),
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_auth_decryption_test_case_192_3),
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_GCM_auth_decryption_test_case_192_4),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_auth_decryption_test_case_192_5),
9656 TEST_CASE_ST(ut_setup, ut_teardown,
9657 test_AES_GCM_auth_decryption_test_case_192_6),
9658 TEST_CASE_ST(ut_setup, ut_teardown,
9659 test_AES_GCM_auth_decryption_test_case_192_7),
9661 /** AES GCM Authenticated Encryption 256 bits key */
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_GCM_auth_encryption_test_case_256_1),
9664 TEST_CASE_ST(ut_setup, ut_teardown,
9665 test_AES_GCM_auth_encryption_test_case_256_2),
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_auth_encryption_test_case_256_3),
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_GCM_auth_encryption_test_case_256_4),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GCM_auth_encryption_test_case_256_5),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_GCM_auth_encryption_test_case_256_6),
9674 TEST_CASE_ST(ut_setup, ut_teardown,
9675 test_AES_GCM_auth_encryption_test_case_256_7),
9677 /** AES GMAC Authentication */
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_AES_GMAC_authentication_test_case_1),
9680 TEST_CASE_ST(ut_setup, ut_teardown,
9681 test_AES_GMAC_authentication_verify_test_case_1),
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GMAC_authentication_test_case_2),
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GMAC_authentication_verify_test_case_2),
9686 TEST_CASE_ST(ut_setup, ut_teardown,
9687 test_AES_GMAC_authentication_test_case_3),
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 test_AES_GMAC_authentication_verify_test_case_3),
9691 /** SNOW 3G encrypt only (UEA2) */
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 test_snow3g_encryption_test_case_1),
9694 TEST_CASE_ST(ut_setup, ut_teardown,
9695 test_snow3g_encryption_test_case_2),
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 test_snow3g_encryption_test_case_3),
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 test_snow3g_encryption_test_case_4),
9700 TEST_CASE_ST(ut_setup, ut_teardown,
9701 test_snow3g_encryption_test_case_5),
9703 TEST_CASE_ST(ut_setup, ut_teardown,
9704 test_snow3g_encryption_test_case_1_oop),
9705 TEST_CASE_ST(ut_setup, ut_teardown,
9706 test_snow3g_decryption_test_case_1_oop),
9708 /** SNOW 3G generate auth, then encrypt (UEA2) */
9709 TEST_CASE_ST(ut_setup, ut_teardown,
9710 test_snow3g_auth_cipher_test_case_1),
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 test_snow3g_auth_cipher_test_case_2),
9713 TEST_CASE_ST(ut_setup, ut_teardown,
9714 test_snow3g_auth_cipher_test_case_2_oop),
9715 TEST_CASE_ST(ut_setup, ut_teardown,
9716 test_snow3g_auth_cipher_part_digest_enc),
9717 TEST_CASE_ST(ut_setup, ut_teardown,
9718 test_snow3g_auth_cipher_part_digest_enc_oop),
9720 /** SNOW 3G decrypt (UEA2), then verify auth */
9721 TEST_CASE_ST(ut_setup, ut_teardown,
9722 test_snow3g_auth_cipher_verify_test_case_1),
9723 TEST_CASE_ST(ut_setup, ut_teardown,
9724 test_snow3g_auth_cipher_verify_test_case_2),
9725 TEST_CASE_ST(ut_setup, ut_teardown,
9726 test_snow3g_auth_cipher_verify_test_case_2_oop),
9727 TEST_CASE_ST(ut_setup, ut_teardown,
9728 test_snow3g_auth_cipher_verify_part_digest_enc),
9729 TEST_CASE_ST(ut_setup, ut_teardown,
9730 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
9732 /** SNOW 3G decrypt only (UEA2) */
9733 TEST_CASE_ST(ut_setup, ut_teardown,
9734 test_snow3g_decryption_test_case_1),
9735 TEST_CASE_ST(ut_setup, ut_teardown,
9736 test_snow3g_decryption_test_case_2),
9737 TEST_CASE_ST(ut_setup, ut_teardown,
9738 test_snow3g_decryption_test_case_3),
9739 TEST_CASE_ST(ut_setup, ut_teardown,
9740 test_snow3g_decryption_test_case_4),
9741 TEST_CASE_ST(ut_setup, ut_teardown,
9742 test_snow3g_decryption_test_case_5),
9743 TEST_CASE_ST(ut_setup, ut_teardown,
9744 test_snow3g_decryption_with_digest_test_case_1),
9745 TEST_CASE_ST(ut_setup, ut_teardown,
9746 test_snow3g_hash_generate_test_case_1),
9747 TEST_CASE_ST(ut_setup, ut_teardown,
9748 test_snow3g_hash_generate_test_case_2),
9749 TEST_CASE_ST(ut_setup, ut_teardown,
9750 test_snow3g_hash_generate_test_case_3),
9751 TEST_CASE_ST(ut_setup, ut_teardown,
9752 test_snow3g_hash_verify_test_case_1),
9753 TEST_CASE_ST(ut_setup, ut_teardown,
9754 test_snow3g_hash_verify_test_case_2),
9755 TEST_CASE_ST(ut_setup, ut_teardown,
9756 test_snow3g_hash_verify_test_case_3),
9757 TEST_CASE_ST(ut_setup, ut_teardown,
9758 test_snow3g_cipher_auth_test_case_1),
9759 TEST_CASE_ST(ut_setup, ut_teardown,
9760 test_snow3g_auth_cipher_with_digest_test_case_1),
9762 /** ZUC encrypt only (EEA3) */
9763 TEST_CASE_ST(ut_setup, ut_teardown,
9764 test_zuc_encryption_test_case_1),
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 test_zuc_encryption_test_case_2),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 test_zuc_encryption_test_case_3),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_zuc_encryption_test_case_4),
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_zuc_encryption_test_case_5),
9774 /** ZUC authenticate (EIA3) */
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_zuc_hash_generate_test_case_6),
9777 TEST_CASE_ST(ut_setup, ut_teardown,
9778 test_zuc_hash_generate_test_case_7),
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 test_zuc_hash_generate_test_case_8),
9782 /** ZUC alg-chain (EEA3/EIA3) */
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_zuc_cipher_auth_test_case_1),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_zuc_cipher_auth_test_case_2),
9788 /** ZUC generate auth, then encrypt (EEA3) */
9789 TEST_CASE_ST(ut_setup, ut_teardown,
9790 test_zuc_auth_cipher_test_case_1),
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_zuc_auth_cipher_test_case_1_oop),
9794 /** ZUC decrypt (EEA3), then verify auth */
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_zuc_auth_cipher_verify_test_case_1),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_zuc_auth_cipher_verify_test_case_1_oop),
9800 /** HMAC_MD5 Authentication */
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_MD5_HMAC_generate_case_1),
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_MD5_HMAC_verify_case_1),
9805 TEST_CASE_ST(ut_setup, ut_teardown,
9806 test_MD5_HMAC_generate_case_2),
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 test_MD5_HMAC_verify_case_2),
9810 /** NULL algo tests done in chain_all,
9811 * cipheronly and authonly suites
9815 TEST_CASE_ST(ut_setup, ut_teardown,
9816 test_kasumi_hash_generate_test_case_1),
9817 TEST_CASE_ST(ut_setup, ut_teardown,
9818 test_kasumi_hash_generate_test_case_2),
9819 TEST_CASE_ST(ut_setup, ut_teardown,
9820 test_kasumi_hash_generate_test_case_3),
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_kasumi_hash_generate_test_case_4),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_kasumi_hash_generate_test_case_5),
9825 TEST_CASE_ST(ut_setup, ut_teardown,
9826 test_kasumi_hash_generate_test_case_6),
9828 TEST_CASE_ST(ut_setup, ut_teardown,
9829 test_kasumi_hash_verify_test_case_1),
9830 TEST_CASE_ST(ut_setup, ut_teardown,
9831 test_kasumi_hash_verify_test_case_2),
9832 TEST_CASE_ST(ut_setup, ut_teardown,
9833 test_kasumi_hash_verify_test_case_3),
9834 TEST_CASE_ST(ut_setup, ut_teardown,
9835 test_kasumi_hash_verify_test_case_4),
9836 TEST_CASE_ST(ut_setup, ut_teardown,
9837 test_kasumi_hash_verify_test_case_5),
9839 TEST_CASE_ST(ut_setup, ut_teardown,
9840 test_kasumi_encryption_test_case_1),
9841 TEST_CASE_ST(ut_setup, ut_teardown,
9842 test_kasumi_encryption_test_case_3),
9843 TEST_CASE_ST(ut_setup, ut_teardown,
9844 test_kasumi_cipher_auth_test_case_1),
9846 /** KASUMI generate auth, then encrypt (F8) */
9847 TEST_CASE_ST(ut_setup, ut_teardown,
9848 test_kasumi_auth_cipher_test_case_1),
9849 TEST_CASE_ST(ut_setup, ut_teardown,
9850 test_kasumi_auth_cipher_test_case_2),
9851 TEST_CASE_ST(ut_setup, ut_teardown,
9852 test_kasumi_auth_cipher_test_case_2_oop),
9854 /** KASUMI decrypt (F8), then verify auth */
9855 TEST_CASE_ST(ut_setup, ut_teardown,
9856 test_kasumi_auth_cipher_verify_test_case_1),
9857 TEST_CASE_ST(ut_setup, ut_teardown,
9858 test_kasumi_auth_cipher_verify_test_case_2),
9859 TEST_CASE_ST(ut_setup, ut_teardown,
9860 test_kasumi_auth_cipher_verify_test_case_2_oop),
9862 /** Negative tests */
9863 TEST_CASE_ST(ut_setup, ut_teardown,
9864 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9865 TEST_CASE_ST(ut_setup, ut_teardown,
9866 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9867 TEST_CASE_ST(ut_setup, ut_teardown,
9868 authentication_verify_AES128_GMAC_fail_data_corrupt),
9869 TEST_CASE_ST(ut_setup, ut_teardown,
9870 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9871 TEST_CASE_ST(ut_setup, ut_teardown,
9872 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9873 TEST_CASE_ST(ut_setup, ut_teardown,
9874 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9876 TEST_CASES_END() /**< NULL terminate unit test array */
9880 static struct unit_test_suite cryptodev_virtio_testsuite = {
9881 .suite_name = "Crypto VIRTIO Unit Test Suite",
9882 .setup = testsuite_setup,
9883 .teardown = testsuite_teardown,
9884 .unit_test_cases = {
9885 TEST_CASE_ST(ut_setup, ut_teardown,
9886 test_AES_cipheronly_virtio_all),
9888 TEST_CASES_END() /**< NULL terminate unit test array */
9892 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9893 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9894 .setup = testsuite_setup,
9895 .teardown = testsuite_teardown,
9896 .unit_test_cases = {
9897 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9898 TEST_CASE_ST(ut_setup, ut_teardown,
9899 test_AES_GCM_authenticated_encryption_test_case_1),
9900 TEST_CASE_ST(ut_setup, ut_teardown,
9901 test_AES_GCM_authenticated_encryption_test_case_2),
9902 TEST_CASE_ST(ut_setup, ut_teardown,
9903 test_AES_GCM_authenticated_encryption_test_case_3),
9904 TEST_CASE_ST(ut_setup, ut_teardown,
9905 test_AES_GCM_authenticated_encryption_test_case_4),
9906 TEST_CASE_ST(ut_setup, ut_teardown,
9907 test_AES_GCM_authenticated_encryption_test_case_5),
9908 TEST_CASE_ST(ut_setup, ut_teardown,
9909 test_AES_GCM_authenticated_encryption_test_case_6),
9910 TEST_CASE_ST(ut_setup, ut_teardown,
9911 test_AES_GCM_authenticated_encryption_test_case_7),
9913 /** AES GCM Authenticated Decryption */
9914 TEST_CASE_ST(ut_setup, ut_teardown,
9915 test_AES_GCM_authenticated_decryption_test_case_1),
9916 TEST_CASE_ST(ut_setup, ut_teardown,
9917 test_AES_GCM_authenticated_decryption_test_case_2),
9918 TEST_CASE_ST(ut_setup, ut_teardown,
9919 test_AES_GCM_authenticated_decryption_test_case_3),
9920 TEST_CASE_ST(ut_setup, ut_teardown,
9921 test_AES_GCM_authenticated_decryption_test_case_4),
9922 TEST_CASE_ST(ut_setup, ut_teardown,
9923 test_AES_GCM_authenticated_decryption_test_case_5),
9924 TEST_CASE_ST(ut_setup, ut_teardown,
9925 test_AES_GCM_authenticated_decryption_test_case_6),
9926 TEST_CASE_ST(ut_setup, ut_teardown,
9927 test_AES_GCM_authenticated_decryption_test_case_7),
9929 /** AES GCM Authenticated Encryption 192 bits key */
9930 TEST_CASE_ST(ut_setup, ut_teardown,
9931 test_AES_GCM_auth_encryption_test_case_192_1),
9932 TEST_CASE_ST(ut_setup, ut_teardown,
9933 test_AES_GCM_auth_encryption_test_case_192_2),
9934 TEST_CASE_ST(ut_setup, ut_teardown,
9935 test_AES_GCM_auth_encryption_test_case_192_3),
9936 TEST_CASE_ST(ut_setup, ut_teardown,
9937 test_AES_GCM_auth_encryption_test_case_192_4),
9938 TEST_CASE_ST(ut_setup, ut_teardown,
9939 test_AES_GCM_auth_encryption_test_case_192_5),
9940 TEST_CASE_ST(ut_setup, ut_teardown,
9941 test_AES_GCM_auth_encryption_test_case_192_6),
9942 TEST_CASE_ST(ut_setup, ut_teardown,
9943 test_AES_GCM_auth_encryption_test_case_192_7),
9945 /** AES GCM Authenticated Decryption 192 bits key */
9946 TEST_CASE_ST(ut_setup, ut_teardown,
9947 test_AES_GCM_auth_decryption_test_case_192_1),
9948 TEST_CASE_ST(ut_setup, ut_teardown,
9949 test_AES_GCM_auth_decryption_test_case_192_2),
9950 TEST_CASE_ST(ut_setup, ut_teardown,
9951 test_AES_GCM_auth_decryption_test_case_192_3),
9952 TEST_CASE_ST(ut_setup, ut_teardown,
9953 test_AES_GCM_auth_decryption_test_case_192_4),
9954 TEST_CASE_ST(ut_setup, ut_teardown,
9955 test_AES_GCM_auth_decryption_test_case_192_5),
9956 TEST_CASE_ST(ut_setup, ut_teardown,
9957 test_AES_GCM_auth_decryption_test_case_192_6),
9958 TEST_CASE_ST(ut_setup, ut_teardown,
9959 test_AES_GCM_auth_decryption_test_case_192_7),
9961 /** AES GCM Authenticated Encryption 256 bits key */
9962 TEST_CASE_ST(ut_setup, ut_teardown,
9963 test_AES_GCM_auth_encryption_test_case_256_1),
9964 TEST_CASE_ST(ut_setup, ut_teardown,
9965 test_AES_GCM_auth_encryption_test_case_256_2),
9966 TEST_CASE_ST(ut_setup, ut_teardown,
9967 test_AES_GCM_auth_encryption_test_case_256_3),
9968 TEST_CASE_ST(ut_setup, ut_teardown,
9969 test_AES_GCM_auth_encryption_test_case_256_4),
9970 TEST_CASE_ST(ut_setup, ut_teardown,
9971 test_AES_GCM_auth_encryption_test_case_256_5),
9972 TEST_CASE_ST(ut_setup, ut_teardown,
9973 test_AES_GCM_auth_encryption_test_case_256_6),
9974 TEST_CASE_ST(ut_setup, ut_teardown,
9975 test_AES_GCM_auth_encryption_test_case_256_7),
9977 /** AES GCM Authenticated Decryption 256 bits key */
9978 TEST_CASE_ST(ut_setup, ut_teardown,
9979 test_AES_GCM_auth_decryption_test_case_256_1),
9980 TEST_CASE_ST(ut_setup, ut_teardown,
9981 test_AES_GCM_auth_decryption_test_case_256_2),
9982 TEST_CASE_ST(ut_setup, ut_teardown,
9983 test_AES_GCM_auth_decryption_test_case_256_3),
9984 TEST_CASE_ST(ut_setup, ut_teardown,
9985 test_AES_GCM_auth_decryption_test_case_256_4),
9986 TEST_CASE_ST(ut_setup, ut_teardown,
9987 test_AES_GCM_auth_decryption_test_case_256_5),
9988 TEST_CASE_ST(ut_setup, ut_teardown,
9989 test_AES_GCM_auth_decryption_test_case_256_6),
9990 TEST_CASE_ST(ut_setup, ut_teardown,
9991 test_AES_GCM_auth_decryption_test_case_256_7),
9993 /** AES GCM Authenticated Encryption big aad size */
9994 TEST_CASE_ST(ut_setup, ut_teardown,
9995 test_AES_GCM_auth_encryption_test_case_aad_1),
9996 TEST_CASE_ST(ut_setup, ut_teardown,
9997 test_AES_GCM_auth_encryption_test_case_aad_2),
9999 /** AES GCM Authenticated Decryption big aad size */
10000 TEST_CASE_ST(ut_setup, ut_teardown,
10001 test_AES_GCM_auth_decryption_test_case_aad_1),
10002 TEST_CASE_ST(ut_setup, ut_teardown,
10003 test_AES_GCM_auth_decryption_test_case_aad_2),
10005 /** Session-less tests */
10006 TEST_CASE_ST(ut_setup, ut_teardown,
10007 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
10008 TEST_CASE_ST(ut_setup, ut_teardown,
10009 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
10011 /** AES GMAC Authentication */
10012 TEST_CASE_ST(ut_setup, ut_teardown,
10013 test_AES_GMAC_authentication_test_case_1),
10014 TEST_CASE_ST(ut_setup, ut_teardown,
10015 test_AES_GMAC_authentication_verify_test_case_1),
10016 TEST_CASE_ST(ut_setup, ut_teardown,
10017 test_AES_GMAC_authentication_test_case_2),
10018 TEST_CASE_ST(ut_setup, ut_teardown,
10019 test_AES_GMAC_authentication_verify_test_case_2),
10020 TEST_CASE_ST(ut_setup, ut_teardown,
10021 test_AES_GMAC_authentication_test_case_3),
10022 TEST_CASE_ST(ut_setup, ut_teardown,
10023 test_AES_GMAC_authentication_verify_test_case_3),
10024 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
10026 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
10027 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
10028 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
10029 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
10030 TEST_CASE_ST(ut_setup, ut_teardown,
10031 test_DES_cipheronly_mb_all),
10032 TEST_CASE_ST(ut_setup, ut_teardown,
10033 test_DES_docsis_mb_all),
10034 TEST_CASE_ST(ut_setup, ut_teardown,
10035 test_3DES_cipheronly_mb_all),
10036 TEST_CASE_ST(ut_setup, ut_teardown,
10037 test_AES_CCM_authenticated_encryption_test_case_128_1),
10038 TEST_CASE_ST(ut_setup, ut_teardown,
10039 test_AES_CCM_authenticated_decryption_test_case_128_1),
10040 TEST_CASE_ST(ut_setup, ut_teardown,
10041 test_AES_CCM_authenticated_encryption_test_case_128_2),
10042 TEST_CASE_ST(ut_setup, ut_teardown,
10043 test_AES_CCM_authenticated_decryption_test_case_128_2),
10044 TEST_CASE_ST(ut_setup, ut_teardown,
10045 test_AES_CCM_authenticated_encryption_test_case_128_3),
10046 TEST_CASE_ST(ut_setup, ut_teardown,
10047 test_AES_CCM_authenticated_decryption_test_case_128_3),
10049 TEST_CASES_END() /**< NULL terminate unit test array */
10053 static struct unit_test_suite cryptodev_openssl_testsuite = {
10054 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
10055 .setup = testsuite_setup,
10056 .teardown = testsuite_teardown,
10057 .unit_test_cases = {
10058 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10059 TEST_CASE_ST(ut_setup, ut_teardown,
10060 test_multi_session_random_usage),
10061 TEST_CASE_ST(ut_setup, ut_teardown,
10062 test_AES_chain_openssl_all),
10063 TEST_CASE_ST(ut_setup, ut_teardown,
10064 test_AES_cipheronly_openssl_all),
10065 TEST_CASE_ST(ut_setup, ut_teardown,
10066 test_3DES_chain_openssl_all),
10067 TEST_CASE_ST(ut_setup, ut_teardown,
10068 test_3DES_cipheronly_openssl_all),
10069 TEST_CASE_ST(ut_setup, ut_teardown,
10070 test_DES_cipheronly_openssl_all),
10071 TEST_CASE_ST(ut_setup, ut_teardown,
10072 test_DES_docsis_openssl_all),
10073 TEST_CASE_ST(ut_setup, ut_teardown,
10074 test_authonly_openssl_all),
10076 /** AES GCM Authenticated Encryption */
10077 TEST_CASE_ST(ut_setup, ut_teardown,
10078 test_AES_GCM_authenticated_encryption_test_case_1),
10079 TEST_CASE_ST(ut_setup, ut_teardown,
10080 test_AES_GCM_authenticated_encryption_test_case_2),
10081 TEST_CASE_ST(ut_setup, ut_teardown,
10082 test_AES_GCM_authenticated_encryption_test_case_3),
10083 TEST_CASE_ST(ut_setup, ut_teardown,
10084 test_AES_GCM_authenticated_encryption_test_case_4),
10085 TEST_CASE_ST(ut_setup, ut_teardown,
10086 test_AES_GCM_authenticated_encryption_test_case_5),
10087 TEST_CASE_ST(ut_setup, ut_teardown,
10088 test_AES_GCM_authenticated_encryption_test_case_6),
10089 TEST_CASE_ST(ut_setup, ut_teardown,
10090 test_AES_GCM_authenticated_encryption_test_case_7),
10092 /** AES GCM Authenticated Decryption */
10093 TEST_CASE_ST(ut_setup, ut_teardown,
10094 test_AES_GCM_authenticated_decryption_test_case_1),
10095 TEST_CASE_ST(ut_setup, ut_teardown,
10096 test_AES_GCM_authenticated_decryption_test_case_2),
10097 TEST_CASE_ST(ut_setup, ut_teardown,
10098 test_AES_GCM_authenticated_decryption_test_case_3),
10099 TEST_CASE_ST(ut_setup, ut_teardown,
10100 test_AES_GCM_authenticated_decryption_test_case_4),
10101 TEST_CASE_ST(ut_setup, ut_teardown,
10102 test_AES_GCM_authenticated_decryption_test_case_5),
10103 TEST_CASE_ST(ut_setup, ut_teardown,
10104 test_AES_GCM_authenticated_decryption_test_case_6),
10105 TEST_CASE_ST(ut_setup, ut_teardown,
10106 test_AES_GCM_authenticated_decryption_test_case_7),
10109 /** AES GCM Authenticated Encryption 192 bits key */
10110 TEST_CASE_ST(ut_setup, ut_teardown,
10111 test_AES_GCM_auth_encryption_test_case_192_1),
10112 TEST_CASE_ST(ut_setup, ut_teardown,
10113 test_AES_GCM_auth_encryption_test_case_192_2),
10114 TEST_CASE_ST(ut_setup, ut_teardown,
10115 test_AES_GCM_auth_encryption_test_case_192_3),
10116 TEST_CASE_ST(ut_setup, ut_teardown,
10117 test_AES_GCM_auth_encryption_test_case_192_4),
10118 TEST_CASE_ST(ut_setup, ut_teardown,
10119 test_AES_GCM_auth_encryption_test_case_192_5),
10120 TEST_CASE_ST(ut_setup, ut_teardown,
10121 test_AES_GCM_auth_encryption_test_case_192_6),
10122 TEST_CASE_ST(ut_setup, ut_teardown,
10123 test_AES_GCM_auth_encryption_test_case_192_7),
10125 /** AES GCM Authenticated Decryption 192 bits key */
10126 TEST_CASE_ST(ut_setup, ut_teardown,
10127 test_AES_GCM_auth_decryption_test_case_192_1),
10128 TEST_CASE_ST(ut_setup, ut_teardown,
10129 test_AES_GCM_auth_decryption_test_case_192_2),
10130 TEST_CASE_ST(ut_setup, ut_teardown,
10131 test_AES_GCM_auth_decryption_test_case_192_3),
10132 TEST_CASE_ST(ut_setup, ut_teardown,
10133 test_AES_GCM_auth_decryption_test_case_192_4),
10134 TEST_CASE_ST(ut_setup, ut_teardown,
10135 test_AES_GCM_auth_decryption_test_case_192_5),
10136 TEST_CASE_ST(ut_setup, ut_teardown,
10137 test_AES_GCM_auth_decryption_test_case_192_6),
10138 TEST_CASE_ST(ut_setup, ut_teardown,
10139 test_AES_GCM_auth_decryption_test_case_192_7),
10141 /** AES GCM Authenticated Encryption 256 bits key */
10142 TEST_CASE_ST(ut_setup, ut_teardown,
10143 test_AES_GCM_auth_encryption_test_case_256_1),
10144 TEST_CASE_ST(ut_setup, ut_teardown,
10145 test_AES_GCM_auth_encryption_test_case_256_2),
10146 TEST_CASE_ST(ut_setup, ut_teardown,
10147 test_AES_GCM_auth_encryption_test_case_256_3),
10148 TEST_CASE_ST(ut_setup, ut_teardown,
10149 test_AES_GCM_auth_encryption_test_case_256_4),
10150 TEST_CASE_ST(ut_setup, ut_teardown,
10151 test_AES_GCM_auth_encryption_test_case_256_5),
10152 TEST_CASE_ST(ut_setup, ut_teardown,
10153 test_AES_GCM_auth_encryption_test_case_256_6),
10154 TEST_CASE_ST(ut_setup, ut_teardown,
10155 test_AES_GCM_auth_encryption_test_case_256_7),
10157 /** AES GCM Authenticated Decryption 256 bits key */
10158 TEST_CASE_ST(ut_setup, ut_teardown,
10159 test_AES_GCM_auth_decryption_test_case_256_1),
10160 TEST_CASE_ST(ut_setup, ut_teardown,
10161 test_AES_GCM_auth_decryption_test_case_256_2),
10162 TEST_CASE_ST(ut_setup, ut_teardown,
10163 test_AES_GCM_auth_decryption_test_case_256_3),
10164 TEST_CASE_ST(ut_setup, ut_teardown,
10165 test_AES_GCM_auth_decryption_test_case_256_4),
10166 TEST_CASE_ST(ut_setup, ut_teardown,
10167 test_AES_GCM_auth_decryption_test_case_256_5),
10168 TEST_CASE_ST(ut_setup, ut_teardown,
10169 test_AES_GCM_auth_decryption_test_case_256_6),
10170 TEST_CASE_ST(ut_setup, ut_teardown,
10171 test_AES_GCM_auth_decryption_test_case_256_7),
10173 /** AES GMAC Authentication */
10174 TEST_CASE_ST(ut_setup, ut_teardown,
10175 test_AES_GMAC_authentication_test_case_1),
10176 TEST_CASE_ST(ut_setup, ut_teardown,
10177 test_AES_GMAC_authentication_verify_test_case_1),
10178 TEST_CASE_ST(ut_setup, ut_teardown,
10179 test_AES_GMAC_authentication_test_case_2),
10180 TEST_CASE_ST(ut_setup, ut_teardown,
10181 test_AES_GMAC_authentication_verify_test_case_2),
10182 TEST_CASE_ST(ut_setup, ut_teardown,
10183 test_AES_GMAC_authentication_test_case_3),
10184 TEST_CASE_ST(ut_setup, ut_teardown,
10185 test_AES_GMAC_authentication_verify_test_case_3),
10186 TEST_CASE_ST(ut_setup, ut_teardown,
10187 test_AES_GMAC_authentication_test_case_4),
10188 TEST_CASE_ST(ut_setup, ut_teardown,
10189 test_AES_GMAC_authentication_verify_test_case_4),
10191 /** AES CCM Authenticated Encryption 128 bits key */
10192 TEST_CASE_ST(ut_setup, ut_teardown,
10193 test_AES_CCM_authenticated_encryption_test_case_128_1),
10194 TEST_CASE_ST(ut_setup, ut_teardown,
10195 test_AES_CCM_authenticated_encryption_test_case_128_2),
10196 TEST_CASE_ST(ut_setup, ut_teardown,
10197 test_AES_CCM_authenticated_encryption_test_case_128_3),
10199 /** AES CCM Authenticated Decryption 128 bits key*/
10200 TEST_CASE_ST(ut_setup, ut_teardown,
10201 test_AES_CCM_authenticated_decryption_test_case_128_1),
10202 TEST_CASE_ST(ut_setup, ut_teardown,
10203 test_AES_CCM_authenticated_decryption_test_case_128_2),
10204 TEST_CASE_ST(ut_setup, ut_teardown,
10205 test_AES_CCM_authenticated_decryption_test_case_128_3),
10207 /** AES CCM Authenticated Encryption 192 bits key */
10208 TEST_CASE_ST(ut_setup, ut_teardown,
10209 test_AES_CCM_authenticated_encryption_test_case_192_1),
10210 TEST_CASE_ST(ut_setup, ut_teardown,
10211 test_AES_CCM_authenticated_encryption_test_case_192_2),
10212 TEST_CASE_ST(ut_setup, ut_teardown,
10213 test_AES_CCM_authenticated_encryption_test_case_192_3),
10215 /** AES CCM Authenticated Decryption 192 bits key*/
10216 TEST_CASE_ST(ut_setup, ut_teardown,
10217 test_AES_CCM_authenticated_decryption_test_case_192_1),
10218 TEST_CASE_ST(ut_setup, ut_teardown,
10219 test_AES_CCM_authenticated_decryption_test_case_192_2),
10220 TEST_CASE_ST(ut_setup, ut_teardown,
10221 test_AES_CCM_authenticated_decryption_test_case_192_3),
10223 /** AES CCM Authenticated Encryption 256 bits key */
10224 TEST_CASE_ST(ut_setup, ut_teardown,
10225 test_AES_CCM_authenticated_encryption_test_case_256_1),
10226 TEST_CASE_ST(ut_setup, ut_teardown,
10227 test_AES_CCM_authenticated_encryption_test_case_256_2),
10228 TEST_CASE_ST(ut_setup, ut_teardown,
10229 test_AES_CCM_authenticated_encryption_test_case_256_3),
10231 /** AES CCM Authenticated Decryption 256 bits key*/
10232 TEST_CASE_ST(ut_setup, ut_teardown,
10233 test_AES_CCM_authenticated_decryption_test_case_256_1),
10234 TEST_CASE_ST(ut_setup, ut_teardown,
10235 test_AES_CCM_authenticated_decryption_test_case_256_2),
10236 TEST_CASE_ST(ut_setup, ut_teardown,
10237 test_AES_CCM_authenticated_decryption_test_case_256_3),
10239 /** Scatter-Gather */
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10243 /** Negative tests */
10244 TEST_CASE_ST(ut_setup, ut_teardown,
10245 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10246 TEST_CASE_ST(ut_setup, ut_teardown,
10247 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10248 TEST_CASE_ST(ut_setup, ut_teardown,
10249 authentication_verify_AES128_GMAC_fail_data_corrupt),
10250 TEST_CASE_ST(ut_setup, ut_teardown,
10251 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10252 TEST_CASE_ST(ut_setup, ut_teardown,
10253 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10254 TEST_CASE_ST(ut_setup, ut_teardown,
10255 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10257 TEST_CASES_END() /**< NULL terminate unit test array */
10261 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
10262 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
10263 .setup = testsuite_setup,
10264 .teardown = testsuite_teardown,
10265 .unit_test_cases = {
10266 /** AES GCM Authenticated Encryption */
10267 TEST_CASE_ST(ut_setup, ut_teardown,
10268 test_AES_GCM_authenticated_encryption_test_case_1),
10269 TEST_CASE_ST(ut_setup, ut_teardown,
10270 test_AES_GCM_authenticated_encryption_test_case_2),
10271 TEST_CASE_ST(ut_setup, ut_teardown,
10272 test_AES_GCM_authenticated_encryption_test_case_3),
10273 TEST_CASE_ST(ut_setup, ut_teardown,
10274 test_AES_GCM_authenticated_encryption_test_case_4),
10275 TEST_CASE_ST(ut_setup, ut_teardown,
10276 test_AES_GCM_authenticated_encryption_test_case_5),
10277 TEST_CASE_ST(ut_setup, ut_teardown,
10278 test_AES_GCM_authenticated_encryption_test_case_6),
10279 TEST_CASE_ST(ut_setup, ut_teardown,
10280 test_AES_GCM_authenticated_encryption_test_case_7),
10282 /** AES GCM Authenticated Decryption */
10283 TEST_CASE_ST(ut_setup, ut_teardown,
10284 test_AES_GCM_authenticated_decryption_test_case_1),
10285 TEST_CASE_ST(ut_setup, ut_teardown,
10286 test_AES_GCM_authenticated_decryption_test_case_2),
10287 TEST_CASE_ST(ut_setup, ut_teardown,
10288 test_AES_GCM_authenticated_decryption_test_case_3),
10289 TEST_CASE_ST(ut_setup, ut_teardown,
10290 test_AES_GCM_authenticated_decryption_test_case_4),
10291 TEST_CASE_ST(ut_setup, ut_teardown,
10292 test_AES_GCM_authenticated_decryption_test_case_5),
10293 TEST_CASE_ST(ut_setup, ut_teardown,
10294 test_AES_GCM_authenticated_decryption_test_case_6),
10295 TEST_CASE_ST(ut_setup, ut_teardown,
10296 test_AES_GCM_authenticated_decryption_test_case_7),
10298 /** AES GCM Authenticated Encryption 192 bits key */
10299 TEST_CASE_ST(ut_setup, ut_teardown,
10300 test_AES_GCM_auth_encryption_test_case_192_1),
10301 TEST_CASE_ST(ut_setup, ut_teardown,
10302 test_AES_GCM_auth_encryption_test_case_192_2),
10303 TEST_CASE_ST(ut_setup, ut_teardown,
10304 test_AES_GCM_auth_encryption_test_case_192_3),
10305 TEST_CASE_ST(ut_setup, ut_teardown,
10306 test_AES_GCM_auth_encryption_test_case_192_4),
10307 TEST_CASE_ST(ut_setup, ut_teardown,
10308 test_AES_GCM_auth_encryption_test_case_192_5),
10309 TEST_CASE_ST(ut_setup, ut_teardown,
10310 test_AES_GCM_auth_encryption_test_case_192_6),
10311 TEST_CASE_ST(ut_setup, ut_teardown,
10312 test_AES_GCM_auth_encryption_test_case_192_7),
10314 /** AES GCM Authenticated Decryption 192 bits key */
10315 TEST_CASE_ST(ut_setup, ut_teardown,
10316 test_AES_GCM_auth_decryption_test_case_192_1),
10317 TEST_CASE_ST(ut_setup, ut_teardown,
10318 test_AES_GCM_auth_decryption_test_case_192_2),
10319 TEST_CASE_ST(ut_setup, ut_teardown,
10320 test_AES_GCM_auth_decryption_test_case_192_3),
10321 TEST_CASE_ST(ut_setup, ut_teardown,
10322 test_AES_GCM_auth_decryption_test_case_192_4),
10323 TEST_CASE_ST(ut_setup, ut_teardown,
10324 test_AES_GCM_auth_decryption_test_case_192_5),
10325 TEST_CASE_ST(ut_setup, ut_teardown,
10326 test_AES_GCM_auth_decryption_test_case_192_6),
10327 TEST_CASE_ST(ut_setup, ut_teardown,
10328 test_AES_GCM_auth_decryption_test_case_192_7),
10330 /** AES GCM Authenticated Encryption 256 bits key */
10331 TEST_CASE_ST(ut_setup, ut_teardown,
10332 test_AES_GCM_auth_encryption_test_case_256_1),
10333 TEST_CASE_ST(ut_setup, ut_teardown,
10334 test_AES_GCM_auth_encryption_test_case_256_2),
10335 TEST_CASE_ST(ut_setup, ut_teardown,
10336 test_AES_GCM_auth_encryption_test_case_256_3),
10337 TEST_CASE_ST(ut_setup, ut_teardown,
10338 test_AES_GCM_auth_encryption_test_case_256_4),
10339 TEST_CASE_ST(ut_setup, ut_teardown,
10340 test_AES_GCM_auth_encryption_test_case_256_5),
10341 TEST_CASE_ST(ut_setup, ut_teardown,
10342 test_AES_GCM_auth_encryption_test_case_256_6),
10343 TEST_CASE_ST(ut_setup, ut_teardown,
10344 test_AES_GCM_auth_encryption_test_case_256_7),
10346 /** AES GCM Authenticated Decryption 256 bits key */
10347 TEST_CASE_ST(ut_setup, ut_teardown,
10348 test_AES_GCM_auth_decryption_test_case_256_1),
10349 TEST_CASE_ST(ut_setup, ut_teardown,
10350 test_AES_GCM_auth_decryption_test_case_256_2),
10351 TEST_CASE_ST(ut_setup, ut_teardown,
10352 test_AES_GCM_auth_decryption_test_case_256_3),
10353 TEST_CASE_ST(ut_setup, ut_teardown,
10354 test_AES_GCM_auth_decryption_test_case_256_4),
10355 TEST_CASE_ST(ut_setup, ut_teardown,
10356 test_AES_GCM_auth_decryption_test_case_256_5),
10357 TEST_CASE_ST(ut_setup, ut_teardown,
10358 test_AES_GCM_auth_decryption_test_case_256_6),
10359 TEST_CASE_ST(ut_setup, ut_teardown,
10360 test_AES_GCM_auth_decryption_test_case_256_7),
10362 /** AES GCM Authenticated Encryption big aad size */
10363 TEST_CASE_ST(ut_setup, ut_teardown,
10364 test_AES_GCM_auth_encryption_test_case_aad_1),
10365 TEST_CASE_ST(ut_setup, ut_teardown,
10366 test_AES_GCM_auth_encryption_test_case_aad_2),
10368 /** AES GCM Authenticated Decryption big aad size */
10369 TEST_CASE_ST(ut_setup, ut_teardown,
10370 test_AES_GCM_auth_decryption_test_case_aad_1),
10371 TEST_CASE_ST(ut_setup, ut_teardown,
10372 test_AES_GCM_auth_decryption_test_case_aad_2),
10374 /** AES GMAC Authentication */
10375 TEST_CASE_ST(ut_setup, ut_teardown,
10376 test_AES_GMAC_authentication_test_case_1),
10377 TEST_CASE_ST(ut_setup, ut_teardown,
10378 test_AES_GMAC_authentication_verify_test_case_1),
10379 TEST_CASE_ST(ut_setup, ut_teardown,
10380 test_AES_GMAC_authentication_test_case_3),
10381 TEST_CASE_ST(ut_setup, ut_teardown,
10382 test_AES_GMAC_authentication_verify_test_case_3),
10383 TEST_CASE_ST(ut_setup, ut_teardown,
10384 test_AES_GMAC_authentication_test_case_4),
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 test_AES_GMAC_authentication_verify_test_case_4),
10388 /** Negative tests */
10389 TEST_CASE_ST(ut_setup, ut_teardown,
10390 authentication_verify_AES128_GMAC_fail_data_corrupt),
10391 TEST_CASE_ST(ut_setup, ut_teardown,
10392 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10394 /** Out of place tests */
10395 TEST_CASE_ST(ut_setup, ut_teardown,
10396 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10397 TEST_CASE_ST(ut_setup, ut_teardown,
10398 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10400 /** Session-less tests */
10401 TEST_CASE_ST(ut_setup, ut_teardown,
10402 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
10403 TEST_CASE_ST(ut_setup, ut_teardown,
10404 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
10406 /** Scatter-Gather */
10407 TEST_CASE_ST(ut_setup, ut_teardown,
10408 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10410 TEST_CASES_END() /**< NULL terminate unit test array */
10414 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
10415 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
10416 .setup = testsuite_setup,
10417 .teardown = testsuite_teardown,
10418 .unit_test_cases = {
10419 /** KASUMI encrypt only (UEA1) */
10420 TEST_CASE_ST(ut_setup, ut_teardown,
10421 test_kasumi_encryption_test_case_1),
10422 TEST_CASE_ST(ut_setup, ut_teardown,
10423 test_kasumi_encryption_test_case_1_sgl),
10424 TEST_CASE_ST(ut_setup, ut_teardown,
10425 test_kasumi_encryption_test_case_2),
10426 TEST_CASE_ST(ut_setup, ut_teardown,
10427 test_kasumi_encryption_test_case_3),
10428 TEST_CASE_ST(ut_setup, ut_teardown,
10429 test_kasumi_encryption_test_case_4),
10430 TEST_CASE_ST(ut_setup, ut_teardown,
10431 test_kasumi_encryption_test_case_5),
10432 /** KASUMI decrypt only (UEA1) */
10433 TEST_CASE_ST(ut_setup, ut_teardown,
10434 test_kasumi_decryption_test_case_1),
10435 TEST_CASE_ST(ut_setup, ut_teardown,
10436 test_kasumi_decryption_test_case_2),
10437 TEST_CASE_ST(ut_setup, ut_teardown,
10438 test_kasumi_decryption_test_case_3),
10439 TEST_CASE_ST(ut_setup, ut_teardown,
10440 test_kasumi_decryption_test_case_4),
10441 TEST_CASE_ST(ut_setup, ut_teardown,
10442 test_kasumi_decryption_test_case_5),
10444 TEST_CASE_ST(ut_setup, ut_teardown,
10445 test_kasumi_encryption_test_case_1_oop),
10446 TEST_CASE_ST(ut_setup, ut_teardown,
10447 test_kasumi_encryption_test_case_1_oop_sgl),
10450 TEST_CASE_ST(ut_setup, ut_teardown,
10451 test_kasumi_decryption_test_case_1_oop),
10453 /** KASUMI hash only (UIA1) */
10454 TEST_CASE_ST(ut_setup, ut_teardown,
10455 test_kasumi_hash_generate_test_case_1),
10456 TEST_CASE_ST(ut_setup, ut_teardown,
10457 test_kasumi_hash_generate_test_case_2),
10458 TEST_CASE_ST(ut_setup, ut_teardown,
10459 test_kasumi_hash_generate_test_case_3),
10460 TEST_CASE_ST(ut_setup, ut_teardown,
10461 test_kasumi_hash_generate_test_case_4),
10462 TEST_CASE_ST(ut_setup, ut_teardown,
10463 test_kasumi_hash_generate_test_case_5),
10464 TEST_CASE_ST(ut_setup, ut_teardown,
10465 test_kasumi_hash_generate_test_case_6),
10466 TEST_CASE_ST(ut_setup, ut_teardown,
10467 test_kasumi_hash_verify_test_case_1),
10468 TEST_CASE_ST(ut_setup, ut_teardown,
10469 test_kasumi_hash_verify_test_case_2),
10470 TEST_CASE_ST(ut_setup, ut_teardown,
10471 test_kasumi_hash_verify_test_case_3),
10472 TEST_CASE_ST(ut_setup, ut_teardown,
10473 test_kasumi_hash_verify_test_case_4),
10474 TEST_CASE_ST(ut_setup, ut_teardown,
10475 test_kasumi_hash_verify_test_case_5),
10476 TEST_CASE_ST(ut_setup, ut_teardown,
10477 test_kasumi_cipher_auth_test_case_1),
10479 /** KASUMI generate auth, then encrypt (F8) */
10480 TEST_CASE_ST(ut_setup, ut_teardown,
10481 test_kasumi_auth_cipher_test_case_1),
10482 TEST_CASE_ST(ut_setup, ut_teardown,
10483 test_kasumi_auth_cipher_test_case_2),
10484 TEST_CASE_ST(ut_setup, ut_teardown,
10485 test_kasumi_auth_cipher_test_case_2_oop),
10487 /** KASUMI decrypt (F8), then verify auth */
10488 TEST_CASE_ST(ut_setup, ut_teardown,
10489 test_kasumi_auth_cipher_verify_test_case_1),
10490 TEST_CASE_ST(ut_setup, ut_teardown,
10491 test_kasumi_auth_cipher_verify_test_case_2),
10492 TEST_CASE_ST(ut_setup, ut_teardown,
10493 test_kasumi_auth_cipher_verify_test_case_2_oop),
10494 TEST_CASES_END() /**< NULL terminate unit test array */
10497 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
10498 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
10499 .setup = testsuite_setup,
10500 .teardown = testsuite_teardown,
10501 .unit_test_cases = {
10502 /** SNOW 3G encrypt only (UEA2) */
10503 TEST_CASE_ST(ut_setup, ut_teardown,
10504 test_snow3g_encryption_test_case_1),
10505 TEST_CASE_ST(ut_setup, ut_teardown,
10506 test_snow3g_encryption_test_case_2),
10507 TEST_CASE_ST(ut_setup, ut_teardown,
10508 test_snow3g_encryption_test_case_3),
10509 TEST_CASE_ST(ut_setup, ut_teardown,
10510 test_snow3g_encryption_test_case_4),
10511 TEST_CASE_ST(ut_setup, ut_teardown,
10512 test_snow3g_encryption_test_case_5),
10513 TEST_CASE_ST(ut_setup, ut_teardown,
10514 test_snow3g_auth_cipher_with_digest_test_case_1),
10516 TEST_CASE_ST(ut_setup, ut_teardown,
10517 test_snow3g_encryption_test_case_1_oop),
10518 TEST_CASE_ST(ut_setup, ut_teardown,
10519 test_snow3g_encryption_test_case_1_oop_sgl),
10520 TEST_CASE_ST(ut_setup, ut_teardown,
10521 test_snow3g_decryption_test_case_1_oop),
10523 TEST_CASE_ST(ut_setup, ut_teardown,
10524 test_snow3g_encryption_test_case_1_offset_oop),
10526 /** SNOW 3G decrypt only (UEA2) */
10527 TEST_CASE_ST(ut_setup, ut_teardown,
10528 test_snow3g_decryption_test_case_1),
10529 TEST_CASE_ST(ut_setup, ut_teardown,
10530 test_snow3g_decryption_test_case_2),
10531 TEST_CASE_ST(ut_setup, ut_teardown,
10532 test_snow3g_decryption_test_case_3),
10533 TEST_CASE_ST(ut_setup, ut_teardown,
10534 test_snow3g_decryption_test_case_4),
10535 TEST_CASE_ST(ut_setup, ut_teardown,
10536 test_snow3g_decryption_test_case_5),
10537 TEST_CASE_ST(ut_setup, ut_teardown,
10538 test_snow3g_decryption_with_digest_test_case_1),
10539 TEST_CASE_ST(ut_setup, ut_teardown,
10540 test_snow3g_hash_generate_test_case_1),
10541 TEST_CASE_ST(ut_setup, ut_teardown,
10542 test_snow3g_hash_generate_test_case_2),
10543 TEST_CASE_ST(ut_setup, ut_teardown,
10544 test_snow3g_hash_generate_test_case_3),
10545 /* Tests with buffers which length is not byte-aligned */
10546 TEST_CASE_ST(ut_setup, ut_teardown,
10547 test_snow3g_hash_generate_test_case_4),
10548 TEST_CASE_ST(ut_setup, ut_teardown,
10549 test_snow3g_hash_generate_test_case_5),
10550 TEST_CASE_ST(ut_setup, ut_teardown,
10551 test_snow3g_hash_generate_test_case_6),
10552 TEST_CASE_ST(ut_setup, ut_teardown,
10553 test_snow3g_hash_verify_test_case_1),
10554 TEST_CASE_ST(ut_setup, ut_teardown,
10555 test_snow3g_hash_verify_test_case_2),
10556 TEST_CASE_ST(ut_setup, ut_teardown,
10557 test_snow3g_hash_verify_test_case_3),
10558 /* Tests with buffers which length is not byte-aligned */
10559 TEST_CASE_ST(ut_setup, ut_teardown,
10560 test_snow3g_hash_verify_test_case_4),
10561 TEST_CASE_ST(ut_setup, ut_teardown,
10562 test_snow3g_hash_verify_test_case_5),
10563 TEST_CASE_ST(ut_setup, ut_teardown,
10564 test_snow3g_hash_verify_test_case_6),
10565 TEST_CASE_ST(ut_setup, ut_teardown,
10566 test_snow3g_cipher_auth_test_case_1),
10568 /** SNOW 3G generate auth, then encrypt (UEA2) */
10569 TEST_CASE_ST(ut_setup, ut_teardown,
10570 test_snow3g_auth_cipher_test_case_1),
10571 TEST_CASE_ST(ut_setup, ut_teardown,
10572 test_snow3g_auth_cipher_test_case_2),
10573 TEST_CASE_ST(ut_setup, ut_teardown,
10574 test_snow3g_auth_cipher_test_case_2_oop),
10575 TEST_CASE_ST(ut_setup, ut_teardown,
10576 test_snow3g_auth_cipher_part_digest_enc),
10577 TEST_CASE_ST(ut_setup, ut_teardown,
10578 test_snow3g_auth_cipher_part_digest_enc_oop),
10580 /** SNOW 3G decrypt (UEA2), then verify auth */
10581 TEST_CASE_ST(ut_setup, ut_teardown,
10582 test_snow3g_auth_cipher_verify_test_case_1),
10583 TEST_CASE_ST(ut_setup, ut_teardown,
10584 test_snow3g_auth_cipher_verify_test_case_2),
10585 TEST_CASE_ST(ut_setup, ut_teardown,
10586 test_snow3g_auth_cipher_verify_test_case_2_oop),
10587 TEST_CASE_ST(ut_setup, ut_teardown,
10588 test_snow3g_auth_cipher_verify_part_digest_enc),
10589 TEST_CASE_ST(ut_setup, ut_teardown,
10590 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
10592 TEST_CASES_END() /**< NULL terminate unit test array */
10596 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
10597 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
10598 .setup = testsuite_setup,
10599 .teardown = testsuite_teardown,
10600 .unit_test_cases = {
10601 /** ZUC encrypt only (EEA3) */
10602 TEST_CASE_ST(ut_setup, ut_teardown,
10603 test_zuc_encryption_test_case_1),
10604 TEST_CASE_ST(ut_setup, ut_teardown,
10605 test_zuc_encryption_test_case_2),
10606 TEST_CASE_ST(ut_setup, ut_teardown,
10607 test_zuc_encryption_test_case_3),
10608 TEST_CASE_ST(ut_setup, ut_teardown,
10609 test_zuc_encryption_test_case_4),
10610 TEST_CASE_ST(ut_setup, ut_teardown,
10611 test_zuc_encryption_test_case_5),
10612 TEST_CASE_ST(ut_setup, ut_teardown,
10613 test_zuc_hash_generate_test_case_1),
10614 TEST_CASE_ST(ut_setup, ut_teardown,
10615 test_zuc_hash_generate_test_case_2),
10616 TEST_CASE_ST(ut_setup, ut_teardown,
10617 test_zuc_hash_generate_test_case_3),
10618 TEST_CASE_ST(ut_setup, ut_teardown,
10619 test_zuc_hash_generate_test_case_4),
10620 TEST_CASE_ST(ut_setup, ut_teardown,
10621 test_zuc_hash_generate_test_case_5),
10622 TEST_CASE_ST(ut_setup, ut_teardown,
10623 test_zuc_encryption_test_case_6_sgl),
10624 TEST_CASES_END() /**< NULL terminate unit test array */
10628 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
10629 .suite_name = "Crypto CAAM JR Unit Test Suite",
10630 .setup = testsuite_setup,
10631 .teardown = testsuite_teardown,
10632 .unit_test_cases = {
10633 TEST_CASE_ST(ut_setup, ut_teardown,
10634 test_device_configure_invalid_dev_id),
10635 TEST_CASE_ST(ut_setup, ut_teardown,
10636 test_multi_session),
10638 TEST_CASE_ST(ut_setup, ut_teardown,
10639 test_AES_chain_caam_jr_all),
10640 TEST_CASE_ST(ut_setup, ut_teardown,
10641 test_3DES_chain_caam_jr_all),
10642 TEST_CASE_ST(ut_setup, ut_teardown,
10643 test_AES_cipheronly_caam_jr_all),
10644 TEST_CASE_ST(ut_setup, ut_teardown,
10645 test_3DES_cipheronly_caam_jr_all),
10646 TEST_CASE_ST(ut_setup, ut_teardown,
10647 test_authonly_caam_jr_all),
10649 TEST_CASES_END() /**< NULL terminate unit test array */
10653 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
10654 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
10655 .setup = testsuite_setup,
10656 .teardown = testsuite_teardown,
10657 .unit_test_cases = {
10658 TEST_CASE_ST(ut_setup, ut_teardown,
10659 test_device_configure_invalid_dev_id),
10660 TEST_CASE_ST(ut_setup, ut_teardown,
10661 test_multi_session),
10663 TEST_CASE_ST(ut_setup, ut_teardown,
10664 test_AES_chain_dpaa_sec_all),
10665 TEST_CASE_ST(ut_setup, ut_teardown,
10666 test_3DES_chain_dpaa_sec_all),
10667 TEST_CASE_ST(ut_setup, ut_teardown,
10668 test_AES_cipheronly_dpaa_sec_all),
10669 TEST_CASE_ST(ut_setup, ut_teardown,
10670 test_3DES_cipheronly_dpaa_sec_all),
10671 TEST_CASE_ST(ut_setup, ut_teardown,
10672 test_authonly_dpaa_sec_all),
10674 /** AES GCM Authenticated Encryption */
10675 TEST_CASE_ST(ut_setup, ut_teardown,
10676 test_AES_GCM_authenticated_encryption_test_case_1),
10677 TEST_CASE_ST(ut_setup, ut_teardown,
10678 test_AES_GCM_authenticated_encryption_test_case_2),
10679 TEST_CASE_ST(ut_setup, ut_teardown,
10680 test_AES_GCM_authenticated_encryption_test_case_3),
10681 TEST_CASE_ST(ut_setup, ut_teardown,
10682 test_AES_GCM_authenticated_encryption_test_case_4),
10683 TEST_CASE_ST(ut_setup, ut_teardown,
10684 test_AES_GCM_authenticated_encryption_test_case_5),
10685 TEST_CASE_ST(ut_setup, ut_teardown,
10686 test_AES_GCM_authenticated_encryption_test_case_6),
10687 TEST_CASE_ST(ut_setup, ut_teardown,
10688 test_AES_GCM_authenticated_encryption_test_case_7),
10690 /** AES GCM Authenticated Decryption */
10691 TEST_CASE_ST(ut_setup, ut_teardown,
10692 test_AES_GCM_authenticated_decryption_test_case_1),
10693 TEST_CASE_ST(ut_setup, ut_teardown,
10694 test_AES_GCM_authenticated_decryption_test_case_2),
10695 TEST_CASE_ST(ut_setup, ut_teardown,
10696 test_AES_GCM_authenticated_decryption_test_case_3),
10697 TEST_CASE_ST(ut_setup, ut_teardown,
10698 test_AES_GCM_authenticated_decryption_test_case_4),
10699 TEST_CASE_ST(ut_setup, ut_teardown,
10700 test_AES_GCM_authenticated_decryption_test_case_5),
10701 TEST_CASE_ST(ut_setup, ut_teardown,
10702 test_AES_GCM_authenticated_decryption_test_case_6),
10703 TEST_CASE_ST(ut_setup, ut_teardown,
10704 test_AES_GCM_authenticated_decryption_test_case_7),
10706 /** AES GCM Authenticated Encryption 256 bits key */
10707 TEST_CASE_ST(ut_setup, ut_teardown,
10708 test_AES_GCM_auth_encryption_test_case_256_1),
10709 TEST_CASE_ST(ut_setup, ut_teardown,
10710 test_AES_GCM_auth_encryption_test_case_256_2),
10711 TEST_CASE_ST(ut_setup, ut_teardown,
10712 test_AES_GCM_auth_encryption_test_case_256_3),
10713 TEST_CASE_ST(ut_setup, ut_teardown,
10714 test_AES_GCM_auth_encryption_test_case_256_4),
10715 TEST_CASE_ST(ut_setup, ut_teardown,
10716 test_AES_GCM_auth_encryption_test_case_256_5),
10717 TEST_CASE_ST(ut_setup, ut_teardown,
10718 test_AES_GCM_auth_encryption_test_case_256_6),
10719 TEST_CASE_ST(ut_setup, ut_teardown,
10720 test_AES_GCM_auth_encryption_test_case_256_7),
10722 /** AES GCM Authenticated Decryption 256 bits key */
10723 TEST_CASE_ST(ut_setup, ut_teardown,
10724 test_AES_GCM_auth_decryption_test_case_256_1),
10725 TEST_CASE_ST(ut_setup, ut_teardown,
10726 test_AES_GCM_auth_decryption_test_case_256_2),
10727 TEST_CASE_ST(ut_setup, ut_teardown,
10728 test_AES_GCM_auth_decryption_test_case_256_3),
10729 TEST_CASE_ST(ut_setup, ut_teardown,
10730 test_AES_GCM_auth_decryption_test_case_256_4),
10731 TEST_CASE_ST(ut_setup, ut_teardown,
10732 test_AES_GCM_auth_decryption_test_case_256_5),
10733 TEST_CASE_ST(ut_setup, ut_teardown,
10734 test_AES_GCM_auth_decryption_test_case_256_6),
10735 TEST_CASE_ST(ut_setup, ut_teardown,
10736 test_AES_GCM_auth_decryption_test_case_256_7),
10738 /** Out of place tests */
10739 TEST_CASE_ST(ut_setup, ut_teardown,
10740 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10741 TEST_CASE_ST(ut_setup, ut_teardown,
10742 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10744 /** Scatter-Gather */
10745 TEST_CASE_ST(ut_setup, ut_teardown,
10746 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10747 TEST_CASE_ST(ut_setup, ut_teardown,
10748 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10749 TEST_CASE_ST(ut_setup, ut_teardown,
10750 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10751 TEST_CASE_ST(ut_setup, ut_teardown,
10752 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10754 TEST_CASES_END() /**< NULL terminate unit test array */
10758 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10759 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10760 .setup = testsuite_setup,
10761 .teardown = testsuite_teardown,
10762 .unit_test_cases = {
10763 TEST_CASE_ST(ut_setup, ut_teardown,
10764 test_device_configure_invalid_dev_id),
10765 TEST_CASE_ST(ut_setup, ut_teardown,
10766 test_multi_session),
10768 TEST_CASE_ST(ut_setup, ut_teardown,
10769 test_AES_chain_dpaa2_sec_all),
10770 TEST_CASE_ST(ut_setup, ut_teardown,
10771 test_3DES_chain_dpaa2_sec_all),
10772 TEST_CASE_ST(ut_setup, ut_teardown,
10773 test_AES_cipheronly_dpaa2_sec_all),
10774 TEST_CASE_ST(ut_setup, ut_teardown,
10775 test_3DES_cipheronly_dpaa2_sec_all),
10776 TEST_CASE_ST(ut_setup, ut_teardown,
10777 test_authonly_dpaa2_sec_all),
10779 /** AES GCM Authenticated Encryption */
10780 TEST_CASE_ST(ut_setup, ut_teardown,
10781 test_AES_GCM_authenticated_encryption_test_case_1),
10782 TEST_CASE_ST(ut_setup, ut_teardown,
10783 test_AES_GCM_authenticated_encryption_test_case_2),
10784 TEST_CASE_ST(ut_setup, ut_teardown,
10785 test_AES_GCM_authenticated_encryption_test_case_3),
10786 TEST_CASE_ST(ut_setup, ut_teardown,
10787 test_AES_GCM_authenticated_encryption_test_case_4),
10788 TEST_CASE_ST(ut_setup, ut_teardown,
10789 test_AES_GCM_authenticated_encryption_test_case_5),
10790 TEST_CASE_ST(ut_setup, ut_teardown,
10791 test_AES_GCM_authenticated_encryption_test_case_6),
10792 TEST_CASE_ST(ut_setup, ut_teardown,
10793 test_AES_GCM_authenticated_encryption_test_case_7),
10795 /** AES GCM Authenticated Decryption */
10796 TEST_CASE_ST(ut_setup, ut_teardown,
10797 test_AES_GCM_authenticated_decryption_test_case_1),
10798 TEST_CASE_ST(ut_setup, ut_teardown,
10799 test_AES_GCM_authenticated_decryption_test_case_2),
10800 TEST_CASE_ST(ut_setup, ut_teardown,
10801 test_AES_GCM_authenticated_decryption_test_case_3),
10802 TEST_CASE_ST(ut_setup, ut_teardown,
10803 test_AES_GCM_authenticated_decryption_test_case_4),
10804 TEST_CASE_ST(ut_setup, ut_teardown,
10805 test_AES_GCM_authenticated_decryption_test_case_5),
10806 TEST_CASE_ST(ut_setup, ut_teardown,
10807 test_AES_GCM_authenticated_decryption_test_case_6),
10808 TEST_CASE_ST(ut_setup, ut_teardown,
10809 test_AES_GCM_authenticated_decryption_test_case_7),
10811 /** AES GCM Authenticated Encryption 192 bits key */
10812 TEST_CASE_ST(ut_setup, ut_teardown,
10813 test_AES_GCM_auth_encryption_test_case_192_1),
10814 TEST_CASE_ST(ut_setup, ut_teardown,
10815 test_AES_GCM_auth_encryption_test_case_192_2),
10816 TEST_CASE_ST(ut_setup, ut_teardown,
10817 test_AES_GCM_auth_encryption_test_case_192_3),
10818 TEST_CASE_ST(ut_setup, ut_teardown,
10819 test_AES_GCM_auth_encryption_test_case_192_4),
10820 TEST_CASE_ST(ut_setup, ut_teardown,
10821 test_AES_GCM_auth_encryption_test_case_192_5),
10822 TEST_CASE_ST(ut_setup, ut_teardown,
10823 test_AES_GCM_auth_encryption_test_case_192_6),
10824 TEST_CASE_ST(ut_setup, ut_teardown,
10825 test_AES_GCM_auth_encryption_test_case_192_7),
10827 /** AES GCM Authenticated Decryption 192 bits key */
10828 TEST_CASE_ST(ut_setup, ut_teardown,
10829 test_AES_GCM_auth_decryption_test_case_192_1),
10830 TEST_CASE_ST(ut_setup, ut_teardown,
10831 test_AES_GCM_auth_decryption_test_case_192_2),
10832 TEST_CASE_ST(ut_setup, ut_teardown,
10833 test_AES_GCM_auth_decryption_test_case_192_3),
10834 TEST_CASE_ST(ut_setup, ut_teardown,
10835 test_AES_GCM_auth_decryption_test_case_192_4),
10836 TEST_CASE_ST(ut_setup, ut_teardown,
10837 test_AES_GCM_auth_decryption_test_case_192_5),
10838 TEST_CASE_ST(ut_setup, ut_teardown,
10839 test_AES_GCM_auth_decryption_test_case_192_6),
10840 TEST_CASE_ST(ut_setup, ut_teardown,
10841 test_AES_GCM_auth_decryption_test_case_192_7),
10843 /** AES GCM Authenticated Encryption 256 bits key */
10844 TEST_CASE_ST(ut_setup, ut_teardown,
10845 test_AES_GCM_auth_encryption_test_case_256_1),
10846 TEST_CASE_ST(ut_setup, ut_teardown,
10847 test_AES_GCM_auth_encryption_test_case_256_2),
10848 TEST_CASE_ST(ut_setup, ut_teardown,
10849 test_AES_GCM_auth_encryption_test_case_256_3),
10850 TEST_CASE_ST(ut_setup, ut_teardown,
10851 test_AES_GCM_auth_encryption_test_case_256_4),
10852 TEST_CASE_ST(ut_setup, ut_teardown,
10853 test_AES_GCM_auth_encryption_test_case_256_5),
10854 TEST_CASE_ST(ut_setup, ut_teardown,
10855 test_AES_GCM_auth_encryption_test_case_256_6),
10856 TEST_CASE_ST(ut_setup, ut_teardown,
10857 test_AES_GCM_auth_encryption_test_case_256_7),
10859 /** AES GCM Authenticated Decryption 256 bits key */
10860 TEST_CASE_ST(ut_setup, ut_teardown,
10861 test_AES_GCM_auth_decryption_test_case_256_1),
10862 TEST_CASE_ST(ut_setup, ut_teardown,
10863 test_AES_GCM_auth_decryption_test_case_256_2),
10864 TEST_CASE_ST(ut_setup, ut_teardown,
10865 test_AES_GCM_auth_decryption_test_case_256_3),
10866 TEST_CASE_ST(ut_setup, ut_teardown,
10867 test_AES_GCM_auth_decryption_test_case_256_4),
10868 TEST_CASE_ST(ut_setup, ut_teardown,
10869 test_AES_GCM_auth_decryption_test_case_256_5),
10870 TEST_CASE_ST(ut_setup, ut_teardown,
10871 test_AES_GCM_auth_decryption_test_case_256_6),
10872 TEST_CASE_ST(ut_setup, ut_teardown,
10873 test_AES_GCM_auth_decryption_test_case_256_7),
10875 /** Out of place tests */
10876 TEST_CASE_ST(ut_setup, ut_teardown,
10877 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10878 TEST_CASE_ST(ut_setup, ut_teardown,
10879 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10881 /** Scatter-Gather */
10882 TEST_CASE_ST(ut_setup, ut_teardown,
10883 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10884 TEST_CASE_ST(ut_setup, ut_teardown,
10885 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10886 TEST_CASE_ST(ut_setup, ut_teardown,
10887 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10888 TEST_CASE_ST(ut_setup, ut_teardown,
10889 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10891 TEST_CASES_END() /**< NULL terminate unit test array */
10895 static struct unit_test_suite cryptodev_null_testsuite = {
10896 .suite_name = "Crypto Device NULL Unit Test Suite",
10897 .setup = testsuite_setup,
10898 .teardown = testsuite_teardown,
10899 .unit_test_cases = {
10900 TEST_CASE_ST(ut_setup, ut_teardown,
10901 test_null_invalid_operation),
10902 TEST_CASE_ST(ut_setup, ut_teardown,
10903 test_null_burst_operation),
10904 TEST_CASE_ST(ut_setup, ut_teardown,
10905 test_AES_chain_null_all),
10906 TEST_CASE_ST(ut_setup, ut_teardown,
10907 test_AES_cipheronly_null_all),
10908 TEST_CASE_ST(ut_setup, ut_teardown,
10909 test_authonly_null_all),
10911 TEST_CASES_END() /**< NULL terminate unit test array */
10915 static struct unit_test_suite cryptodev_armv8_testsuite = {
10916 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10917 .setup = testsuite_setup,
10918 .teardown = testsuite_teardown,
10919 .unit_test_cases = {
10920 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10922 /** Negative tests */
10923 TEST_CASE_ST(ut_setup, ut_teardown,
10924 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10925 TEST_CASE_ST(ut_setup, ut_teardown,
10926 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10928 TEST_CASES_END() /**< NULL terminate unit test array */
10932 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10933 .suite_name = "Crypto Device Marvell Component Test Suite",
10934 .setup = testsuite_setup,
10935 .teardown = testsuite_teardown,
10936 .unit_test_cases = {
10937 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10938 TEST_CASE_ST(ut_setup, ut_teardown,
10939 test_multi_session_random_usage),
10940 TEST_CASE_ST(ut_setup, ut_teardown,
10941 test_AES_chain_mrvl_all),
10942 TEST_CASE_ST(ut_setup, ut_teardown,
10943 test_AES_cipheronly_mrvl_all),
10944 TEST_CASE_ST(ut_setup, ut_teardown,
10945 test_authonly_mrvl_all),
10946 TEST_CASE_ST(ut_setup, ut_teardown,
10947 test_3DES_chain_mrvl_all),
10948 TEST_CASE_ST(ut_setup, ut_teardown,
10949 test_3DES_cipheronly_mrvl_all),
10951 /** Negative tests */
10952 TEST_CASE_ST(ut_setup, ut_teardown,
10953 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10954 TEST_CASE_ST(ut_setup, ut_teardown,
10955 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10956 TEST_CASE_ST(ut_setup, ut_teardown,
10957 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10958 TEST_CASE_ST(ut_setup, ut_teardown,
10959 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10961 TEST_CASES_END() /**< NULL terminate unit test array */
10965 static struct unit_test_suite cryptodev_ccp_testsuite = {
10966 .suite_name = "Crypto Device CCP Unit Test Suite",
10967 .setup = testsuite_setup,
10968 .teardown = testsuite_teardown,
10969 .unit_test_cases = {
10970 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10971 TEST_CASE_ST(ut_setup, ut_teardown,
10972 test_multi_session_random_usage),
10973 TEST_CASE_ST(ut_setup, ut_teardown,
10974 test_AES_chain_ccp_all),
10975 TEST_CASE_ST(ut_setup, ut_teardown,
10976 test_AES_cipheronly_ccp_all),
10977 TEST_CASE_ST(ut_setup, ut_teardown,
10978 test_3DES_chain_ccp_all),
10979 TEST_CASE_ST(ut_setup, ut_teardown,
10980 test_3DES_cipheronly_ccp_all),
10981 TEST_CASE_ST(ut_setup, ut_teardown,
10982 test_authonly_ccp_all),
10984 /** Negative tests */
10985 TEST_CASE_ST(ut_setup, ut_teardown,
10986 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10987 TEST_CASE_ST(ut_setup, ut_teardown,
10988 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10989 TEST_CASE_ST(ut_setup, ut_teardown,
10990 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10991 TEST_CASE_ST(ut_setup, ut_teardown,
10992 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10994 TEST_CASES_END() /**< NULL terminate unit test array */
10998 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10999 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
11000 .setup = testsuite_setup,
11001 .teardown = testsuite_teardown,
11002 .unit_test_cases = {
11003 TEST_CASE_ST(ut_setup, ut_teardown,
11004 test_AES_chain_octeontx_all),
11005 TEST_CASE_ST(ut_setup, ut_teardown,
11006 test_AES_cipheronly_octeontx_all),
11007 TEST_CASE_ST(ut_setup, ut_teardown,
11008 test_3DES_chain_octeontx_all),
11009 TEST_CASE_ST(ut_setup, ut_teardown,
11010 test_3DES_cipheronly_octeontx_all),
11011 TEST_CASE_ST(ut_setup, ut_teardown,
11012 test_authonly_octeontx_all),
11014 /** AES GCM Authenticated Encryption */
11015 TEST_CASE_ST(ut_setup, ut_teardown,
11016 test_AES_GCM_authenticated_encryption_test_case_1),
11017 TEST_CASE_ST(ut_setup, ut_teardown,
11018 test_AES_GCM_authenticated_encryption_test_case_2),
11019 TEST_CASE_ST(ut_setup, ut_teardown,
11020 test_AES_GCM_authenticated_encryption_test_case_3),
11021 TEST_CASE_ST(ut_setup, ut_teardown,
11022 test_AES_GCM_authenticated_encryption_test_case_4),
11023 TEST_CASE_ST(ut_setup, ut_teardown,
11024 test_AES_GCM_authenticated_encryption_test_case_5),
11025 TEST_CASE_ST(ut_setup, ut_teardown,
11026 test_AES_GCM_authenticated_encryption_test_case_6),
11027 TEST_CASE_ST(ut_setup, ut_teardown,
11028 test_AES_GCM_authenticated_encryption_test_case_7),
11030 /** AES GCM Authenticated Decryption */
11031 TEST_CASE_ST(ut_setup, ut_teardown,
11032 test_AES_GCM_authenticated_decryption_test_case_1),
11033 TEST_CASE_ST(ut_setup, ut_teardown,
11034 test_AES_GCM_authenticated_decryption_test_case_2),
11035 TEST_CASE_ST(ut_setup, ut_teardown,
11036 test_AES_GCM_authenticated_decryption_test_case_3),
11037 TEST_CASE_ST(ut_setup, ut_teardown,
11038 test_AES_GCM_authenticated_decryption_test_case_4),
11039 TEST_CASE_ST(ut_setup, ut_teardown,
11040 test_AES_GCM_authenticated_decryption_test_case_5),
11041 TEST_CASE_ST(ut_setup, ut_teardown,
11042 test_AES_GCM_authenticated_decryption_test_case_6),
11043 TEST_CASE_ST(ut_setup, ut_teardown,
11044 test_AES_GCM_authenticated_decryption_test_case_7),
11045 /** AES GMAC Authentication */
11046 TEST_CASE_ST(ut_setup, ut_teardown,
11047 test_AES_GMAC_authentication_test_case_1),
11048 TEST_CASE_ST(ut_setup, ut_teardown,
11049 test_AES_GMAC_authentication_verify_test_case_1),
11050 TEST_CASE_ST(ut_setup, ut_teardown,
11051 test_AES_GMAC_authentication_test_case_2),
11052 TEST_CASE_ST(ut_setup, ut_teardown,
11053 test_AES_GMAC_authentication_verify_test_case_2),
11054 TEST_CASE_ST(ut_setup, ut_teardown,
11055 test_AES_GMAC_authentication_test_case_3),
11056 TEST_CASE_ST(ut_setup, ut_teardown,
11057 test_AES_GMAC_authentication_verify_test_case_3),
11059 /** SNOW 3G encrypt only (UEA2) */
11060 TEST_CASE_ST(ut_setup, ut_teardown,
11061 test_snow3g_encryption_test_case_1),
11062 TEST_CASE_ST(ut_setup, ut_teardown,
11063 test_snow3g_encryption_test_case_2),
11064 TEST_CASE_ST(ut_setup, ut_teardown,
11065 test_snow3g_encryption_test_case_3),
11066 TEST_CASE_ST(ut_setup, ut_teardown,
11067 test_snow3g_encryption_test_case_4),
11068 TEST_CASE_ST(ut_setup, ut_teardown,
11069 test_snow3g_encryption_test_case_5),
11071 TEST_CASE_ST(ut_setup, ut_teardown,
11072 test_snow3g_encryption_test_case_1_oop),
11073 TEST_CASE_ST(ut_setup, ut_teardown,
11074 test_snow3g_decryption_test_case_1_oop),
11075 TEST_CASE_ST(ut_setup, ut_teardown,
11076 test_snow3g_encryption_test_case_1_oop_sgl),
11078 /** SNOW 3G decrypt only (UEA2) */
11079 TEST_CASE_ST(ut_setup, ut_teardown,
11080 test_snow3g_decryption_test_case_1),
11081 TEST_CASE_ST(ut_setup, ut_teardown,
11082 test_snow3g_decryption_test_case_2),
11083 TEST_CASE_ST(ut_setup, ut_teardown,
11084 test_snow3g_decryption_test_case_3),
11085 TEST_CASE_ST(ut_setup, ut_teardown,
11086 test_snow3g_decryption_test_case_4),
11087 TEST_CASE_ST(ut_setup, ut_teardown,
11088 test_snow3g_decryption_test_case_5),
11090 TEST_CASE_ST(ut_setup, ut_teardown,
11091 test_snow3g_hash_generate_test_case_1),
11092 TEST_CASE_ST(ut_setup, ut_teardown,
11093 test_snow3g_hash_generate_test_case_2),
11094 TEST_CASE_ST(ut_setup, ut_teardown,
11095 test_snow3g_hash_generate_test_case_3),
11096 TEST_CASE_ST(ut_setup, ut_teardown,
11097 test_snow3g_hash_verify_test_case_1),
11098 TEST_CASE_ST(ut_setup, ut_teardown,
11099 test_snow3g_hash_verify_test_case_2),
11100 TEST_CASE_ST(ut_setup, ut_teardown,
11101 test_snow3g_hash_verify_test_case_3),
11103 /** ZUC encrypt only (EEA3) */
11104 TEST_CASE_ST(ut_setup, ut_teardown,
11105 test_zuc_encryption_test_case_1),
11106 TEST_CASE_ST(ut_setup, ut_teardown,
11107 test_zuc_encryption_test_case_2),
11108 TEST_CASE_ST(ut_setup, ut_teardown,
11109 test_zuc_encryption_test_case_3),
11110 TEST_CASE_ST(ut_setup, ut_teardown,
11111 test_zuc_encryption_test_case_4),
11112 TEST_CASE_ST(ut_setup, ut_teardown,
11113 test_zuc_encryption_test_case_5),
11114 TEST_CASE_ST(ut_setup, ut_teardown,
11115 test_zuc_hash_generate_test_case_1),
11116 TEST_CASE_ST(ut_setup, ut_teardown,
11117 test_zuc_hash_generate_test_case_2),
11118 TEST_CASE_ST(ut_setup, ut_teardown,
11119 test_zuc_hash_generate_test_case_3),
11120 TEST_CASE_ST(ut_setup, ut_teardown,
11121 test_zuc_hash_generate_test_case_4),
11122 TEST_CASE_ST(ut_setup, ut_teardown,
11123 test_zuc_hash_generate_test_case_5),
11124 TEST_CASE_ST(ut_setup, ut_teardown,
11125 test_zuc_encryption_test_case_6_sgl),
11127 /** KASUMI encrypt only (UEA1) */
11128 TEST_CASE_ST(ut_setup, ut_teardown,
11129 test_kasumi_encryption_test_case_1),
11130 TEST_CASE_ST(ut_setup, ut_teardown,
11131 test_kasumi_encryption_test_case_2),
11132 TEST_CASE_ST(ut_setup, ut_teardown,
11133 test_kasumi_encryption_test_case_3),
11134 TEST_CASE_ST(ut_setup, ut_teardown,
11135 test_kasumi_encryption_test_case_4),
11136 TEST_CASE_ST(ut_setup, ut_teardown,
11137 test_kasumi_encryption_test_case_5),
11138 TEST_CASE_ST(ut_setup, ut_teardown,
11139 test_kasumi_encryption_test_case_1_sgl),
11140 TEST_CASE_ST(ut_setup, ut_teardown,
11141 test_kasumi_encryption_test_case_1_oop_sgl),
11142 /** KASUMI decrypt only (UEA1) */
11143 TEST_CASE_ST(ut_setup, ut_teardown,
11144 test_kasumi_decryption_test_case_1),
11145 TEST_CASE_ST(ut_setup, ut_teardown,
11146 test_kasumi_decryption_test_case_2),
11147 TEST_CASE_ST(ut_setup, ut_teardown,
11148 test_kasumi_decryption_test_case_3),
11149 TEST_CASE_ST(ut_setup, ut_teardown,
11150 test_kasumi_decryption_test_case_4),
11151 TEST_CASE_ST(ut_setup, ut_teardown,
11152 test_kasumi_decryption_test_case_5),
11154 TEST_CASE_ST(ut_setup, ut_teardown,
11155 test_kasumi_encryption_test_case_1_oop),
11156 TEST_CASE_ST(ut_setup, ut_teardown,
11157 test_kasumi_decryption_test_case_1_oop),
11159 /** KASUMI hash only (UIA1) */
11160 TEST_CASE_ST(ut_setup, ut_teardown,
11161 test_kasumi_hash_generate_test_case_1),
11162 TEST_CASE_ST(ut_setup, ut_teardown,
11163 test_kasumi_hash_generate_test_case_2),
11164 TEST_CASE_ST(ut_setup, ut_teardown,
11165 test_kasumi_hash_generate_test_case_3),
11166 TEST_CASE_ST(ut_setup, ut_teardown,
11167 test_kasumi_hash_generate_test_case_4),
11168 TEST_CASE_ST(ut_setup, ut_teardown,
11169 test_kasumi_hash_generate_test_case_5),
11170 TEST_CASE_ST(ut_setup, ut_teardown,
11171 test_kasumi_hash_generate_test_case_6),
11172 TEST_CASE_ST(ut_setup, ut_teardown,
11173 test_kasumi_hash_verify_test_case_1),
11174 TEST_CASE_ST(ut_setup, ut_teardown,
11175 test_kasumi_hash_verify_test_case_2),
11176 TEST_CASE_ST(ut_setup, ut_teardown,
11177 test_kasumi_hash_verify_test_case_3),
11178 TEST_CASE_ST(ut_setup, ut_teardown,
11179 test_kasumi_hash_verify_test_case_4),
11180 TEST_CASE_ST(ut_setup, ut_teardown,
11181 test_kasumi_hash_verify_test_case_5),
11184 TEST_CASE_ST(ut_setup, ut_teardown,
11185 test_null_cipher_only_operation),
11186 TEST_CASE_ST(ut_setup, ut_teardown,
11187 test_null_auth_only_operation),
11188 TEST_CASE_ST(ut_setup, ut_teardown,
11189 test_null_cipher_auth_operation),
11190 TEST_CASE_ST(ut_setup, ut_teardown,
11191 test_null_auth_cipher_operation),
11193 /** Negative tests */
11194 TEST_CASE_ST(ut_setup, ut_teardown,
11195 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11196 TEST_CASE_ST(ut_setup, ut_teardown,
11197 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11198 TEST_CASE_ST(ut_setup, ut_teardown,
11199 authentication_verify_AES128_GMAC_fail_data_corrupt),
11200 TEST_CASE_ST(ut_setup, ut_teardown,
11201 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11202 TEST_CASE_ST(ut_setup, ut_teardown,
11203 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11204 TEST_CASE_ST(ut_setup, ut_teardown,
11205 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11206 TEST_CASES_END() /**< NULL terminate unit test array */
11211 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
11213 gbl_driver_id = rte_cryptodev_driver_id_get(
11214 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
11216 if (gbl_driver_id == -1) {
11217 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
11218 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
11219 "are enabled in config file to run this testsuite.\n");
11220 return TEST_SKIPPED;
11223 return unit_test_suite_runner(&cryptodev_qat_testsuite);
11227 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
11229 gbl_driver_id = rte_cryptodev_driver_id_get(
11230 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
11232 if (gbl_driver_id == -1) {
11233 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
11234 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
11235 "in config file to run this testsuite.\n");
11236 return TEST_FAILED;
11239 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
11243 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
11245 gbl_driver_id = rte_cryptodev_driver_id_get(
11246 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11248 if (gbl_driver_id == -1) {
11249 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
11250 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
11251 "in config file to run this testsuite.\n");
11252 return TEST_SKIPPED;
11255 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
11259 test_cryptodev_openssl(void)
11261 gbl_driver_id = rte_cryptodev_driver_id_get(
11262 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
11264 if (gbl_driver_id == -1) {
11265 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
11266 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
11267 "in config file to run this testsuite.\n");
11268 return TEST_SKIPPED;
11271 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
11275 test_cryptodev_aesni_gcm(void)
11277 gbl_driver_id = rte_cryptodev_driver_id_get(
11278 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
11280 if (gbl_driver_id == -1) {
11281 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
11282 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
11283 "in config file to run this testsuite.\n");
11284 return TEST_SKIPPED;
11287 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
11291 test_cryptodev_null(void)
11293 gbl_driver_id = rte_cryptodev_driver_id_get(
11294 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
11296 if (gbl_driver_id == -1) {
11297 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
11298 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
11299 "in config file to run this testsuite.\n");
11300 return TEST_SKIPPED;
11303 return unit_test_suite_runner(&cryptodev_null_testsuite);
11307 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
11309 gbl_driver_id = rte_cryptodev_driver_id_get(
11310 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
11312 if (gbl_driver_id == -1) {
11313 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
11314 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
11315 "in config file to run this testsuite.\n");
11316 return TEST_SKIPPED;
11319 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
11323 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
11325 gbl_driver_id = rte_cryptodev_driver_id_get(
11326 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
11328 if (gbl_driver_id == -1) {
11329 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
11330 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
11331 "in config file to run this testsuite.\n");
11332 return TEST_SKIPPED;
11335 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
11339 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
11341 gbl_driver_id = rte_cryptodev_driver_id_get(
11342 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
11344 if (gbl_driver_id == -1) {
11345 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
11346 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
11347 "in config file to run this testsuite.\n");
11348 return TEST_SKIPPED;
11351 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
11355 test_cryptodev_armv8(void)
11357 gbl_driver_id = rte_cryptodev_driver_id_get(
11358 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
11360 if (gbl_driver_id == -1) {
11361 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
11362 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
11363 "in config file to run this testsuite.\n");
11364 return TEST_SKIPPED;
11367 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
11371 test_cryptodev_mrvl(void)
11373 gbl_driver_id = rte_cryptodev_driver_id_get(
11374 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
11376 if (gbl_driver_id == -1) {
11377 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
11378 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
11379 "in config file to run this testsuite.\n");
11380 return TEST_SKIPPED;
11383 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
11386 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11389 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
11391 gbl_driver_id = rte_cryptodev_driver_id_get(
11392 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
11394 if (gbl_driver_id == -1) {
11395 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
11396 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
11397 "in config file to run this testsuite.\n");
11398 return TEST_SKIPPED;
11401 if (rte_cryptodev_driver_id_get(
11402 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
11403 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
11404 " enabled in config file to run this testsuite.\n");
11405 return TEST_SKIPPED;
11407 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
11410 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
11415 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
11417 gbl_driver_id = rte_cryptodev_driver_id_get(
11418 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
11420 if (gbl_driver_id == -1) {
11421 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
11422 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
11423 "in config file to run this testsuite.\n");
11424 return TEST_SKIPPED;
11427 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
11431 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
11433 gbl_driver_id = rte_cryptodev_driver_id_get(
11434 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
11436 if (gbl_driver_id == -1) {
11437 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
11438 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
11439 "in config file to run this testsuite.\n");
11440 return TEST_SKIPPED;
11443 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
11447 test_cryptodev_ccp(void)
11449 gbl_driver_id = rte_cryptodev_driver_id_get(
11450 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
11452 if (gbl_driver_id == -1) {
11453 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
11454 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
11455 "in config file to run this testsuite.\n");
11456 return TEST_FAILED;
11459 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
11463 test_cryptodev_octeontx(void)
11465 gbl_driver_id = rte_cryptodev_driver_id_get(
11466 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
11467 if (gbl_driver_id == -1) {
11468 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
11469 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
11470 "enabled in config file to run this "
11472 return TEST_FAILED;
11474 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
11478 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
11480 gbl_driver_id = rte_cryptodev_driver_id_get(
11481 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
11483 if (gbl_driver_id == -1) {
11484 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
11485 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
11486 "in config file to run this testsuite.\n");
11487 return TEST_FAILED;
11490 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
11493 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
11494 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
11495 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
11496 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
11497 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
11498 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
11499 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
11500 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
11501 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
11502 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
11503 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
11504 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
11505 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
11506 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
11507 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
11508 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);