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,
2881 uint8_t op_mode, uint8_t do_sgl)
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;
2904 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2905 (op_mode == IN_PLACE ?
2906 ut_params->ibuf : ut_params->obuf),
2907 uint8_t *, data_pad_len);
2908 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2909 (op_mode == IN_PLACE ?
2910 ut_params->ibuf : ut_params->obuf),
2912 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2914 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2915 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2916 sym_op->m_src : sym_op->m_dst);
2917 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2918 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2919 sgl_buf = sgl_buf->next;
2921 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2922 uint8_t *, remaining_off);
2923 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2925 memset(sym_op->auth.digest.data, 0, remaining_off);
2926 while (sgl_buf->next != NULL) {
2927 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2928 0, rte_pktmbuf_data_len(sgl_buf));
2929 sgl_buf = sgl_buf->next;
2933 /* Copy cipher and auth IVs at the end of the crypto operation */
2934 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2935 ut_params->op, uint8_t *, IV_OFFSET);
2937 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2938 iv_ptr += cipher_iv_len;
2939 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2941 sym_op->cipher.data.length = cipher_len;
2942 sym_op->cipher.data.offset = cipher_offset;
2944 sym_op->auth.data.length = auth_len;
2945 sym_op->auth.data.offset = auth_offset;
2951 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2953 struct crypto_testsuite_params *ts_params = &testsuite_params;
2954 struct crypto_unittest_params *ut_params = &unittest_params;
2957 unsigned plaintext_pad_len;
2958 unsigned plaintext_len;
2961 /* Create SNOW 3G session */
2962 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2963 tdata->key.data, tdata->key.len,
2964 tdata->auth_iv.len, tdata->digest.len,
2965 RTE_CRYPTO_AUTH_OP_GENERATE,
2966 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2970 /* alloc mbuf and set payload */
2971 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2973 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2974 rte_pktmbuf_tailroom(ut_params->ibuf));
2976 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2977 /* Append data which is padded to a multiple of */
2978 /* the algorithms block size */
2979 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2980 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2982 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2984 /* Create SNOW 3G operation */
2985 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2986 tdata->auth_iv.data, tdata->auth_iv.len,
2987 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2988 tdata->validAuthLenInBits.len,
2993 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2995 ut_params->obuf = ut_params->op->sym->m_src;
2996 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2997 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2998 + plaintext_pad_len;
3001 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3004 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3005 "SNOW 3G Generated auth tag not as expected");
3011 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3013 struct crypto_testsuite_params *ts_params = &testsuite_params;
3014 struct crypto_unittest_params *ut_params = &unittest_params;
3017 unsigned plaintext_pad_len;
3018 unsigned plaintext_len;
3021 /* Create SNOW 3G session */
3022 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3023 tdata->key.data, tdata->key.len,
3024 tdata->auth_iv.len, tdata->digest.len,
3025 RTE_CRYPTO_AUTH_OP_VERIFY,
3026 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3029 /* alloc mbuf and set payload */
3030 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3032 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3033 rte_pktmbuf_tailroom(ut_params->ibuf));
3035 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3036 /* Append data which is padded to a multiple of */
3037 /* the algorithms block size */
3038 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3039 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3041 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3043 /* Create SNOW 3G operation */
3044 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3046 tdata->auth_iv.data, tdata->auth_iv.len,
3048 RTE_CRYPTO_AUTH_OP_VERIFY,
3049 tdata->validAuthLenInBits.len,
3054 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3056 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3057 ut_params->obuf = ut_params->op->sym->m_src;
3058 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3059 + plaintext_pad_len;
3062 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3071 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3073 struct crypto_testsuite_params *ts_params = &testsuite_params;
3074 struct crypto_unittest_params *ut_params = &unittest_params;
3077 unsigned plaintext_pad_len;
3078 unsigned plaintext_len;
3081 /* Create KASUMI session */
3082 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3083 tdata->key.data, tdata->key.len,
3084 0, tdata->digest.len,
3085 RTE_CRYPTO_AUTH_OP_GENERATE,
3086 RTE_CRYPTO_AUTH_KASUMI_F9);
3090 /* alloc mbuf and set payload */
3091 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3093 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3094 rte_pktmbuf_tailroom(ut_params->ibuf));
3096 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3097 /* Append data which is padded to a multiple of */
3098 /* the algorithms block size */
3099 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3100 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3102 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3104 /* Create KASUMI operation */
3105 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3107 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3108 tdata->plaintext.len,
3113 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3115 ut_params->obuf = ut_params->op->sym->m_src;
3116 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3117 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3118 + plaintext_pad_len;
3121 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3124 DIGEST_BYTE_LENGTH_KASUMI_F9,
3125 "KASUMI Generated auth tag not as expected");
3131 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3133 struct crypto_testsuite_params *ts_params = &testsuite_params;
3134 struct crypto_unittest_params *ut_params = &unittest_params;
3137 unsigned plaintext_pad_len;
3138 unsigned plaintext_len;
3141 /* Create KASUMI session */
3142 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3143 tdata->key.data, tdata->key.len,
3144 0, tdata->digest.len,
3145 RTE_CRYPTO_AUTH_OP_VERIFY,
3146 RTE_CRYPTO_AUTH_KASUMI_F9);
3149 /* alloc mbuf and set payload */
3150 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3152 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3153 rte_pktmbuf_tailroom(ut_params->ibuf));
3155 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3156 /* Append data which is padded to a multiple */
3157 /* of the algorithms block size */
3158 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3159 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3161 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3163 /* Create KASUMI operation */
3164 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3168 RTE_CRYPTO_AUTH_OP_VERIFY,
3169 tdata->plaintext.len,
3174 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3176 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3177 ut_params->obuf = ut_params->op->sym->m_src;
3178 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3179 + plaintext_pad_len;
3182 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3191 test_snow3g_hash_generate_test_case_1(void)
3193 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3197 test_snow3g_hash_generate_test_case_2(void)
3199 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3203 test_snow3g_hash_generate_test_case_3(void)
3205 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3209 test_snow3g_hash_generate_test_case_4(void)
3211 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3215 test_snow3g_hash_generate_test_case_5(void)
3217 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3221 test_snow3g_hash_generate_test_case_6(void)
3223 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3227 test_snow3g_hash_verify_test_case_1(void)
3229 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3234 test_snow3g_hash_verify_test_case_2(void)
3236 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3240 test_snow3g_hash_verify_test_case_3(void)
3242 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3246 test_snow3g_hash_verify_test_case_4(void)
3248 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3252 test_snow3g_hash_verify_test_case_5(void)
3254 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3258 test_snow3g_hash_verify_test_case_6(void)
3260 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3264 test_kasumi_hash_generate_test_case_1(void)
3266 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3270 test_kasumi_hash_generate_test_case_2(void)
3272 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3276 test_kasumi_hash_generate_test_case_3(void)
3278 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3282 test_kasumi_hash_generate_test_case_4(void)
3284 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3288 test_kasumi_hash_generate_test_case_5(void)
3290 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3294 test_kasumi_hash_generate_test_case_6(void)
3296 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3300 test_kasumi_hash_verify_test_case_1(void)
3302 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3306 test_kasumi_hash_verify_test_case_2(void)
3308 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3312 test_kasumi_hash_verify_test_case_3(void)
3314 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3318 test_kasumi_hash_verify_test_case_4(void)
3320 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3324 test_kasumi_hash_verify_test_case_5(void)
3326 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3330 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3332 struct crypto_testsuite_params *ts_params = &testsuite_params;
3333 struct crypto_unittest_params *ut_params = &unittest_params;
3336 uint8_t *plaintext, *ciphertext;
3337 unsigned plaintext_pad_len;
3338 unsigned plaintext_len;
3340 /* Create KASUMI session */
3341 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3342 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3343 RTE_CRYPTO_CIPHER_KASUMI_F8,
3344 tdata->key.data, tdata->key.len,
3345 tdata->cipher_iv.len);
3349 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3351 /* Clear mbuf payload */
3352 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3353 rte_pktmbuf_tailroom(ut_params->ibuf));
3355 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3356 /* Append data which is padded to a multiple */
3357 /* of the algorithms block size */
3358 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3359 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3361 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3363 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3365 /* Create KASUMI operation */
3366 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3367 tdata->cipher_iv.len,
3368 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3369 tdata->validCipherOffsetInBits.len);
3373 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3375 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3377 ut_params->obuf = ut_params->op->sym->m_dst;
3378 if (ut_params->obuf)
3379 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3381 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3383 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3385 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3386 (tdata->validCipherOffsetInBits.len >> 3);
3388 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3390 reference_ciphertext,
3391 tdata->validCipherLenInBits.len,
3392 "KASUMI Ciphertext data not as expected");
3397 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3399 struct crypto_testsuite_params *ts_params = &testsuite_params;
3400 struct crypto_unittest_params *ut_params = &unittest_params;
3404 unsigned int plaintext_pad_len;
3405 unsigned int plaintext_len;
3407 uint8_t buffer[10000];
3408 const uint8_t *ciphertext;
3410 struct rte_cryptodev_info dev_info;
3412 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3414 uint64_t feat_flags = dev_info.feature_flags;
3416 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3417 printf("Device doesn't support in-place scatter-gather. "
3422 /* Create KASUMI session */
3423 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3424 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3425 RTE_CRYPTO_CIPHER_KASUMI_F8,
3426 tdata->key.data, tdata->key.len,
3427 tdata->cipher_iv.len);
3431 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3434 /* Append data which is padded to a multiple */
3435 /* of the algorithms block size */
3436 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3438 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3439 plaintext_pad_len, 10, 0);
3441 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3443 /* Create KASUMI operation */
3444 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3445 tdata->cipher_iv.len,
3446 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3447 tdata->validCipherOffsetInBits.len);
3451 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3453 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3455 ut_params->obuf = ut_params->op->sym->m_dst;
3457 if (ut_params->obuf)
3458 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3459 plaintext_len, buffer);
3461 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3462 tdata->validCipherOffsetInBits.len >> 3,
3463 plaintext_len, buffer);
3466 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3468 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3469 (tdata->validCipherOffsetInBits.len >> 3);
3471 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3473 reference_ciphertext,
3474 tdata->validCipherLenInBits.len,
3475 "KASUMI Ciphertext data not as expected");
3480 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3482 struct crypto_testsuite_params *ts_params = &testsuite_params;
3483 struct crypto_unittest_params *ut_params = &unittest_params;
3486 uint8_t *plaintext, *ciphertext;
3487 unsigned plaintext_pad_len;
3488 unsigned plaintext_len;
3490 /* Create KASUMI session */
3491 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3492 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3493 RTE_CRYPTO_CIPHER_KASUMI_F8,
3494 tdata->key.data, tdata->key.len,
3495 tdata->cipher_iv.len);
3499 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3500 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3502 /* Clear mbuf payload */
3503 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3504 rte_pktmbuf_tailroom(ut_params->ibuf));
3506 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3507 /* Append data which is padded to a multiple */
3508 /* of the algorithms block size */
3509 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3510 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3512 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3513 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3515 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3517 /* Create KASUMI operation */
3518 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3519 tdata->cipher_iv.len,
3520 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3521 tdata->validCipherOffsetInBits.len);
3525 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3527 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3529 ut_params->obuf = ut_params->op->sym->m_dst;
3530 if (ut_params->obuf)
3531 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3533 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3535 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3537 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3538 (tdata->validCipherOffsetInBits.len >> 3);
3540 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3542 reference_ciphertext,
3543 tdata->validCipherLenInBits.len,
3544 "KASUMI Ciphertext data not as expected");
3549 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3551 struct crypto_testsuite_params *ts_params = &testsuite_params;
3552 struct crypto_unittest_params *ut_params = &unittest_params;
3555 unsigned int plaintext_pad_len;
3556 unsigned int plaintext_len;
3558 const uint8_t *ciphertext;
3559 uint8_t buffer[2048];
3561 struct rte_cryptodev_info dev_info;
3563 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3565 uint64_t feat_flags = dev_info.feature_flags;
3566 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3567 printf("Device doesn't support out-of-place scatter-gather "
3568 "in both input and output mbufs. "
3573 /* Create KASUMI session */
3574 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3575 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3576 RTE_CRYPTO_CIPHER_KASUMI_F8,
3577 tdata->key.data, tdata->key.len,
3578 tdata->cipher_iv.len);
3582 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3583 /* Append data which is padded to a multiple */
3584 /* of the algorithms block size */
3585 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3587 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3588 plaintext_pad_len, 10, 0);
3589 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3590 plaintext_pad_len, 3, 0);
3592 /* Append data which is padded to a multiple */
3593 /* of the algorithms block size */
3594 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3596 /* Create KASUMI operation */
3597 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3598 tdata->cipher_iv.len,
3599 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3600 tdata->validCipherOffsetInBits.len);
3604 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3606 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3608 ut_params->obuf = ut_params->op->sym->m_dst;
3609 if (ut_params->obuf)
3610 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3611 plaintext_pad_len, buffer);
3613 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3614 tdata->validCipherOffsetInBits.len >> 3,
3615 plaintext_pad_len, buffer);
3617 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3618 (tdata->validCipherOffsetInBits.len >> 3);
3620 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3622 reference_ciphertext,
3623 tdata->validCipherLenInBits.len,
3624 "KASUMI Ciphertext data not as expected");
3630 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3632 struct crypto_testsuite_params *ts_params = &testsuite_params;
3633 struct crypto_unittest_params *ut_params = &unittest_params;
3636 uint8_t *ciphertext, *plaintext;
3637 unsigned ciphertext_pad_len;
3638 unsigned ciphertext_len;
3640 /* Create KASUMI session */
3641 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3642 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3643 RTE_CRYPTO_CIPHER_KASUMI_F8,
3644 tdata->key.data, tdata->key.len,
3645 tdata->cipher_iv.len);
3649 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3650 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3652 /* Clear mbuf payload */
3653 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3654 rte_pktmbuf_tailroom(ut_params->ibuf));
3656 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3657 /* Append data which is padded to a multiple */
3658 /* of the algorithms block size */
3659 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3660 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3661 ciphertext_pad_len);
3662 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3663 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3665 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3667 /* Create KASUMI operation */
3668 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3669 tdata->cipher_iv.len,
3670 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3671 tdata->validCipherOffsetInBits.len);
3675 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3677 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3679 ut_params->obuf = ut_params->op->sym->m_dst;
3680 if (ut_params->obuf)
3681 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3683 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3685 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3687 const uint8_t *reference_plaintext = tdata->plaintext.data +
3688 (tdata->validCipherOffsetInBits.len >> 3);
3690 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3692 reference_plaintext,
3693 tdata->validCipherLenInBits.len,
3694 "KASUMI Plaintext data not as expected");
3699 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3701 struct crypto_testsuite_params *ts_params = &testsuite_params;
3702 struct crypto_unittest_params *ut_params = &unittest_params;
3705 uint8_t *ciphertext, *plaintext;
3706 unsigned ciphertext_pad_len;
3707 unsigned ciphertext_len;
3709 /* Create KASUMI session */
3710 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3711 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3712 RTE_CRYPTO_CIPHER_KASUMI_F8,
3713 tdata->key.data, tdata->key.len,
3714 tdata->cipher_iv.len);
3718 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3720 /* Clear mbuf payload */
3721 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3722 rte_pktmbuf_tailroom(ut_params->ibuf));
3724 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3725 /* Append data which is padded to a multiple */
3726 /* of the algorithms block size */
3727 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3728 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3729 ciphertext_pad_len);
3730 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3732 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3734 /* Create KASUMI operation */
3735 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3736 tdata->cipher_iv.len,
3737 tdata->ciphertext.len,
3738 tdata->validCipherOffsetInBits.len);
3742 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3744 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3746 ut_params->obuf = ut_params->op->sym->m_dst;
3747 if (ut_params->obuf)
3748 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3750 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3752 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3754 const uint8_t *reference_plaintext = tdata->plaintext.data +
3755 (tdata->validCipherOffsetInBits.len >> 3);
3757 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3759 reference_plaintext,
3760 tdata->validCipherLenInBits.len,
3761 "KASUMI Plaintext data not as expected");
3766 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3768 struct crypto_testsuite_params *ts_params = &testsuite_params;
3769 struct crypto_unittest_params *ut_params = &unittest_params;
3772 uint8_t *plaintext, *ciphertext;
3773 unsigned plaintext_pad_len;
3774 unsigned plaintext_len;
3776 /* Create SNOW 3G session */
3777 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3778 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3779 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3780 tdata->key.data, tdata->key.len,
3781 tdata->cipher_iv.len);
3785 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3787 /* Clear mbuf payload */
3788 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3789 rte_pktmbuf_tailroom(ut_params->ibuf));
3791 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3792 /* Append data which is padded to a multiple of */
3793 /* the algorithms block size */
3794 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3795 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3797 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3799 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3801 /* Create SNOW 3G operation */
3802 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3803 tdata->cipher_iv.len,
3804 tdata->validCipherLenInBits.len,
3809 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3811 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3813 ut_params->obuf = ut_params->op->sym->m_dst;
3814 if (ut_params->obuf)
3815 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3817 ciphertext = plaintext;
3819 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3822 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3824 tdata->ciphertext.data,
3825 tdata->validDataLenInBits.len,
3826 "SNOW 3G Ciphertext data not as expected");
3832 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3834 struct crypto_testsuite_params *ts_params = &testsuite_params;
3835 struct crypto_unittest_params *ut_params = &unittest_params;
3836 uint8_t *plaintext, *ciphertext;
3839 unsigned plaintext_pad_len;
3840 unsigned plaintext_len;
3842 /* Create SNOW 3G session */
3843 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3844 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3845 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3846 tdata->key.data, tdata->key.len,
3847 tdata->cipher_iv.len);
3851 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3852 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3854 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3855 "Failed to allocate input buffer in mempool");
3856 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3857 "Failed to allocate output buffer in mempool");
3859 /* Clear mbuf payload */
3860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3861 rte_pktmbuf_tailroom(ut_params->ibuf));
3863 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3864 /* Append data which is padded to a multiple of */
3865 /* the algorithms block size */
3866 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3867 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3869 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3870 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3872 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3874 /* Create SNOW 3G operation */
3875 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3876 tdata->cipher_iv.len,
3877 tdata->validCipherLenInBits.len,
3882 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3884 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3886 ut_params->obuf = ut_params->op->sym->m_dst;
3887 if (ut_params->obuf)
3888 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3890 ciphertext = plaintext;
3892 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3895 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3897 tdata->ciphertext.data,
3898 tdata->validDataLenInBits.len,
3899 "SNOW 3G Ciphertext data not as expected");
3904 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3906 struct crypto_testsuite_params *ts_params = &testsuite_params;
3907 struct crypto_unittest_params *ut_params = &unittest_params;
3910 unsigned int plaintext_pad_len;
3911 unsigned int plaintext_len;
3912 uint8_t buffer[10000];
3913 const uint8_t *ciphertext;
3915 struct rte_cryptodev_info dev_info;
3917 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3919 uint64_t feat_flags = dev_info.feature_flags;
3921 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3922 printf("Device doesn't support out-of-place scatter-gather "
3923 "in both input and output mbufs. "
3928 /* Create SNOW 3G session */
3929 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3930 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3931 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3932 tdata->key.data, tdata->key.len,
3933 tdata->cipher_iv.len);
3937 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3938 /* Append data which is padded to a multiple of */
3939 /* the algorithms block size */
3940 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3942 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3943 plaintext_pad_len, 10, 0);
3944 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3945 plaintext_pad_len, 3, 0);
3947 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3948 "Failed to allocate input buffer in mempool");
3949 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3950 "Failed to allocate output buffer in mempool");
3952 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3954 /* Create SNOW 3G operation */
3955 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3956 tdata->cipher_iv.len,
3957 tdata->validCipherLenInBits.len,
3962 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3964 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3966 ut_params->obuf = ut_params->op->sym->m_dst;
3967 if (ut_params->obuf)
3968 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3969 plaintext_len, buffer);
3971 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3972 plaintext_len, buffer);
3974 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3977 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3979 tdata->ciphertext.data,
3980 tdata->validDataLenInBits.len,
3981 "SNOW 3G Ciphertext data not as expected");
3986 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3988 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3990 uint8_t curr_byte, prev_byte;
3991 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3992 uint8_t lower_byte_mask = (1 << offset) - 1;
3995 prev_byte = buffer[0];
3996 buffer[0] >>= offset;
3998 for (i = 1; i < length_in_bytes; i++) {
3999 curr_byte = buffer[i];
4000 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4001 (curr_byte >> offset);
4002 prev_byte = curr_byte;
4007 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4009 struct crypto_testsuite_params *ts_params = &testsuite_params;
4010 struct crypto_unittest_params *ut_params = &unittest_params;
4011 uint8_t *plaintext, *ciphertext;
4013 uint32_t plaintext_len;
4014 uint32_t plaintext_pad_len;
4015 uint8_t extra_offset = 4;
4016 uint8_t *expected_ciphertext_shifted;
4018 /* Create SNOW 3G session */
4019 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4020 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4021 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4022 tdata->key.data, tdata->key.len,
4023 tdata->cipher_iv.len);
4027 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4028 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4030 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4031 "Failed to allocate input buffer in mempool");
4032 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4033 "Failed to allocate output buffer in mempool");
4035 /* Clear mbuf payload */
4036 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4037 rte_pktmbuf_tailroom(ut_params->ibuf));
4039 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4041 * Append data which is padded to a
4042 * multiple of the algorithms block size
4044 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4046 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4049 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4051 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4052 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4054 #ifdef RTE_APP_TEST_DEBUG
4055 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4057 /* Create SNOW 3G operation */
4058 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4059 tdata->cipher_iv.len,
4060 tdata->validCipherLenInBits.len,
4065 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4067 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4069 ut_params->obuf = ut_params->op->sym->m_dst;
4070 if (ut_params->obuf)
4071 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4073 ciphertext = plaintext;
4075 #ifdef RTE_APP_TEST_DEBUG
4076 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4079 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4081 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4082 "failed to reserve memory for ciphertext shifted\n");
4084 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4085 ceil_byte_length(tdata->ciphertext.len));
4086 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4089 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4091 expected_ciphertext_shifted,
4092 tdata->validDataLenInBits.len,
4094 "SNOW 3G Ciphertext data not as expected");
4098 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4100 struct crypto_testsuite_params *ts_params = &testsuite_params;
4101 struct crypto_unittest_params *ut_params = &unittest_params;
4105 uint8_t *plaintext, *ciphertext;
4106 unsigned ciphertext_pad_len;
4107 unsigned ciphertext_len;
4109 /* Create SNOW 3G session */
4110 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4111 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4112 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4113 tdata->key.data, tdata->key.len,
4114 tdata->cipher_iv.len);
4118 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4120 /* Clear mbuf payload */
4121 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4122 rte_pktmbuf_tailroom(ut_params->ibuf));
4124 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4125 /* Append data which is padded to a multiple of */
4126 /* the algorithms block size */
4127 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4128 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4129 ciphertext_pad_len);
4130 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4132 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4134 /* Create SNOW 3G operation */
4135 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4136 tdata->cipher_iv.len,
4137 tdata->validCipherLenInBits.len,
4138 tdata->cipher.offset_bits);
4142 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4144 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4145 ut_params->obuf = ut_params->op->sym->m_dst;
4146 if (ut_params->obuf)
4147 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4149 plaintext = ciphertext;
4151 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4154 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4155 tdata->plaintext.data,
4156 tdata->validDataLenInBits.len,
4157 "SNOW 3G Plaintext data not as expected");
4161 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4163 struct crypto_testsuite_params *ts_params = &testsuite_params;
4164 struct crypto_unittest_params *ut_params = &unittest_params;
4168 uint8_t *plaintext, *ciphertext;
4169 unsigned ciphertext_pad_len;
4170 unsigned ciphertext_len;
4172 /* Create SNOW 3G session */
4173 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4174 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4175 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4176 tdata->key.data, tdata->key.len,
4177 tdata->cipher_iv.len);
4181 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4182 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4184 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4185 "Failed to allocate input buffer");
4186 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4187 "Failed to allocate output buffer");
4189 /* Clear mbuf payload */
4190 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4191 rte_pktmbuf_tailroom(ut_params->ibuf));
4193 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4194 rte_pktmbuf_tailroom(ut_params->obuf));
4196 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4197 /* Append data which is padded to a multiple of */
4198 /* the algorithms block size */
4199 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4200 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4201 ciphertext_pad_len);
4202 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4203 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4205 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4207 /* Create SNOW 3G operation */
4208 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4209 tdata->cipher_iv.len,
4210 tdata->validCipherLenInBits.len,
4215 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4217 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4218 ut_params->obuf = ut_params->op->sym->m_dst;
4219 if (ut_params->obuf)
4220 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4222 plaintext = ciphertext;
4224 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4227 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4228 tdata->plaintext.data,
4229 tdata->validDataLenInBits.len,
4230 "SNOW 3G Plaintext data not as expected");
4235 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4237 struct crypto_testsuite_params *ts_params = &testsuite_params;
4238 struct crypto_unittest_params *ut_params = &unittest_params;
4242 uint8_t *plaintext, *ciphertext;
4243 unsigned int plaintext_pad_len;
4244 unsigned int plaintext_len;
4246 struct rte_cryptodev_sym_capability_idx cap_idx;
4248 /* Check if device supports ZUC EEA3 */
4249 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4250 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4252 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4256 /* Check if device supports ZUC EIA3 */
4257 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4258 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4260 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4264 /* Create ZUC session */
4265 retval = create_zuc_cipher_auth_encrypt_generate_session(
4266 ts_params->valid_devs[0],
4270 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4272 /* clear mbuf payload */
4273 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4274 rte_pktmbuf_tailroom(ut_params->ibuf));
4276 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4277 /* Append data which is padded to a multiple of */
4278 /* the algorithms block size */
4279 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4280 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4282 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4284 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4286 /* Create ZUC operation */
4287 retval = create_zuc_cipher_hash_generate_operation(tdata);
4291 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4294 ut_params->obuf = ut_params->op->sym->m_src;
4295 if (ut_params->obuf)
4296 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4298 ciphertext = plaintext;
4300 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4302 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4304 tdata->ciphertext.data,
4305 tdata->validDataLenInBits.len,
4306 "ZUC Ciphertext data not as expected");
4308 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4309 + plaintext_pad_len;
4312 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4316 "ZUC Generated auth tag not as expected");
4321 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4323 struct crypto_testsuite_params *ts_params = &testsuite_params;
4324 struct crypto_unittest_params *ut_params = &unittest_params;
4328 uint8_t *plaintext, *ciphertext;
4329 unsigned plaintext_pad_len;
4330 unsigned plaintext_len;
4332 /* Create SNOW 3G session */
4333 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4334 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4335 RTE_CRYPTO_AUTH_OP_GENERATE,
4336 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4337 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4338 tdata->key.data, tdata->key.len,
4339 tdata->auth_iv.len, tdata->digest.len,
4340 tdata->cipher_iv.len);
4343 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4345 /* clear mbuf payload */
4346 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4347 rte_pktmbuf_tailroom(ut_params->ibuf));
4349 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4350 /* Append data which is padded to a multiple of */
4351 /* the algorithms block size */
4352 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4353 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4355 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4357 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4359 /* Create SNOW 3G operation */
4360 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4361 tdata->digest.len, tdata->auth_iv.data,
4363 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4364 tdata->cipher_iv.data, tdata->cipher_iv.len,
4365 tdata->validCipherLenInBits.len,
4367 tdata->validAuthLenInBits.len,
4373 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4375 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4376 ut_params->obuf = ut_params->op->sym->m_src;
4377 if (ut_params->obuf)
4378 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4380 ciphertext = plaintext;
4382 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4384 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4386 tdata->ciphertext.data,
4387 tdata->validDataLenInBits.len,
4388 "SNOW 3G Ciphertext data not as expected");
4390 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4391 + plaintext_pad_len;
4394 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4397 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4398 "SNOW 3G Generated auth tag not as expected");
4403 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4404 uint8_t op_mode, uint8_t verify)
4406 struct crypto_testsuite_params *ts_params = &testsuite_params;
4407 struct crypto_unittest_params *ut_params = &unittest_params;
4411 uint8_t *plaintext = NULL, *ciphertext = NULL;
4412 unsigned int plaintext_pad_len;
4413 unsigned int plaintext_len;
4414 unsigned int ciphertext_pad_len;
4415 unsigned int ciphertext_len;
4417 struct rte_cryptodev_info dev_info;
4419 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4421 uint64_t feat_flags = dev_info.feature_flags;
4423 if (op_mode == OUT_OF_PLACE) {
4424 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4425 printf("Device doesn't support digest encrypted.\n");
4430 /* Create SNOW 3G session */
4431 retval = create_wireless_algo_auth_cipher_session(
4432 ts_params->valid_devs[0],
4433 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4434 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4435 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4436 : RTE_CRYPTO_AUTH_OP_GENERATE),
4437 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4438 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4439 tdata->key.data, tdata->key.len,
4440 tdata->auth_iv.len, tdata->digest.len,
4441 tdata->cipher_iv.len);
4446 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4447 if (op_mode == OUT_OF_PLACE)
4448 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4450 /* clear mbuf payload */
4451 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4452 rte_pktmbuf_tailroom(ut_params->ibuf));
4453 if (op_mode == OUT_OF_PLACE)
4454 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4455 rte_pktmbuf_tailroom(ut_params->obuf));
4457 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4458 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4459 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4460 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4463 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4464 ciphertext_pad_len);
4465 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4466 if (op_mode == OUT_OF_PLACE)
4467 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4468 debug_hexdump(stdout, "ciphertext:", ciphertext,
4471 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4473 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4474 if (op_mode == OUT_OF_PLACE)
4475 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4476 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4479 /* Create SNOW 3G operation */
4480 retval = create_wireless_algo_auth_cipher_operation(
4482 tdata->cipher_iv.data, tdata->cipher_iv.len,
4483 tdata->auth_iv.data, tdata->auth_iv.len,
4484 (tdata->digest.offset_bytes == 0 ?
4485 (verify ? ciphertext_pad_len : plaintext_pad_len)
4486 : tdata->digest.offset_bytes),
4487 tdata->validCipherLenInBits.len,
4488 tdata->cipher.offset_bits,
4489 tdata->validAuthLenInBits.len,
4490 tdata->auth.offset_bits,
4496 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4499 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4501 ut_params->obuf = (op_mode == IN_PLACE ?
4502 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4505 if (ut_params->obuf)
4506 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4509 plaintext = ciphertext +
4510 (tdata->cipher.offset_bits >> 3);
4512 debug_hexdump(stdout, "plaintext:", plaintext,
4513 (tdata->plaintext.len >> 3) - tdata->digest.len);
4514 debug_hexdump(stdout, "plaintext expected:",
4515 tdata->plaintext.data,
4516 (tdata->plaintext.len >> 3) - tdata->digest.len);
4518 if (ut_params->obuf)
4519 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4522 ciphertext = plaintext;
4524 debug_hexdump(stdout, "ciphertext:", ciphertext,
4526 debug_hexdump(stdout, "ciphertext expected:",
4527 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4529 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4530 + (tdata->digest.offset_bytes == 0 ?
4531 plaintext_pad_len : tdata->digest.offset_bytes);
4533 debug_hexdump(stdout, "digest:", ut_params->digest,
4535 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4541 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4543 tdata->plaintext.data,
4544 tdata->plaintext.len >> 3,
4545 "SNOW 3G Plaintext data not as expected");
4547 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4549 tdata->ciphertext.data,
4550 tdata->validDataLenInBits.len,
4551 "SNOW 3G Ciphertext data not as expected");
4553 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4556 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4557 "SNOW 3G Generated auth tag not as expected");
4563 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4564 uint8_t op_mode, uint8_t verify)
4566 struct crypto_testsuite_params *ts_params = &testsuite_params;
4567 struct crypto_unittest_params *ut_params = &unittest_params;
4571 const uint8_t *plaintext = NULL;
4572 const uint8_t *ciphertext = NULL;
4573 const uint8_t *digest = NULL;
4574 unsigned int plaintext_pad_len;
4575 unsigned int plaintext_len;
4576 unsigned int ciphertext_pad_len;
4577 unsigned int ciphertext_len;
4578 uint8_t buffer[10000];
4579 uint8_t digest_buffer[10000];
4581 struct rte_cryptodev_info dev_info;
4583 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4585 uint64_t feat_flags = dev_info.feature_flags;
4587 if (op_mode == IN_PLACE) {
4588 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4589 printf("Device doesn't support in-place scatter-gather "
4590 "in both input and output mbufs.\n");
4594 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4595 printf("Device doesn't support out-of-place scatter-gather "
4596 "in both input and output mbufs.\n");
4599 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4600 printf("Device doesn't support digest encrypted.\n");
4605 /* Create SNOW 3G session */
4606 retval = create_wireless_algo_auth_cipher_session(
4607 ts_params->valid_devs[0],
4608 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4609 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4610 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4611 : RTE_CRYPTO_AUTH_OP_GENERATE),
4612 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4613 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4614 tdata->key.data, tdata->key.len,
4615 tdata->auth_iv.len, tdata->digest.len,
4616 tdata->cipher_iv.len);
4621 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4622 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4623 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4624 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4626 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4627 plaintext_pad_len, 15, 0);
4628 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4629 "Failed to allocate input buffer in mempool");
4631 if (op_mode == OUT_OF_PLACE) {
4632 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4633 plaintext_pad_len, 15, 0);
4634 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4635 "Failed to allocate output buffer in mempool");
4639 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4640 tdata->ciphertext.data);
4641 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4642 ciphertext_len, buffer);
4643 debug_hexdump(stdout, "ciphertext:", ciphertext,
4646 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4647 tdata->plaintext.data);
4648 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4649 plaintext_len, buffer);
4650 debug_hexdump(stdout, "plaintext:", plaintext,
4653 memset(buffer, 0, sizeof(buffer));
4655 /* Create SNOW 3G operation */
4656 retval = create_wireless_algo_auth_cipher_operation(
4658 tdata->cipher_iv.data, tdata->cipher_iv.len,
4659 tdata->auth_iv.data, tdata->auth_iv.len,
4660 (tdata->digest.offset_bytes == 0 ?
4661 (verify ? ciphertext_pad_len : plaintext_pad_len)
4662 : tdata->digest.offset_bytes),
4663 tdata->validCipherLenInBits.len,
4664 tdata->cipher.offset_bits,
4665 tdata->validAuthLenInBits.len,
4666 tdata->auth.offset_bits,
4672 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4675 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4677 ut_params->obuf = (op_mode == IN_PLACE ?
4678 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4681 if (ut_params->obuf)
4682 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4683 plaintext_len, buffer);
4685 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4686 plaintext_len, buffer);
4688 debug_hexdump(stdout, "plaintext:", plaintext,
4689 (tdata->plaintext.len >> 3) - tdata->digest.len);
4690 debug_hexdump(stdout, "plaintext expected:",
4691 tdata->plaintext.data,
4692 (tdata->plaintext.len >> 3) - tdata->digest.len);
4694 if (ut_params->obuf)
4695 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4696 ciphertext_len, buffer);
4698 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4699 ciphertext_len, buffer);
4701 debug_hexdump(stdout, "ciphertext:", ciphertext,
4703 debug_hexdump(stdout, "ciphertext expected:",
4704 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4706 if (ut_params->obuf)
4707 digest = rte_pktmbuf_read(ut_params->obuf,
4708 (tdata->digest.offset_bytes == 0 ?
4709 plaintext_pad_len : tdata->digest.offset_bytes),
4710 tdata->digest.len, digest_buffer);
4712 digest = rte_pktmbuf_read(ut_params->ibuf,
4713 (tdata->digest.offset_bytes == 0 ?
4714 plaintext_pad_len : tdata->digest.offset_bytes),
4715 tdata->digest.len, digest_buffer);
4717 debug_hexdump(stdout, "digest:", digest,
4719 debug_hexdump(stdout, "digest expected:",
4720 tdata->digest.data, tdata->digest.len);
4725 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4727 tdata->plaintext.data,
4728 tdata->plaintext.len >> 3,
4729 "SNOW 3G Plaintext data not as expected");
4731 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4733 tdata->ciphertext.data,
4734 tdata->validDataLenInBits.len,
4735 "SNOW 3G Ciphertext data not as expected");
4737 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4740 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4741 "SNOW 3G Generated auth tag not as expected");
4747 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4748 uint8_t op_mode, uint8_t verify)
4750 struct crypto_testsuite_params *ts_params = &testsuite_params;
4751 struct crypto_unittest_params *ut_params = &unittest_params;
4755 uint8_t *plaintext = NULL, *ciphertext = NULL;
4756 unsigned int plaintext_pad_len;
4757 unsigned int plaintext_len;
4758 unsigned int ciphertext_pad_len;
4759 unsigned int ciphertext_len;
4761 struct rte_cryptodev_info dev_info;
4763 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4765 uint64_t feat_flags = dev_info.feature_flags;
4767 if (op_mode == OUT_OF_PLACE) {
4768 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4769 printf("Device doesn't support digest encrypted.\n");
4774 /* Create KASUMI session */
4775 retval = create_wireless_algo_auth_cipher_session(
4776 ts_params->valid_devs[0],
4777 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4778 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4779 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4780 : RTE_CRYPTO_AUTH_OP_GENERATE),
4781 RTE_CRYPTO_AUTH_KASUMI_F9,
4782 RTE_CRYPTO_CIPHER_KASUMI_F8,
4783 tdata->key.data, tdata->key.len,
4784 0, tdata->digest.len,
4785 tdata->cipher_iv.len);
4790 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4791 if (op_mode == OUT_OF_PLACE)
4792 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4794 /* clear mbuf payload */
4795 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4796 rte_pktmbuf_tailroom(ut_params->ibuf));
4797 if (op_mode == OUT_OF_PLACE)
4798 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4799 rte_pktmbuf_tailroom(ut_params->obuf));
4801 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4802 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4803 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4804 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4807 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4808 ciphertext_pad_len);
4809 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4810 if (op_mode == OUT_OF_PLACE)
4811 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4812 debug_hexdump(stdout, "ciphertext:", ciphertext,
4815 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4817 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4818 if (op_mode == OUT_OF_PLACE)
4819 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4820 debug_hexdump(stdout, "plaintext:", plaintext,
4824 /* Create KASUMI operation */
4825 retval = create_wireless_algo_auth_cipher_operation(
4827 tdata->cipher_iv.data, tdata->cipher_iv.len,
4829 (tdata->digest.offset_bytes == 0 ?
4830 (verify ? ciphertext_pad_len : plaintext_pad_len)
4831 : tdata->digest.offset_bytes),
4832 tdata->validCipherLenInBits.len,
4833 tdata->validCipherOffsetInBits.len,
4834 tdata->validAuthLenInBits.len,
4841 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4844 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4846 ut_params->obuf = (op_mode == IN_PLACE ?
4847 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4851 if (ut_params->obuf)
4852 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4855 plaintext = ciphertext;
4857 debug_hexdump(stdout, "plaintext:", plaintext,
4858 (tdata->plaintext.len >> 3) - tdata->digest.len);
4859 debug_hexdump(stdout, "plaintext expected:",
4860 tdata->plaintext.data,
4861 (tdata->plaintext.len >> 3) - tdata->digest.len);
4863 if (ut_params->obuf)
4864 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4867 ciphertext = plaintext;
4869 debug_hexdump(stdout, "ciphertext:", ciphertext,
4871 debug_hexdump(stdout, "ciphertext expected:",
4872 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4874 ut_params->digest = rte_pktmbuf_mtod(
4875 ut_params->obuf, uint8_t *) +
4876 (tdata->digest.offset_bytes == 0 ?
4877 plaintext_pad_len : tdata->digest.offset_bytes);
4879 debug_hexdump(stdout, "digest:", ut_params->digest,
4881 debug_hexdump(stdout, "digest expected:",
4882 tdata->digest.data, tdata->digest.len);
4887 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4889 tdata->plaintext.data,
4890 tdata->plaintext.len >> 3,
4891 "KASUMI Plaintext data not as expected");
4893 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4895 tdata->ciphertext.data,
4896 tdata->ciphertext.len >> 3,
4897 "KASUMI Ciphertext data not as expected");
4899 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4902 DIGEST_BYTE_LENGTH_KASUMI_F9,
4903 "KASUMI Generated auth tag not as expected");
4909 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4910 uint8_t op_mode, uint8_t verify)
4912 struct crypto_testsuite_params *ts_params = &testsuite_params;
4913 struct crypto_unittest_params *ut_params = &unittest_params;
4917 const uint8_t *plaintext = NULL;
4918 const uint8_t *ciphertext = NULL;
4919 const uint8_t *digest = NULL;
4920 unsigned int plaintext_pad_len;
4921 unsigned int plaintext_len;
4922 unsigned int ciphertext_pad_len;
4923 unsigned int ciphertext_len;
4924 uint8_t buffer[10000];
4925 uint8_t digest_buffer[10000];
4927 struct rte_cryptodev_info dev_info;
4929 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4931 uint64_t feat_flags = dev_info.feature_flags;
4933 if (op_mode == IN_PLACE) {
4934 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4935 printf("Device doesn't support in-place scatter-gather "
4936 "in both input and output mbufs.\n");
4940 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4941 printf("Device doesn't support out-of-place scatter-gather "
4942 "in both input and output mbufs.\n");
4945 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4946 printf("Device doesn't support digest encrypted.\n");
4951 /* Create KASUMI session */
4952 retval = create_wireless_algo_auth_cipher_session(
4953 ts_params->valid_devs[0],
4954 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4955 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4956 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4957 : RTE_CRYPTO_AUTH_OP_GENERATE),
4958 RTE_CRYPTO_AUTH_KASUMI_F9,
4959 RTE_CRYPTO_CIPHER_KASUMI_F8,
4960 tdata->key.data, tdata->key.len,
4961 0, tdata->digest.len,
4962 tdata->cipher_iv.len);
4967 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4968 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4969 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4970 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4972 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4973 plaintext_pad_len, 15, 0);
4974 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4975 "Failed to allocate input buffer in mempool");
4977 if (op_mode == OUT_OF_PLACE) {
4978 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4979 plaintext_pad_len, 15, 0);
4980 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4981 "Failed to allocate output buffer in mempool");
4985 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4986 tdata->ciphertext.data);
4987 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4988 ciphertext_len, buffer);
4989 debug_hexdump(stdout, "ciphertext:", ciphertext,
4992 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4993 tdata->plaintext.data);
4994 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4995 plaintext_len, buffer);
4996 debug_hexdump(stdout, "plaintext:", plaintext,
4999 memset(buffer, 0, sizeof(buffer));
5001 /* Create KASUMI operation */
5002 retval = create_wireless_algo_auth_cipher_operation(
5004 tdata->cipher_iv.data, tdata->cipher_iv.len,
5006 (tdata->digest.offset_bytes == 0 ?
5007 (verify ? ciphertext_pad_len : plaintext_pad_len)
5008 : tdata->digest.offset_bytes),
5009 tdata->validCipherLenInBits.len,
5010 tdata->validCipherOffsetInBits.len,
5011 tdata->validAuthLenInBits.len,
5018 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5021 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5023 ut_params->obuf = (op_mode == IN_PLACE ?
5024 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5027 if (ut_params->obuf)
5028 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5029 plaintext_len, buffer);
5031 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5032 plaintext_len, buffer);
5034 debug_hexdump(stdout, "plaintext:", plaintext,
5035 (tdata->plaintext.len >> 3) - tdata->digest.len);
5036 debug_hexdump(stdout, "plaintext expected:",
5037 tdata->plaintext.data,
5038 (tdata->plaintext.len >> 3) - tdata->digest.len);
5040 if (ut_params->obuf)
5041 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5042 ciphertext_len, buffer);
5044 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5045 ciphertext_len, buffer);
5047 debug_hexdump(stdout, "ciphertext:", ciphertext,
5049 debug_hexdump(stdout, "ciphertext expected:",
5050 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5052 if (ut_params->obuf)
5053 digest = rte_pktmbuf_read(ut_params->obuf,
5054 (tdata->digest.offset_bytes == 0 ?
5055 plaintext_pad_len : tdata->digest.offset_bytes),
5056 tdata->digest.len, digest_buffer);
5058 digest = rte_pktmbuf_read(ut_params->ibuf,
5059 (tdata->digest.offset_bytes == 0 ?
5060 plaintext_pad_len : tdata->digest.offset_bytes),
5061 tdata->digest.len, digest_buffer);
5063 debug_hexdump(stdout, "digest:", digest,
5065 debug_hexdump(stdout, "digest expected:",
5066 tdata->digest.data, tdata->digest.len);
5071 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5073 tdata->plaintext.data,
5074 tdata->plaintext.len >> 3,
5075 "KASUMI Plaintext data not as expected");
5077 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5079 tdata->ciphertext.data,
5080 tdata->validDataLenInBits.len,
5081 "KASUMI Ciphertext data not as expected");
5083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5086 DIGEST_BYTE_LENGTH_KASUMI_F9,
5087 "KASUMI Generated auth tag not as expected");
5093 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5095 struct crypto_testsuite_params *ts_params = &testsuite_params;
5096 struct crypto_unittest_params *ut_params = &unittest_params;
5100 uint8_t *plaintext, *ciphertext;
5101 unsigned plaintext_pad_len;
5102 unsigned plaintext_len;
5104 /* Create KASUMI session */
5105 retval = create_wireless_algo_cipher_auth_session(
5106 ts_params->valid_devs[0],
5107 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5108 RTE_CRYPTO_AUTH_OP_GENERATE,
5109 RTE_CRYPTO_AUTH_KASUMI_F9,
5110 RTE_CRYPTO_CIPHER_KASUMI_F8,
5111 tdata->key.data, tdata->key.len,
5112 0, tdata->digest.len,
5113 tdata->cipher_iv.len);
5117 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5119 /* clear mbuf payload */
5120 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5121 rte_pktmbuf_tailroom(ut_params->ibuf));
5123 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5124 /* Append data which is padded to a multiple of */
5125 /* the algorithms block size */
5126 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5127 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5129 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5131 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5133 /* Create KASUMI operation */
5134 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5135 tdata->digest.len, NULL, 0,
5136 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5137 tdata->cipher_iv.data, tdata->cipher_iv.len,
5138 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5139 tdata->validCipherOffsetInBits.len,
5140 tdata->validAuthLenInBits.len,
5146 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5148 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5150 if (ut_params->op->sym->m_dst)
5151 ut_params->obuf = ut_params->op->sym->m_dst;
5153 ut_params->obuf = ut_params->op->sym->m_src;
5155 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5156 tdata->validCipherOffsetInBits.len >> 3);
5158 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5159 + plaintext_pad_len;
5161 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5162 (tdata->validCipherOffsetInBits.len >> 3);
5164 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5166 reference_ciphertext,
5167 tdata->validCipherLenInBits.len,
5168 "KASUMI Ciphertext data not as expected");
5171 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5174 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5175 "KASUMI Generated auth tag not as expected");
5180 test_zuc_encryption(const struct wireless_test_data *tdata)
5182 struct crypto_testsuite_params *ts_params = &testsuite_params;
5183 struct crypto_unittest_params *ut_params = &unittest_params;
5186 uint8_t *plaintext, *ciphertext;
5187 unsigned plaintext_pad_len;
5188 unsigned plaintext_len;
5190 struct rte_cryptodev_sym_capability_idx cap_idx;
5192 /* Check if device supports ZUC EEA3 */
5193 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5194 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5196 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5200 /* Create ZUC session */
5201 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5202 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5203 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5204 tdata->key.data, tdata->key.len,
5205 tdata->cipher_iv.len);
5209 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5211 /* Clear mbuf payload */
5212 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5213 rte_pktmbuf_tailroom(ut_params->ibuf));
5215 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5216 /* Append data which is padded to a multiple */
5217 /* of the algorithms block size */
5218 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5219 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5221 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5223 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5225 /* Create ZUC operation */
5226 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5227 tdata->cipher_iv.len,
5228 tdata->plaintext.len,
5233 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5235 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5237 ut_params->obuf = ut_params->op->sym->m_dst;
5238 if (ut_params->obuf)
5239 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5241 ciphertext = plaintext;
5243 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5246 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5248 tdata->ciphertext.data,
5249 tdata->validCipherLenInBits.len,
5250 "ZUC Ciphertext data not as expected");
5255 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5257 struct crypto_testsuite_params *ts_params = &testsuite_params;
5258 struct crypto_unittest_params *ut_params = &unittest_params;
5262 unsigned int plaintext_pad_len;
5263 unsigned int plaintext_len;
5264 const uint8_t *ciphertext;
5265 uint8_t ciphertext_buffer[2048];
5266 struct rte_cryptodev_info dev_info;
5268 struct rte_cryptodev_sym_capability_idx cap_idx;
5270 /* Check if device supports ZUC EEA3 */
5271 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5272 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5274 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5278 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5280 uint64_t feat_flags = dev_info.feature_flags;
5282 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5283 printf("Device doesn't support in-place scatter-gather. "
5288 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5290 /* Append data which is padded to a multiple */
5291 /* of the algorithms block size */
5292 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5294 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5295 plaintext_pad_len, 10, 0);
5297 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5298 tdata->plaintext.data);
5300 /* Create ZUC session */
5301 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5302 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5303 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5304 tdata->key.data, tdata->key.len,
5305 tdata->cipher_iv.len);
5309 /* Clear mbuf payload */
5311 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5313 /* Create ZUC operation */
5314 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5315 tdata->cipher_iv.len, tdata->plaintext.len,
5320 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5322 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5324 ut_params->obuf = ut_params->op->sym->m_dst;
5325 if (ut_params->obuf)
5326 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5327 0, plaintext_len, ciphertext_buffer);
5329 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5330 0, plaintext_len, ciphertext_buffer);
5333 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5336 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5338 tdata->ciphertext.data,
5339 tdata->validCipherLenInBits.len,
5340 "ZUC Ciphertext data not as expected");
5346 test_zuc_authentication(const struct wireless_test_data *tdata)
5348 struct crypto_testsuite_params *ts_params = &testsuite_params;
5349 struct crypto_unittest_params *ut_params = &unittest_params;
5352 unsigned plaintext_pad_len;
5353 unsigned plaintext_len;
5356 struct rte_cryptodev_sym_capability_idx cap_idx;
5358 /* Check if device supports ZUC EIA3 */
5359 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5360 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5362 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5366 /* Create ZUC session */
5367 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5368 tdata->key.data, tdata->key.len,
5369 tdata->auth_iv.len, tdata->digest.len,
5370 RTE_CRYPTO_AUTH_OP_GENERATE,
5371 RTE_CRYPTO_AUTH_ZUC_EIA3);
5375 /* alloc mbuf and set payload */
5376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5378 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5379 rte_pktmbuf_tailroom(ut_params->ibuf));
5381 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5382 /* Append data which is padded to a multiple of */
5383 /* the algorithms block size */
5384 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5385 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5387 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5389 /* Create ZUC operation */
5390 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5391 tdata->auth_iv.data, tdata->auth_iv.len,
5392 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5393 tdata->validAuthLenInBits.len,
5398 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5400 ut_params->obuf = ut_params->op->sym->m_src;
5401 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5402 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5403 + plaintext_pad_len;
5406 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5409 DIGEST_BYTE_LENGTH_KASUMI_F9,
5410 "ZUC Generated auth tag not as expected");
5416 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5417 uint8_t op_mode, uint8_t verify)
5419 struct crypto_testsuite_params *ts_params = &testsuite_params;
5420 struct crypto_unittest_params *ut_params = &unittest_params;
5424 uint8_t *plaintext = NULL, *ciphertext = NULL;
5425 unsigned int plaintext_pad_len;
5426 unsigned int plaintext_len;
5427 unsigned int ciphertext_pad_len;
5428 unsigned int ciphertext_len;
5430 struct rte_cryptodev_info dev_info;
5431 struct rte_cryptodev_sym_capability_idx cap_idx;
5433 /* Check if device supports ZUC EIA3 */
5434 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5435 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5437 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5441 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5443 uint64_t feat_flags = dev_info.feature_flags;
5445 if (op_mode == OUT_OF_PLACE) {
5446 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5447 printf("Device doesn't support digest encrypted.\n");
5452 /* Create ZUC session */
5453 retval = create_wireless_algo_auth_cipher_session(
5454 ts_params->valid_devs[0],
5455 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5456 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5457 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5458 : RTE_CRYPTO_AUTH_OP_GENERATE),
5459 RTE_CRYPTO_AUTH_ZUC_EIA3,
5460 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5461 tdata->key.data, tdata->key.len,
5462 tdata->auth_iv.len, tdata->digest.len,
5463 tdata->cipher_iv.len);
5468 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5469 if (op_mode == OUT_OF_PLACE)
5470 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5472 /* clear mbuf payload */
5473 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5474 rte_pktmbuf_tailroom(ut_params->ibuf));
5475 if (op_mode == OUT_OF_PLACE)
5476 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5477 rte_pktmbuf_tailroom(ut_params->obuf));
5479 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5480 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5481 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5482 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5485 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5486 ciphertext_pad_len);
5487 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5488 if (op_mode == OUT_OF_PLACE)
5489 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5490 debug_hexdump(stdout, "ciphertext:", ciphertext,
5493 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5495 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5496 if (op_mode == OUT_OF_PLACE)
5497 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5498 debug_hexdump(stdout, "plaintext:", plaintext,
5502 /* Create ZUC operation */
5503 retval = create_wireless_algo_auth_cipher_operation(
5505 tdata->cipher_iv.data, tdata->cipher_iv.len,
5506 tdata->auth_iv.data, tdata->auth_iv.len,
5507 (tdata->digest.offset_bytes == 0 ?
5508 (verify ? ciphertext_pad_len : plaintext_pad_len)
5509 : tdata->digest.offset_bytes),
5510 tdata->validCipherLenInBits.len,
5511 tdata->validCipherOffsetInBits.len,
5512 tdata->validAuthLenInBits.len,
5519 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5522 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5524 ut_params->obuf = (op_mode == IN_PLACE ?
5525 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5529 if (ut_params->obuf)
5530 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5533 plaintext = ciphertext;
5535 debug_hexdump(stdout, "plaintext:", plaintext,
5536 (tdata->plaintext.len >> 3) - tdata->digest.len);
5537 debug_hexdump(stdout, "plaintext expected:",
5538 tdata->plaintext.data,
5539 (tdata->plaintext.len >> 3) - tdata->digest.len);
5541 if (ut_params->obuf)
5542 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5545 ciphertext = plaintext;
5547 debug_hexdump(stdout, "ciphertext:", ciphertext,
5549 debug_hexdump(stdout, "ciphertext expected:",
5550 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5552 ut_params->digest = rte_pktmbuf_mtod(
5553 ut_params->obuf, uint8_t *) +
5554 (tdata->digest.offset_bytes == 0 ?
5555 plaintext_pad_len : tdata->digest.offset_bytes);
5557 debug_hexdump(stdout, "digest:", ut_params->digest,
5559 debug_hexdump(stdout, "digest expected:",
5560 tdata->digest.data, tdata->digest.len);
5565 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5567 tdata->plaintext.data,
5568 tdata->plaintext.len >> 3,
5569 "ZUC Plaintext data not as expected");
5571 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5573 tdata->ciphertext.data,
5574 tdata->ciphertext.len >> 3,
5575 "ZUC Ciphertext data not as expected");
5577 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5580 DIGEST_BYTE_LENGTH_KASUMI_F9,
5581 "ZUC Generated auth tag not as expected");
5587 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5588 uint8_t op_mode, uint8_t verify)
5590 struct crypto_testsuite_params *ts_params = &testsuite_params;
5591 struct crypto_unittest_params *ut_params = &unittest_params;
5595 const uint8_t *plaintext = NULL;
5596 const uint8_t *ciphertext = NULL;
5597 const uint8_t *digest = NULL;
5598 unsigned int plaintext_pad_len;
5599 unsigned int plaintext_len;
5600 unsigned int ciphertext_pad_len;
5601 unsigned int ciphertext_len;
5602 uint8_t buffer[10000];
5603 uint8_t digest_buffer[10000];
5605 struct rte_cryptodev_info dev_info;
5606 struct rte_cryptodev_sym_capability_idx cap_idx;
5608 /* Check if device supports ZUC EIA3 */
5609 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5610 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5612 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5616 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5618 uint64_t feat_flags = dev_info.feature_flags;
5620 if (op_mode == IN_PLACE) {
5621 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5622 printf("Device doesn't support in-place scatter-gather "
5623 "in both input and output mbufs.\n");
5627 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5628 printf("Device doesn't support out-of-place scatter-gather "
5629 "in both input and output mbufs.\n");
5632 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5633 printf("Device doesn't support digest encrypted.\n");
5638 /* Create ZUC session */
5639 retval = create_wireless_algo_auth_cipher_session(
5640 ts_params->valid_devs[0],
5641 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5642 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5643 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5644 : RTE_CRYPTO_AUTH_OP_GENERATE),
5645 RTE_CRYPTO_AUTH_ZUC_EIA3,
5646 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5647 tdata->key.data, tdata->key.len,
5648 tdata->auth_iv.len, tdata->digest.len,
5649 tdata->cipher_iv.len);
5654 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5655 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5656 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5657 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5659 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5660 plaintext_pad_len, 15, 0);
5661 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5662 "Failed to allocate input buffer in mempool");
5664 if (op_mode == OUT_OF_PLACE) {
5665 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5666 plaintext_pad_len, 15, 0);
5667 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5668 "Failed to allocate output buffer in mempool");
5672 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5673 tdata->ciphertext.data);
5674 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5675 ciphertext_len, buffer);
5676 debug_hexdump(stdout, "ciphertext:", ciphertext,
5679 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5680 tdata->plaintext.data);
5681 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5682 plaintext_len, buffer);
5683 debug_hexdump(stdout, "plaintext:", plaintext,
5686 memset(buffer, 0, sizeof(buffer));
5688 /* Create ZUC operation */
5689 retval = create_wireless_algo_auth_cipher_operation(
5691 tdata->cipher_iv.data, tdata->cipher_iv.len,
5693 (tdata->digest.offset_bytes == 0 ?
5694 (verify ? ciphertext_pad_len : plaintext_pad_len)
5695 : tdata->digest.offset_bytes),
5696 tdata->validCipherLenInBits.len,
5697 tdata->validCipherOffsetInBits.len,
5698 tdata->validAuthLenInBits.len,
5705 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5708 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5710 ut_params->obuf = (op_mode == IN_PLACE ?
5711 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5714 if (ut_params->obuf)
5715 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5716 plaintext_len, buffer);
5718 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5719 plaintext_len, buffer);
5721 debug_hexdump(stdout, "plaintext:", plaintext,
5722 (tdata->plaintext.len >> 3) - tdata->digest.len);
5723 debug_hexdump(stdout, "plaintext expected:",
5724 tdata->plaintext.data,
5725 (tdata->plaintext.len >> 3) - tdata->digest.len);
5727 if (ut_params->obuf)
5728 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5729 ciphertext_len, buffer);
5731 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5732 ciphertext_len, buffer);
5734 debug_hexdump(stdout, "ciphertext:", ciphertext,
5736 debug_hexdump(stdout, "ciphertext expected:",
5737 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5739 if (ut_params->obuf)
5740 digest = rte_pktmbuf_read(ut_params->obuf,
5741 (tdata->digest.offset_bytes == 0 ?
5742 plaintext_pad_len : tdata->digest.offset_bytes),
5743 tdata->digest.len, digest_buffer);
5745 digest = rte_pktmbuf_read(ut_params->ibuf,
5746 (tdata->digest.offset_bytes == 0 ?
5747 plaintext_pad_len : tdata->digest.offset_bytes),
5748 tdata->digest.len, digest_buffer);
5750 debug_hexdump(stdout, "digest:", digest,
5752 debug_hexdump(stdout, "digest expected:",
5753 tdata->digest.data, tdata->digest.len);
5758 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5760 tdata->plaintext.data,
5761 tdata->plaintext.len >> 3,
5762 "ZUC Plaintext data not as expected");
5764 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5766 tdata->ciphertext.data,
5767 tdata->validDataLenInBits.len,
5768 "ZUC Ciphertext data not as expected");
5770 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5773 DIGEST_BYTE_LENGTH_KASUMI_F9,
5774 "ZUC Generated auth tag not as expected");
5780 test_kasumi_encryption_test_case_1(void)
5782 return test_kasumi_encryption(&kasumi_test_case_1);
5786 test_kasumi_encryption_test_case_1_sgl(void)
5788 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5792 test_kasumi_encryption_test_case_1_oop(void)
5794 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5798 test_kasumi_encryption_test_case_1_oop_sgl(void)
5800 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5804 test_kasumi_encryption_test_case_2(void)
5806 return test_kasumi_encryption(&kasumi_test_case_2);
5810 test_kasumi_encryption_test_case_3(void)
5812 return test_kasumi_encryption(&kasumi_test_case_3);
5816 test_kasumi_encryption_test_case_4(void)
5818 return test_kasumi_encryption(&kasumi_test_case_4);
5822 test_kasumi_encryption_test_case_5(void)
5824 return test_kasumi_encryption(&kasumi_test_case_5);
5828 test_kasumi_decryption_test_case_1(void)
5830 return test_kasumi_decryption(&kasumi_test_case_1);
5834 test_kasumi_decryption_test_case_1_oop(void)
5836 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5840 test_kasumi_decryption_test_case_2(void)
5842 return test_kasumi_decryption(&kasumi_test_case_2);
5846 test_kasumi_decryption_test_case_3(void)
5848 return test_kasumi_decryption(&kasumi_test_case_3);
5852 test_kasumi_decryption_test_case_4(void)
5854 return test_kasumi_decryption(&kasumi_test_case_4);
5858 test_kasumi_decryption_test_case_5(void)
5860 return test_kasumi_decryption(&kasumi_test_case_5);
5863 test_snow3g_encryption_test_case_1(void)
5865 return test_snow3g_encryption(&snow3g_test_case_1);
5869 test_snow3g_encryption_test_case_1_oop(void)
5871 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5875 test_snow3g_encryption_test_case_1_oop_sgl(void)
5877 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5882 test_snow3g_encryption_test_case_1_offset_oop(void)
5884 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5888 test_snow3g_encryption_test_case_2(void)
5890 return test_snow3g_encryption(&snow3g_test_case_2);
5894 test_snow3g_encryption_test_case_3(void)
5896 return test_snow3g_encryption(&snow3g_test_case_3);
5900 test_snow3g_encryption_test_case_4(void)
5902 return test_snow3g_encryption(&snow3g_test_case_4);
5906 test_snow3g_encryption_test_case_5(void)
5908 return test_snow3g_encryption(&snow3g_test_case_5);
5912 test_snow3g_decryption_test_case_1(void)
5914 return test_snow3g_decryption(&snow3g_test_case_1);
5918 test_snow3g_decryption_test_case_1_oop(void)
5920 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5924 test_snow3g_decryption_test_case_2(void)
5926 return test_snow3g_decryption(&snow3g_test_case_2);
5930 test_snow3g_decryption_test_case_3(void)
5932 return test_snow3g_decryption(&snow3g_test_case_3);
5936 test_snow3g_decryption_test_case_4(void)
5938 return test_snow3g_decryption(&snow3g_test_case_4);
5942 test_snow3g_decryption_test_case_5(void)
5944 return test_snow3g_decryption(&snow3g_test_case_5);
5948 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5949 * Pattern digest from snow3g_test_data must be allocated as
5950 * 4 last bytes in plaintext.
5953 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5954 struct snow3g_hash_test_data *output)
5956 if ((pattern != NULL) && (output != NULL)) {
5957 output->key.len = pattern->key.len;
5959 memcpy(output->key.data,
5960 pattern->key.data, pattern->key.len);
5962 output->auth_iv.len = pattern->auth_iv.len;
5964 memcpy(output->auth_iv.data,
5965 pattern->auth_iv.data, pattern->auth_iv.len);
5967 output->plaintext.len = pattern->plaintext.len;
5969 memcpy(output->plaintext.data,
5970 pattern->plaintext.data, pattern->plaintext.len >> 3);
5972 output->digest.len = pattern->digest.len;
5974 memcpy(output->digest.data,
5975 &pattern->plaintext.data[pattern->digest.offset_bytes],
5976 pattern->digest.len);
5978 output->validAuthLenInBits.len =
5979 pattern->validAuthLenInBits.len;
5984 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5987 test_snow3g_decryption_with_digest_test_case_1(void)
5989 struct snow3g_hash_test_data snow3g_hash_data;
5992 * Function prepare data for hash veryfication test case.
5993 * Digest is allocated in 4 last bytes in plaintext, pattern.
5995 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5997 return test_snow3g_decryption(&snow3g_test_case_7) &
5998 test_snow3g_authentication_verify(&snow3g_hash_data);
6002 test_snow3g_cipher_auth_test_case_1(void)
6004 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6008 test_snow3g_auth_cipher_test_case_1(void)
6010 return test_snow3g_auth_cipher(
6011 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6015 test_snow3g_auth_cipher_test_case_2(void)
6017 return test_snow3g_auth_cipher(
6018 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6022 test_snow3g_auth_cipher_test_case_2_oop(void)
6024 return test_snow3g_auth_cipher(
6025 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6029 test_snow3g_auth_cipher_part_digest_enc(void)
6031 return test_snow3g_auth_cipher(
6032 &snow3g_auth_cipher_partial_digest_encryption,
6037 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6039 return test_snow3g_auth_cipher(
6040 &snow3g_auth_cipher_partial_digest_encryption,
6045 test_snow3g_auth_cipher_test_case_3_sgl(void)
6047 return test_snow3g_auth_cipher_sgl(
6048 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6052 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6054 return test_snow3g_auth_cipher_sgl(
6055 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6059 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6061 return test_snow3g_auth_cipher_sgl(
6062 &snow3g_auth_cipher_partial_digest_encryption,
6067 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6069 return test_snow3g_auth_cipher_sgl(
6070 &snow3g_auth_cipher_partial_digest_encryption,
6075 test_snow3g_auth_cipher_verify_test_case_1(void)
6077 return test_snow3g_auth_cipher(
6078 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6082 test_snow3g_auth_cipher_verify_test_case_2(void)
6084 return test_snow3g_auth_cipher(
6085 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6089 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6091 return test_snow3g_auth_cipher(
6092 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6096 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6098 return test_snow3g_auth_cipher(
6099 &snow3g_auth_cipher_partial_digest_encryption,
6104 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6106 return test_snow3g_auth_cipher(
6107 &snow3g_auth_cipher_partial_digest_encryption,
6112 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6114 return test_snow3g_auth_cipher_sgl(
6115 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6119 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6121 return test_snow3g_auth_cipher_sgl(
6122 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6126 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6128 return test_snow3g_auth_cipher_sgl(
6129 &snow3g_auth_cipher_partial_digest_encryption,
6134 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6136 return test_snow3g_auth_cipher_sgl(
6137 &snow3g_auth_cipher_partial_digest_encryption,
6142 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6144 return test_snow3g_auth_cipher(
6145 &snow3g_test_case_7, IN_PLACE, 0);
6149 test_kasumi_auth_cipher_test_case_1(void)
6151 return test_kasumi_auth_cipher(
6152 &kasumi_test_case_3, IN_PLACE, 0);
6156 test_kasumi_auth_cipher_test_case_2(void)
6158 return test_kasumi_auth_cipher(
6159 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6163 test_kasumi_auth_cipher_test_case_2_oop(void)
6165 return test_kasumi_auth_cipher(
6166 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6170 test_kasumi_auth_cipher_test_case_2_sgl(void)
6172 return test_kasumi_auth_cipher_sgl(
6173 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6177 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6179 return test_kasumi_auth_cipher_sgl(
6180 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6184 test_kasumi_auth_cipher_verify_test_case_1(void)
6186 return test_kasumi_auth_cipher(
6187 &kasumi_test_case_3, IN_PLACE, 1);
6191 test_kasumi_auth_cipher_verify_test_case_2(void)
6193 return test_kasumi_auth_cipher(
6194 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6198 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6200 return test_kasumi_auth_cipher(
6201 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6205 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6207 return test_kasumi_auth_cipher_sgl(
6208 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6212 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6214 return test_kasumi_auth_cipher_sgl(
6215 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6219 test_kasumi_cipher_auth_test_case_1(void)
6221 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6225 test_zuc_encryption_test_case_1(void)
6227 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6231 test_zuc_encryption_test_case_2(void)
6233 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6237 test_zuc_encryption_test_case_3(void)
6239 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6243 test_zuc_encryption_test_case_4(void)
6245 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6249 test_zuc_encryption_test_case_5(void)
6251 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6255 test_zuc_encryption_test_case_6_sgl(void)
6257 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6261 test_zuc_hash_generate_test_case_1(void)
6263 return test_zuc_authentication(&zuc_test_case_auth_1b);
6267 test_zuc_hash_generate_test_case_2(void)
6269 return test_zuc_authentication(&zuc_test_case_auth_90b);
6273 test_zuc_hash_generate_test_case_3(void)
6275 return test_zuc_authentication(&zuc_test_case_auth_577b);
6279 test_zuc_hash_generate_test_case_4(void)
6281 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6285 test_zuc_hash_generate_test_case_5(void)
6287 return test_zuc_authentication(&zuc_test_auth_5670b);
6291 test_zuc_hash_generate_test_case_6(void)
6293 return test_zuc_authentication(&zuc_test_case_auth_128b);
6297 test_zuc_hash_generate_test_case_7(void)
6299 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6303 test_zuc_hash_generate_test_case_8(void)
6305 return test_zuc_authentication(&zuc_test_case_auth_584b);
6309 test_zuc_cipher_auth_test_case_1(void)
6311 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6315 test_zuc_cipher_auth_test_case_2(void)
6317 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6321 test_zuc_auth_cipher_test_case_1(void)
6323 return test_zuc_auth_cipher(
6324 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6328 test_zuc_auth_cipher_test_case_1_oop(void)
6330 return test_zuc_auth_cipher(
6331 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6335 test_zuc_auth_cipher_test_case_1_sgl(void)
6337 return test_zuc_auth_cipher_sgl(
6338 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6342 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6344 return test_zuc_auth_cipher_sgl(
6345 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6349 test_zuc_auth_cipher_verify_test_case_1(void)
6351 return test_zuc_auth_cipher(
6352 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6356 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6358 return test_zuc_auth_cipher(
6359 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6363 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6365 return test_zuc_auth_cipher_sgl(
6366 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6370 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6372 return test_zuc_auth_cipher_sgl(
6373 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6377 test_3DES_chain_qat_all(void)
6379 struct crypto_testsuite_params *ts_params = &testsuite_params;
6382 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6383 ts_params->op_mpool,
6384 ts_params->session_mpool, ts_params->session_priv_mpool,
6385 ts_params->valid_devs[0],
6386 rte_cryptodev_driver_id_get(
6387 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6388 BLKCIPHER_3DES_CHAIN_TYPE);
6390 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6392 return TEST_SUCCESS;
6396 test_DES_cipheronly_qat_all(void)
6398 struct crypto_testsuite_params *ts_params = &testsuite_params;
6401 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6402 ts_params->op_mpool,
6403 ts_params->session_mpool, ts_params->session_priv_mpool,
6404 ts_params->valid_devs[0],
6405 rte_cryptodev_driver_id_get(
6406 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6407 BLKCIPHER_DES_CIPHERONLY_TYPE);
6409 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6411 return TEST_SUCCESS;
6415 test_DES_cipheronly_openssl_all(void)
6417 struct crypto_testsuite_params *ts_params = &testsuite_params;
6420 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6421 ts_params->op_mpool,
6422 ts_params->session_mpool, ts_params->session_priv_mpool,
6423 ts_params->valid_devs[0],
6424 rte_cryptodev_driver_id_get(
6425 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6426 BLKCIPHER_DES_CIPHERONLY_TYPE);
6428 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6430 return TEST_SUCCESS;
6434 test_DES_docsis_openssl_all(void)
6436 struct crypto_testsuite_params *ts_params = &testsuite_params;
6439 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6440 ts_params->op_mpool,
6441 ts_params->session_mpool, ts_params->session_priv_mpool,
6442 ts_params->valid_devs[0],
6443 rte_cryptodev_driver_id_get(
6444 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6445 BLKCIPHER_DES_DOCSIS_TYPE);
6447 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6449 return TEST_SUCCESS;
6453 test_DES_cipheronly_mb_all(void)
6455 struct crypto_testsuite_params *ts_params = &testsuite_params;
6458 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6459 ts_params->op_mpool,
6460 ts_params->session_mpool, ts_params->session_priv_mpool,
6461 ts_params->valid_devs[0],
6462 rte_cryptodev_driver_id_get(
6463 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6464 BLKCIPHER_DES_CIPHERONLY_TYPE);
6466 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6468 return TEST_SUCCESS;
6471 test_3DES_cipheronly_mb_all(void)
6473 struct crypto_testsuite_params *ts_params = &testsuite_params;
6476 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6477 ts_params->op_mpool,
6478 ts_params->session_mpool, ts_params->session_priv_mpool,
6479 ts_params->valid_devs[0],
6480 rte_cryptodev_driver_id_get(
6481 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6482 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6484 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6486 return TEST_SUCCESS;
6490 test_DES_docsis_mb_all(void)
6492 struct crypto_testsuite_params *ts_params = &testsuite_params;
6495 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6496 ts_params->op_mpool,
6497 ts_params->session_mpool, ts_params->session_priv_mpool,
6498 ts_params->valid_devs[0],
6499 rte_cryptodev_driver_id_get(
6500 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6501 BLKCIPHER_DES_DOCSIS_TYPE);
6503 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6505 return TEST_SUCCESS;
6509 test_3DES_chain_caam_jr_all(void)
6511 struct crypto_testsuite_params *ts_params = &testsuite_params;
6514 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6515 ts_params->op_mpool,
6516 ts_params->session_mpool, ts_params->session_priv_mpool,
6517 ts_params->valid_devs[0],
6518 rte_cryptodev_driver_id_get(
6519 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6520 BLKCIPHER_3DES_CHAIN_TYPE);
6522 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6524 return TEST_SUCCESS;
6528 test_3DES_cipheronly_caam_jr_all(void)
6530 struct crypto_testsuite_params *ts_params = &testsuite_params;
6533 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6534 ts_params->op_mpool,
6535 ts_params->session_mpool, ts_params->session_priv_mpool,
6536 ts_params->valid_devs[0],
6537 rte_cryptodev_driver_id_get(
6538 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6539 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6541 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6543 return TEST_SUCCESS;
6547 test_3DES_chain_dpaa_sec_all(void)
6549 struct crypto_testsuite_params *ts_params = &testsuite_params;
6552 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6553 ts_params->op_mpool,
6554 ts_params->session_mpool, ts_params->session_priv_mpool,
6555 ts_params->valid_devs[0],
6556 rte_cryptodev_driver_id_get(
6557 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
6558 BLKCIPHER_3DES_CHAIN_TYPE);
6560 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6562 return TEST_SUCCESS;
6566 test_3DES_cipheronly_dpaa_sec_all(void)
6568 struct crypto_testsuite_params *ts_params = &testsuite_params;
6571 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6572 ts_params->op_mpool,
6573 ts_params->session_mpool, ts_params->session_priv_mpool,
6574 ts_params->valid_devs[0],
6575 rte_cryptodev_driver_id_get(
6576 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
6577 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6579 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6581 return TEST_SUCCESS;
6585 test_3DES_chain_dpaa2_sec_all(void)
6587 struct crypto_testsuite_params *ts_params = &testsuite_params;
6590 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6591 ts_params->op_mpool,
6592 ts_params->session_mpool, ts_params->session_priv_mpool,
6593 ts_params->valid_devs[0],
6594 rte_cryptodev_driver_id_get(
6595 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
6596 BLKCIPHER_3DES_CHAIN_TYPE);
6598 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6600 return TEST_SUCCESS;
6604 test_3DES_cipheronly_dpaa2_sec_all(void)
6606 struct crypto_testsuite_params *ts_params = &testsuite_params;
6609 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6610 ts_params->op_mpool,
6611 ts_params->session_mpool, ts_params->session_priv_mpool,
6612 ts_params->valid_devs[0],
6613 rte_cryptodev_driver_id_get(
6614 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
6615 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6617 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6619 return TEST_SUCCESS;
6623 test_3DES_chain_ccp_all(void)
6625 struct crypto_testsuite_params *ts_params = &testsuite_params;
6628 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6629 ts_params->op_mpool,
6630 ts_params->session_mpool, ts_params->session_priv_mpool,
6631 ts_params->valid_devs[0],
6632 rte_cryptodev_driver_id_get(
6633 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
6634 BLKCIPHER_3DES_CHAIN_TYPE);
6636 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6638 return TEST_SUCCESS;
6642 test_3DES_cipheronly_ccp_all(void)
6644 struct crypto_testsuite_params *ts_params = &testsuite_params;
6647 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6648 ts_params->op_mpool,
6649 ts_params->session_mpool, ts_params->session_priv_mpool,
6650 ts_params->valid_devs[0],
6651 rte_cryptodev_driver_id_get(
6652 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
6653 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6655 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6657 return TEST_SUCCESS;
6661 test_3DES_cipheronly_qat_all(void)
6663 struct crypto_testsuite_params *ts_params = &testsuite_params;
6666 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6667 ts_params->op_mpool,
6668 ts_params->session_mpool, ts_params->session_priv_mpool,
6669 ts_params->valid_devs[0],
6670 rte_cryptodev_driver_id_get(
6671 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6672 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6674 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6676 return TEST_SUCCESS;
6680 test_3DES_chain_openssl_all(void)
6682 struct crypto_testsuite_params *ts_params = &testsuite_params;
6685 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6686 ts_params->op_mpool,
6687 ts_params->session_mpool, ts_params->session_priv_mpool,
6688 ts_params->valid_devs[0],
6689 rte_cryptodev_driver_id_get(
6690 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6691 BLKCIPHER_3DES_CHAIN_TYPE);
6693 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6695 return TEST_SUCCESS;
6699 test_3DES_cipheronly_openssl_all(void)
6701 struct crypto_testsuite_params *ts_params = &testsuite_params;
6704 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6705 ts_params->op_mpool,
6706 ts_params->session_mpool, ts_params->session_priv_mpool,
6707 ts_params->valid_devs[0],
6708 rte_cryptodev_driver_id_get(
6709 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6710 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6712 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6714 return TEST_SUCCESS;
6717 /* ***** AEAD algorithm Tests ***** */
6720 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6721 enum rte_crypto_aead_operation op,
6722 const uint8_t *key, const uint8_t key_len,
6723 const uint16_t aad_len, const uint8_t auth_len,
6726 uint8_t aead_key[key_len];
6728 struct crypto_testsuite_params *ts_params = &testsuite_params;
6729 struct crypto_unittest_params *ut_params = &unittest_params;
6731 memcpy(aead_key, key, key_len);
6733 /* Setup AEAD Parameters */
6734 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6735 ut_params->aead_xform.next = NULL;
6736 ut_params->aead_xform.aead.algo = algo;
6737 ut_params->aead_xform.aead.op = op;
6738 ut_params->aead_xform.aead.key.data = aead_key;
6739 ut_params->aead_xform.aead.key.length = key_len;
6740 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6741 ut_params->aead_xform.aead.iv.length = iv_len;
6742 ut_params->aead_xform.aead.digest_length = auth_len;
6743 ut_params->aead_xform.aead.aad_length = aad_len;
6745 debug_hexdump(stdout, "key:", key, key_len);
6747 /* Create Crypto session*/
6748 ut_params->sess = rte_cryptodev_sym_session_create(
6749 ts_params->session_mpool);
6751 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6752 &ut_params->aead_xform,
6753 ts_params->session_priv_mpool);
6755 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6761 create_aead_xform(struct rte_crypto_op *op,
6762 enum rte_crypto_aead_algorithm algo,
6763 enum rte_crypto_aead_operation aead_op,
6764 uint8_t *key, const uint8_t key_len,
6765 const uint8_t aad_len, const uint8_t auth_len,
6768 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6769 "failed to allocate space for crypto transform");
6771 struct rte_crypto_sym_op *sym_op = op->sym;
6773 /* Setup AEAD Parameters */
6774 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6775 sym_op->xform->next = NULL;
6776 sym_op->xform->aead.algo = algo;
6777 sym_op->xform->aead.op = aead_op;
6778 sym_op->xform->aead.key.data = key;
6779 sym_op->xform->aead.key.length = key_len;
6780 sym_op->xform->aead.iv.offset = IV_OFFSET;
6781 sym_op->xform->aead.iv.length = iv_len;
6782 sym_op->xform->aead.digest_length = auth_len;
6783 sym_op->xform->aead.aad_length = aad_len;
6785 debug_hexdump(stdout, "key:", key, key_len);
6791 create_aead_operation(enum rte_crypto_aead_operation op,
6792 const struct aead_test_data *tdata)
6794 struct crypto_testsuite_params *ts_params = &testsuite_params;
6795 struct crypto_unittest_params *ut_params = &unittest_params;
6797 uint8_t *plaintext, *ciphertext;
6798 unsigned int aad_pad_len, plaintext_pad_len;
6800 /* Generate Crypto op data structure */
6801 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6802 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6803 TEST_ASSERT_NOT_NULL(ut_params->op,
6804 "Failed to allocate symmetric crypto operation struct");
6806 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6808 /* Append aad data */
6809 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6810 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6811 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6813 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6814 "no room to append aad");
6816 sym_op->aead.aad.phys_addr =
6817 rte_pktmbuf_iova(ut_params->ibuf);
6818 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6819 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6820 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6823 /* Append IV at the end of the crypto operation*/
6824 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6825 uint8_t *, IV_OFFSET);
6827 /* Copy IV 1 byte after the IV pointer, according to the API */
6828 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6829 debug_hexdump(stdout, "iv:", iv_ptr,
6832 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6833 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6835 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6836 "no room to append aad");
6838 sym_op->aead.aad.phys_addr =
6839 rte_pktmbuf_iova(ut_params->ibuf);
6840 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6841 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6844 /* Append IV at the end of the crypto operation*/
6845 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6846 uint8_t *, IV_OFFSET);
6848 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6849 debug_hexdump(stdout, "iv:", iv_ptr,
6853 /* Append plaintext/ciphertext */
6854 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6855 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6856 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6858 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6860 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6861 debug_hexdump(stdout, "plaintext:", plaintext,
6862 tdata->plaintext.len);
6864 if (ut_params->obuf) {
6865 ciphertext = (uint8_t *)rte_pktmbuf_append(
6867 plaintext_pad_len + aad_pad_len);
6868 TEST_ASSERT_NOT_NULL(ciphertext,
6869 "no room to append ciphertext");
6871 memset(ciphertext + aad_pad_len, 0,
6872 tdata->ciphertext.len);
6875 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6876 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6878 TEST_ASSERT_NOT_NULL(ciphertext,
6879 "no room to append ciphertext");
6881 memcpy(ciphertext, tdata->ciphertext.data,
6882 tdata->ciphertext.len);
6883 debug_hexdump(stdout, "ciphertext:", ciphertext,
6884 tdata->ciphertext.len);
6886 if (ut_params->obuf) {
6887 plaintext = (uint8_t *)rte_pktmbuf_append(
6889 plaintext_pad_len + aad_pad_len);
6890 TEST_ASSERT_NOT_NULL(plaintext,
6891 "no room to append plaintext");
6893 memset(plaintext + aad_pad_len, 0,
6894 tdata->plaintext.len);
6898 /* Append digest data */
6899 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6900 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6901 ut_params->obuf ? ut_params->obuf :
6903 tdata->auth_tag.len);
6904 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6905 "no room to append digest");
6906 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6907 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6908 ut_params->obuf ? ut_params->obuf :
6913 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6914 ut_params->ibuf, tdata->auth_tag.len);
6915 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6916 "no room to append digest");
6917 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6919 plaintext_pad_len + aad_pad_len);
6921 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6922 tdata->auth_tag.len);
6923 debug_hexdump(stdout, "digest:",
6924 sym_op->aead.digest.data,
6925 tdata->auth_tag.len);
6928 sym_op->aead.data.length = tdata->plaintext.len;
6929 sym_op->aead.data.offset = aad_pad_len;
6935 test_authenticated_encryption(const struct aead_test_data *tdata)
6937 struct crypto_testsuite_params *ts_params = &testsuite_params;
6938 struct crypto_unittest_params *ut_params = &unittest_params;
6941 uint8_t *ciphertext, *auth_tag;
6942 uint16_t plaintext_pad_len;
6945 /* Create AEAD session */
6946 retval = create_aead_session(ts_params->valid_devs[0],
6948 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6949 tdata->key.data, tdata->key.len,
6950 tdata->aad.len, tdata->auth_tag.len,
6955 if (tdata->aad.len > MBUF_SIZE) {
6956 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6957 /* Populate full size of add data */
6958 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6959 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6961 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6963 /* clear mbuf payload */
6964 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6965 rte_pktmbuf_tailroom(ut_params->ibuf));
6967 /* Create AEAD operation */
6968 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6972 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6974 ut_params->op->sym->m_src = ut_params->ibuf;
6976 /* Process crypto operation */
6977 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6978 ut_params->op), "failed to process sym crypto op");
6980 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6981 "crypto op processing failed");
6983 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6985 if (ut_params->op->sym->m_dst) {
6986 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6988 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6989 uint8_t *, plaintext_pad_len);
6991 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6993 ut_params->op->sym->cipher.data.offset);
6994 auth_tag = ciphertext + plaintext_pad_len;
6997 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6998 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7001 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7003 tdata->ciphertext.data,
7004 tdata->ciphertext.len,
7005 "Ciphertext data not as expected");
7007 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7009 tdata->auth_tag.data,
7010 tdata->auth_tag.len,
7011 "Generated auth tag not as expected");
7018 test_AES_GCM_authenticated_encryption_test_case_1(void)
7020 return test_authenticated_encryption(&gcm_test_case_1);
7024 test_AES_GCM_authenticated_encryption_test_case_2(void)
7026 return test_authenticated_encryption(&gcm_test_case_2);
7030 test_AES_GCM_authenticated_encryption_test_case_3(void)
7032 return test_authenticated_encryption(&gcm_test_case_3);
7036 test_AES_GCM_authenticated_encryption_test_case_4(void)
7038 return test_authenticated_encryption(&gcm_test_case_4);
7042 test_AES_GCM_authenticated_encryption_test_case_5(void)
7044 return test_authenticated_encryption(&gcm_test_case_5);
7048 test_AES_GCM_authenticated_encryption_test_case_6(void)
7050 return test_authenticated_encryption(&gcm_test_case_6);
7054 test_AES_GCM_authenticated_encryption_test_case_7(void)
7056 return test_authenticated_encryption(&gcm_test_case_7);
7060 test_AES_GCM_auth_encryption_test_case_192_1(void)
7062 return test_authenticated_encryption(&gcm_test_case_192_1);
7066 test_AES_GCM_auth_encryption_test_case_192_2(void)
7068 return test_authenticated_encryption(&gcm_test_case_192_2);
7072 test_AES_GCM_auth_encryption_test_case_192_3(void)
7074 return test_authenticated_encryption(&gcm_test_case_192_3);
7078 test_AES_GCM_auth_encryption_test_case_192_4(void)
7080 return test_authenticated_encryption(&gcm_test_case_192_4);
7084 test_AES_GCM_auth_encryption_test_case_192_5(void)
7086 return test_authenticated_encryption(&gcm_test_case_192_5);
7090 test_AES_GCM_auth_encryption_test_case_192_6(void)
7092 return test_authenticated_encryption(&gcm_test_case_192_6);
7096 test_AES_GCM_auth_encryption_test_case_192_7(void)
7098 return test_authenticated_encryption(&gcm_test_case_192_7);
7102 test_AES_GCM_auth_encryption_test_case_256_1(void)
7104 return test_authenticated_encryption(&gcm_test_case_256_1);
7108 test_AES_GCM_auth_encryption_test_case_256_2(void)
7110 return test_authenticated_encryption(&gcm_test_case_256_2);
7114 test_AES_GCM_auth_encryption_test_case_256_3(void)
7116 return test_authenticated_encryption(&gcm_test_case_256_3);
7120 test_AES_GCM_auth_encryption_test_case_256_4(void)
7122 return test_authenticated_encryption(&gcm_test_case_256_4);
7126 test_AES_GCM_auth_encryption_test_case_256_5(void)
7128 return test_authenticated_encryption(&gcm_test_case_256_5);
7132 test_AES_GCM_auth_encryption_test_case_256_6(void)
7134 return test_authenticated_encryption(&gcm_test_case_256_6);
7138 test_AES_GCM_auth_encryption_test_case_256_7(void)
7140 return test_authenticated_encryption(&gcm_test_case_256_7);
7144 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7146 return test_authenticated_encryption(&gcm_test_case_aad_1);
7150 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7152 return test_authenticated_encryption(&gcm_test_case_aad_2);
7156 test_authenticated_decryption(const struct aead_test_data *tdata)
7158 struct crypto_testsuite_params *ts_params = &testsuite_params;
7159 struct crypto_unittest_params *ut_params = &unittest_params;
7165 /* Create AEAD session */
7166 retval = create_aead_session(ts_params->valid_devs[0],
7168 RTE_CRYPTO_AEAD_OP_DECRYPT,
7169 tdata->key.data, tdata->key.len,
7170 tdata->aad.len, tdata->auth_tag.len,
7175 /* alloc mbuf and set payload */
7176 if (tdata->aad.len > MBUF_SIZE) {
7177 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7178 /* Populate full size of add data */
7179 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7180 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7184 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7185 rte_pktmbuf_tailroom(ut_params->ibuf));
7187 /* Create AEAD operation */
7188 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7192 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7194 ut_params->op->sym->m_src = ut_params->ibuf;
7196 /* Process crypto operation */
7197 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7198 ut_params->op), "failed to process sym crypto op");
7200 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7201 "crypto op processing failed");
7203 if (ut_params->op->sym->m_dst)
7204 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7207 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7209 ut_params->op->sym->cipher.data.offset);
7211 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7214 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7216 tdata->plaintext.data,
7217 tdata->plaintext.len,
7218 "Plaintext data not as expected");
7220 TEST_ASSERT_EQUAL(ut_params->op->status,
7221 RTE_CRYPTO_OP_STATUS_SUCCESS,
7222 "Authentication failed");
7227 test_AES_GCM_authenticated_decryption_test_case_1(void)
7229 return test_authenticated_decryption(&gcm_test_case_1);
7233 test_AES_GCM_authenticated_decryption_test_case_2(void)
7235 return test_authenticated_decryption(&gcm_test_case_2);
7239 test_AES_GCM_authenticated_decryption_test_case_3(void)
7241 return test_authenticated_decryption(&gcm_test_case_3);
7245 test_AES_GCM_authenticated_decryption_test_case_4(void)
7247 return test_authenticated_decryption(&gcm_test_case_4);
7251 test_AES_GCM_authenticated_decryption_test_case_5(void)
7253 return test_authenticated_decryption(&gcm_test_case_5);
7257 test_AES_GCM_authenticated_decryption_test_case_6(void)
7259 return test_authenticated_decryption(&gcm_test_case_6);
7263 test_AES_GCM_authenticated_decryption_test_case_7(void)
7265 return test_authenticated_decryption(&gcm_test_case_7);
7269 test_AES_GCM_auth_decryption_test_case_192_1(void)
7271 return test_authenticated_decryption(&gcm_test_case_192_1);
7275 test_AES_GCM_auth_decryption_test_case_192_2(void)
7277 return test_authenticated_decryption(&gcm_test_case_192_2);
7281 test_AES_GCM_auth_decryption_test_case_192_3(void)
7283 return test_authenticated_decryption(&gcm_test_case_192_3);
7287 test_AES_GCM_auth_decryption_test_case_192_4(void)
7289 return test_authenticated_decryption(&gcm_test_case_192_4);
7293 test_AES_GCM_auth_decryption_test_case_192_5(void)
7295 return test_authenticated_decryption(&gcm_test_case_192_5);
7299 test_AES_GCM_auth_decryption_test_case_192_6(void)
7301 return test_authenticated_decryption(&gcm_test_case_192_6);
7305 test_AES_GCM_auth_decryption_test_case_192_7(void)
7307 return test_authenticated_decryption(&gcm_test_case_192_7);
7311 test_AES_GCM_auth_decryption_test_case_256_1(void)
7313 return test_authenticated_decryption(&gcm_test_case_256_1);
7317 test_AES_GCM_auth_decryption_test_case_256_2(void)
7319 return test_authenticated_decryption(&gcm_test_case_256_2);
7323 test_AES_GCM_auth_decryption_test_case_256_3(void)
7325 return test_authenticated_decryption(&gcm_test_case_256_3);
7329 test_AES_GCM_auth_decryption_test_case_256_4(void)
7331 return test_authenticated_decryption(&gcm_test_case_256_4);
7335 test_AES_GCM_auth_decryption_test_case_256_5(void)
7337 return test_authenticated_decryption(&gcm_test_case_256_5);
7341 test_AES_GCM_auth_decryption_test_case_256_6(void)
7343 return test_authenticated_decryption(&gcm_test_case_256_6);
7347 test_AES_GCM_auth_decryption_test_case_256_7(void)
7349 return test_authenticated_decryption(&gcm_test_case_256_7);
7353 test_AES_GCM_auth_decryption_test_case_aad_1(void)
7355 return test_authenticated_decryption(&gcm_test_case_aad_1);
7359 test_AES_GCM_auth_decryption_test_case_aad_2(void)
7361 return test_authenticated_decryption(&gcm_test_case_aad_2);
7365 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
7367 struct crypto_testsuite_params *ts_params = &testsuite_params;
7368 struct crypto_unittest_params *ut_params = &unittest_params;
7371 uint8_t *ciphertext, *auth_tag;
7372 uint16_t plaintext_pad_len;
7374 /* Create AEAD session */
7375 retval = create_aead_session(ts_params->valid_devs[0],
7377 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7378 tdata->key.data, tdata->key.len,
7379 tdata->aad.len, tdata->auth_tag.len,
7384 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7385 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7387 /* clear mbuf payload */
7388 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7389 rte_pktmbuf_tailroom(ut_params->ibuf));
7390 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7391 rte_pktmbuf_tailroom(ut_params->obuf));
7393 /* Create AEAD operation */
7394 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7398 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7400 ut_params->op->sym->m_src = ut_params->ibuf;
7401 ut_params->op->sym->m_dst = ut_params->obuf;
7403 /* Process crypto operation */
7404 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7405 ut_params->op), "failed to process sym crypto op");
7407 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7408 "crypto op processing failed");
7410 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7412 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
7413 ut_params->op->sym->cipher.data.offset);
7414 auth_tag = ciphertext + plaintext_pad_len;
7416 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7417 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7420 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7422 tdata->ciphertext.data,
7423 tdata->ciphertext.len,
7424 "Ciphertext data not as expected");
7426 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7428 tdata->auth_tag.data,
7429 tdata->auth_tag.len,
7430 "Generated auth tag not as expected");
7437 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
7439 return test_authenticated_encryption_oop(&gcm_test_case_5);
7443 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
7445 struct crypto_testsuite_params *ts_params = &testsuite_params;
7446 struct crypto_unittest_params *ut_params = &unittest_params;
7451 /* Create AEAD session */
7452 retval = create_aead_session(ts_params->valid_devs[0],
7454 RTE_CRYPTO_AEAD_OP_DECRYPT,
7455 tdata->key.data, tdata->key.len,
7456 tdata->aad.len, tdata->auth_tag.len,
7461 /* alloc mbuf and set payload */
7462 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7463 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7465 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7466 rte_pktmbuf_tailroom(ut_params->ibuf));
7467 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7468 rte_pktmbuf_tailroom(ut_params->obuf));
7470 /* Create AEAD operation */
7471 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7475 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7477 ut_params->op->sym->m_src = ut_params->ibuf;
7478 ut_params->op->sym->m_dst = ut_params->obuf;
7480 /* Process crypto operation */
7481 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7482 ut_params->op), "failed to process sym crypto op");
7484 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7485 "crypto op processing failed");
7487 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
7488 ut_params->op->sym->cipher.data.offset);
7490 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7493 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7495 tdata->plaintext.data,
7496 tdata->plaintext.len,
7497 "Plaintext data not as expected");
7499 TEST_ASSERT_EQUAL(ut_params->op->status,
7500 RTE_CRYPTO_OP_STATUS_SUCCESS,
7501 "Authentication failed");
7506 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
7508 return test_authenticated_decryption_oop(&gcm_test_case_5);
7512 test_authenticated_encryption_sessionless(
7513 const struct aead_test_data *tdata)
7515 struct crypto_testsuite_params *ts_params = &testsuite_params;
7516 struct crypto_unittest_params *ut_params = &unittest_params;
7519 uint8_t *ciphertext, *auth_tag;
7520 uint16_t plaintext_pad_len;
7521 uint8_t key[tdata->key.len + 1];
7523 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7525 /* clear mbuf payload */
7526 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7527 rte_pktmbuf_tailroom(ut_params->ibuf));
7529 /* Create AEAD operation */
7530 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7534 /* Create GCM xform */
7535 memcpy(key, tdata->key.data, tdata->key.len);
7536 retval = create_aead_xform(ut_params->op,
7538 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7539 key, tdata->key.len,
7540 tdata->aad.len, tdata->auth_tag.len,
7545 ut_params->op->sym->m_src = ut_params->ibuf;
7547 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
7548 RTE_CRYPTO_OP_SESSIONLESS,
7549 "crypto op session type not sessionless");
7551 /* Process crypto operation */
7552 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7553 ut_params->op), "failed to process sym crypto op");
7555 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7557 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7558 "crypto op status not success");
7560 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7562 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7563 ut_params->op->sym->cipher.data.offset);
7564 auth_tag = ciphertext + plaintext_pad_len;
7566 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7567 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7570 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7572 tdata->ciphertext.data,
7573 tdata->ciphertext.len,
7574 "Ciphertext data not as expected");
7576 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7578 tdata->auth_tag.data,
7579 tdata->auth_tag.len,
7580 "Generated auth tag not as expected");
7587 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
7589 return test_authenticated_encryption_sessionless(
7594 test_authenticated_decryption_sessionless(
7595 const struct aead_test_data *tdata)
7597 struct crypto_testsuite_params *ts_params = &testsuite_params;
7598 struct crypto_unittest_params *ut_params = &unittest_params;
7602 uint8_t key[tdata->key.len + 1];
7604 /* alloc mbuf and set payload */
7605 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7607 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7608 rte_pktmbuf_tailroom(ut_params->ibuf));
7610 /* Create AEAD operation */
7611 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7615 /* Create AEAD xform */
7616 memcpy(key, tdata->key.data, tdata->key.len);
7617 retval = create_aead_xform(ut_params->op,
7619 RTE_CRYPTO_AEAD_OP_DECRYPT,
7620 key, tdata->key.len,
7621 tdata->aad.len, tdata->auth_tag.len,
7626 ut_params->op->sym->m_src = ut_params->ibuf;
7628 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
7629 RTE_CRYPTO_OP_SESSIONLESS,
7630 "crypto op session type not sessionless");
7632 /* Process crypto operation */
7633 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7634 ut_params->op), "failed to process sym crypto op");
7636 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7638 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7639 "crypto op status not success");
7641 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7642 ut_params->op->sym->cipher.data.offset);
7644 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7647 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7649 tdata->plaintext.data,
7650 tdata->plaintext.len,
7651 "Plaintext data not as expected");
7653 TEST_ASSERT_EQUAL(ut_params->op->status,
7654 RTE_CRYPTO_OP_STATUS_SUCCESS,
7655 "Authentication failed");
7660 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
7662 return test_authenticated_decryption_sessionless(
7667 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
7669 return test_authenticated_encryption(&ccm_test_case_128_1);
7673 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
7675 return test_authenticated_encryption(&ccm_test_case_128_2);
7679 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
7681 return test_authenticated_encryption(&ccm_test_case_128_3);
7685 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
7687 return test_authenticated_decryption(&ccm_test_case_128_1);
7691 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
7693 return test_authenticated_decryption(&ccm_test_case_128_2);
7697 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
7699 return test_authenticated_decryption(&ccm_test_case_128_3);
7703 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
7705 return test_authenticated_encryption(&ccm_test_case_192_1);
7709 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
7711 return test_authenticated_encryption(&ccm_test_case_192_2);
7715 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
7717 return test_authenticated_encryption(&ccm_test_case_192_3);
7721 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
7723 return test_authenticated_decryption(&ccm_test_case_192_1);
7727 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
7729 return test_authenticated_decryption(&ccm_test_case_192_2);
7733 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
7735 return test_authenticated_decryption(&ccm_test_case_192_3);
7739 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
7741 return test_authenticated_encryption(&ccm_test_case_256_1);
7745 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
7747 return test_authenticated_encryption(&ccm_test_case_256_2);
7751 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
7753 return test_authenticated_encryption(&ccm_test_case_256_3);
7757 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
7759 return test_authenticated_decryption(&ccm_test_case_256_1);
7763 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
7765 return test_authenticated_decryption(&ccm_test_case_256_2);
7769 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
7771 return test_authenticated_decryption(&ccm_test_case_256_3);
7777 struct crypto_testsuite_params *ts_params = &testsuite_params;
7778 struct rte_cryptodev_stats stats;
7779 struct rte_cryptodev *dev;
7780 cryptodev_stats_get_t temp_pfn;
7782 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7783 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
7784 &stats) == -ENODEV),
7785 "rte_cryptodev_stats_get invalid dev failed");
7786 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
7787 "rte_cryptodev_stats_get invalid Param failed");
7788 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
7789 temp_pfn = dev->dev_ops->stats_get;
7790 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
7791 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
7793 "rte_cryptodev_stats_get invalid Param failed");
7794 dev->dev_ops->stats_get = temp_pfn;
7796 /* Test expected values */
7798 test_AES_CBC_HMAC_SHA1_encrypt_digest();
7800 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7802 "rte_cryptodev_stats_get failed");
7803 TEST_ASSERT((stats.enqueued_count == 1),
7804 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7805 TEST_ASSERT((stats.dequeued_count == 1),
7806 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7807 TEST_ASSERT((stats.enqueue_err_count == 0),
7808 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7809 TEST_ASSERT((stats.dequeue_err_count == 0),
7810 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7812 /* invalid device but should ignore and not reset device stats*/
7813 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
7814 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7816 "rte_cryptodev_stats_get failed");
7817 TEST_ASSERT((stats.enqueued_count == 1),
7818 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7820 /* check that a valid reset clears stats */
7821 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7822 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7824 "rte_cryptodev_stats_get failed");
7825 TEST_ASSERT((stats.enqueued_count == 0),
7826 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7827 TEST_ASSERT((stats.dequeued_count == 0),
7828 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7830 return TEST_SUCCESS;
7833 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
7834 struct crypto_unittest_params *ut_params,
7835 enum rte_crypto_auth_operation op,
7836 const struct HMAC_MD5_vector *test_case)
7840 memcpy(key, test_case->key.data, test_case->key.len);
7842 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7843 ut_params->auth_xform.next = NULL;
7844 ut_params->auth_xform.auth.op = op;
7846 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
7848 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
7849 ut_params->auth_xform.auth.key.length = test_case->key.len;
7850 ut_params->auth_xform.auth.key.data = key;
7852 ut_params->sess = rte_cryptodev_sym_session_create(
7853 ts_params->session_mpool);
7855 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7856 ut_params->sess, &ut_params->auth_xform,
7857 ts_params->session_priv_mpool);
7859 if (ut_params->sess == NULL)
7862 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7864 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7865 rte_pktmbuf_tailroom(ut_params->ibuf));
7870 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
7871 const struct HMAC_MD5_vector *test_case,
7872 uint8_t **plaintext)
7874 uint16_t plaintext_pad_len;
7876 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7878 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7881 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7883 memcpy(*plaintext, test_case->plaintext.data,
7884 test_case->plaintext.len);
7886 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7887 ut_params->ibuf, MD5_DIGEST_LEN);
7888 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7889 "no room to append digest");
7890 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7891 ut_params->ibuf, plaintext_pad_len);
7893 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7894 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
7895 test_case->auth_tag.len);
7898 sym_op->auth.data.offset = 0;
7899 sym_op->auth.data.length = test_case->plaintext.len;
7901 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7902 ut_params->op->sym->m_src = ut_params->ibuf;
7908 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
7910 uint16_t plaintext_pad_len;
7911 uint8_t *plaintext, *auth_tag;
7913 struct crypto_testsuite_params *ts_params = &testsuite_params;
7914 struct crypto_unittest_params *ut_params = &unittest_params;
7916 if (MD5_HMAC_create_session(ts_params, ut_params,
7917 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
7920 /* Generate Crypto op data structure */
7921 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7922 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7923 TEST_ASSERT_NOT_NULL(ut_params->op,
7924 "Failed to allocate symmetric crypto operation struct");
7926 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7929 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7932 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7933 ut_params->op), "failed to process sym crypto op");
7935 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7936 "crypto op processing failed");
7938 if (ut_params->op->sym->m_dst) {
7939 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7940 uint8_t *, plaintext_pad_len);
7942 auth_tag = plaintext + plaintext_pad_len;
7945 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7947 test_case->auth_tag.data,
7948 test_case->auth_tag.len,
7949 "HMAC_MD5 generated tag not as expected");
7951 return TEST_SUCCESS;
7955 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
7959 struct crypto_testsuite_params *ts_params = &testsuite_params;
7960 struct crypto_unittest_params *ut_params = &unittest_params;
7962 if (MD5_HMAC_create_session(ts_params, ut_params,
7963 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
7967 /* Generate Crypto op data structure */
7968 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7969 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7970 TEST_ASSERT_NOT_NULL(ut_params->op,
7971 "Failed to allocate symmetric crypto operation struct");
7973 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7976 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7977 ut_params->op), "failed to process sym crypto op");
7979 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7980 "HMAC_MD5 crypto op processing failed");
7982 return TEST_SUCCESS;
7986 test_MD5_HMAC_generate_case_1(void)
7988 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
7992 test_MD5_HMAC_verify_case_1(void)
7994 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
7998 test_MD5_HMAC_generate_case_2(void)
8000 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8004 test_MD5_HMAC_verify_case_2(void)
8006 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8010 test_multi_session(void)
8012 struct crypto_testsuite_params *ts_params = &testsuite_params;
8013 struct crypto_unittest_params *ut_params = &unittest_params;
8015 struct rte_cryptodev_info dev_info;
8016 struct rte_cryptodev_sym_session **sessions;
8020 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8021 aes_cbc_key, hmac_sha512_key);
8024 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8026 sessions = rte_malloc(NULL,
8027 (sizeof(struct rte_cryptodev_sym_session *) *
8028 MAX_NB_SESSIONS) + 1, 0);
8030 /* Create multiple crypto sessions*/
8031 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8033 sessions[i] = rte_cryptodev_sym_session_create(
8034 ts_params->session_mpool);
8036 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8037 sessions[i], &ut_params->auth_xform,
8038 ts_params->session_priv_mpool);
8039 TEST_ASSERT_NOT_NULL(sessions[i],
8040 "Session creation failed at session number %u",
8043 /* Attempt to send a request on each session */
8044 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
8048 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
8049 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
8051 "Failed to perform decrypt on request number %u.", i);
8052 /* free crypto operation structure */
8054 rte_crypto_op_free(ut_params->op);
8057 * free mbuf - both obuf and ibuf are usually the same,
8058 * so check if they point at the same address is necessary,
8059 * to avoid freeing the mbuf twice.
8061 if (ut_params->obuf) {
8062 rte_pktmbuf_free(ut_params->obuf);
8063 if (ut_params->ibuf == ut_params->obuf)
8064 ut_params->ibuf = 0;
8065 ut_params->obuf = 0;
8067 if (ut_params->ibuf) {
8068 rte_pktmbuf_free(ut_params->ibuf);
8069 ut_params->ibuf = 0;
8073 /* Next session create should fail */
8074 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8075 sessions[i], &ut_params->auth_xform,
8076 ts_params->session_priv_mpool);
8077 TEST_ASSERT_NULL(sessions[i],
8078 "Session creation succeeded unexpectedly!");
8080 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8081 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8083 rte_cryptodev_sym_session_free(sessions[i]);
8088 return TEST_SUCCESS;
8091 struct multi_session_params {
8092 struct crypto_unittest_params ut_params;
8093 uint8_t *cipher_key;
8095 const uint8_t *cipher;
8096 const uint8_t *digest;
8100 #define MB_SESSION_NUMBER 3
8103 test_multi_session_random_usage(void)
8105 struct crypto_testsuite_params *ts_params = &testsuite_params;
8106 struct rte_cryptodev_info dev_info;
8107 struct rte_cryptodev_sym_session **sessions;
8109 struct multi_session_params ut_paramz[] = {
8112 .cipher_key = ms_aes_cbc_key0,
8113 .hmac_key = ms_hmac_key0,
8114 .cipher = ms_aes_cbc_cipher0,
8115 .digest = ms_hmac_digest0,
8116 .iv = ms_aes_cbc_iv0
8119 .cipher_key = ms_aes_cbc_key1,
8120 .hmac_key = ms_hmac_key1,
8121 .cipher = ms_aes_cbc_cipher1,
8122 .digest = ms_hmac_digest1,
8123 .iv = ms_aes_cbc_iv1
8126 .cipher_key = ms_aes_cbc_key2,
8127 .hmac_key = ms_hmac_key2,
8128 .cipher = ms_aes_cbc_cipher2,
8129 .digest = ms_hmac_digest2,
8130 .iv = ms_aes_cbc_iv2
8135 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8137 sessions = rte_malloc(NULL,
8138 (sizeof(struct rte_cryptodev_sym_session *)
8139 * MAX_NB_SESSIONS) + 1, 0);
8141 for (i = 0; i < MB_SESSION_NUMBER; i++) {
8142 sessions[i] = rte_cryptodev_sym_session_create(
8143 ts_params->session_mpool);
8145 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
8146 sizeof(struct crypto_unittest_params));
8148 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
8149 &ut_paramz[i].ut_params,
8150 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
8152 /* Create multiple crypto sessions*/
8153 rte_cryptodev_sym_session_init(
8154 ts_params->valid_devs[0],
8156 &ut_paramz[i].ut_params.auth_xform,
8157 ts_params->session_priv_mpool);
8159 TEST_ASSERT_NOT_NULL(sessions[i],
8160 "Session creation failed at session number %u",
8166 for (i = 0; i < 40000; i++) {
8168 j = rand() % MB_SESSION_NUMBER;
8170 TEST_ASSERT_SUCCESS(
8171 test_AES_CBC_HMAC_SHA512_decrypt_perform(
8173 &ut_paramz[j].ut_params,
8174 ts_params, ut_paramz[j].cipher,
8175 ut_paramz[j].digest,
8177 "Failed to perform decrypt on request number %u.", i);
8179 if (ut_paramz[j].ut_params.op)
8180 rte_crypto_op_free(ut_paramz[j].ut_params.op);
8183 * free mbuf - both obuf and ibuf are usually the same,
8184 * so check if they point at the same address is necessary,
8185 * to avoid freeing the mbuf twice.
8187 if (ut_paramz[j].ut_params.obuf) {
8188 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
8189 if (ut_paramz[j].ut_params.ibuf
8190 == ut_paramz[j].ut_params.obuf)
8191 ut_paramz[j].ut_params.ibuf = 0;
8192 ut_paramz[j].ut_params.obuf = 0;
8194 if (ut_paramz[j].ut_params.ibuf) {
8195 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
8196 ut_paramz[j].ut_params.ibuf = 0;
8200 for (i = 0; i < MB_SESSION_NUMBER; i++) {
8201 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8203 rte_cryptodev_sym_session_free(sessions[i]);
8208 return TEST_SUCCESS;
8212 test_null_cipher_only_operation(void)
8214 struct crypto_testsuite_params *ts_params = &testsuite_params;
8215 struct crypto_unittest_params *ut_params = &unittest_params;
8217 /* Generate test mbuf data and space for digest */
8218 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8219 catch_22_quote, QUOTE_512_BYTES, 0);
8221 /* Setup Cipher Parameters */
8222 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8223 ut_params->cipher_xform.next = NULL;
8225 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8226 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8228 ut_params->sess = rte_cryptodev_sym_session_create(
8229 ts_params->session_mpool);
8231 /* Create Crypto session*/
8232 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8234 &ut_params->cipher_xform,
8235 ts_params->session_priv_mpool);
8236 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8238 /* Generate Crypto op data structure */
8239 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8240 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8241 TEST_ASSERT_NOT_NULL(ut_params->op,
8242 "Failed to allocate symmetric crypto operation struct");
8244 /* Set crypto operation data parameters */
8245 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8247 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8249 /* set crypto operation source mbuf */
8250 sym_op->m_src = ut_params->ibuf;
8252 sym_op->cipher.data.offset = 0;
8253 sym_op->cipher.data.length = QUOTE_512_BYTES;
8255 /* Process crypto operation */
8256 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8258 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8260 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8261 "crypto operation processing failed");
8264 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8265 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8268 "Ciphertext data not as expected");
8270 return TEST_SUCCESS;
8272 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
8273 0xab, 0xab, 0xab, 0xab,
8274 0xab, 0xab, 0xab, 0xab,
8275 0xab, 0xab, 0xab, 0xab};
8277 test_null_auth_only_operation(void)
8279 struct crypto_testsuite_params *ts_params = &testsuite_params;
8280 struct crypto_unittest_params *ut_params = &unittest_params;
8283 /* Generate test mbuf data and space for digest */
8284 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8285 catch_22_quote, QUOTE_512_BYTES, 0);
8287 /* create a pointer for digest, but don't expect anything to be written
8288 * here in a NULL auth algo so no mbuf append done.
8290 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8292 /* prefill the memory pointed to by digest */
8293 memcpy(digest, orig_data, sizeof(orig_data));
8295 /* Setup HMAC Parameters */
8296 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8297 ut_params->auth_xform.next = NULL;
8299 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8300 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8302 ut_params->sess = rte_cryptodev_sym_session_create(
8303 ts_params->session_mpool);
8305 /* Create Crypto session*/
8306 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8307 ut_params->sess, &ut_params->auth_xform,
8308 ts_params->session_priv_mpool);
8309 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8311 /* Generate Crypto op data structure */
8312 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8313 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8314 TEST_ASSERT_NOT_NULL(ut_params->op,
8315 "Failed to allocate symmetric crypto operation struct");
8317 /* Set crypto operation data parameters */
8318 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8320 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8322 sym_op->m_src = ut_params->ibuf;
8324 sym_op->auth.data.offset = 0;
8325 sym_op->auth.data.length = QUOTE_512_BYTES;
8326 sym_op->auth.digest.data = digest;
8327 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8330 /* Process crypto operation */
8331 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8333 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8335 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8336 "crypto operation processing failed");
8337 /* Make sure memory pointed to by digest hasn't been overwritten */
8338 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8342 "Memory at digest ptr overwritten unexpectedly");
8344 return TEST_SUCCESS;
8349 test_null_cipher_auth_operation(void)
8351 struct crypto_testsuite_params *ts_params = &testsuite_params;
8352 struct crypto_unittest_params *ut_params = &unittest_params;
8355 /* Generate test mbuf data and space for digest */
8356 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8357 catch_22_quote, QUOTE_512_BYTES, 0);
8359 /* create a pointer for digest, but don't expect anything to be written
8360 * here in a NULL auth algo so no mbuf append done.
8362 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8364 /* prefill the memory pointed to by digest */
8365 memcpy(digest, orig_data, sizeof(orig_data));
8367 /* Setup Cipher Parameters */
8368 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8369 ut_params->cipher_xform.next = &ut_params->auth_xform;
8371 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8372 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8374 /* Setup HMAC Parameters */
8375 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8376 ut_params->auth_xform.next = NULL;
8378 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8379 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8381 ut_params->sess = rte_cryptodev_sym_session_create(
8382 ts_params->session_mpool);
8384 /* Create Crypto session*/
8385 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8386 ut_params->sess, &ut_params->cipher_xform,
8387 ts_params->session_priv_mpool);
8388 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8390 /* Generate Crypto op data structure */
8391 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8392 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8393 TEST_ASSERT_NOT_NULL(ut_params->op,
8394 "Failed to allocate symmetric crypto operation struct");
8396 /* Set crypto operation data parameters */
8397 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8399 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8401 sym_op->m_src = ut_params->ibuf;
8403 sym_op->cipher.data.offset = 0;
8404 sym_op->cipher.data.length = QUOTE_512_BYTES;
8406 sym_op->auth.data.offset = 0;
8407 sym_op->auth.data.length = QUOTE_512_BYTES;
8408 sym_op->auth.digest.data = digest;
8409 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8412 /* Process crypto operation */
8413 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8415 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8417 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8418 "crypto operation processing failed");
8421 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8422 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8425 "Ciphertext data not as expected");
8426 /* Make sure memory pointed to by digest hasn't been overwritten */
8427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8431 "Memory at digest ptr overwritten unexpectedly");
8433 return TEST_SUCCESS;
8437 test_null_auth_cipher_operation(void)
8439 struct crypto_testsuite_params *ts_params = &testsuite_params;
8440 struct crypto_unittest_params *ut_params = &unittest_params;
8443 /* Generate test mbuf data */
8444 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8445 catch_22_quote, QUOTE_512_BYTES, 0);
8447 /* create a pointer for digest, but don't expect anything to be written
8448 * here in a NULL auth algo so no mbuf append done.
8450 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8452 /* prefill the memory pointed to by digest */
8453 memcpy(digest, orig_data, sizeof(orig_data));
8455 /* Setup Cipher Parameters */
8456 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8457 ut_params->cipher_xform.next = NULL;
8459 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8460 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8462 /* Setup HMAC Parameters */
8463 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8464 ut_params->auth_xform.next = &ut_params->cipher_xform;
8466 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8467 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8469 ut_params->sess = rte_cryptodev_sym_session_create(
8470 ts_params->session_mpool);
8472 /* Create Crypto session*/
8473 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8474 ut_params->sess, &ut_params->cipher_xform,
8475 ts_params->session_priv_mpool);
8476 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8478 /* Generate Crypto op data structure */
8479 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8480 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8481 TEST_ASSERT_NOT_NULL(ut_params->op,
8482 "Failed to allocate symmetric crypto operation struct");
8484 /* Set crypto operation data parameters */
8485 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8487 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8489 sym_op->m_src = ut_params->ibuf;
8491 sym_op->cipher.data.offset = 0;
8492 sym_op->cipher.data.length = QUOTE_512_BYTES;
8494 sym_op->auth.data.offset = 0;
8495 sym_op->auth.data.length = QUOTE_512_BYTES;
8496 sym_op->auth.digest.data = digest;
8497 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8500 /* Process crypto operation */
8501 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8503 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8505 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8506 "crypto operation processing failed");
8509 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8510 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8513 "Ciphertext data not as expected");
8514 /* Make sure memory pointed to by digest hasn't been overwritten */
8515 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8519 "Memory at digest ptr overwritten unexpectedly");
8521 return TEST_SUCCESS;
8526 test_null_invalid_operation(void)
8528 struct crypto_testsuite_params *ts_params = &testsuite_params;
8529 struct crypto_unittest_params *ut_params = &unittest_params;
8532 /* Setup Cipher Parameters */
8533 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8534 ut_params->cipher_xform.next = NULL;
8536 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
8537 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8539 ut_params->sess = rte_cryptodev_sym_session_create(
8540 ts_params->session_mpool);
8542 /* Create Crypto session*/
8543 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8544 ut_params->sess, &ut_params->cipher_xform,
8545 ts_params->session_priv_mpool);
8546 TEST_ASSERT(ret < 0,
8547 "Session creation succeeded unexpectedly");
8550 /* Setup HMAC Parameters */
8551 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8552 ut_params->auth_xform.next = NULL;
8554 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
8555 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8557 ut_params->sess = rte_cryptodev_sym_session_create(
8558 ts_params->session_mpool);
8560 /* Create Crypto session*/
8561 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8562 ut_params->sess, &ut_params->auth_xform,
8563 ts_params->session_priv_mpool);
8564 TEST_ASSERT(ret < 0,
8565 "Session creation succeeded unexpectedly");
8567 return TEST_SUCCESS;
8571 #define NULL_BURST_LENGTH (32)
8574 test_null_burst_operation(void)
8576 struct crypto_testsuite_params *ts_params = &testsuite_params;
8577 struct crypto_unittest_params *ut_params = &unittest_params;
8579 unsigned i, burst_len = NULL_BURST_LENGTH;
8581 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
8582 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
8584 /* Setup Cipher Parameters */
8585 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8586 ut_params->cipher_xform.next = &ut_params->auth_xform;
8588 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8589 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8591 /* Setup HMAC Parameters */
8592 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8593 ut_params->auth_xform.next = NULL;
8595 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8596 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8598 ut_params->sess = rte_cryptodev_sym_session_create(
8599 ts_params->session_mpool);
8601 /* Create Crypto session*/
8602 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8603 ut_params->sess, &ut_params->cipher_xform,
8604 ts_params->session_priv_mpool);
8605 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8607 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
8608 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
8609 burst_len, "failed to generate burst of crypto ops");
8611 /* Generate an operation for each mbuf in burst */
8612 for (i = 0; i < burst_len; i++) {
8613 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8615 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
8617 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
8621 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
8623 burst[i]->sym->m_src = m;
8626 /* Process crypto operation */
8627 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
8628 0, burst, burst_len),
8630 "Error enqueuing burst");
8632 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
8633 0, burst_dequeued, burst_len),
8635 "Error dequeuing burst");
8638 for (i = 0; i < burst_len; i++) {
8640 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
8641 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
8643 "data not as expected");
8645 rte_pktmbuf_free(burst[i]->sym->m_src);
8646 rte_crypto_op_free(burst[i]);
8649 return TEST_SUCCESS;
8653 generate_gmac_large_plaintext(uint8_t *data)
8657 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
8658 memcpy(&data[i], &data[0], 32);
8662 create_gmac_operation(enum rte_crypto_auth_operation op,
8663 const struct gmac_test_data *tdata)
8665 struct crypto_testsuite_params *ts_params = &testsuite_params;
8666 struct crypto_unittest_params *ut_params = &unittest_params;
8667 struct rte_crypto_sym_op *sym_op;
8669 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8671 /* Generate Crypto op data structure */
8672 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8673 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8674 TEST_ASSERT_NOT_NULL(ut_params->op,
8675 "Failed to allocate symmetric crypto operation struct");
8677 sym_op = ut_params->op->sym;
8679 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8680 ut_params->ibuf, tdata->gmac_tag.len);
8681 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8682 "no room to append digest");
8684 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8685 ut_params->ibuf, plaintext_pad_len);
8687 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8688 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
8689 tdata->gmac_tag.len);
8690 debug_hexdump(stdout, "digest:",
8691 sym_op->auth.digest.data,
8692 tdata->gmac_tag.len);
8695 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8696 uint8_t *, IV_OFFSET);
8698 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8700 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
8702 sym_op->cipher.data.length = 0;
8703 sym_op->cipher.data.offset = 0;
8705 sym_op->auth.data.offset = 0;
8706 sym_op->auth.data.length = tdata->plaintext.len;
8711 static int create_gmac_session(uint8_t dev_id,
8712 const struct gmac_test_data *tdata,
8713 enum rte_crypto_auth_operation auth_op)
8715 uint8_t auth_key[tdata->key.len];
8717 struct crypto_testsuite_params *ts_params = &testsuite_params;
8718 struct crypto_unittest_params *ut_params = &unittest_params;
8720 memcpy(auth_key, tdata->key.data, tdata->key.len);
8722 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8723 ut_params->auth_xform.next = NULL;
8725 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
8726 ut_params->auth_xform.auth.op = auth_op;
8727 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
8728 ut_params->auth_xform.auth.key.length = tdata->key.len;
8729 ut_params->auth_xform.auth.key.data = auth_key;
8730 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
8731 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
8734 ut_params->sess = rte_cryptodev_sym_session_create(
8735 ts_params->session_mpool);
8737 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8738 &ut_params->auth_xform,
8739 ts_params->session_priv_mpool);
8741 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8747 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
8749 struct crypto_testsuite_params *ts_params = &testsuite_params;
8750 struct crypto_unittest_params *ut_params = &unittest_params;
8754 uint8_t *auth_tag, *plaintext;
8755 uint16_t plaintext_pad_len;
8757 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8758 "No GMAC length in the source data");
8760 retval = create_gmac_session(ts_params->valid_devs[0],
8761 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
8766 if (tdata->plaintext.len > MBUF_SIZE)
8767 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8769 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8770 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8771 "Failed to allocate input buffer in mempool");
8773 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8774 rte_pktmbuf_tailroom(ut_params->ibuf));
8776 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8778 * Runtime generate the large plain text instead of use hard code
8779 * plain text vector. It is done to avoid create huge source file
8780 * with the test vector.
8782 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8783 generate_gmac_large_plaintext(tdata->plaintext.data);
8785 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8787 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8789 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8790 debug_hexdump(stdout, "plaintext:", plaintext,
8791 tdata->plaintext.len);
8793 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
8799 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8801 ut_params->op->sym->m_src = ut_params->ibuf;
8803 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8804 ut_params->op), "failed to process sym crypto op");
8806 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8807 "crypto op processing failed");
8809 if (ut_params->op->sym->m_dst) {
8810 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8811 uint8_t *, plaintext_pad_len);
8813 auth_tag = plaintext + plaintext_pad_len;
8816 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
8818 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8820 tdata->gmac_tag.data,
8821 tdata->gmac_tag.len,
8822 "GMAC Generated auth tag not as expected");
8828 test_AES_GMAC_authentication_test_case_1(void)
8830 return test_AES_GMAC_authentication(&gmac_test_case_1);
8834 test_AES_GMAC_authentication_test_case_2(void)
8836 return test_AES_GMAC_authentication(&gmac_test_case_2);
8840 test_AES_GMAC_authentication_test_case_3(void)
8842 return test_AES_GMAC_authentication(&gmac_test_case_3);
8846 test_AES_GMAC_authentication_test_case_4(void)
8848 return test_AES_GMAC_authentication(&gmac_test_case_4);
8852 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
8854 struct crypto_testsuite_params *ts_params = &testsuite_params;
8855 struct crypto_unittest_params *ut_params = &unittest_params;
8857 uint32_t plaintext_pad_len;
8860 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8861 "No GMAC length in the source data");
8863 retval = create_gmac_session(ts_params->valid_devs[0],
8864 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
8869 if (tdata->plaintext.len > MBUF_SIZE)
8870 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8873 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8874 "Failed to allocate input buffer in mempool");
8876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8877 rte_pktmbuf_tailroom(ut_params->ibuf));
8879 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8882 * Runtime generate the large plain text instead of use hard code
8883 * plain text vector. It is done to avoid create huge source file
8884 * with the test vector.
8886 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8887 generate_gmac_large_plaintext(tdata->plaintext.data);
8889 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8891 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8893 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8894 debug_hexdump(stdout, "plaintext:", plaintext,
8895 tdata->plaintext.len);
8897 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
8903 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8905 ut_params->op->sym->m_src = ut_params->ibuf;
8907 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8908 ut_params->op), "failed to process sym crypto op");
8910 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8911 "crypto op processing failed");
8918 test_AES_GMAC_authentication_verify_test_case_1(void)
8920 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
8924 test_AES_GMAC_authentication_verify_test_case_2(void)
8926 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
8930 test_AES_GMAC_authentication_verify_test_case_3(void)
8932 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
8936 test_AES_GMAC_authentication_verify_test_case_4(void)
8938 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
8941 struct test_crypto_vector {
8942 enum rte_crypto_cipher_algorithm crypto_algo;
8955 const uint8_t *data;
8960 const uint8_t *data;
8964 enum rte_crypto_auth_algorithm auth_algo;
8972 const uint8_t *data;
8982 static const struct test_crypto_vector
8983 hmac_sha1_test_crypto_vector = {
8984 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
8986 .data = plaintext_hash,
8991 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
8992 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
8993 0xDE, 0xF4, 0xDE, 0xAD
8999 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
9000 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
9001 0x3F, 0x91, 0x64, 0x59
9007 static const struct test_crypto_vector
9008 aes128_gmac_test_vector = {
9009 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
9011 .data = plaintext_hash,
9016 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9017 0x08, 0x09, 0x0A, 0x0B
9023 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9024 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
9030 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
9031 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
9037 static const struct test_crypto_vector
9038 aes128cbc_hmac_sha1_test_vector = {
9039 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9042 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9043 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9049 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9050 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
9055 .data = plaintext_hash,
9059 .data = ciphertext512_aes128cbc,
9062 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9065 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9066 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9067 0xDE, 0xF4, 0xDE, 0xAD
9073 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
9074 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9075 0x18, 0x8C, 0x1D, 0x32
9082 data_corruption(uint8_t *data)
9088 tag_corruption(uint8_t *data, unsigned int tag_offset)
9090 data[tag_offset] += 1;
9094 create_auth_session(struct crypto_unittest_params *ut_params,
9096 const struct test_crypto_vector *reference,
9097 enum rte_crypto_auth_operation auth_op)
9099 struct crypto_testsuite_params *ts_params = &testsuite_params;
9100 uint8_t auth_key[reference->auth_key.len + 1];
9102 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9104 /* Setup Authentication Parameters */
9105 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9106 ut_params->auth_xform.auth.op = auth_op;
9107 ut_params->auth_xform.next = NULL;
9108 ut_params->auth_xform.auth.algo = reference->auth_algo;
9109 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9110 ut_params->auth_xform.auth.key.data = auth_key;
9111 ut_params->auth_xform.auth.digest_length = reference->digest.len;
9113 /* Create Crypto session*/
9114 ut_params->sess = rte_cryptodev_sym_session_create(
9115 ts_params->session_mpool);
9117 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9118 &ut_params->auth_xform,
9119 ts_params->session_priv_mpool);
9121 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9127 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
9129 const struct test_crypto_vector *reference,
9130 enum rte_crypto_auth_operation auth_op,
9131 enum rte_crypto_cipher_operation cipher_op)
9133 struct crypto_testsuite_params *ts_params = &testsuite_params;
9134 uint8_t cipher_key[reference->cipher_key.len + 1];
9135 uint8_t auth_key[reference->auth_key.len + 1];
9137 memcpy(cipher_key, reference->cipher_key.data,
9138 reference->cipher_key.len);
9139 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9141 /* Setup Authentication Parameters */
9142 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9143 ut_params->auth_xform.auth.op = auth_op;
9144 ut_params->auth_xform.auth.algo = reference->auth_algo;
9145 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9146 ut_params->auth_xform.auth.key.data = auth_key;
9147 ut_params->auth_xform.auth.digest_length = reference->digest.len;
9149 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
9150 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9151 ut_params->auth_xform.auth.iv.length = reference->iv.len;
9153 ut_params->auth_xform.next = &ut_params->cipher_xform;
9155 /* Setup Cipher Parameters */
9156 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9157 ut_params->cipher_xform.next = NULL;
9158 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
9159 ut_params->cipher_xform.cipher.op = cipher_op;
9160 ut_params->cipher_xform.cipher.key.data = cipher_key;
9161 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
9162 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9163 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
9166 /* Create Crypto session*/
9167 ut_params->sess = rte_cryptodev_sym_session_create(
9168 ts_params->session_mpool);
9170 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9171 &ut_params->auth_xform,
9172 ts_params->session_priv_mpool);
9174 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9180 create_auth_operation(struct crypto_testsuite_params *ts_params,
9181 struct crypto_unittest_params *ut_params,
9182 const struct test_crypto_vector *reference,
9183 unsigned int auth_generate)
9185 /* Generate Crypto op data structure */
9186 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9187 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9188 TEST_ASSERT_NOT_NULL(ut_params->op,
9189 "Failed to allocate pktmbuf offload");
9191 /* Set crypto operation data parameters */
9192 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9194 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9196 /* set crypto operation source mbuf */
9197 sym_op->m_src = ut_params->ibuf;
9200 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9201 ut_params->ibuf, reference->digest.len);
9203 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9204 "no room to append auth tag");
9206 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9207 ut_params->ibuf, reference->plaintext.len);
9210 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9212 memcpy(sym_op->auth.digest.data,
9213 reference->digest.data,
9214 reference->digest.len);
9216 debug_hexdump(stdout, "digest:",
9217 sym_op->auth.digest.data,
9218 reference->digest.len);
9220 sym_op->auth.data.length = reference->plaintext.len;
9221 sym_op->auth.data.offset = 0;
9227 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
9228 struct crypto_unittest_params *ut_params,
9229 const struct test_crypto_vector *reference,
9230 unsigned int auth_generate)
9232 /* Generate Crypto op data structure */
9233 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9234 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9235 TEST_ASSERT_NOT_NULL(ut_params->op,
9236 "Failed to allocate pktmbuf offload");
9238 /* Set crypto operation data parameters */
9239 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9241 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9243 /* set crypto operation source mbuf */
9244 sym_op->m_src = ut_params->ibuf;
9247 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9248 ut_params->ibuf, reference->digest.len);
9250 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9251 "no room to append auth tag");
9253 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9254 ut_params->ibuf, reference->ciphertext.len);
9257 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9259 memcpy(sym_op->auth.digest.data,
9260 reference->digest.data,
9261 reference->digest.len);
9263 debug_hexdump(stdout, "digest:",
9264 sym_op->auth.digest.data,
9265 reference->digest.len);
9267 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
9268 reference->iv.data, reference->iv.len);
9270 sym_op->cipher.data.length = 0;
9271 sym_op->cipher.data.offset = 0;
9273 sym_op->auth.data.length = reference->plaintext.len;
9274 sym_op->auth.data.offset = 0;
9280 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
9281 struct crypto_unittest_params *ut_params,
9282 const struct test_crypto_vector *reference,
9283 unsigned int auth_generate)
9285 /* Generate Crypto op data structure */
9286 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9287 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9288 TEST_ASSERT_NOT_NULL(ut_params->op,
9289 "Failed to allocate pktmbuf offload");
9291 /* Set crypto operation data parameters */
9292 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9294 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9296 /* set crypto operation source mbuf */
9297 sym_op->m_src = ut_params->ibuf;
9300 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9301 ut_params->ibuf, reference->digest.len);
9303 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9304 "no room to append auth tag");
9306 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9307 ut_params->ibuf, reference->ciphertext.len);
9310 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9312 memcpy(sym_op->auth.digest.data,
9313 reference->digest.data,
9314 reference->digest.len);
9316 debug_hexdump(stdout, "digest:",
9317 sym_op->auth.digest.data,
9318 reference->digest.len);
9320 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
9321 reference->iv.data, reference->iv.len);
9323 sym_op->cipher.data.length = reference->ciphertext.len;
9324 sym_op->cipher.data.offset = 0;
9326 sym_op->auth.data.length = reference->ciphertext.len;
9327 sym_op->auth.data.offset = 0;
9333 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
9334 struct crypto_unittest_params *ut_params,
9335 const struct test_crypto_vector *reference)
9337 return create_auth_operation(ts_params, ut_params, reference, 0);
9341 create_auth_verify_GMAC_operation(
9342 struct crypto_testsuite_params *ts_params,
9343 struct crypto_unittest_params *ut_params,
9344 const struct test_crypto_vector *reference)
9346 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
9350 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
9351 struct crypto_unittest_params *ut_params,
9352 const struct test_crypto_vector *reference)
9354 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
9358 test_authentication_verify_fail_when_data_corruption(
9359 struct crypto_testsuite_params *ts_params,
9360 struct crypto_unittest_params *ut_params,
9361 const struct test_crypto_vector *reference,
9362 unsigned int data_corrupted)
9368 /* Create session */
9369 retval = create_auth_session(ut_params,
9370 ts_params->valid_devs[0],
9372 RTE_CRYPTO_AUTH_OP_VERIFY);
9376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9377 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9378 "Failed to allocate input buffer in mempool");
9380 /* clear mbuf payload */
9381 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9382 rte_pktmbuf_tailroom(ut_params->ibuf));
9384 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9385 reference->plaintext.len);
9386 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9387 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
9389 debug_hexdump(stdout, "plaintext:", plaintext,
9390 reference->plaintext.len);
9392 /* Create operation */
9393 retval = create_auth_verify_operation(ts_params, ut_params, reference);
9399 data_corruption(plaintext);
9401 tag_corruption(plaintext, reference->plaintext.len);
9403 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9405 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9406 TEST_ASSERT_EQUAL(ut_params->op->status,
9407 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9408 "authentication not failed");
9410 ut_params->obuf = ut_params->op->sym->m_src;
9411 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9417 test_authentication_verify_GMAC_fail_when_corruption(
9418 struct crypto_testsuite_params *ts_params,
9419 struct crypto_unittest_params *ut_params,
9420 const struct test_crypto_vector *reference,
9421 unsigned int data_corrupted)
9426 /* Create session */
9427 retval = create_auth_cipher_session(ut_params,
9428 ts_params->valid_devs[0],
9430 RTE_CRYPTO_AUTH_OP_VERIFY,
9431 RTE_CRYPTO_CIPHER_OP_DECRYPT);
9435 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9436 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9437 "Failed to allocate input buffer in mempool");
9439 /* clear mbuf payload */
9440 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9441 rte_pktmbuf_tailroom(ut_params->ibuf));
9443 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9444 reference->plaintext.len);
9445 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9446 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
9448 debug_hexdump(stdout, "plaintext:", plaintext,
9449 reference->plaintext.len);
9451 /* Create operation */
9452 retval = create_auth_verify_GMAC_operation(ts_params,
9460 data_corruption(plaintext);
9462 tag_corruption(plaintext, reference->aad.len);
9464 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9466 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9467 TEST_ASSERT_EQUAL(ut_params->op->status,
9468 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9469 "authentication not failed");
9471 ut_params->obuf = ut_params->op->sym->m_src;
9472 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9478 test_authenticated_decryption_fail_when_corruption(
9479 struct crypto_testsuite_params *ts_params,
9480 struct crypto_unittest_params *ut_params,
9481 const struct test_crypto_vector *reference,
9482 unsigned int data_corrupted)
9486 uint8_t *ciphertext;
9488 /* Create session */
9489 retval = create_auth_cipher_session(ut_params,
9490 ts_params->valid_devs[0],
9492 RTE_CRYPTO_AUTH_OP_VERIFY,
9493 RTE_CRYPTO_CIPHER_OP_DECRYPT);
9497 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9498 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9499 "Failed to allocate input buffer in mempool");
9501 /* clear mbuf payload */
9502 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9503 rte_pktmbuf_tailroom(ut_params->ibuf));
9505 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9506 reference->ciphertext.len);
9507 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
9508 memcpy(ciphertext, reference->ciphertext.data,
9509 reference->ciphertext.len);
9511 /* Create operation */
9512 retval = create_cipher_auth_verify_operation(ts_params,
9520 data_corruption(ciphertext);
9522 tag_corruption(ciphertext, reference->ciphertext.len);
9524 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9527 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9528 TEST_ASSERT_EQUAL(ut_params->op->status,
9529 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9530 "authentication not failed");
9532 ut_params->obuf = ut_params->op->sym->m_src;
9533 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9539 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
9540 const struct aead_test_data *tdata,
9541 void *digest_mem, uint64_t digest_phys)
9543 struct crypto_testsuite_params *ts_params = &testsuite_params;
9544 struct crypto_unittest_params *ut_params = &unittest_params;
9546 const unsigned int auth_tag_len = tdata->auth_tag.len;
9547 const unsigned int iv_len = tdata->iv.len;
9548 unsigned int aad_len = tdata->aad.len;
9550 /* Generate Crypto op data structure */
9551 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9552 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9553 TEST_ASSERT_NOT_NULL(ut_params->op,
9554 "Failed to allocate symmetric crypto operation struct");
9556 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9558 sym_op->aead.digest.data = digest_mem;
9560 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9561 "no room to append digest");
9563 sym_op->aead.digest.phys_addr = digest_phys;
9565 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
9566 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9568 debug_hexdump(stdout, "digest:",
9569 sym_op->aead.digest.data,
9573 /* Append aad data */
9574 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9575 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9576 uint8_t *, IV_OFFSET);
9578 /* Copy IV 1 byte after the IV pointer, according to the API */
9579 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
9581 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
9583 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
9584 ut_params->ibuf, aad_len);
9585 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9586 "no room to prepend aad");
9587 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
9590 memset(sym_op->aead.aad.data, 0, aad_len);
9591 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
9592 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
9594 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
9595 debug_hexdump(stdout, "aad:",
9596 sym_op->aead.aad.data, aad_len);
9598 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9599 uint8_t *, IV_OFFSET);
9601 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
9603 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
9604 ut_params->ibuf, aad_len);
9605 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9606 "no room to prepend aad");
9607 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
9610 memset(sym_op->aead.aad.data, 0, aad_len);
9611 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
9613 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
9614 debug_hexdump(stdout, "aad:",
9615 sym_op->aead.aad.data, aad_len);
9618 sym_op->aead.data.length = tdata->plaintext.len;
9619 sym_op->aead.data.offset = aad_len;
9624 #define SGL_MAX_NO 16
9627 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
9628 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
9630 struct crypto_testsuite_params *ts_params = &testsuite_params;
9631 struct crypto_unittest_params *ut_params = &unittest_params;
9632 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
9635 int to_trn_tbl[SGL_MAX_NO];
9637 unsigned int trn_data = 0;
9638 uint8_t *plaintext, *ciphertext, *auth_tag;
9640 if (fragsz > tdata->plaintext.len)
9641 fragsz = tdata->plaintext.len;
9643 uint16_t plaintext_len = fragsz;
9644 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9646 if (fragsz_oop > tdata->plaintext.len)
9647 frag_size_oop = tdata->plaintext.len;
9650 void *digest_mem = NULL;
9652 uint32_t prepend_len = tdata->aad.len;
9654 if (tdata->plaintext.len % fragsz != 0) {
9655 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
9658 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
9663 * For out-op-place we need to alloc another mbuf
9666 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9667 rte_pktmbuf_append(ut_params->obuf,
9668 frag_size_oop + prepend_len);
9669 buf_oop = ut_params->obuf;
9672 /* Create AEAD session */
9673 retval = create_aead_session(ts_params->valid_devs[0],
9675 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9676 tdata->key.data, tdata->key.len,
9677 tdata->aad.len, tdata->auth_tag.len,
9682 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9684 /* clear mbuf payload */
9685 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9686 rte_pktmbuf_tailroom(ut_params->ibuf));
9688 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9691 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
9693 trn_data += plaintext_len;
9695 buf = ut_params->ibuf;
9698 * Loop until no more fragments
9701 while (trn_data < tdata->plaintext.len) {
9703 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
9704 (tdata->plaintext.len - trn_data) : fragsz;
9706 to_trn_tbl[ecx++] = to_trn;
9708 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9711 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9712 rte_pktmbuf_tailroom(buf));
9715 if (oop && !fragsz_oop) {
9716 buf_last_oop = buf_oop->next =
9717 rte_pktmbuf_alloc(ts_params->mbuf_pool);
9718 buf_oop = buf_oop->next;
9719 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9720 0, rte_pktmbuf_tailroom(buf_oop));
9721 rte_pktmbuf_append(buf_oop, to_trn);
9724 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9727 memcpy(plaintext, tdata->plaintext.data + trn_data,
9730 if (trn_data == tdata->plaintext.len) {
9733 digest_mem = rte_pktmbuf_append(buf_oop,
9734 tdata->auth_tag.len);
9736 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
9737 tdata->auth_tag.len);
9741 uint64_t digest_phys = 0;
9743 ut_params->ibuf->nb_segs = segs;
9746 if (fragsz_oop && oop) {
9750 if (frag_size_oop == tdata->plaintext.len) {
9751 digest_mem = rte_pktmbuf_append(ut_params->obuf,
9752 tdata->auth_tag.len);
9754 digest_phys = rte_pktmbuf_iova_offset(
9756 tdata->plaintext.len + prepend_len);
9759 trn_data = frag_size_oop;
9760 while (trn_data < tdata->plaintext.len) {
9763 (tdata->plaintext.len - trn_data <
9765 (tdata->plaintext.len - trn_data) :
9768 to_trn_tbl[ecx++] = to_trn;
9770 buf_last_oop = buf_oop->next =
9771 rte_pktmbuf_alloc(ts_params->mbuf_pool);
9772 buf_oop = buf_oop->next;
9773 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9774 0, rte_pktmbuf_tailroom(buf_oop));
9775 rte_pktmbuf_append(buf_oop, to_trn);
9779 if (trn_data == tdata->plaintext.len) {
9780 digest_mem = rte_pktmbuf_append(buf_oop,
9781 tdata->auth_tag.len);
9785 ut_params->obuf->nb_segs = segs;
9789 * Place digest at the end of the last buffer
9792 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
9793 if (oop && buf_last_oop)
9794 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
9796 if (!digest_mem && !oop) {
9797 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9798 + tdata->auth_tag.len);
9799 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
9800 tdata->plaintext.len);
9803 /* Create AEAD operation */
9804 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
9805 tdata, digest_mem, digest_phys);
9810 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9812 ut_params->op->sym->m_src = ut_params->ibuf;
9814 ut_params->op->sym->m_dst = ut_params->obuf;
9816 /* Process crypto operation */
9817 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9818 ut_params->op), "failed to process sym crypto op");
9820 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9821 "crypto op processing failed");
9824 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9825 uint8_t *, prepend_len);
9827 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9828 uint8_t *, prepend_len);
9832 fragsz = fragsz_oop;
9834 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9836 tdata->ciphertext.data,
9838 "Ciphertext data not as expected");
9840 buf = ut_params->op->sym->m_src->next;
9842 buf = ut_params->op->sym->m_dst->next;
9844 unsigned int off = fragsz;
9848 ciphertext = rte_pktmbuf_mtod(buf,
9851 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9853 tdata->ciphertext.data + off,
9855 "Ciphertext data not as expected");
9857 off += to_trn_tbl[ecx++];
9861 auth_tag = digest_mem;
9862 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9864 tdata->auth_tag.data,
9865 tdata->auth_tag.len,
9866 "Generated auth tag not as expected");
9872 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
9874 return test_authenticated_encryption_SGL(
9875 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
9879 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
9881 return test_authenticated_encryption_SGL(
9882 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
9886 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
9888 return test_authenticated_encryption_SGL(
9889 &gcm_test_case_8, OUT_OF_PLACE, 400,
9890 gcm_test_case_8.plaintext.len);
9894 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
9897 return test_authenticated_encryption_SGL(
9898 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
9902 test_authentication_verify_fail_when_data_corrupted(
9903 struct crypto_testsuite_params *ts_params,
9904 struct crypto_unittest_params *ut_params,
9905 const struct test_crypto_vector *reference)
9907 return test_authentication_verify_fail_when_data_corruption(
9908 ts_params, ut_params, reference, 1);
9912 test_authentication_verify_fail_when_tag_corrupted(
9913 struct crypto_testsuite_params *ts_params,
9914 struct crypto_unittest_params *ut_params,
9915 const struct test_crypto_vector *reference)
9917 return test_authentication_verify_fail_when_data_corruption(
9918 ts_params, ut_params, reference, 0);
9922 test_authentication_verify_GMAC_fail_when_data_corrupted(
9923 struct crypto_testsuite_params *ts_params,
9924 struct crypto_unittest_params *ut_params,
9925 const struct test_crypto_vector *reference)
9927 return test_authentication_verify_GMAC_fail_when_corruption(
9928 ts_params, ut_params, reference, 1);
9932 test_authentication_verify_GMAC_fail_when_tag_corrupted(
9933 struct crypto_testsuite_params *ts_params,
9934 struct crypto_unittest_params *ut_params,
9935 const struct test_crypto_vector *reference)
9937 return test_authentication_verify_GMAC_fail_when_corruption(
9938 ts_params, ut_params, reference, 0);
9942 test_authenticated_decryption_fail_when_data_corrupted(
9943 struct crypto_testsuite_params *ts_params,
9944 struct crypto_unittest_params *ut_params,
9945 const struct test_crypto_vector *reference)
9947 return test_authenticated_decryption_fail_when_corruption(
9948 ts_params, ut_params, reference, 1);
9952 test_authenticated_decryption_fail_when_tag_corrupted(
9953 struct crypto_testsuite_params *ts_params,
9954 struct crypto_unittest_params *ut_params,
9955 const struct test_crypto_vector *reference)
9957 return test_authenticated_decryption_fail_when_corruption(
9958 ts_params, ut_params, reference, 0);
9962 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
9964 return test_authentication_verify_fail_when_data_corrupted(
9965 &testsuite_params, &unittest_params,
9966 &hmac_sha1_test_crypto_vector);
9970 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
9972 return test_authentication_verify_fail_when_tag_corrupted(
9973 &testsuite_params, &unittest_params,
9974 &hmac_sha1_test_crypto_vector);
9978 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
9980 return test_authentication_verify_GMAC_fail_when_data_corrupted(
9981 &testsuite_params, &unittest_params,
9982 &aes128_gmac_test_vector);
9986 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
9988 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
9989 &testsuite_params, &unittest_params,
9990 &aes128_gmac_test_vector);
9994 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
9996 return test_authenticated_decryption_fail_when_data_corrupted(
9999 &aes128cbc_hmac_sha1_test_vector);
10003 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
10005 return test_authenticated_decryption_fail_when_tag_corrupted(
10008 &aes128cbc_hmac_sha1_test_vector);
10011 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10013 /* global AESNI slave IDs for the scheduler test */
10014 uint8_t aesni_ids[2];
10017 test_scheduler_attach_slave_op(void)
10019 struct crypto_testsuite_params *ts_params = &testsuite_params;
10020 uint8_t sched_id = ts_params->valid_devs[0];
10021 uint32_t nb_devs, i, nb_devs_attached = 0;
10023 char vdev_name[32];
10025 /* create 2 AESNI_MB if necessary */
10026 nb_devs = rte_cryptodev_device_count_by_driver(
10027 rte_cryptodev_driver_id_get(
10028 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
10030 for (i = nb_devs; i < 2; i++) {
10031 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
10032 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
10034 ret = rte_vdev_init(vdev_name, NULL);
10036 TEST_ASSERT(ret == 0,
10037 "Failed to create instance %u of"
10039 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10043 /* attach 2 AESNI_MB cdevs */
10044 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
10046 struct rte_cryptodev_info info;
10047 unsigned int session_size;
10049 rte_cryptodev_info_get(i, &info);
10050 if (info.driver_id != rte_cryptodev_driver_id_get(
10051 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
10054 session_size = rte_cryptodev_sym_get_private_session_size(i);
10056 * Create the session mempool again, since now there are new devices
10057 * to use the mempool.
10059 if (ts_params->session_mpool) {
10060 rte_mempool_free(ts_params->session_mpool);
10061 ts_params->session_mpool = NULL;
10063 if (ts_params->session_priv_mpool) {
10064 rte_mempool_free(ts_params->session_priv_mpool);
10065 ts_params->session_priv_mpool = NULL;
10068 if (info.sym.max_nb_sessions != 0 &&
10069 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
10070 RTE_LOG(ERR, USER1,
10071 "Device does not support "
10072 "at least %u sessions\n",
10074 return TEST_FAILED;
10077 * Create mempool with maximum number of sessions,
10078 * to include the session headers
10080 if (ts_params->session_mpool == NULL) {
10081 ts_params->session_mpool =
10082 rte_cryptodev_sym_session_pool_create(
10084 MAX_NB_SESSIONS, 0, 0, 0,
10086 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
10087 "session mempool allocation failed");
10091 * Create mempool with maximum number of sessions,
10092 * to include device specific session private data
10094 if (ts_params->session_priv_mpool == NULL) {
10095 ts_params->session_priv_mpool = rte_mempool_create(
10096 "test_sess_mp_priv",
10099 0, 0, NULL, NULL, NULL,
10100 NULL, SOCKET_ID_ANY,
10103 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
10104 "session mempool allocation failed");
10107 ts_params->qp_conf.mp_session = ts_params->session_mpool;
10108 ts_params->qp_conf.mp_session_private =
10109 ts_params->session_priv_mpool;
10111 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
10114 TEST_ASSERT(ret == 0,
10115 "Failed to attach device %u of pmd : %s", i,
10116 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10118 aesni_ids[nb_devs_attached] = (uint8_t)i;
10120 nb_devs_attached++;
10127 test_scheduler_detach_slave_op(void)
10129 struct crypto_testsuite_params *ts_params = &testsuite_params;
10130 uint8_t sched_id = ts_params->valid_devs[0];
10134 for (i = 0; i < 2; i++) {
10135 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
10137 TEST_ASSERT(ret == 0,
10138 "Failed to detach device %u", aesni_ids[i]);
10145 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
10147 struct crypto_testsuite_params *ts_params = &testsuite_params;
10148 uint8_t sched_id = ts_params->valid_devs[0];
10150 return rte_cryptodev_scheduler_mode_set(sched_id,
10155 test_scheduler_mode_roundrobin_op(void)
10157 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
10158 0, "Failed to set roundrobin mode");
10164 test_scheduler_mode_multicore_op(void)
10166 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
10167 0, "Failed to set multicore mode");
10173 test_scheduler_mode_failover_op(void)
10175 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
10176 0, "Failed to set failover mode");
10182 test_scheduler_mode_pkt_size_distr_op(void)
10184 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
10185 0, "Failed to set pktsize mode");
10190 static struct unit_test_suite cryptodev_scheduler_testsuite = {
10191 .suite_name = "Crypto Device Scheduler Unit Test Suite",
10192 .setup = testsuite_setup,
10193 .teardown = testsuite_teardown,
10194 .unit_test_cases = {
10196 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10197 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
10198 TEST_CASE_ST(ut_setup, ut_teardown,
10199 test_AES_chain_scheduler_all),
10200 TEST_CASE_ST(ut_setup, ut_teardown,
10201 test_AES_cipheronly_scheduler_all),
10202 TEST_CASE_ST(ut_setup, ut_teardown,
10203 test_authonly_scheduler_all),
10204 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10207 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10208 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
10209 TEST_CASE_ST(ut_setup, ut_teardown,
10210 test_AES_chain_scheduler_all),
10211 TEST_CASE_ST(ut_setup, ut_teardown,
10212 test_AES_cipheronly_scheduler_all),
10213 TEST_CASE_ST(ut_setup, ut_teardown,
10214 test_authonly_scheduler_all),
10215 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10218 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10219 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
10220 TEST_CASE_ST(ut_setup, ut_teardown,
10221 test_AES_chain_scheduler_all),
10222 TEST_CASE_ST(ut_setup, ut_teardown,
10223 test_AES_cipheronly_scheduler_all),
10224 TEST_CASE_ST(ut_setup, ut_teardown,
10225 test_authonly_scheduler_all),
10226 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10229 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10230 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
10231 TEST_CASE_ST(ut_setup, ut_teardown,
10232 test_AES_chain_scheduler_all),
10233 TEST_CASE_ST(ut_setup, ut_teardown,
10234 test_AES_cipheronly_scheduler_all),
10235 TEST_CASE_ST(ut_setup, ut_teardown,
10236 test_authonly_scheduler_all),
10237 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10239 TEST_CASES_END() /**< NULL terminate unit test array */
10243 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
10245 static struct unit_test_suite cryptodev_qat_testsuite = {
10246 .suite_name = "Crypto QAT Unit Test Suite",
10247 .setup = testsuite_setup,
10248 .teardown = testsuite_teardown,
10249 .unit_test_cases = {
10250 TEST_CASE_ST(ut_setup, ut_teardown,
10251 test_device_configure_invalid_dev_id),
10252 TEST_CASE_ST(ut_setup, ut_teardown,
10253 test_device_configure_invalid_queue_pair_ids),
10254 TEST_CASE_ST(ut_setup, ut_teardown,
10255 test_queue_pair_descriptor_setup),
10256 TEST_CASE_ST(ut_setup, ut_teardown,
10257 test_multi_session),
10259 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
10260 TEST_CASE_ST(ut_setup, ut_teardown,
10261 test_AES_cipheronly_qat_all),
10262 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
10263 TEST_CASE_ST(ut_setup, ut_teardown,
10264 test_3DES_cipheronly_qat_all),
10265 TEST_CASE_ST(ut_setup, ut_teardown,
10266 test_DES_cipheronly_qat_all),
10267 TEST_CASE_ST(ut_setup, ut_teardown,
10268 test_AES_docsis_qat_all),
10269 TEST_CASE_ST(ut_setup, ut_teardown,
10270 test_DES_docsis_qat_all),
10271 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
10272 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
10274 /** AES CCM Authenticated Encryption 128 bits key */
10275 TEST_CASE_ST(ut_setup, ut_teardown,
10276 test_AES_CCM_authenticated_encryption_test_case_128_1),
10277 TEST_CASE_ST(ut_setup, ut_teardown,
10278 test_AES_CCM_authenticated_encryption_test_case_128_2),
10279 TEST_CASE_ST(ut_setup, ut_teardown,
10280 test_AES_CCM_authenticated_encryption_test_case_128_3),
10282 /** AES CCM Authenticated Decryption 128 bits key*/
10283 TEST_CASE_ST(ut_setup, ut_teardown,
10284 test_AES_CCM_authenticated_decryption_test_case_128_1),
10285 TEST_CASE_ST(ut_setup, ut_teardown,
10286 test_AES_CCM_authenticated_decryption_test_case_128_2),
10287 TEST_CASE_ST(ut_setup, ut_teardown,
10288 test_AES_CCM_authenticated_decryption_test_case_128_3),
10290 /** AES GCM Authenticated Encryption */
10291 TEST_CASE_ST(ut_setup, ut_teardown,
10292 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10293 TEST_CASE_ST(ut_setup, ut_teardown,
10294 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10295 TEST_CASE_ST(ut_setup, ut_teardown,
10296 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10297 TEST_CASE_ST(ut_setup, ut_teardown,
10298 test_AES_GCM_authenticated_encryption_test_case_1),
10299 TEST_CASE_ST(ut_setup, ut_teardown,
10300 test_AES_GCM_authenticated_encryption_test_case_2),
10301 TEST_CASE_ST(ut_setup, ut_teardown,
10302 test_AES_GCM_authenticated_encryption_test_case_3),
10303 TEST_CASE_ST(ut_setup, ut_teardown,
10304 test_AES_GCM_authenticated_encryption_test_case_4),
10305 TEST_CASE_ST(ut_setup, ut_teardown,
10306 test_AES_GCM_authenticated_encryption_test_case_5),
10307 TEST_CASE_ST(ut_setup, ut_teardown,
10308 test_AES_GCM_authenticated_encryption_test_case_6),
10309 TEST_CASE_ST(ut_setup, ut_teardown,
10310 test_AES_GCM_authenticated_encryption_test_case_7),
10312 /** AES GCM Authenticated Decryption */
10313 TEST_CASE_ST(ut_setup, ut_teardown,
10314 test_AES_GCM_authenticated_decryption_test_case_1),
10315 TEST_CASE_ST(ut_setup, ut_teardown,
10316 test_AES_GCM_authenticated_decryption_test_case_2),
10317 TEST_CASE_ST(ut_setup, ut_teardown,
10318 test_AES_GCM_authenticated_decryption_test_case_3),
10319 TEST_CASE_ST(ut_setup, ut_teardown,
10320 test_AES_GCM_authenticated_decryption_test_case_4),
10321 TEST_CASE_ST(ut_setup, ut_teardown,
10322 test_AES_GCM_authenticated_decryption_test_case_5),
10323 TEST_CASE_ST(ut_setup, ut_teardown,
10324 test_AES_GCM_authenticated_decryption_test_case_6),
10325 TEST_CASE_ST(ut_setup, ut_teardown,
10326 test_AES_GCM_authenticated_decryption_test_case_7),
10328 /** AES GCM Authenticated Encryption 192 bits key */
10329 TEST_CASE_ST(ut_setup, ut_teardown,
10330 test_AES_GCM_auth_encryption_test_case_192_1),
10331 TEST_CASE_ST(ut_setup, ut_teardown,
10332 test_AES_GCM_auth_encryption_test_case_192_2),
10333 TEST_CASE_ST(ut_setup, ut_teardown,
10334 test_AES_GCM_auth_encryption_test_case_192_3),
10335 TEST_CASE_ST(ut_setup, ut_teardown,
10336 test_AES_GCM_auth_encryption_test_case_192_4),
10337 TEST_CASE_ST(ut_setup, ut_teardown,
10338 test_AES_GCM_auth_encryption_test_case_192_5),
10339 TEST_CASE_ST(ut_setup, ut_teardown,
10340 test_AES_GCM_auth_encryption_test_case_192_6),
10341 TEST_CASE_ST(ut_setup, ut_teardown,
10342 test_AES_GCM_auth_encryption_test_case_192_7),
10344 /** AES GCM Authenticated Decryption 192 bits key */
10345 TEST_CASE_ST(ut_setup, ut_teardown,
10346 test_AES_GCM_auth_decryption_test_case_192_1),
10347 TEST_CASE_ST(ut_setup, ut_teardown,
10348 test_AES_GCM_auth_decryption_test_case_192_2),
10349 TEST_CASE_ST(ut_setup, ut_teardown,
10350 test_AES_GCM_auth_decryption_test_case_192_3),
10351 TEST_CASE_ST(ut_setup, ut_teardown,
10352 test_AES_GCM_auth_decryption_test_case_192_4),
10353 TEST_CASE_ST(ut_setup, ut_teardown,
10354 test_AES_GCM_auth_decryption_test_case_192_5),
10355 TEST_CASE_ST(ut_setup, ut_teardown,
10356 test_AES_GCM_auth_decryption_test_case_192_6),
10357 TEST_CASE_ST(ut_setup, ut_teardown,
10358 test_AES_GCM_auth_decryption_test_case_192_7),
10360 /** AES GCM Authenticated Encryption 256 bits key */
10361 TEST_CASE_ST(ut_setup, ut_teardown,
10362 test_AES_GCM_auth_encryption_test_case_256_1),
10363 TEST_CASE_ST(ut_setup, ut_teardown,
10364 test_AES_GCM_auth_encryption_test_case_256_2),
10365 TEST_CASE_ST(ut_setup, ut_teardown,
10366 test_AES_GCM_auth_encryption_test_case_256_3),
10367 TEST_CASE_ST(ut_setup, ut_teardown,
10368 test_AES_GCM_auth_encryption_test_case_256_4),
10369 TEST_CASE_ST(ut_setup, ut_teardown,
10370 test_AES_GCM_auth_encryption_test_case_256_5),
10371 TEST_CASE_ST(ut_setup, ut_teardown,
10372 test_AES_GCM_auth_encryption_test_case_256_6),
10373 TEST_CASE_ST(ut_setup, ut_teardown,
10374 test_AES_GCM_auth_encryption_test_case_256_7),
10376 /** AES GMAC Authentication */
10377 TEST_CASE_ST(ut_setup, ut_teardown,
10378 test_AES_GMAC_authentication_test_case_1),
10379 TEST_CASE_ST(ut_setup, ut_teardown,
10380 test_AES_GMAC_authentication_verify_test_case_1),
10381 TEST_CASE_ST(ut_setup, ut_teardown,
10382 test_AES_GMAC_authentication_test_case_2),
10383 TEST_CASE_ST(ut_setup, ut_teardown,
10384 test_AES_GMAC_authentication_verify_test_case_2),
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 test_AES_GMAC_authentication_test_case_3),
10387 TEST_CASE_ST(ut_setup, ut_teardown,
10388 test_AES_GMAC_authentication_verify_test_case_3),
10390 /** SNOW 3G encrypt only (UEA2) */
10391 TEST_CASE_ST(ut_setup, ut_teardown,
10392 test_snow3g_encryption_test_case_1),
10393 TEST_CASE_ST(ut_setup, ut_teardown,
10394 test_snow3g_encryption_test_case_2),
10395 TEST_CASE_ST(ut_setup, ut_teardown,
10396 test_snow3g_encryption_test_case_3),
10397 TEST_CASE_ST(ut_setup, ut_teardown,
10398 test_snow3g_encryption_test_case_4),
10399 TEST_CASE_ST(ut_setup, ut_teardown,
10400 test_snow3g_encryption_test_case_5),
10402 TEST_CASE_ST(ut_setup, ut_teardown,
10403 test_snow3g_encryption_test_case_1_oop),
10404 TEST_CASE_ST(ut_setup, ut_teardown,
10405 test_snow3g_decryption_test_case_1_oop),
10407 /** SNOW 3G generate auth, then encrypt (UEA2) */
10408 TEST_CASE_ST(ut_setup, ut_teardown,
10409 test_snow3g_auth_cipher_test_case_1),
10410 TEST_CASE_ST(ut_setup, ut_teardown,
10411 test_snow3g_auth_cipher_test_case_2),
10412 TEST_CASE_ST(ut_setup, ut_teardown,
10413 test_snow3g_auth_cipher_test_case_2_oop),
10414 TEST_CASE_ST(ut_setup, ut_teardown,
10415 test_snow3g_auth_cipher_part_digest_enc),
10416 TEST_CASE_ST(ut_setup, ut_teardown,
10417 test_snow3g_auth_cipher_part_digest_enc_oop),
10418 TEST_CASE_ST(ut_setup, ut_teardown,
10419 test_snow3g_auth_cipher_test_case_3_sgl),
10420 TEST_CASE_ST(ut_setup, ut_teardown,
10421 test_snow3g_auth_cipher_test_case_3_oop_sgl),
10422 TEST_CASE_ST(ut_setup, ut_teardown,
10423 test_snow3g_auth_cipher_part_digest_enc_sgl),
10424 TEST_CASE_ST(ut_setup, ut_teardown,
10425 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
10427 /** SNOW 3G decrypt (UEA2), then verify auth */
10428 TEST_CASE_ST(ut_setup, ut_teardown,
10429 test_snow3g_auth_cipher_verify_test_case_1),
10430 TEST_CASE_ST(ut_setup, ut_teardown,
10431 test_snow3g_auth_cipher_verify_test_case_2),
10432 TEST_CASE_ST(ut_setup, ut_teardown,
10433 test_snow3g_auth_cipher_verify_test_case_2_oop),
10434 TEST_CASE_ST(ut_setup, ut_teardown,
10435 test_snow3g_auth_cipher_verify_part_digest_enc),
10436 TEST_CASE_ST(ut_setup, ut_teardown,
10437 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
10438 TEST_CASE_ST(ut_setup, ut_teardown,
10439 test_snow3g_auth_cipher_verify_test_case_3_sgl),
10440 TEST_CASE_ST(ut_setup, ut_teardown,
10441 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
10442 TEST_CASE_ST(ut_setup, ut_teardown,
10443 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
10444 TEST_CASE_ST(ut_setup, ut_teardown,
10445 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
10447 /** SNOW 3G decrypt only (UEA2) */
10448 TEST_CASE_ST(ut_setup, ut_teardown,
10449 test_snow3g_decryption_test_case_1),
10450 TEST_CASE_ST(ut_setup, ut_teardown,
10451 test_snow3g_decryption_test_case_2),
10452 TEST_CASE_ST(ut_setup, ut_teardown,
10453 test_snow3g_decryption_test_case_3),
10454 TEST_CASE_ST(ut_setup, ut_teardown,
10455 test_snow3g_decryption_test_case_4),
10456 TEST_CASE_ST(ut_setup, ut_teardown,
10457 test_snow3g_decryption_test_case_5),
10458 TEST_CASE_ST(ut_setup, ut_teardown,
10459 test_snow3g_decryption_with_digest_test_case_1),
10460 TEST_CASE_ST(ut_setup, ut_teardown,
10461 test_snow3g_hash_generate_test_case_1),
10462 TEST_CASE_ST(ut_setup, ut_teardown,
10463 test_snow3g_hash_generate_test_case_2),
10464 TEST_CASE_ST(ut_setup, ut_teardown,
10465 test_snow3g_hash_generate_test_case_3),
10466 TEST_CASE_ST(ut_setup, ut_teardown,
10467 test_snow3g_hash_verify_test_case_1),
10468 TEST_CASE_ST(ut_setup, ut_teardown,
10469 test_snow3g_hash_verify_test_case_2),
10470 TEST_CASE_ST(ut_setup, ut_teardown,
10471 test_snow3g_hash_verify_test_case_3),
10472 TEST_CASE_ST(ut_setup, ut_teardown,
10473 test_snow3g_cipher_auth_test_case_1),
10474 TEST_CASE_ST(ut_setup, ut_teardown,
10475 test_snow3g_auth_cipher_with_digest_test_case_1),
10477 /** ZUC encrypt only (EEA3) */
10478 TEST_CASE_ST(ut_setup, ut_teardown,
10479 test_zuc_encryption_test_case_1),
10480 TEST_CASE_ST(ut_setup, ut_teardown,
10481 test_zuc_encryption_test_case_2),
10482 TEST_CASE_ST(ut_setup, ut_teardown,
10483 test_zuc_encryption_test_case_3),
10484 TEST_CASE_ST(ut_setup, ut_teardown,
10485 test_zuc_encryption_test_case_4),
10486 TEST_CASE_ST(ut_setup, ut_teardown,
10487 test_zuc_encryption_test_case_5),
10489 /** ZUC authenticate (EIA3) */
10490 TEST_CASE_ST(ut_setup, ut_teardown,
10491 test_zuc_hash_generate_test_case_6),
10492 TEST_CASE_ST(ut_setup, ut_teardown,
10493 test_zuc_hash_generate_test_case_7),
10494 TEST_CASE_ST(ut_setup, ut_teardown,
10495 test_zuc_hash_generate_test_case_8),
10497 /** ZUC alg-chain (EEA3/EIA3) */
10498 TEST_CASE_ST(ut_setup, ut_teardown,
10499 test_zuc_cipher_auth_test_case_1),
10500 TEST_CASE_ST(ut_setup, ut_teardown,
10501 test_zuc_cipher_auth_test_case_2),
10503 /** ZUC generate auth, then encrypt (EEA3) */
10504 TEST_CASE_ST(ut_setup, ut_teardown,
10505 test_zuc_auth_cipher_test_case_1),
10506 TEST_CASE_ST(ut_setup, ut_teardown,
10507 test_zuc_auth_cipher_test_case_1_oop),
10508 TEST_CASE_ST(ut_setup, ut_teardown,
10509 test_zuc_auth_cipher_test_case_1_sgl),
10510 TEST_CASE_ST(ut_setup, ut_teardown,
10511 test_zuc_auth_cipher_test_case_1_oop_sgl),
10513 /** ZUC decrypt (EEA3), then verify auth */
10514 TEST_CASE_ST(ut_setup, ut_teardown,
10515 test_zuc_auth_cipher_verify_test_case_1),
10516 TEST_CASE_ST(ut_setup, ut_teardown,
10517 test_zuc_auth_cipher_verify_test_case_1_oop),
10518 TEST_CASE_ST(ut_setup, ut_teardown,
10519 test_zuc_auth_cipher_verify_test_case_1_sgl),
10520 TEST_CASE_ST(ut_setup, ut_teardown,
10521 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
10523 /** HMAC_MD5 Authentication */
10524 TEST_CASE_ST(ut_setup, ut_teardown,
10525 test_MD5_HMAC_generate_case_1),
10526 TEST_CASE_ST(ut_setup, ut_teardown,
10527 test_MD5_HMAC_verify_case_1),
10528 TEST_CASE_ST(ut_setup, ut_teardown,
10529 test_MD5_HMAC_generate_case_2),
10530 TEST_CASE_ST(ut_setup, ut_teardown,
10531 test_MD5_HMAC_verify_case_2),
10533 /** NULL algo tests done in chain_all,
10534 * cipheronly and authonly suites
10537 /** KASUMI tests */
10538 TEST_CASE_ST(ut_setup, ut_teardown,
10539 test_kasumi_hash_generate_test_case_1),
10540 TEST_CASE_ST(ut_setup, ut_teardown,
10541 test_kasumi_hash_generate_test_case_2),
10542 TEST_CASE_ST(ut_setup, ut_teardown,
10543 test_kasumi_hash_generate_test_case_3),
10544 TEST_CASE_ST(ut_setup, ut_teardown,
10545 test_kasumi_hash_generate_test_case_4),
10546 TEST_CASE_ST(ut_setup, ut_teardown,
10547 test_kasumi_hash_generate_test_case_5),
10548 TEST_CASE_ST(ut_setup, ut_teardown,
10549 test_kasumi_hash_generate_test_case_6),
10551 TEST_CASE_ST(ut_setup, ut_teardown,
10552 test_kasumi_hash_verify_test_case_1),
10553 TEST_CASE_ST(ut_setup, ut_teardown,
10554 test_kasumi_hash_verify_test_case_2),
10555 TEST_CASE_ST(ut_setup, ut_teardown,
10556 test_kasumi_hash_verify_test_case_3),
10557 TEST_CASE_ST(ut_setup, ut_teardown,
10558 test_kasumi_hash_verify_test_case_4),
10559 TEST_CASE_ST(ut_setup, ut_teardown,
10560 test_kasumi_hash_verify_test_case_5),
10562 TEST_CASE_ST(ut_setup, ut_teardown,
10563 test_kasumi_encryption_test_case_1),
10564 TEST_CASE_ST(ut_setup, ut_teardown,
10565 test_kasumi_encryption_test_case_3),
10566 TEST_CASE_ST(ut_setup, ut_teardown,
10567 test_kasumi_cipher_auth_test_case_1),
10569 /** KASUMI generate auth, then encrypt (F8) */
10570 TEST_CASE_ST(ut_setup, ut_teardown,
10571 test_kasumi_auth_cipher_test_case_1),
10572 TEST_CASE_ST(ut_setup, ut_teardown,
10573 test_kasumi_auth_cipher_test_case_2),
10574 TEST_CASE_ST(ut_setup, ut_teardown,
10575 test_kasumi_auth_cipher_test_case_2_oop),
10576 TEST_CASE_ST(ut_setup, ut_teardown,
10577 test_kasumi_auth_cipher_test_case_2_sgl),
10578 TEST_CASE_ST(ut_setup, ut_teardown,
10579 test_kasumi_auth_cipher_test_case_2_oop_sgl),
10581 /** KASUMI decrypt (F8), then verify auth */
10582 TEST_CASE_ST(ut_setup, ut_teardown,
10583 test_kasumi_auth_cipher_verify_test_case_1),
10584 TEST_CASE_ST(ut_setup, ut_teardown,
10585 test_kasumi_auth_cipher_verify_test_case_2),
10586 TEST_CASE_ST(ut_setup, ut_teardown,
10587 test_kasumi_auth_cipher_verify_test_case_2_oop),
10588 TEST_CASE_ST(ut_setup, ut_teardown,
10589 test_kasumi_auth_cipher_verify_test_case_2_sgl),
10590 TEST_CASE_ST(ut_setup, ut_teardown,
10591 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
10593 /** Negative tests */
10594 TEST_CASE_ST(ut_setup, ut_teardown,
10595 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10596 TEST_CASE_ST(ut_setup, ut_teardown,
10597 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10598 TEST_CASE_ST(ut_setup, ut_teardown,
10599 authentication_verify_AES128_GMAC_fail_data_corrupt),
10600 TEST_CASE_ST(ut_setup, ut_teardown,
10601 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10602 TEST_CASE_ST(ut_setup, ut_teardown,
10603 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10604 TEST_CASE_ST(ut_setup, ut_teardown,
10605 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10607 TEST_CASES_END() /**< NULL terminate unit test array */
10611 static struct unit_test_suite cryptodev_virtio_testsuite = {
10612 .suite_name = "Crypto VIRTIO Unit Test Suite",
10613 .setup = testsuite_setup,
10614 .teardown = testsuite_teardown,
10615 .unit_test_cases = {
10616 TEST_CASE_ST(ut_setup, ut_teardown,
10617 test_AES_cipheronly_virtio_all),
10619 TEST_CASES_END() /**< NULL terminate unit test array */
10623 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
10624 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
10625 .setup = testsuite_setup,
10626 .teardown = testsuite_teardown,
10627 .unit_test_cases = {
10628 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
10629 TEST_CASE_ST(ut_setup, ut_teardown,
10630 test_AES_GCM_authenticated_encryption_test_case_1),
10631 TEST_CASE_ST(ut_setup, ut_teardown,
10632 test_AES_GCM_authenticated_encryption_test_case_2),
10633 TEST_CASE_ST(ut_setup, ut_teardown,
10634 test_AES_GCM_authenticated_encryption_test_case_3),
10635 TEST_CASE_ST(ut_setup, ut_teardown,
10636 test_AES_GCM_authenticated_encryption_test_case_4),
10637 TEST_CASE_ST(ut_setup, ut_teardown,
10638 test_AES_GCM_authenticated_encryption_test_case_5),
10639 TEST_CASE_ST(ut_setup, ut_teardown,
10640 test_AES_GCM_authenticated_encryption_test_case_6),
10641 TEST_CASE_ST(ut_setup, ut_teardown,
10642 test_AES_GCM_authenticated_encryption_test_case_7),
10644 /** AES GCM Authenticated Decryption */
10645 TEST_CASE_ST(ut_setup, ut_teardown,
10646 test_AES_GCM_authenticated_decryption_test_case_1),
10647 TEST_CASE_ST(ut_setup, ut_teardown,
10648 test_AES_GCM_authenticated_decryption_test_case_2),
10649 TEST_CASE_ST(ut_setup, ut_teardown,
10650 test_AES_GCM_authenticated_decryption_test_case_3),
10651 TEST_CASE_ST(ut_setup, ut_teardown,
10652 test_AES_GCM_authenticated_decryption_test_case_4),
10653 TEST_CASE_ST(ut_setup, ut_teardown,
10654 test_AES_GCM_authenticated_decryption_test_case_5),
10655 TEST_CASE_ST(ut_setup, ut_teardown,
10656 test_AES_GCM_authenticated_decryption_test_case_6),
10657 TEST_CASE_ST(ut_setup, ut_teardown,
10658 test_AES_GCM_authenticated_decryption_test_case_7),
10660 /** AES GCM Authenticated Encryption 192 bits key */
10661 TEST_CASE_ST(ut_setup, ut_teardown,
10662 test_AES_GCM_auth_encryption_test_case_192_1),
10663 TEST_CASE_ST(ut_setup, ut_teardown,
10664 test_AES_GCM_auth_encryption_test_case_192_2),
10665 TEST_CASE_ST(ut_setup, ut_teardown,
10666 test_AES_GCM_auth_encryption_test_case_192_3),
10667 TEST_CASE_ST(ut_setup, ut_teardown,
10668 test_AES_GCM_auth_encryption_test_case_192_4),
10669 TEST_CASE_ST(ut_setup, ut_teardown,
10670 test_AES_GCM_auth_encryption_test_case_192_5),
10671 TEST_CASE_ST(ut_setup, ut_teardown,
10672 test_AES_GCM_auth_encryption_test_case_192_6),
10673 TEST_CASE_ST(ut_setup, ut_teardown,
10674 test_AES_GCM_auth_encryption_test_case_192_7),
10676 /** AES GCM Authenticated Decryption 192 bits key */
10677 TEST_CASE_ST(ut_setup, ut_teardown,
10678 test_AES_GCM_auth_decryption_test_case_192_1),
10679 TEST_CASE_ST(ut_setup, ut_teardown,
10680 test_AES_GCM_auth_decryption_test_case_192_2),
10681 TEST_CASE_ST(ut_setup, ut_teardown,
10682 test_AES_GCM_auth_decryption_test_case_192_3),
10683 TEST_CASE_ST(ut_setup, ut_teardown,
10684 test_AES_GCM_auth_decryption_test_case_192_4),
10685 TEST_CASE_ST(ut_setup, ut_teardown,
10686 test_AES_GCM_auth_decryption_test_case_192_5),
10687 TEST_CASE_ST(ut_setup, ut_teardown,
10688 test_AES_GCM_auth_decryption_test_case_192_6),
10689 TEST_CASE_ST(ut_setup, ut_teardown,
10690 test_AES_GCM_auth_decryption_test_case_192_7),
10692 /** AES GCM Authenticated Encryption 256 bits key */
10693 TEST_CASE_ST(ut_setup, ut_teardown,
10694 test_AES_GCM_auth_encryption_test_case_256_1),
10695 TEST_CASE_ST(ut_setup, ut_teardown,
10696 test_AES_GCM_auth_encryption_test_case_256_2),
10697 TEST_CASE_ST(ut_setup, ut_teardown,
10698 test_AES_GCM_auth_encryption_test_case_256_3),
10699 TEST_CASE_ST(ut_setup, ut_teardown,
10700 test_AES_GCM_auth_encryption_test_case_256_4),
10701 TEST_CASE_ST(ut_setup, ut_teardown,
10702 test_AES_GCM_auth_encryption_test_case_256_5),
10703 TEST_CASE_ST(ut_setup, ut_teardown,
10704 test_AES_GCM_auth_encryption_test_case_256_6),
10705 TEST_CASE_ST(ut_setup, ut_teardown,
10706 test_AES_GCM_auth_encryption_test_case_256_7),
10708 /** AES GCM Authenticated Decryption 256 bits key */
10709 TEST_CASE_ST(ut_setup, ut_teardown,
10710 test_AES_GCM_auth_decryption_test_case_256_1),
10711 TEST_CASE_ST(ut_setup, ut_teardown,
10712 test_AES_GCM_auth_decryption_test_case_256_2),
10713 TEST_CASE_ST(ut_setup, ut_teardown,
10714 test_AES_GCM_auth_decryption_test_case_256_3),
10715 TEST_CASE_ST(ut_setup, ut_teardown,
10716 test_AES_GCM_auth_decryption_test_case_256_4),
10717 TEST_CASE_ST(ut_setup, ut_teardown,
10718 test_AES_GCM_auth_decryption_test_case_256_5),
10719 TEST_CASE_ST(ut_setup, ut_teardown,
10720 test_AES_GCM_auth_decryption_test_case_256_6),
10721 TEST_CASE_ST(ut_setup, ut_teardown,
10722 test_AES_GCM_auth_decryption_test_case_256_7),
10724 /** AES GCM Authenticated Encryption big aad size */
10725 TEST_CASE_ST(ut_setup, ut_teardown,
10726 test_AES_GCM_auth_encryption_test_case_aad_1),
10727 TEST_CASE_ST(ut_setup, ut_teardown,
10728 test_AES_GCM_auth_encryption_test_case_aad_2),
10730 /** AES GCM Authenticated Decryption big aad size */
10731 TEST_CASE_ST(ut_setup, ut_teardown,
10732 test_AES_GCM_auth_decryption_test_case_aad_1),
10733 TEST_CASE_ST(ut_setup, ut_teardown,
10734 test_AES_GCM_auth_decryption_test_case_aad_2),
10736 /** Session-less tests */
10737 TEST_CASE_ST(ut_setup, ut_teardown,
10738 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
10739 TEST_CASE_ST(ut_setup, ut_teardown,
10740 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
10742 /** AES GMAC Authentication */
10743 TEST_CASE_ST(ut_setup, ut_teardown,
10744 test_AES_GMAC_authentication_test_case_1),
10745 TEST_CASE_ST(ut_setup, ut_teardown,
10746 test_AES_GMAC_authentication_verify_test_case_1),
10747 TEST_CASE_ST(ut_setup, ut_teardown,
10748 test_AES_GMAC_authentication_test_case_2),
10749 TEST_CASE_ST(ut_setup, ut_teardown,
10750 test_AES_GMAC_authentication_verify_test_case_2),
10751 TEST_CASE_ST(ut_setup, ut_teardown,
10752 test_AES_GMAC_authentication_test_case_3),
10753 TEST_CASE_ST(ut_setup, ut_teardown,
10754 test_AES_GMAC_authentication_verify_test_case_3),
10755 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
10757 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
10758 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
10759 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
10760 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
10761 TEST_CASE_ST(ut_setup, ut_teardown,
10762 test_DES_cipheronly_mb_all),
10763 TEST_CASE_ST(ut_setup, ut_teardown,
10764 test_DES_docsis_mb_all),
10765 TEST_CASE_ST(ut_setup, ut_teardown,
10766 test_3DES_cipheronly_mb_all),
10767 TEST_CASE_ST(ut_setup, ut_teardown,
10768 test_AES_CCM_authenticated_encryption_test_case_128_1),
10769 TEST_CASE_ST(ut_setup, ut_teardown,
10770 test_AES_CCM_authenticated_decryption_test_case_128_1),
10771 TEST_CASE_ST(ut_setup, ut_teardown,
10772 test_AES_CCM_authenticated_encryption_test_case_128_2),
10773 TEST_CASE_ST(ut_setup, ut_teardown,
10774 test_AES_CCM_authenticated_decryption_test_case_128_2),
10775 TEST_CASE_ST(ut_setup, ut_teardown,
10776 test_AES_CCM_authenticated_encryption_test_case_128_3),
10777 TEST_CASE_ST(ut_setup, ut_teardown,
10778 test_AES_CCM_authenticated_decryption_test_case_128_3),
10780 TEST_CASES_END() /**< NULL terminate unit test array */
10784 static struct unit_test_suite cryptodev_openssl_testsuite = {
10785 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
10786 .setup = testsuite_setup,
10787 .teardown = testsuite_teardown,
10788 .unit_test_cases = {
10789 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10790 TEST_CASE_ST(ut_setup, ut_teardown,
10791 test_multi_session_random_usage),
10792 TEST_CASE_ST(ut_setup, ut_teardown,
10793 test_AES_chain_openssl_all),
10794 TEST_CASE_ST(ut_setup, ut_teardown,
10795 test_AES_cipheronly_openssl_all),
10796 TEST_CASE_ST(ut_setup, ut_teardown,
10797 test_3DES_chain_openssl_all),
10798 TEST_CASE_ST(ut_setup, ut_teardown,
10799 test_3DES_cipheronly_openssl_all),
10800 TEST_CASE_ST(ut_setup, ut_teardown,
10801 test_DES_cipheronly_openssl_all),
10802 TEST_CASE_ST(ut_setup, ut_teardown,
10803 test_DES_docsis_openssl_all),
10804 TEST_CASE_ST(ut_setup, ut_teardown,
10805 test_authonly_openssl_all),
10807 /** AES GCM Authenticated Encryption */
10808 TEST_CASE_ST(ut_setup, ut_teardown,
10809 test_AES_GCM_authenticated_encryption_test_case_1),
10810 TEST_CASE_ST(ut_setup, ut_teardown,
10811 test_AES_GCM_authenticated_encryption_test_case_2),
10812 TEST_CASE_ST(ut_setup, ut_teardown,
10813 test_AES_GCM_authenticated_encryption_test_case_3),
10814 TEST_CASE_ST(ut_setup, ut_teardown,
10815 test_AES_GCM_authenticated_encryption_test_case_4),
10816 TEST_CASE_ST(ut_setup, ut_teardown,
10817 test_AES_GCM_authenticated_encryption_test_case_5),
10818 TEST_CASE_ST(ut_setup, ut_teardown,
10819 test_AES_GCM_authenticated_encryption_test_case_6),
10820 TEST_CASE_ST(ut_setup, ut_teardown,
10821 test_AES_GCM_authenticated_encryption_test_case_7),
10823 /** AES GCM Authenticated Decryption */
10824 TEST_CASE_ST(ut_setup, ut_teardown,
10825 test_AES_GCM_authenticated_decryption_test_case_1),
10826 TEST_CASE_ST(ut_setup, ut_teardown,
10827 test_AES_GCM_authenticated_decryption_test_case_2),
10828 TEST_CASE_ST(ut_setup, ut_teardown,
10829 test_AES_GCM_authenticated_decryption_test_case_3),
10830 TEST_CASE_ST(ut_setup, ut_teardown,
10831 test_AES_GCM_authenticated_decryption_test_case_4),
10832 TEST_CASE_ST(ut_setup, ut_teardown,
10833 test_AES_GCM_authenticated_decryption_test_case_5),
10834 TEST_CASE_ST(ut_setup, ut_teardown,
10835 test_AES_GCM_authenticated_decryption_test_case_6),
10836 TEST_CASE_ST(ut_setup, ut_teardown,
10837 test_AES_GCM_authenticated_decryption_test_case_7),
10840 /** AES GCM Authenticated Encryption 192 bits key */
10841 TEST_CASE_ST(ut_setup, ut_teardown,
10842 test_AES_GCM_auth_encryption_test_case_192_1),
10843 TEST_CASE_ST(ut_setup, ut_teardown,
10844 test_AES_GCM_auth_encryption_test_case_192_2),
10845 TEST_CASE_ST(ut_setup, ut_teardown,
10846 test_AES_GCM_auth_encryption_test_case_192_3),
10847 TEST_CASE_ST(ut_setup, ut_teardown,
10848 test_AES_GCM_auth_encryption_test_case_192_4),
10849 TEST_CASE_ST(ut_setup, ut_teardown,
10850 test_AES_GCM_auth_encryption_test_case_192_5),
10851 TEST_CASE_ST(ut_setup, ut_teardown,
10852 test_AES_GCM_auth_encryption_test_case_192_6),
10853 TEST_CASE_ST(ut_setup, ut_teardown,
10854 test_AES_GCM_auth_encryption_test_case_192_7),
10856 /** AES GCM Authenticated Decryption 192 bits key */
10857 TEST_CASE_ST(ut_setup, ut_teardown,
10858 test_AES_GCM_auth_decryption_test_case_192_1),
10859 TEST_CASE_ST(ut_setup, ut_teardown,
10860 test_AES_GCM_auth_decryption_test_case_192_2),
10861 TEST_CASE_ST(ut_setup, ut_teardown,
10862 test_AES_GCM_auth_decryption_test_case_192_3),
10863 TEST_CASE_ST(ut_setup, ut_teardown,
10864 test_AES_GCM_auth_decryption_test_case_192_4),
10865 TEST_CASE_ST(ut_setup, ut_teardown,
10866 test_AES_GCM_auth_decryption_test_case_192_5),
10867 TEST_CASE_ST(ut_setup, ut_teardown,
10868 test_AES_GCM_auth_decryption_test_case_192_6),
10869 TEST_CASE_ST(ut_setup, ut_teardown,
10870 test_AES_GCM_auth_decryption_test_case_192_7),
10872 /** AES GCM Authenticated Encryption 256 bits key */
10873 TEST_CASE_ST(ut_setup, ut_teardown,
10874 test_AES_GCM_auth_encryption_test_case_256_1),
10875 TEST_CASE_ST(ut_setup, ut_teardown,
10876 test_AES_GCM_auth_encryption_test_case_256_2),
10877 TEST_CASE_ST(ut_setup, ut_teardown,
10878 test_AES_GCM_auth_encryption_test_case_256_3),
10879 TEST_CASE_ST(ut_setup, ut_teardown,
10880 test_AES_GCM_auth_encryption_test_case_256_4),
10881 TEST_CASE_ST(ut_setup, ut_teardown,
10882 test_AES_GCM_auth_encryption_test_case_256_5),
10883 TEST_CASE_ST(ut_setup, ut_teardown,
10884 test_AES_GCM_auth_encryption_test_case_256_6),
10885 TEST_CASE_ST(ut_setup, ut_teardown,
10886 test_AES_GCM_auth_encryption_test_case_256_7),
10888 /** AES GCM Authenticated Decryption 256 bits key */
10889 TEST_CASE_ST(ut_setup, ut_teardown,
10890 test_AES_GCM_auth_decryption_test_case_256_1),
10891 TEST_CASE_ST(ut_setup, ut_teardown,
10892 test_AES_GCM_auth_decryption_test_case_256_2),
10893 TEST_CASE_ST(ut_setup, ut_teardown,
10894 test_AES_GCM_auth_decryption_test_case_256_3),
10895 TEST_CASE_ST(ut_setup, ut_teardown,
10896 test_AES_GCM_auth_decryption_test_case_256_4),
10897 TEST_CASE_ST(ut_setup, ut_teardown,
10898 test_AES_GCM_auth_decryption_test_case_256_5),
10899 TEST_CASE_ST(ut_setup, ut_teardown,
10900 test_AES_GCM_auth_decryption_test_case_256_6),
10901 TEST_CASE_ST(ut_setup, ut_teardown,
10902 test_AES_GCM_auth_decryption_test_case_256_7),
10904 /** AES GMAC Authentication */
10905 TEST_CASE_ST(ut_setup, ut_teardown,
10906 test_AES_GMAC_authentication_test_case_1),
10907 TEST_CASE_ST(ut_setup, ut_teardown,
10908 test_AES_GMAC_authentication_verify_test_case_1),
10909 TEST_CASE_ST(ut_setup, ut_teardown,
10910 test_AES_GMAC_authentication_test_case_2),
10911 TEST_CASE_ST(ut_setup, ut_teardown,
10912 test_AES_GMAC_authentication_verify_test_case_2),
10913 TEST_CASE_ST(ut_setup, ut_teardown,
10914 test_AES_GMAC_authentication_test_case_3),
10915 TEST_CASE_ST(ut_setup, ut_teardown,
10916 test_AES_GMAC_authentication_verify_test_case_3),
10917 TEST_CASE_ST(ut_setup, ut_teardown,
10918 test_AES_GMAC_authentication_test_case_4),
10919 TEST_CASE_ST(ut_setup, ut_teardown,
10920 test_AES_GMAC_authentication_verify_test_case_4),
10922 /** AES CCM Authenticated Encryption 128 bits key */
10923 TEST_CASE_ST(ut_setup, ut_teardown,
10924 test_AES_CCM_authenticated_encryption_test_case_128_1),
10925 TEST_CASE_ST(ut_setup, ut_teardown,
10926 test_AES_CCM_authenticated_encryption_test_case_128_2),
10927 TEST_CASE_ST(ut_setup, ut_teardown,
10928 test_AES_CCM_authenticated_encryption_test_case_128_3),
10930 /** AES CCM Authenticated Decryption 128 bits key*/
10931 TEST_CASE_ST(ut_setup, ut_teardown,
10932 test_AES_CCM_authenticated_decryption_test_case_128_1),
10933 TEST_CASE_ST(ut_setup, ut_teardown,
10934 test_AES_CCM_authenticated_decryption_test_case_128_2),
10935 TEST_CASE_ST(ut_setup, ut_teardown,
10936 test_AES_CCM_authenticated_decryption_test_case_128_3),
10938 /** AES CCM Authenticated Encryption 192 bits key */
10939 TEST_CASE_ST(ut_setup, ut_teardown,
10940 test_AES_CCM_authenticated_encryption_test_case_192_1),
10941 TEST_CASE_ST(ut_setup, ut_teardown,
10942 test_AES_CCM_authenticated_encryption_test_case_192_2),
10943 TEST_CASE_ST(ut_setup, ut_teardown,
10944 test_AES_CCM_authenticated_encryption_test_case_192_3),
10946 /** AES CCM Authenticated Decryption 192 bits key*/
10947 TEST_CASE_ST(ut_setup, ut_teardown,
10948 test_AES_CCM_authenticated_decryption_test_case_192_1),
10949 TEST_CASE_ST(ut_setup, ut_teardown,
10950 test_AES_CCM_authenticated_decryption_test_case_192_2),
10951 TEST_CASE_ST(ut_setup, ut_teardown,
10952 test_AES_CCM_authenticated_decryption_test_case_192_3),
10954 /** AES CCM Authenticated Encryption 256 bits key */
10955 TEST_CASE_ST(ut_setup, ut_teardown,
10956 test_AES_CCM_authenticated_encryption_test_case_256_1),
10957 TEST_CASE_ST(ut_setup, ut_teardown,
10958 test_AES_CCM_authenticated_encryption_test_case_256_2),
10959 TEST_CASE_ST(ut_setup, ut_teardown,
10960 test_AES_CCM_authenticated_encryption_test_case_256_3),
10962 /** AES CCM Authenticated Decryption 256 bits key*/
10963 TEST_CASE_ST(ut_setup, ut_teardown,
10964 test_AES_CCM_authenticated_decryption_test_case_256_1),
10965 TEST_CASE_ST(ut_setup, ut_teardown,
10966 test_AES_CCM_authenticated_decryption_test_case_256_2),
10967 TEST_CASE_ST(ut_setup, ut_teardown,
10968 test_AES_CCM_authenticated_decryption_test_case_256_3),
10970 /** Scatter-Gather */
10971 TEST_CASE_ST(ut_setup, ut_teardown,
10972 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10974 /** Negative tests */
10975 TEST_CASE_ST(ut_setup, ut_teardown,
10976 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10977 TEST_CASE_ST(ut_setup, ut_teardown,
10978 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10979 TEST_CASE_ST(ut_setup, ut_teardown,
10980 authentication_verify_AES128_GMAC_fail_data_corrupt),
10981 TEST_CASE_ST(ut_setup, ut_teardown,
10982 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10983 TEST_CASE_ST(ut_setup, ut_teardown,
10984 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10985 TEST_CASE_ST(ut_setup, ut_teardown,
10986 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10988 TEST_CASES_END() /**< NULL terminate unit test array */
10992 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
10993 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
10994 .setup = testsuite_setup,
10995 .teardown = testsuite_teardown,
10996 .unit_test_cases = {
10997 /** AES GCM Authenticated Encryption */
10998 TEST_CASE_ST(ut_setup, ut_teardown,
10999 test_AES_GCM_authenticated_encryption_test_case_1),
11000 TEST_CASE_ST(ut_setup, ut_teardown,
11001 test_AES_GCM_authenticated_encryption_test_case_2),
11002 TEST_CASE_ST(ut_setup, ut_teardown,
11003 test_AES_GCM_authenticated_encryption_test_case_3),
11004 TEST_CASE_ST(ut_setup, ut_teardown,
11005 test_AES_GCM_authenticated_encryption_test_case_4),
11006 TEST_CASE_ST(ut_setup, ut_teardown,
11007 test_AES_GCM_authenticated_encryption_test_case_5),
11008 TEST_CASE_ST(ut_setup, ut_teardown,
11009 test_AES_GCM_authenticated_encryption_test_case_6),
11010 TEST_CASE_ST(ut_setup, ut_teardown,
11011 test_AES_GCM_authenticated_encryption_test_case_7),
11013 /** AES GCM Authenticated Decryption */
11014 TEST_CASE_ST(ut_setup, ut_teardown,
11015 test_AES_GCM_authenticated_decryption_test_case_1),
11016 TEST_CASE_ST(ut_setup, ut_teardown,
11017 test_AES_GCM_authenticated_decryption_test_case_2),
11018 TEST_CASE_ST(ut_setup, ut_teardown,
11019 test_AES_GCM_authenticated_decryption_test_case_3),
11020 TEST_CASE_ST(ut_setup, ut_teardown,
11021 test_AES_GCM_authenticated_decryption_test_case_4),
11022 TEST_CASE_ST(ut_setup, ut_teardown,
11023 test_AES_GCM_authenticated_decryption_test_case_5),
11024 TEST_CASE_ST(ut_setup, ut_teardown,
11025 test_AES_GCM_authenticated_decryption_test_case_6),
11026 TEST_CASE_ST(ut_setup, ut_teardown,
11027 test_AES_GCM_authenticated_decryption_test_case_7),
11029 /** AES GCM Authenticated Encryption 192 bits key */
11030 TEST_CASE_ST(ut_setup, ut_teardown,
11031 test_AES_GCM_auth_encryption_test_case_192_1),
11032 TEST_CASE_ST(ut_setup, ut_teardown,
11033 test_AES_GCM_auth_encryption_test_case_192_2),
11034 TEST_CASE_ST(ut_setup, ut_teardown,
11035 test_AES_GCM_auth_encryption_test_case_192_3),
11036 TEST_CASE_ST(ut_setup, ut_teardown,
11037 test_AES_GCM_auth_encryption_test_case_192_4),
11038 TEST_CASE_ST(ut_setup, ut_teardown,
11039 test_AES_GCM_auth_encryption_test_case_192_5),
11040 TEST_CASE_ST(ut_setup, ut_teardown,
11041 test_AES_GCM_auth_encryption_test_case_192_6),
11042 TEST_CASE_ST(ut_setup, ut_teardown,
11043 test_AES_GCM_auth_encryption_test_case_192_7),
11045 /** AES GCM Authenticated Decryption 192 bits key */
11046 TEST_CASE_ST(ut_setup, ut_teardown,
11047 test_AES_GCM_auth_decryption_test_case_192_1),
11048 TEST_CASE_ST(ut_setup, ut_teardown,
11049 test_AES_GCM_auth_decryption_test_case_192_2),
11050 TEST_CASE_ST(ut_setup, ut_teardown,
11051 test_AES_GCM_auth_decryption_test_case_192_3),
11052 TEST_CASE_ST(ut_setup, ut_teardown,
11053 test_AES_GCM_auth_decryption_test_case_192_4),
11054 TEST_CASE_ST(ut_setup, ut_teardown,
11055 test_AES_GCM_auth_decryption_test_case_192_5),
11056 TEST_CASE_ST(ut_setup, ut_teardown,
11057 test_AES_GCM_auth_decryption_test_case_192_6),
11058 TEST_CASE_ST(ut_setup, ut_teardown,
11059 test_AES_GCM_auth_decryption_test_case_192_7),
11061 /** AES GCM Authenticated Encryption 256 bits key */
11062 TEST_CASE_ST(ut_setup, ut_teardown,
11063 test_AES_GCM_auth_encryption_test_case_256_1),
11064 TEST_CASE_ST(ut_setup, ut_teardown,
11065 test_AES_GCM_auth_encryption_test_case_256_2),
11066 TEST_CASE_ST(ut_setup, ut_teardown,
11067 test_AES_GCM_auth_encryption_test_case_256_3),
11068 TEST_CASE_ST(ut_setup, ut_teardown,
11069 test_AES_GCM_auth_encryption_test_case_256_4),
11070 TEST_CASE_ST(ut_setup, ut_teardown,
11071 test_AES_GCM_auth_encryption_test_case_256_5),
11072 TEST_CASE_ST(ut_setup, ut_teardown,
11073 test_AES_GCM_auth_encryption_test_case_256_6),
11074 TEST_CASE_ST(ut_setup, ut_teardown,
11075 test_AES_GCM_auth_encryption_test_case_256_7),
11077 /** AES GCM Authenticated Decryption 256 bits key */
11078 TEST_CASE_ST(ut_setup, ut_teardown,
11079 test_AES_GCM_auth_decryption_test_case_256_1),
11080 TEST_CASE_ST(ut_setup, ut_teardown,
11081 test_AES_GCM_auth_decryption_test_case_256_2),
11082 TEST_CASE_ST(ut_setup, ut_teardown,
11083 test_AES_GCM_auth_decryption_test_case_256_3),
11084 TEST_CASE_ST(ut_setup, ut_teardown,
11085 test_AES_GCM_auth_decryption_test_case_256_4),
11086 TEST_CASE_ST(ut_setup, ut_teardown,
11087 test_AES_GCM_auth_decryption_test_case_256_5),
11088 TEST_CASE_ST(ut_setup, ut_teardown,
11089 test_AES_GCM_auth_decryption_test_case_256_6),
11090 TEST_CASE_ST(ut_setup, ut_teardown,
11091 test_AES_GCM_auth_decryption_test_case_256_7),
11093 /** AES GCM Authenticated Encryption big aad size */
11094 TEST_CASE_ST(ut_setup, ut_teardown,
11095 test_AES_GCM_auth_encryption_test_case_aad_1),
11096 TEST_CASE_ST(ut_setup, ut_teardown,
11097 test_AES_GCM_auth_encryption_test_case_aad_2),
11099 /** AES GCM Authenticated Decryption big aad size */
11100 TEST_CASE_ST(ut_setup, ut_teardown,
11101 test_AES_GCM_auth_decryption_test_case_aad_1),
11102 TEST_CASE_ST(ut_setup, ut_teardown,
11103 test_AES_GCM_auth_decryption_test_case_aad_2),
11105 /** AES GMAC Authentication */
11106 TEST_CASE_ST(ut_setup, ut_teardown,
11107 test_AES_GMAC_authentication_test_case_1),
11108 TEST_CASE_ST(ut_setup, ut_teardown,
11109 test_AES_GMAC_authentication_verify_test_case_1),
11110 TEST_CASE_ST(ut_setup, ut_teardown,
11111 test_AES_GMAC_authentication_test_case_3),
11112 TEST_CASE_ST(ut_setup, ut_teardown,
11113 test_AES_GMAC_authentication_verify_test_case_3),
11114 TEST_CASE_ST(ut_setup, ut_teardown,
11115 test_AES_GMAC_authentication_test_case_4),
11116 TEST_CASE_ST(ut_setup, ut_teardown,
11117 test_AES_GMAC_authentication_verify_test_case_4),
11119 /** Negative tests */
11120 TEST_CASE_ST(ut_setup, ut_teardown,
11121 authentication_verify_AES128_GMAC_fail_data_corrupt),
11122 TEST_CASE_ST(ut_setup, ut_teardown,
11123 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11125 /** Out of place tests */
11126 TEST_CASE_ST(ut_setup, ut_teardown,
11127 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11128 TEST_CASE_ST(ut_setup, ut_teardown,
11129 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11131 /** Session-less tests */
11132 TEST_CASE_ST(ut_setup, ut_teardown,
11133 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11134 TEST_CASE_ST(ut_setup, ut_teardown,
11135 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11137 /** Scatter-Gather */
11138 TEST_CASE_ST(ut_setup, ut_teardown,
11139 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11141 TEST_CASES_END() /**< NULL terminate unit test array */
11145 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
11146 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
11147 .setup = testsuite_setup,
11148 .teardown = testsuite_teardown,
11149 .unit_test_cases = {
11150 /** KASUMI encrypt only (UEA1) */
11151 TEST_CASE_ST(ut_setup, ut_teardown,
11152 test_kasumi_encryption_test_case_1),
11153 TEST_CASE_ST(ut_setup, ut_teardown,
11154 test_kasumi_encryption_test_case_1_sgl),
11155 TEST_CASE_ST(ut_setup, ut_teardown,
11156 test_kasumi_encryption_test_case_2),
11157 TEST_CASE_ST(ut_setup, ut_teardown,
11158 test_kasumi_encryption_test_case_3),
11159 TEST_CASE_ST(ut_setup, ut_teardown,
11160 test_kasumi_encryption_test_case_4),
11161 TEST_CASE_ST(ut_setup, ut_teardown,
11162 test_kasumi_encryption_test_case_5),
11163 /** KASUMI decrypt only (UEA1) */
11164 TEST_CASE_ST(ut_setup, ut_teardown,
11165 test_kasumi_decryption_test_case_1),
11166 TEST_CASE_ST(ut_setup, ut_teardown,
11167 test_kasumi_decryption_test_case_2),
11168 TEST_CASE_ST(ut_setup, ut_teardown,
11169 test_kasumi_decryption_test_case_3),
11170 TEST_CASE_ST(ut_setup, ut_teardown,
11171 test_kasumi_decryption_test_case_4),
11172 TEST_CASE_ST(ut_setup, ut_teardown,
11173 test_kasumi_decryption_test_case_5),
11175 TEST_CASE_ST(ut_setup, ut_teardown,
11176 test_kasumi_encryption_test_case_1_oop),
11177 TEST_CASE_ST(ut_setup, ut_teardown,
11178 test_kasumi_encryption_test_case_1_oop_sgl),
11181 TEST_CASE_ST(ut_setup, ut_teardown,
11182 test_kasumi_decryption_test_case_1_oop),
11184 /** KASUMI hash only (UIA1) */
11185 TEST_CASE_ST(ut_setup, ut_teardown,
11186 test_kasumi_hash_generate_test_case_1),
11187 TEST_CASE_ST(ut_setup, ut_teardown,
11188 test_kasumi_hash_generate_test_case_2),
11189 TEST_CASE_ST(ut_setup, ut_teardown,
11190 test_kasumi_hash_generate_test_case_3),
11191 TEST_CASE_ST(ut_setup, ut_teardown,
11192 test_kasumi_hash_generate_test_case_4),
11193 TEST_CASE_ST(ut_setup, ut_teardown,
11194 test_kasumi_hash_generate_test_case_5),
11195 TEST_CASE_ST(ut_setup, ut_teardown,
11196 test_kasumi_hash_generate_test_case_6),
11197 TEST_CASE_ST(ut_setup, ut_teardown,
11198 test_kasumi_hash_verify_test_case_1),
11199 TEST_CASE_ST(ut_setup, ut_teardown,
11200 test_kasumi_hash_verify_test_case_2),
11201 TEST_CASE_ST(ut_setup, ut_teardown,
11202 test_kasumi_hash_verify_test_case_3),
11203 TEST_CASE_ST(ut_setup, ut_teardown,
11204 test_kasumi_hash_verify_test_case_4),
11205 TEST_CASE_ST(ut_setup, ut_teardown,
11206 test_kasumi_hash_verify_test_case_5),
11207 TEST_CASE_ST(ut_setup, ut_teardown,
11208 test_kasumi_cipher_auth_test_case_1),
11210 /** KASUMI generate auth, then encrypt (F8) */
11211 TEST_CASE_ST(ut_setup, ut_teardown,
11212 test_kasumi_auth_cipher_test_case_1),
11213 TEST_CASE_ST(ut_setup, ut_teardown,
11214 test_kasumi_auth_cipher_test_case_2),
11215 TEST_CASE_ST(ut_setup, ut_teardown,
11216 test_kasumi_auth_cipher_test_case_2_oop),
11217 TEST_CASE_ST(ut_setup, ut_teardown,
11218 test_kasumi_auth_cipher_test_case_2_sgl),
11219 TEST_CASE_ST(ut_setup, ut_teardown,
11220 test_kasumi_auth_cipher_test_case_2_oop_sgl),
11222 /** KASUMI decrypt (F8), then verify auth */
11223 TEST_CASE_ST(ut_setup, ut_teardown,
11224 test_kasumi_auth_cipher_verify_test_case_1),
11225 TEST_CASE_ST(ut_setup, ut_teardown,
11226 test_kasumi_auth_cipher_verify_test_case_2),
11227 TEST_CASE_ST(ut_setup, ut_teardown,
11228 test_kasumi_auth_cipher_verify_test_case_2_oop),
11229 TEST_CASE_ST(ut_setup, ut_teardown,
11230 test_kasumi_auth_cipher_verify_test_case_2_sgl),
11231 TEST_CASE_ST(ut_setup, ut_teardown,
11232 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
11233 TEST_CASES_END() /**< NULL terminate unit test array */
11236 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
11237 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
11238 .setup = testsuite_setup,
11239 .teardown = testsuite_teardown,
11240 .unit_test_cases = {
11241 /** SNOW 3G encrypt only (UEA2) */
11242 TEST_CASE_ST(ut_setup, ut_teardown,
11243 test_snow3g_encryption_test_case_1),
11244 TEST_CASE_ST(ut_setup, ut_teardown,
11245 test_snow3g_encryption_test_case_2),
11246 TEST_CASE_ST(ut_setup, ut_teardown,
11247 test_snow3g_encryption_test_case_3),
11248 TEST_CASE_ST(ut_setup, ut_teardown,
11249 test_snow3g_encryption_test_case_4),
11250 TEST_CASE_ST(ut_setup, ut_teardown,
11251 test_snow3g_encryption_test_case_5),
11252 TEST_CASE_ST(ut_setup, ut_teardown,
11253 test_snow3g_auth_cipher_with_digest_test_case_1),
11255 TEST_CASE_ST(ut_setup, ut_teardown,
11256 test_snow3g_encryption_test_case_1_oop),
11257 TEST_CASE_ST(ut_setup, ut_teardown,
11258 test_snow3g_encryption_test_case_1_oop_sgl),
11259 TEST_CASE_ST(ut_setup, ut_teardown,
11260 test_snow3g_decryption_test_case_1_oop),
11262 TEST_CASE_ST(ut_setup, ut_teardown,
11263 test_snow3g_encryption_test_case_1_offset_oop),
11265 /** SNOW 3G decrypt only (UEA2) */
11266 TEST_CASE_ST(ut_setup, ut_teardown,
11267 test_snow3g_decryption_test_case_1),
11268 TEST_CASE_ST(ut_setup, ut_teardown,
11269 test_snow3g_decryption_test_case_2),
11270 TEST_CASE_ST(ut_setup, ut_teardown,
11271 test_snow3g_decryption_test_case_3),
11272 TEST_CASE_ST(ut_setup, ut_teardown,
11273 test_snow3g_decryption_test_case_4),
11274 TEST_CASE_ST(ut_setup, ut_teardown,
11275 test_snow3g_decryption_test_case_5),
11276 TEST_CASE_ST(ut_setup, ut_teardown,
11277 test_snow3g_decryption_with_digest_test_case_1),
11278 TEST_CASE_ST(ut_setup, ut_teardown,
11279 test_snow3g_hash_generate_test_case_1),
11280 TEST_CASE_ST(ut_setup, ut_teardown,
11281 test_snow3g_hash_generate_test_case_2),
11282 TEST_CASE_ST(ut_setup, ut_teardown,
11283 test_snow3g_hash_generate_test_case_3),
11284 /* Tests with buffers which length is not byte-aligned */
11285 TEST_CASE_ST(ut_setup, ut_teardown,
11286 test_snow3g_hash_generate_test_case_4),
11287 TEST_CASE_ST(ut_setup, ut_teardown,
11288 test_snow3g_hash_generate_test_case_5),
11289 TEST_CASE_ST(ut_setup, ut_teardown,
11290 test_snow3g_hash_generate_test_case_6),
11291 TEST_CASE_ST(ut_setup, ut_teardown,
11292 test_snow3g_hash_verify_test_case_1),
11293 TEST_CASE_ST(ut_setup, ut_teardown,
11294 test_snow3g_hash_verify_test_case_2),
11295 TEST_CASE_ST(ut_setup, ut_teardown,
11296 test_snow3g_hash_verify_test_case_3),
11297 /* Tests with buffers which length is not byte-aligned */
11298 TEST_CASE_ST(ut_setup, ut_teardown,
11299 test_snow3g_hash_verify_test_case_4),
11300 TEST_CASE_ST(ut_setup, ut_teardown,
11301 test_snow3g_hash_verify_test_case_5),
11302 TEST_CASE_ST(ut_setup, ut_teardown,
11303 test_snow3g_hash_verify_test_case_6),
11304 TEST_CASE_ST(ut_setup, ut_teardown,
11305 test_snow3g_cipher_auth_test_case_1),
11307 /** SNOW 3G generate auth, then encrypt (UEA2) */
11308 TEST_CASE_ST(ut_setup, ut_teardown,
11309 test_snow3g_auth_cipher_test_case_1),
11310 TEST_CASE_ST(ut_setup, ut_teardown,
11311 test_snow3g_auth_cipher_test_case_2),
11312 TEST_CASE_ST(ut_setup, ut_teardown,
11313 test_snow3g_auth_cipher_test_case_2_oop),
11314 TEST_CASE_ST(ut_setup, ut_teardown,
11315 test_snow3g_auth_cipher_part_digest_enc),
11316 TEST_CASE_ST(ut_setup, ut_teardown,
11317 test_snow3g_auth_cipher_part_digest_enc_oop),
11318 TEST_CASE_ST(ut_setup, ut_teardown,
11319 test_snow3g_auth_cipher_test_case_3_sgl),
11320 TEST_CASE_ST(ut_setup, ut_teardown,
11321 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11322 TEST_CASE_ST(ut_setup, ut_teardown,
11323 test_snow3g_auth_cipher_part_digest_enc_sgl),
11324 TEST_CASE_ST(ut_setup, ut_teardown,
11325 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11327 /** SNOW 3G decrypt (UEA2), then verify auth */
11328 TEST_CASE_ST(ut_setup, ut_teardown,
11329 test_snow3g_auth_cipher_verify_test_case_1),
11330 TEST_CASE_ST(ut_setup, ut_teardown,
11331 test_snow3g_auth_cipher_verify_test_case_2),
11332 TEST_CASE_ST(ut_setup, ut_teardown,
11333 test_snow3g_auth_cipher_verify_test_case_2_oop),
11334 TEST_CASE_ST(ut_setup, ut_teardown,
11335 test_snow3g_auth_cipher_verify_part_digest_enc),
11336 TEST_CASE_ST(ut_setup, ut_teardown,
11337 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11338 TEST_CASE_ST(ut_setup, ut_teardown,
11339 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11340 TEST_CASE_ST(ut_setup, ut_teardown,
11341 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11342 TEST_CASE_ST(ut_setup, ut_teardown,
11343 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11344 TEST_CASE_ST(ut_setup, ut_teardown,
11345 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11347 TEST_CASES_END() /**< NULL terminate unit test array */
11351 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
11352 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
11353 .setup = testsuite_setup,
11354 .teardown = testsuite_teardown,
11355 .unit_test_cases = {
11356 /** ZUC encrypt only (EEA3) */
11357 TEST_CASE_ST(ut_setup, ut_teardown,
11358 test_zuc_encryption_test_case_1),
11359 TEST_CASE_ST(ut_setup, ut_teardown,
11360 test_zuc_encryption_test_case_2),
11361 TEST_CASE_ST(ut_setup, ut_teardown,
11362 test_zuc_encryption_test_case_3),
11363 TEST_CASE_ST(ut_setup, ut_teardown,
11364 test_zuc_encryption_test_case_4),
11365 TEST_CASE_ST(ut_setup, ut_teardown,
11366 test_zuc_encryption_test_case_5),
11367 TEST_CASE_ST(ut_setup, ut_teardown,
11368 test_zuc_hash_generate_test_case_1),
11369 TEST_CASE_ST(ut_setup, ut_teardown,
11370 test_zuc_hash_generate_test_case_2),
11371 TEST_CASE_ST(ut_setup, ut_teardown,
11372 test_zuc_hash_generate_test_case_3),
11373 TEST_CASE_ST(ut_setup, ut_teardown,
11374 test_zuc_hash_generate_test_case_4),
11375 TEST_CASE_ST(ut_setup, ut_teardown,
11376 test_zuc_hash_generate_test_case_5),
11377 TEST_CASE_ST(ut_setup, ut_teardown,
11378 test_zuc_encryption_test_case_6_sgl),
11379 TEST_CASES_END() /**< NULL terminate unit test array */
11383 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
11384 .suite_name = "Crypto CAAM JR Unit Test Suite",
11385 .setup = testsuite_setup,
11386 .teardown = testsuite_teardown,
11387 .unit_test_cases = {
11388 TEST_CASE_ST(ut_setup, ut_teardown,
11389 test_device_configure_invalid_dev_id),
11390 TEST_CASE_ST(ut_setup, ut_teardown,
11391 test_multi_session),
11393 TEST_CASE_ST(ut_setup, ut_teardown,
11394 test_AES_chain_caam_jr_all),
11395 TEST_CASE_ST(ut_setup, ut_teardown,
11396 test_3DES_chain_caam_jr_all),
11397 TEST_CASE_ST(ut_setup, ut_teardown,
11398 test_AES_cipheronly_caam_jr_all),
11399 TEST_CASE_ST(ut_setup, ut_teardown,
11400 test_3DES_cipheronly_caam_jr_all),
11401 TEST_CASE_ST(ut_setup, ut_teardown,
11402 test_authonly_caam_jr_all),
11404 TEST_CASES_END() /**< NULL terminate unit test array */
11408 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
11409 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
11410 .setup = testsuite_setup,
11411 .teardown = testsuite_teardown,
11412 .unit_test_cases = {
11413 TEST_CASE_ST(ut_setup, ut_teardown,
11414 test_device_configure_invalid_dev_id),
11415 TEST_CASE_ST(ut_setup, ut_teardown,
11416 test_multi_session),
11418 TEST_CASE_ST(ut_setup, ut_teardown,
11419 test_AES_chain_dpaa_sec_all),
11420 TEST_CASE_ST(ut_setup, ut_teardown,
11421 test_3DES_chain_dpaa_sec_all),
11422 TEST_CASE_ST(ut_setup, ut_teardown,
11423 test_AES_cipheronly_dpaa_sec_all),
11424 TEST_CASE_ST(ut_setup, ut_teardown,
11425 test_3DES_cipheronly_dpaa_sec_all),
11426 TEST_CASE_ST(ut_setup, ut_teardown,
11427 test_authonly_dpaa_sec_all),
11429 /** AES GCM Authenticated Encryption */
11430 TEST_CASE_ST(ut_setup, ut_teardown,
11431 test_AES_GCM_authenticated_encryption_test_case_1),
11432 TEST_CASE_ST(ut_setup, ut_teardown,
11433 test_AES_GCM_authenticated_encryption_test_case_2),
11434 TEST_CASE_ST(ut_setup, ut_teardown,
11435 test_AES_GCM_authenticated_encryption_test_case_3),
11436 TEST_CASE_ST(ut_setup, ut_teardown,
11437 test_AES_GCM_authenticated_encryption_test_case_4),
11438 TEST_CASE_ST(ut_setup, ut_teardown,
11439 test_AES_GCM_authenticated_encryption_test_case_5),
11440 TEST_CASE_ST(ut_setup, ut_teardown,
11441 test_AES_GCM_authenticated_encryption_test_case_6),
11442 TEST_CASE_ST(ut_setup, ut_teardown,
11443 test_AES_GCM_authenticated_encryption_test_case_7),
11445 /** AES GCM Authenticated Decryption */
11446 TEST_CASE_ST(ut_setup, ut_teardown,
11447 test_AES_GCM_authenticated_decryption_test_case_1),
11448 TEST_CASE_ST(ut_setup, ut_teardown,
11449 test_AES_GCM_authenticated_decryption_test_case_2),
11450 TEST_CASE_ST(ut_setup, ut_teardown,
11451 test_AES_GCM_authenticated_decryption_test_case_3),
11452 TEST_CASE_ST(ut_setup, ut_teardown,
11453 test_AES_GCM_authenticated_decryption_test_case_4),
11454 TEST_CASE_ST(ut_setup, ut_teardown,
11455 test_AES_GCM_authenticated_decryption_test_case_5),
11456 TEST_CASE_ST(ut_setup, ut_teardown,
11457 test_AES_GCM_authenticated_decryption_test_case_6),
11458 TEST_CASE_ST(ut_setup, ut_teardown,
11459 test_AES_GCM_authenticated_decryption_test_case_7),
11461 /** AES GCM Authenticated Encryption 256 bits key */
11462 TEST_CASE_ST(ut_setup, ut_teardown,
11463 test_AES_GCM_auth_encryption_test_case_256_1),
11464 TEST_CASE_ST(ut_setup, ut_teardown,
11465 test_AES_GCM_auth_encryption_test_case_256_2),
11466 TEST_CASE_ST(ut_setup, ut_teardown,
11467 test_AES_GCM_auth_encryption_test_case_256_3),
11468 TEST_CASE_ST(ut_setup, ut_teardown,
11469 test_AES_GCM_auth_encryption_test_case_256_4),
11470 TEST_CASE_ST(ut_setup, ut_teardown,
11471 test_AES_GCM_auth_encryption_test_case_256_5),
11472 TEST_CASE_ST(ut_setup, ut_teardown,
11473 test_AES_GCM_auth_encryption_test_case_256_6),
11474 TEST_CASE_ST(ut_setup, ut_teardown,
11475 test_AES_GCM_auth_encryption_test_case_256_7),
11477 /** AES GCM Authenticated Decryption 256 bits key */
11478 TEST_CASE_ST(ut_setup, ut_teardown,
11479 test_AES_GCM_auth_decryption_test_case_256_1),
11480 TEST_CASE_ST(ut_setup, ut_teardown,
11481 test_AES_GCM_auth_decryption_test_case_256_2),
11482 TEST_CASE_ST(ut_setup, ut_teardown,
11483 test_AES_GCM_auth_decryption_test_case_256_3),
11484 TEST_CASE_ST(ut_setup, ut_teardown,
11485 test_AES_GCM_auth_decryption_test_case_256_4),
11486 TEST_CASE_ST(ut_setup, ut_teardown,
11487 test_AES_GCM_auth_decryption_test_case_256_5),
11488 TEST_CASE_ST(ut_setup, ut_teardown,
11489 test_AES_GCM_auth_decryption_test_case_256_6),
11490 TEST_CASE_ST(ut_setup, ut_teardown,
11491 test_AES_GCM_auth_decryption_test_case_256_7),
11493 /** Out of place tests */
11494 TEST_CASE_ST(ut_setup, ut_teardown,
11495 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11496 TEST_CASE_ST(ut_setup, ut_teardown,
11497 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11499 /** Scatter-Gather */
11500 TEST_CASE_ST(ut_setup, ut_teardown,
11501 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11502 TEST_CASE_ST(ut_setup, ut_teardown,
11503 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11504 TEST_CASE_ST(ut_setup, ut_teardown,
11505 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11506 TEST_CASE_ST(ut_setup, ut_teardown,
11507 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11509 TEST_CASES_END() /**< NULL terminate unit test array */
11513 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
11514 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
11515 .setup = testsuite_setup,
11516 .teardown = testsuite_teardown,
11517 .unit_test_cases = {
11518 TEST_CASE_ST(ut_setup, ut_teardown,
11519 test_device_configure_invalid_dev_id),
11520 TEST_CASE_ST(ut_setup, ut_teardown,
11521 test_multi_session),
11523 TEST_CASE_ST(ut_setup, ut_teardown,
11524 test_AES_chain_dpaa2_sec_all),
11525 TEST_CASE_ST(ut_setup, ut_teardown,
11526 test_3DES_chain_dpaa2_sec_all),
11527 TEST_CASE_ST(ut_setup, ut_teardown,
11528 test_AES_cipheronly_dpaa2_sec_all),
11529 TEST_CASE_ST(ut_setup, ut_teardown,
11530 test_3DES_cipheronly_dpaa2_sec_all),
11531 TEST_CASE_ST(ut_setup, ut_teardown,
11532 test_authonly_dpaa2_sec_all),
11534 /** AES GCM Authenticated Encryption */
11535 TEST_CASE_ST(ut_setup, ut_teardown,
11536 test_AES_GCM_authenticated_encryption_test_case_1),
11537 TEST_CASE_ST(ut_setup, ut_teardown,
11538 test_AES_GCM_authenticated_encryption_test_case_2),
11539 TEST_CASE_ST(ut_setup, ut_teardown,
11540 test_AES_GCM_authenticated_encryption_test_case_3),
11541 TEST_CASE_ST(ut_setup, ut_teardown,
11542 test_AES_GCM_authenticated_encryption_test_case_4),
11543 TEST_CASE_ST(ut_setup, ut_teardown,
11544 test_AES_GCM_authenticated_encryption_test_case_5),
11545 TEST_CASE_ST(ut_setup, ut_teardown,
11546 test_AES_GCM_authenticated_encryption_test_case_6),
11547 TEST_CASE_ST(ut_setup, ut_teardown,
11548 test_AES_GCM_authenticated_encryption_test_case_7),
11550 /** AES GCM Authenticated Decryption */
11551 TEST_CASE_ST(ut_setup, ut_teardown,
11552 test_AES_GCM_authenticated_decryption_test_case_1),
11553 TEST_CASE_ST(ut_setup, ut_teardown,
11554 test_AES_GCM_authenticated_decryption_test_case_2),
11555 TEST_CASE_ST(ut_setup, ut_teardown,
11556 test_AES_GCM_authenticated_decryption_test_case_3),
11557 TEST_CASE_ST(ut_setup, ut_teardown,
11558 test_AES_GCM_authenticated_decryption_test_case_4),
11559 TEST_CASE_ST(ut_setup, ut_teardown,
11560 test_AES_GCM_authenticated_decryption_test_case_5),
11561 TEST_CASE_ST(ut_setup, ut_teardown,
11562 test_AES_GCM_authenticated_decryption_test_case_6),
11563 TEST_CASE_ST(ut_setup, ut_teardown,
11564 test_AES_GCM_authenticated_decryption_test_case_7),
11566 /** AES GCM Authenticated Encryption 192 bits key */
11567 TEST_CASE_ST(ut_setup, ut_teardown,
11568 test_AES_GCM_auth_encryption_test_case_192_1),
11569 TEST_CASE_ST(ut_setup, ut_teardown,
11570 test_AES_GCM_auth_encryption_test_case_192_2),
11571 TEST_CASE_ST(ut_setup, ut_teardown,
11572 test_AES_GCM_auth_encryption_test_case_192_3),
11573 TEST_CASE_ST(ut_setup, ut_teardown,
11574 test_AES_GCM_auth_encryption_test_case_192_4),
11575 TEST_CASE_ST(ut_setup, ut_teardown,
11576 test_AES_GCM_auth_encryption_test_case_192_5),
11577 TEST_CASE_ST(ut_setup, ut_teardown,
11578 test_AES_GCM_auth_encryption_test_case_192_6),
11579 TEST_CASE_ST(ut_setup, ut_teardown,
11580 test_AES_GCM_auth_encryption_test_case_192_7),
11582 /** AES GCM Authenticated Decryption 192 bits key */
11583 TEST_CASE_ST(ut_setup, ut_teardown,
11584 test_AES_GCM_auth_decryption_test_case_192_1),
11585 TEST_CASE_ST(ut_setup, ut_teardown,
11586 test_AES_GCM_auth_decryption_test_case_192_2),
11587 TEST_CASE_ST(ut_setup, ut_teardown,
11588 test_AES_GCM_auth_decryption_test_case_192_3),
11589 TEST_CASE_ST(ut_setup, ut_teardown,
11590 test_AES_GCM_auth_decryption_test_case_192_4),
11591 TEST_CASE_ST(ut_setup, ut_teardown,
11592 test_AES_GCM_auth_decryption_test_case_192_5),
11593 TEST_CASE_ST(ut_setup, ut_teardown,
11594 test_AES_GCM_auth_decryption_test_case_192_6),
11595 TEST_CASE_ST(ut_setup, ut_teardown,
11596 test_AES_GCM_auth_decryption_test_case_192_7),
11598 /** AES GCM Authenticated Encryption 256 bits key */
11599 TEST_CASE_ST(ut_setup, ut_teardown,
11600 test_AES_GCM_auth_encryption_test_case_256_1),
11601 TEST_CASE_ST(ut_setup, ut_teardown,
11602 test_AES_GCM_auth_encryption_test_case_256_2),
11603 TEST_CASE_ST(ut_setup, ut_teardown,
11604 test_AES_GCM_auth_encryption_test_case_256_3),
11605 TEST_CASE_ST(ut_setup, ut_teardown,
11606 test_AES_GCM_auth_encryption_test_case_256_4),
11607 TEST_CASE_ST(ut_setup, ut_teardown,
11608 test_AES_GCM_auth_encryption_test_case_256_5),
11609 TEST_CASE_ST(ut_setup, ut_teardown,
11610 test_AES_GCM_auth_encryption_test_case_256_6),
11611 TEST_CASE_ST(ut_setup, ut_teardown,
11612 test_AES_GCM_auth_encryption_test_case_256_7),
11614 /** AES GCM Authenticated Decryption 256 bits key */
11615 TEST_CASE_ST(ut_setup, ut_teardown,
11616 test_AES_GCM_auth_decryption_test_case_256_1),
11617 TEST_CASE_ST(ut_setup, ut_teardown,
11618 test_AES_GCM_auth_decryption_test_case_256_2),
11619 TEST_CASE_ST(ut_setup, ut_teardown,
11620 test_AES_GCM_auth_decryption_test_case_256_3),
11621 TEST_CASE_ST(ut_setup, ut_teardown,
11622 test_AES_GCM_auth_decryption_test_case_256_4),
11623 TEST_CASE_ST(ut_setup, ut_teardown,
11624 test_AES_GCM_auth_decryption_test_case_256_5),
11625 TEST_CASE_ST(ut_setup, ut_teardown,
11626 test_AES_GCM_auth_decryption_test_case_256_6),
11627 TEST_CASE_ST(ut_setup, ut_teardown,
11628 test_AES_GCM_auth_decryption_test_case_256_7),
11630 /** Out of place tests */
11631 TEST_CASE_ST(ut_setup, ut_teardown,
11632 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11633 TEST_CASE_ST(ut_setup, ut_teardown,
11634 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11636 /** Scatter-Gather */
11637 TEST_CASE_ST(ut_setup, ut_teardown,
11638 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11639 TEST_CASE_ST(ut_setup, ut_teardown,
11640 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11641 TEST_CASE_ST(ut_setup, ut_teardown,
11642 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11643 TEST_CASE_ST(ut_setup, ut_teardown,
11644 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11646 TEST_CASES_END() /**< NULL terminate unit test array */
11650 static struct unit_test_suite cryptodev_null_testsuite = {
11651 .suite_name = "Crypto Device NULL Unit Test Suite",
11652 .setup = testsuite_setup,
11653 .teardown = testsuite_teardown,
11654 .unit_test_cases = {
11655 TEST_CASE_ST(ut_setup, ut_teardown,
11656 test_null_invalid_operation),
11657 TEST_CASE_ST(ut_setup, ut_teardown,
11658 test_null_burst_operation),
11659 TEST_CASE_ST(ut_setup, ut_teardown,
11660 test_AES_chain_null_all),
11661 TEST_CASE_ST(ut_setup, ut_teardown,
11662 test_AES_cipheronly_null_all),
11663 TEST_CASE_ST(ut_setup, ut_teardown,
11664 test_authonly_null_all),
11666 TEST_CASES_END() /**< NULL terminate unit test array */
11670 static struct unit_test_suite cryptodev_armv8_testsuite = {
11671 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
11672 .setup = testsuite_setup,
11673 .teardown = testsuite_teardown,
11674 .unit_test_cases = {
11675 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
11677 /** Negative tests */
11678 TEST_CASE_ST(ut_setup, ut_teardown,
11679 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11680 TEST_CASE_ST(ut_setup, ut_teardown,
11681 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11683 TEST_CASES_END() /**< NULL terminate unit test array */
11687 static struct unit_test_suite cryptodev_mrvl_testsuite = {
11688 .suite_name = "Crypto Device Marvell Component Test Suite",
11689 .setup = testsuite_setup,
11690 .teardown = testsuite_teardown,
11691 .unit_test_cases = {
11692 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11693 TEST_CASE_ST(ut_setup, ut_teardown,
11694 test_multi_session_random_usage),
11695 TEST_CASE_ST(ut_setup, ut_teardown,
11696 test_AES_chain_mrvl_all),
11697 TEST_CASE_ST(ut_setup, ut_teardown,
11698 test_AES_cipheronly_mrvl_all),
11699 TEST_CASE_ST(ut_setup, ut_teardown,
11700 test_authonly_mrvl_all),
11701 TEST_CASE_ST(ut_setup, ut_teardown,
11702 test_3DES_chain_mrvl_all),
11703 TEST_CASE_ST(ut_setup, ut_teardown,
11704 test_3DES_cipheronly_mrvl_all),
11706 /** Negative tests */
11707 TEST_CASE_ST(ut_setup, ut_teardown,
11708 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11709 TEST_CASE_ST(ut_setup, ut_teardown,
11710 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11711 TEST_CASE_ST(ut_setup, ut_teardown,
11712 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11713 TEST_CASE_ST(ut_setup, ut_teardown,
11714 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11716 TEST_CASES_END() /**< NULL terminate unit test array */
11720 static struct unit_test_suite cryptodev_ccp_testsuite = {
11721 .suite_name = "Crypto Device CCP Unit Test Suite",
11722 .setup = testsuite_setup,
11723 .teardown = testsuite_teardown,
11724 .unit_test_cases = {
11725 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11726 TEST_CASE_ST(ut_setup, ut_teardown,
11727 test_multi_session_random_usage),
11728 TEST_CASE_ST(ut_setup, ut_teardown,
11729 test_AES_chain_ccp_all),
11730 TEST_CASE_ST(ut_setup, ut_teardown,
11731 test_AES_cipheronly_ccp_all),
11732 TEST_CASE_ST(ut_setup, ut_teardown,
11733 test_3DES_chain_ccp_all),
11734 TEST_CASE_ST(ut_setup, ut_teardown,
11735 test_3DES_cipheronly_ccp_all),
11736 TEST_CASE_ST(ut_setup, ut_teardown,
11737 test_authonly_ccp_all),
11739 /** Negative tests */
11740 TEST_CASE_ST(ut_setup, ut_teardown,
11741 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11742 TEST_CASE_ST(ut_setup, ut_teardown,
11743 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11744 TEST_CASE_ST(ut_setup, ut_teardown,
11745 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11746 TEST_CASE_ST(ut_setup, ut_teardown,
11747 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11749 TEST_CASES_END() /**< NULL terminate unit test array */
11753 static struct unit_test_suite cryptodev_octeontx_testsuite = {
11754 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
11755 .setup = testsuite_setup,
11756 .teardown = testsuite_teardown,
11757 .unit_test_cases = {
11758 TEST_CASE_ST(ut_setup, ut_teardown,
11759 test_AES_chain_octeontx_all),
11760 TEST_CASE_ST(ut_setup, ut_teardown,
11761 test_AES_cipheronly_octeontx_all),
11762 TEST_CASE_ST(ut_setup, ut_teardown,
11763 test_3DES_chain_octeontx_all),
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_3DES_cipheronly_octeontx_all),
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_authonly_octeontx_all),
11769 /** AES GCM Authenticated Encryption */
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_AES_GCM_authenticated_encryption_test_case_1),
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_AES_GCM_authenticated_encryption_test_case_2),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_AES_GCM_authenticated_encryption_test_case_3),
11776 TEST_CASE_ST(ut_setup, ut_teardown,
11777 test_AES_GCM_authenticated_encryption_test_case_4),
11778 TEST_CASE_ST(ut_setup, ut_teardown,
11779 test_AES_GCM_authenticated_encryption_test_case_5),
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_GCM_authenticated_encryption_test_case_6),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_GCM_authenticated_encryption_test_case_7),
11785 /** AES GCM Authenticated Decryption */
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_AES_GCM_authenticated_decryption_test_case_1),
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_AES_GCM_authenticated_decryption_test_case_2),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_AES_GCM_authenticated_decryption_test_case_3),
11792 TEST_CASE_ST(ut_setup, ut_teardown,
11793 test_AES_GCM_authenticated_decryption_test_case_4),
11794 TEST_CASE_ST(ut_setup, ut_teardown,
11795 test_AES_GCM_authenticated_decryption_test_case_5),
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 test_AES_GCM_authenticated_decryption_test_case_6),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 test_AES_GCM_authenticated_decryption_test_case_7),
11800 /** AES GMAC Authentication */
11801 TEST_CASE_ST(ut_setup, ut_teardown,
11802 test_AES_GMAC_authentication_test_case_1),
11803 TEST_CASE_ST(ut_setup, ut_teardown,
11804 test_AES_GMAC_authentication_verify_test_case_1),
11805 TEST_CASE_ST(ut_setup, ut_teardown,
11806 test_AES_GMAC_authentication_test_case_2),
11807 TEST_CASE_ST(ut_setup, ut_teardown,
11808 test_AES_GMAC_authentication_verify_test_case_2),
11809 TEST_CASE_ST(ut_setup, ut_teardown,
11810 test_AES_GMAC_authentication_test_case_3),
11811 TEST_CASE_ST(ut_setup, ut_teardown,
11812 test_AES_GMAC_authentication_verify_test_case_3),
11814 /** SNOW 3G encrypt only (UEA2) */
11815 TEST_CASE_ST(ut_setup, ut_teardown,
11816 test_snow3g_encryption_test_case_1),
11817 TEST_CASE_ST(ut_setup, ut_teardown,
11818 test_snow3g_encryption_test_case_2),
11819 TEST_CASE_ST(ut_setup, ut_teardown,
11820 test_snow3g_encryption_test_case_3),
11821 TEST_CASE_ST(ut_setup, ut_teardown,
11822 test_snow3g_encryption_test_case_4),
11823 TEST_CASE_ST(ut_setup, ut_teardown,
11824 test_snow3g_encryption_test_case_5),
11826 TEST_CASE_ST(ut_setup, ut_teardown,
11827 test_snow3g_encryption_test_case_1_oop),
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_snow3g_decryption_test_case_1_oop),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_snow3g_encryption_test_case_1_oop_sgl),
11833 /** SNOW 3G decrypt only (UEA2) */
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_snow3g_decryption_test_case_1),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_snow3g_decryption_test_case_2),
11838 TEST_CASE_ST(ut_setup, ut_teardown,
11839 test_snow3g_decryption_test_case_3),
11840 TEST_CASE_ST(ut_setup, ut_teardown,
11841 test_snow3g_decryption_test_case_4),
11842 TEST_CASE_ST(ut_setup, ut_teardown,
11843 test_snow3g_decryption_test_case_5),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_snow3g_hash_generate_test_case_1),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_snow3g_hash_generate_test_case_2),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_snow3g_hash_generate_test_case_3),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_snow3g_hash_verify_test_case_1),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_snow3g_hash_verify_test_case_2),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_snow3g_hash_verify_test_case_3),
11858 /** ZUC encrypt only (EEA3) */
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_zuc_encryption_test_case_1),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_zuc_encryption_test_case_2),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_zuc_encryption_test_case_3),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_zuc_encryption_test_case_4),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_zuc_encryption_test_case_5),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_zuc_hash_generate_test_case_1),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_zuc_hash_generate_test_case_2),
11873 TEST_CASE_ST(ut_setup, ut_teardown,
11874 test_zuc_hash_generate_test_case_3),
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_zuc_hash_generate_test_case_4),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_zuc_hash_generate_test_case_5),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_zuc_encryption_test_case_6_sgl),
11882 /** KASUMI encrypt only (UEA1) */
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_kasumi_encryption_test_case_1),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_kasumi_encryption_test_case_2),
11887 TEST_CASE_ST(ut_setup, ut_teardown,
11888 test_kasumi_encryption_test_case_3),
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_kasumi_encryption_test_case_4),
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_kasumi_encryption_test_case_5),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_kasumi_encryption_test_case_1_sgl),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_kasumi_encryption_test_case_1_oop_sgl),
11897 /** KASUMI decrypt only (UEA1) */
11898 TEST_CASE_ST(ut_setup, ut_teardown,
11899 test_kasumi_decryption_test_case_1),
11900 TEST_CASE_ST(ut_setup, ut_teardown,
11901 test_kasumi_decryption_test_case_2),
11902 TEST_CASE_ST(ut_setup, ut_teardown,
11903 test_kasumi_decryption_test_case_3),
11904 TEST_CASE_ST(ut_setup, ut_teardown,
11905 test_kasumi_decryption_test_case_4),
11906 TEST_CASE_ST(ut_setup, ut_teardown,
11907 test_kasumi_decryption_test_case_5),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_kasumi_encryption_test_case_1_oop),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_kasumi_decryption_test_case_1_oop),
11914 /** KASUMI hash only (UIA1) */
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_kasumi_hash_generate_test_case_1),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_kasumi_hash_generate_test_case_2),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_kasumi_hash_generate_test_case_3),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_kasumi_hash_generate_test_case_4),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_kasumi_hash_generate_test_case_5),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_kasumi_hash_generate_test_case_6),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_kasumi_hash_verify_test_case_1),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_kasumi_hash_verify_test_case_2),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_kasumi_hash_verify_test_case_3),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_kasumi_hash_verify_test_case_4),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_kasumi_hash_verify_test_case_5),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_null_cipher_only_operation),
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_null_auth_only_operation),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_null_cipher_auth_operation),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_null_auth_cipher_operation),
11948 /** Negative tests */
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 authentication_verify_AES128_GMAC_fail_data_corrupt),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11961 TEST_CASES_END() /**< NULL terminate unit test array */
11966 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
11968 gbl_driver_id = rte_cryptodev_driver_id_get(
11969 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
11971 if (gbl_driver_id == -1) {
11972 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
11973 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
11974 "are enabled in config file to run this testsuite.\n");
11975 return TEST_SKIPPED;
11978 return unit_test_suite_runner(&cryptodev_qat_testsuite);
11982 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
11984 gbl_driver_id = rte_cryptodev_driver_id_get(
11985 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
11987 if (gbl_driver_id == -1) {
11988 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
11989 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
11990 "in config file to run this testsuite.\n");
11991 return TEST_FAILED;
11994 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
11998 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12000 gbl_driver_id = rte_cryptodev_driver_id_get(
12001 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12003 if (gbl_driver_id == -1) {
12004 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12005 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12006 "in config file to run this testsuite.\n");
12007 return TEST_SKIPPED;
12010 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
12014 test_cryptodev_openssl(void)
12016 gbl_driver_id = rte_cryptodev_driver_id_get(
12017 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
12019 if (gbl_driver_id == -1) {
12020 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
12021 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
12022 "in config file to run this testsuite.\n");
12023 return TEST_SKIPPED;
12026 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
12030 test_cryptodev_aesni_gcm(void)
12032 gbl_driver_id = rte_cryptodev_driver_id_get(
12033 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12035 if (gbl_driver_id == -1) {
12036 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
12037 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
12038 "in config file to run this testsuite.\n");
12039 return TEST_SKIPPED;
12042 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
12046 test_cryptodev_null(void)
12048 gbl_driver_id = rte_cryptodev_driver_id_get(
12049 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
12051 if (gbl_driver_id == -1) {
12052 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
12053 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
12054 "in config file to run this testsuite.\n");
12055 return TEST_SKIPPED;
12058 return unit_test_suite_runner(&cryptodev_null_testsuite);
12062 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
12064 gbl_driver_id = rte_cryptodev_driver_id_get(
12065 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
12067 if (gbl_driver_id == -1) {
12068 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
12069 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
12070 "in config file to run this testsuite.\n");
12071 return TEST_SKIPPED;
12074 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
12078 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
12080 gbl_driver_id = rte_cryptodev_driver_id_get(
12081 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
12083 if (gbl_driver_id == -1) {
12084 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12085 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
12086 "in config file to run this testsuite.\n");
12087 return TEST_SKIPPED;
12090 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
12094 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
12096 gbl_driver_id = rte_cryptodev_driver_id_get(
12097 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
12099 if (gbl_driver_id == -1) {
12100 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12101 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
12102 "in config file to run this testsuite.\n");
12103 return TEST_SKIPPED;
12106 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
12110 test_cryptodev_armv8(void)
12112 gbl_driver_id = rte_cryptodev_driver_id_get(
12113 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
12115 if (gbl_driver_id == -1) {
12116 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
12117 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
12118 "in config file to run this testsuite.\n");
12119 return TEST_SKIPPED;
12122 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
12126 test_cryptodev_mrvl(void)
12128 gbl_driver_id = rte_cryptodev_driver_id_get(
12129 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
12131 if (gbl_driver_id == -1) {
12132 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
12133 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
12134 "in config file to run this testsuite.\n");
12135 return TEST_SKIPPED;
12138 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
12141 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12144 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
12146 gbl_driver_id = rte_cryptodev_driver_id_get(
12147 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
12149 if (gbl_driver_id == -1) {
12150 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
12151 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
12152 "in config file to run this testsuite.\n");
12153 return TEST_SKIPPED;
12156 if (rte_cryptodev_driver_id_get(
12157 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
12158 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
12159 " enabled in config file to run this testsuite.\n");
12160 return TEST_SKIPPED;
12162 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
12165 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
12170 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12172 gbl_driver_id = rte_cryptodev_driver_id_get(
12173 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
12175 if (gbl_driver_id == -1) {
12176 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
12177 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
12178 "in config file to run this testsuite.\n");
12179 return TEST_SKIPPED;
12182 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
12186 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12188 gbl_driver_id = rte_cryptodev_driver_id_get(
12189 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
12191 if (gbl_driver_id == -1) {
12192 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
12193 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
12194 "in config file to run this testsuite.\n");
12195 return TEST_SKIPPED;
12198 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
12202 test_cryptodev_ccp(void)
12204 gbl_driver_id = rte_cryptodev_driver_id_get(
12205 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
12207 if (gbl_driver_id == -1) {
12208 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
12209 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
12210 "in config file to run this testsuite.\n");
12211 return TEST_FAILED;
12214 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
12218 test_cryptodev_octeontx(void)
12220 gbl_driver_id = rte_cryptodev_driver_id_get(
12221 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
12222 if (gbl_driver_id == -1) {
12223 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
12224 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
12225 "enabled in config file to run this "
12227 return TEST_FAILED;
12229 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
12233 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
12235 gbl_driver_id = rte_cryptodev_driver_id_get(
12236 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
12238 if (gbl_driver_id == -1) {
12239 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
12240 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
12241 "in config file to run this testsuite.\n");
12242 return TEST_FAILED;
12245 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
12248 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
12249 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
12250 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
12251 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
12252 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
12253 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
12254 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
12255 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
12256 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
12257 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
12258 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
12259 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
12260 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
12261 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
12262 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
12263 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);