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 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2913 "no room to append auth tag");
2914 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2916 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2917 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2918 sym_op->m_src : sym_op->m_dst);
2919 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2920 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2921 sgl_buf = sgl_buf->next;
2923 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2924 uint8_t *, remaining_off);
2925 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2927 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2928 "no room to append auth tag");
2929 memset(sym_op->auth.digest.data, 0, remaining_off);
2930 while (sgl_buf->next != NULL) {
2931 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2932 0, rte_pktmbuf_data_len(sgl_buf));
2933 sgl_buf = sgl_buf->next;
2937 /* Copy cipher and auth IVs at the end of the crypto operation */
2938 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2939 ut_params->op, uint8_t *, IV_OFFSET);
2941 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2942 iv_ptr += cipher_iv_len;
2943 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2945 sym_op->cipher.data.length = cipher_len;
2946 sym_op->cipher.data.offset = cipher_offset;
2948 sym_op->auth.data.length = auth_len;
2949 sym_op->auth.data.offset = auth_offset;
2955 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2957 struct crypto_testsuite_params *ts_params = &testsuite_params;
2958 struct crypto_unittest_params *ut_params = &unittest_params;
2961 unsigned plaintext_pad_len;
2962 unsigned plaintext_len;
2965 /* Create SNOW 3G session */
2966 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2967 tdata->key.data, tdata->key.len,
2968 tdata->auth_iv.len, tdata->digest.len,
2969 RTE_CRYPTO_AUTH_OP_GENERATE,
2970 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2974 /* alloc mbuf and set payload */
2975 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2977 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2978 rte_pktmbuf_tailroom(ut_params->ibuf));
2980 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2981 /* Append data which is padded to a multiple of */
2982 /* the algorithms block size */
2983 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2984 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2986 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2988 /* Create SNOW 3G operation */
2989 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2990 tdata->auth_iv.data, tdata->auth_iv.len,
2991 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2992 tdata->validAuthLenInBits.len,
2997 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2999 ut_params->obuf = ut_params->op->sym->m_src;
3000 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3001 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3002 + plaintext_pad_len;
3005 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3008 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3009 "SNOW 3G Generated auth tag not as expected");
3015 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3017 struct crypto_testsuite_params *ts_params = &testsuite_params;
3018 struct crypto_unittest_params *ut_params = &unittest_params;
3021 unsigned plaintext_pad_len;
3022 unsigned plaintext_len;
3025 /* Create SNOW 3G session */
3026 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3027 tdata->key.data, tdata->key.len,
3028 tdata->auth_iv.len, tdata->digest.len,
3029 RTE_CRYPTO_AUTH_OP_VERIFY,
3030 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3033 /* alloc mbuf and set payload */
3034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3036 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3037 rte_pktmbuf_tailroom(ut_params->ibuf));
3039 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3040 /* Append data which is padded to a multiple of */
3041 /* the algorithms block size */
3042 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3043 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3045 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3047 /* Create SNOW 3G operation */
3048 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3050 tdata->auth_iv.data, tdata->auth_iv.len,
3052 RTE_CRYPTO_AUTH_OP_VERIFY,
3053 tdata->validAuthLenInBits.len,
3058 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3060 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3061 ut_params->obuf = ut_params->op->sym->m_src;
3062 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3063 + plaintext_pad_len;
3066 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3075 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3077 struct crypto_testsuite_params *ts_params = &testsuite_params;
3078 struct crypto_unittest_params *ut_params = &unittest_params;
3081 unsigned plaintext_pad_len;
3082 unsigned plaintext_len;
3085 /* Create KASUMI session */
3086 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3087 tdata->key.data, tdata->key.len,
3088 0, tdata->digest.len,
3089 RTE_CRYPTO_AUTH_OP_GENERATE,
3090 RTE_CRYPTO_AUTH_KASUMI_F9);
3094 /* alloc mbuf and set payload */
3095 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3097 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3098 rte_pktmbuf_tailroom(ut_params->ibuf));
3100 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3101 /* Append data which is padded to a multiple of */
3102 /* the algorithms block size */
3103 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3104 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3106 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3108 /* Create KASUMI operation */
3109 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3111 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3112 tdata->plaintext.len,
3117 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3119 ut_params->obuf = ut_params->op->sym->m_src;
3120 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3121 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3122 + plaintext_pad_len;
3125 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3128 DIGEST_BYTE_LENGTH_KASUMI_F9,
3129 "KASUMI Generated auth tag not as expected");
3135 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3137 struct crypto_testsuite_params *ts_params = &testsuite_params;
3138 struct crypto_unittest_params *ut_params = &unittest_params;
3141 unsigned plaintext_pad_len;
3142 unsigned plaintext_len;
3145 /* Create KASUMI session */
3146 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3147 tdata->key.data, tdata->key.len,
3148 0, tdata->digest.len,
3149 RTE_CRYPTO_AUTH_OP_VERIFY,
3150 RTE_CRYPTO_AUTH_KASUMI_F9);
3153 /* alloc mbuf and set payload */
3154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3156 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3157 rte_pktmbuf_tailroom(ut_params->ibuf));
3159 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3160 /* Append data which is padded to a multiple */
3161 /* of the algorithms block size */
3162 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3163 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3165 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3167 /* Create KASUMI operation */
3168 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3172 RTE_CRYPTO_AUTH_OP_VERIFY,
3173 tdata->plaintext.len,
3178 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3180 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3181 ut_params->obuf = ut_params->op->sym->m_src;
3182 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3183 + plaintext_pad_len;
3186 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3195 test_snow3g_hash_generate_test_case_1(void)
3197 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3201 test_snow3g_hash_generate_test_case_2(void)
3203 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3207 test_snow3g_hash_generate_test_case_3(void)
3209 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3213 test_snow3g_hash_generate_test_case_4(void)
3215 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3219 test_snow3g_hash_generate_test_case_5(void)
3221 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3225 test_snow3g_hash_generate_test_case_6(void)
3227 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3231 test_snow3g_hash_verify_test_case_1(void)
3233 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3238 test_snow3g_hash_verify_test_case_2(void)
3240 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3244 test_snow3g_hash_verify_test_case_3(void)
3246 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3250 test_snow3g_hash_verify_test_case_4(void)
3252 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3256 test_snow3g_hash_verify_test_case_5(void)
3258 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3262 test_snow3g_hash_verify_test_case_6(void)
3264 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3268 test_kasumi_hash_generate_test_case_1(void)
3270 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3274 test_kasumi_hash_generate_test_case_2(void)
3276 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3280 test_kasumi_hash_generate_test_case_3(void)
3282 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3286 test_kasumi_hash_generate_test_case_4(void)
3288 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3292 test_kasumi_hash_generate_test_case_5(void)
3294 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3298 test_kasumi_hash_generate_test_case_6(void)
3300 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3304 test_kasumi_hash_verify_test_case_1(void)
3306 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3310 test_kasumi_hash_verify_test_case_2(void)
3312 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3316 test_kasumi_hash_verify_test_case_3(void)
3318 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3322 test_kasumi_hash_verify_test_case_4(void)
3324 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3328 test_kasumi_hash_verify_test_case_5(void)
3330 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3334 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3336 struct crypto_testsuite_params *ts_params = &testsuite_params;
3337 struct crypto_unittest_params *ut_params = &unittest_params;
3340 uint8_t *plaintext, *ciphertext;
3341 unsigned plaintext_pad_len;
3342 unsigned plaintext_len;
3344 /* Create KASUMI session */
3345 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3346 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3347 RTE_CRYPTO_CIPHER_KASUMI_F8,
3348 tdata->key.data, tdata->key.len,
3349 tdata->cipher_iv.len);
3353 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3355 /* Clear mbuf payload */
3356 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3357 rte_pktmbuf_tailroom(ut_params->ibuf));
3359 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3360 /* Append data which is padded to a multiple */
3361 /* of the algorithms block size */
3362 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3363 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3365 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3367 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3369 /* Create KASUMI operation */
3370 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3371 tdata->cipher_iv.len,
3372 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3373 tdata->validCipherOffsetInBits.len);
3377 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3379 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3381 ut_params->obuf = ut_params->op->sym->m_dst;
3382 if (ut_params->obuf)
3383 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3385 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3387 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3389 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3390 (tdata->validCipherOffsetInBits.len >> 3);
3392 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3394 reference_ciphertext,
3395 tdata->validCipherLenInBits.len,
3396 "KASUMI Ciphertext data not as expected");
3401 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3403 struct crypto_testsuite_params *ts_params = &testsuite_params;
3404 struct crypto_unittest_params *ut_params = &unittest_params;
3408 unsigned int plaintext_pad_len;
3409 unsigned int plaintext_len;
3411 uint8_t buffer[10000];
3412 const uint8_t *ciphertext;
3414 struct rte_cryptodev_info dev_info;
3416 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3418 uint64_t feat_flags = dev_info.feature_flags;
3420 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3421 printf("Device doesn't support in-place scatter-gather. "
3426 /* Create KASUMI session */
3427 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3428 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3429 RTE_CRYPTO_CIPHER_KASUMI_F8,
3430 tdata->key.data, tdata->key.len,
3431 tdata->cipher_iv.len);
3435 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3438 /* Append data which is padded to a multiple */
3439 /* of the algorithms block size */
3440 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3442 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3443 plaintext_pad_len, 10, 0);
3445 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3447 /* Create KASUMI operation */
3448 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3449 tdata->cipher_iv.len,
3450 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3451 tdata->validCipherOffsetInBits.len);
3455 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3457 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3459 ut_params->obuf = ut_params->op->sym->m_dst;
3461 if (ut_params->obuf)
3462 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3463 plaintext_len, buffer);
3465 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3466 tdata->validCipherOffsetInBits.len >> 3,
3467 plaintext_len, buffer);
3470 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3472 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3473 (tdata->validCipherOffsetInBits.len >> 3);
3475 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3477 reference_ciphertext,
3478 tdata->validCipherLenInBits.len,
3479 "KASUMI Ciphertext data not as expected");
3484 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3486 struct crypto_testsuite_params *ts_params = &testsuite_params;
3487 struct crypto_unittest_params *ut_params = &unittest_params;
3490 uint8_t *plaintext, *ciphertext;
3491 unsigned plaintext_pad_len;
3492 unsigned plaintext_len;
3494 /* Create KASUMI session */
3495 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3496 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3497 RTE_CRYPTO_CIPHER_KASUMI_F8,
3498 tdata->key.data, tdata->key.len,
3499 tdata->cipher_iv.len);
3503 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3504 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3506 /* Clear mbuf payload */
3507 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3508 rte_pktmbuf_tailroom(ut_params->ibuf));
3510 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3511 /* Append data which is padded to a multiple */
3512 /* of the algorithms block size */
3513 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3514 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3516 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3517 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3519 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3521 /* Create KASUMI operation */
3522 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3523 tdata->cipher_iv.len,
3524 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3525 tdata->validCipherOffsetInBits.len);
3529 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3531 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3533 ut_params->obuf = ut_params->op->sym->m_dst;
3534 if (ut_params->obuf)
3535 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3537 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3539 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3541 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3542 (tdata->validCipherOffsetInBits.len >> 3);
3544 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3546 reference_ciphertext,
3547 tdata->validCipherLenInBits.len,
3548 "KASUMI Ciphertext data not as expected");
3553 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3555 struct crypto_testsuite_params *ts_params = &testsuite_params;
3556 struct crypto_unittest_params *ut_params = &unittest_params;
3559 unsigned int plaintext_pad_len;
3560 unsigned int plaintext_len;
3562 const uint8_t *ciphertext;
3563 uint8_t buffer[2048];
3565 struct rte_cryptodev_info dev_info;
3567 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3569 uint64_t feat_flags = dev_info.feature_flags;
3570 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3571 printf("Device doesn't support out-of-place scatter-gather "
3572 "in both input and output mbufs. "
3577 /* Create KASUMI session */
3578 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3579 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3580 RTE_CRYPTO_CIPHER_KASUMI_F8,
3581 tdata->key.data, tdata->key.len,
3582 tdata->cipher_iv.len);
3586 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3587 /* Append data which is padded to a multiple */
3588 /* of the algorithms block size */
3589 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3591 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3592 plaintext_pad_len, 10, 0);
3593 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3594 plaintext_pad_len, 3, 0);
3596 /* Append data which is padded to a multiple */
3597 /* of the algorithms block size */
3598 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3600 /* Create KASUMI operation */
3601 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3602 tdata->cipher_iv.len,
3603 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3604 tdata->validCipherOffsetInBits.len);
3608 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3610 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3612 ut_params->obuf = ut_params->op->sym->m_dst;
3613 if (ut_params->obuf)
3614 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3615 plaintext_pad_len, buffer);
3617 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3618 tdata->validCipherOffsetInBits.len >> 3,
3619 plaintext_pad_len, buffer);
3621 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3622 (tdata->validCipherOffsetInBits.len >> 3);
3624 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3626 reference_ciphertext,
3627 tdata->validCipherLenInBits.len,
3628 "KASUMI Ciphertext data not as expected");
3634 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3636 struct crypto_testsuite_params *ts_params = &testsuite_params;
3637 struct crypto_unittest_params *ut_params = &unittest_params;
3640 uint8_t *ciphertext, *plaintext;
3641 unsigned ciphertext_pad_len;
3642 unsigned ciphertext_len;
3644 /* Create KASUMI session */
3645 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3646 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3647 RTE_CRYPTO_CIPHER_KASUMI_F8,
3648 tdata->key.data, tdata->key.len,
3649 tdata->cipher_iv.len);
3653 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3654 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3656 /* Clear mbuf payload */
3657 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3658 rte_pktmbuf_tailroom(ut_params->ibuf));
3660 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3661 /* Append data which is padded to a multiple */
3662 /* of the algorithms block size */
3663 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3664 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3665 ciphertext_pad_len);
3666 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3667 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3669 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3671 /* Create KASUMI operation */
3672 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3673 tdata->cipher_iv.len,
3674 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3675 tdata->validCipherOffsetInBits.len);
3679 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3681 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3683 ut_params->obuf = ut_params->op->sym->m_dst;
3684 if (ut_params->obuf)
3685 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3687 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3689 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3691 const uint8_t *reference_plaintext = tdata->plaintext.data +
3692 (tdata->validCipherOffsetInBits.len >> 3);
3694 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3696 reference_plaintext,
3697 tdata->validCipherLenInBits.len,
3698 "KASUMI Plaintext data not as expected");
3703 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3705 struct crypto_testsuite_params *ts_params = &testsuite_params;
3706 struct crypto_unittest_params *ut_params = &unittest_params;
3709 uint8_t *ciphertext, *plaintext;
3710 unsigned ciphertext_pad_len;
3711 unsigned ciphertext_len;
3713 /* Create KASUMI session */
3714 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3715 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3716 RTE_CRYPTO_CIPHER_KASUMI_F8,
3717 tdata->key.data, tdata->key.len,
3718 tdata->cipher_iv.len);
3722 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3724 /* Clear mbuf payload */
3725 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3726 rte_pktmbuf_tailroom(ut_params->ibuf));
3728 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3729 /* Append data which is padded to a multiple */
3730 /* of the algorithms block size */
3731 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3732 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3733 ciphertext_pad_len);
3734 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3736 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3738 /* Create KASUMI operation */
3739 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3740 tdata->cipher_iv.len,
3741 tdata->ciphertext.len,
3742 tdata->validCipherOffsetInBits.len);
3746 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3748 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3750 ut_params->obuf = ut_params->op->sym->m_dst;
3751 if (ut_params->obuf)
3752 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3754 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3756 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3758 const uint8_t *reference_plaintext = tdata->plaintext.data +
3759 (tdata->validCipherOffsetInBits.len >> 3);
3761 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3763 reference_plaintext,
3764 tdata->validCipherLenInBits.len,
3765 "KASUMI Plaintext data not as expected");
3770 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3772 struct crypto_testsuite_params *ts_params = &testsuite_params;
3773 struct crypto_unittest_params *ut_params = &unittest_params;
3776 uint8_t *plaintext, *ciphertext;
3777 unsigned plaintext_pad_len;
3778 unsigned plaintext_len;
3780 /* Create SNOW 3G session */
3781 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3782 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3783 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3784 tdata->key.data, tdata->key.len,
3785 tdata->cipher_iv.len);
3789 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3791 /* Clear mbuf payload */
3792 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3793 rte_pktmbuf_tailroom(ut_params->ibuf));
3795 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3796 /* Append data which is padded to a multiple of */
3797 /* the algorithms block size */
3798 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3799 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3801 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3803 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3805 /* Create SNOW 3G operation */
3806 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3807 tdata->cipher_iv.len,
3808 tdata->validCipherLenInBits.len,
3813 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3815 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3817 ut_params->obuf = ut_params->op->sym->m_dst;
3818 if (ut_params->obuf)
3819 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3821 ciphertext = plaintext;
3823 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3826 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3828 tdata->ciphertext.data,
3829 tdata->validDataLenInBits.len,
3830 "SNOW 3G Ciphertext data not as expected");
3836 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3838 struct crypto_testsuite_params *ts_params = &testsuite_params;
3839 struct crypto_unittest_params *ut_params = &unittest_params;
3840 uint8_t *plaintext, *ciphertext;
3843 unsigned plaintext_pad_len;
3844 unsigned plaintext_len;
3846 /* Create SNOW 3G session */
3847 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3848 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3849 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3850 tdata->key.data, tdata->key.len,
3851 tdata->cipher_iv.len);
3855 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3856 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3858 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3859 "Failed to allocate input buffer in mempool");
3860 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3861 "Failed to allocate output buffer in mempool");
3863 /* Clear mbuf payload */
3864 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3865 rte_pktmbuf_tailroom(ut_params->ibuf));
3867 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3868 /* Append data which is padded to a multiple of */
3869 /* the algorithms block size */
3870 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3871 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3873 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3874 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3876 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3878 /* Create SNOW 3G operation */
3879 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3880 tdata->cipher_iv.len,
3881 tdata->validCipherLenInBits.len,
3886 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3888 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3890 ut_params->obuf = ut_params->op->sym->m_dst;
3891 if (ut_params->obuf)
3892 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3894 ciphertext = plaintext;
3896 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3899 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3901 tdata->ciphertext.data,
3902 tdata->validDataLenInBits.len,
3903 "SNOW 3G Ciphertext data not as expected");
3908 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3910 struct crypto_testsuite_params *ts_params = &testsuite_params;
3911 struct crypto_unittest_params *ut_params = &unittest_params;
3914 unsigned int plaintext_pad_len;
3915 unsigned int plaintext_len;
3916 uint8_t buffer[10000];
3917 const uint8_t *ciphertext;
3919 struct rte_cryptodev_info dev_info;
3921 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3923 uint64_t feat_flags = dev_info.feature_flags;
3925 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3926 printf("Device doesn't support out-of-place scatter-gather "
3927 "in both input and output mbufs. "
3932 /* Create SNOW 3G session */
3933 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3934 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3935 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3936 tdata->key.data, tdata->key.len,
3937 tdata->cipher_iv.len);
3941 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3942 /* Append data which is padded to a multiple of */
3943 /* the algorithms block size */
3944 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3946 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3947 plaintext_pad_len, 10, 0);
3948 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3949 plaintext_pad_len, 3, 0);
3951 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3952 "Failed to allocate input buffer in mempool");
3953 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3954 "Failed to allocate output buffer in mempool");
3956 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3958 /* Create SNOW 3G operation */
3959 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3960 tdata->cipher_iv.len,
3961 tdata->validCipherLenInBits.len,
3966 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3968 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3970 ut_params->obuf = ut_params->op->sym->m_dst;
3971 if (ut_params->obuf)
3972 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3973 plaintext_len, buffer);
3975 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3976 plaintext_len, buffer);
3978 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3981 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3983 tdata->ciphertext.data,
3984 tdata->validDataLenInBits.len,
3985 "SNOW 3G Ciphertext data not as expected");
3990 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3992 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3994 uint8_t curr_byte, prev_byte;
3995 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3996 uint8_t lower_byte_mask = (1 << offset) - 1;
3999 prev_byte = buffer[0];
4000 buffer[0] >>= offset;
4002 for (i = 1; i < length_in_bytes; i++) {
4003 curr_byte = buffer[i];
4004 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4005 (curr_byte >> offset);
4006 prev_byte = curr_byte;
4011 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4013 struct crypto_testsuite_params *ts_params = &testsuite_params;
4014 struct crypto_unittest_params *ut_params = &unittest_params;
4015 uint8_t *plaintext, *ciphertext;
4017 uint32_t plaintext_len;
4018 uint32_t plaintext_pad_len;
4019 uint8_t extra_offset = 4;
4020 uint8_t *expected_ciphertext_shifted;
4022 /* Create SNOW 3G session */
4023 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4024 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4025 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4026 tdata->key.data, tdata->key.len,
4027 tdata->cipher_iv.len);
4031 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4032 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4034 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4035 "Failed to allocate input buffer in mempool");
4036 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4037 "Failed to allocate output buffer in mempool");
4039 /* Clear mbuf payload */
4040 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4041 rte_pktmbuf_tailroom(ut_params->ibuf));
4043 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4045 * Append data which is padded to a
4046 * multiple of the algorithms block size
4048 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4050 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4053 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4055 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4056 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4058 #ifdef RTE_APP_TEST_DEBUG
4059 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4061 /* Create SNOW 3G operation */
4062 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4063 tdata->cipher_iv.len,
4064 tdata->validCipherLenInBits.len,
4069 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4071 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4073 ut_params->obuf = ut_params->op->sym->m_dst;
4074 if (ut_params->obuf)
4075 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4077 ciphertext = plaintext;
4079 #ifdef RTE_APP_TEST_DEBUG
4080 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4083 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4085 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4086 "failed to reserve memory for ciphertext shifted\n");
4088 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4089 ceil_byte_length(tdata->ciphertext.len));
4090 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4093 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4095 expected_ciphertext_shifted,
4096 tdata->validDataLenInBits.len,
4098 "SNOW 3G Ciphertext data not as expected");
4102 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4104 struct crypto_testsuite_params *ts_params = &testsuite_params;
4105 struct crypto_unittest_params *ut_params = &unittest_params;
4109 uint8_t *plaintext, *ciphertext;
4110 unsigned ciphertext_pad_len;
4111 unsigned ciphertext_len;
4113 /* Create SNOW 3G session */
4114 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4115 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4116 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4117 tdata->key.data, tdata->key.len,
4118 tdata->cipher_iv.len);
4122 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4124 /* Clear mbuf payload */
4125 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4126 rte_pktmbuf_tailroom(ut_params->ibuf));
4128 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4129 /* Append data which is padded to a multiple of */
4130 /* the algorithms block size */
4131 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4132 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4133 ciphertext_pad_len);
4134 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4136 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4138 /* Create SNOW 3G operation */
4139 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4140 tdata->cipher_iv.len,
4141 tdata->validCipherLenInBits.len,
4142 tdata->cipher.offset_bits);
4146 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4148 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4149 ut_params->obuf = ut_params->op->sym->m_dst;
4150 if (ut_params->obuf)
4151 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4153 plaintext = ciphertext;
4155 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4158 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4159 tdata->plaintext.data,
4160 tdata->validDataLenInBits.len,
4161 "SNOW 3G Plaintext data not as expected");
4165 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4167 struct crypto_testsuite_params *ts_params = &testsuite_params;
4168 struct crypto_unittest_params *ut_params = &unittest_params;
4172 uint8_t *plaintext, *ciphertext;
4173 unsigned ciphertext_pad_len;
4174 unsigned ciphertext_len;
4176 /* Create SNOW 3G session */
4177 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4178 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4179 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4180 tdata->key.data, tdata->key.len,
4181 tdata->cipher_iv.len);
4185 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4186 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4188 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4189 "Failed to allocate input buffer");
4190 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4191 "Failed to allocate output buffer");
4193 /* Clear mbuf payload */
4194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4195 rte_pktmbuf_tailroom(ut_params->ibuf));
4197 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4198 rte_pktmbuf_tailroom(ut_params->obuf));
4200 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4201 /* Append data which is padded to a multiple of */
4202 /* the algorithms block size */
4203 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4204 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4205 ciphertext_pad_len);
4206 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4207 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4209 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4211 /* Create SNOW 3G operation */
4212 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4213 tdata->cipher_iv.len,
4214 tdata->validCipherLenInBits.len,
4219 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4221 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4222 ut_params->obuf = ut_params->op->sym->m_dst;
4223 if (ut_params->obuf)
4224 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4226 plaintext = ciphertext;
4228 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4231 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4232 tdata->plaintext.data,
4233 tdata->validDataLenInBits.len,
4234 "SNOW 3G Plaintext data not as expected");
4239 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4241 struct crypto_testsuite_params *ts_params = &testsuite_params;
4242 struct crypto_unittest_params *ut_params = &unittest_params;
4246 uint8_t *plaintext, *ciphertext;
4247 unsigned int plaintext_pad_len;
4248 unsigned int plaintext_len;
4250 struct rte_cryptodev_sym_capability_idx cap_idx;
4252 /* Check if device supports ZUC EEA3 */
4253 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4254 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4256 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4260 /* Check if device supports ZUC EIA3 */
4261 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4262 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4264 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4268 /* Create ZUC session */
4269 retval = create_zuc_cipher_auth_encrypt_generate_session(
4270 ts_params->valid_devs[0],
4274 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4276 /* clear mbuf payload */
4277 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4278 rte_pktmbuf_tailroom(ut_params->ibuf));
4280 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4281 /* Append data which is padded to a multiple of */
4282 /* the algorithms block size */
4283 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4284 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4286 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4288 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4290 /* Create ZUC operation */
4291 retval = create_zuc_cipher_hash_generate_operation(tdata);
4295 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4297 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4298 ut_params->obuf = ut_params->op->sym->m_src;
4299 if (ut_params->obuf)
4300 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4302 ciphertext = plaintext;
4304 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4308 tdata->ciphertext.data,
4309 tdata->validDataLenInBits.len,
4310 "ZUC Ciphertext data not as expected");
4312 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4313 + plaintext_pad_len;
4316 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4320 "ZUC Generated auth tag not as expected");
4325 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4327 struct crypto_testsuite_params *ts_params = &testsuite_params;
4328 struct crypto_unittest_params *ut_params = &unittest_params;
4332 uint8_t *plaintext, *ciphertext;
4333 unsigned plaintext_pad_len;
4334 unsigned plaintext_len;
4336 /* Create SNOW 3G session */
4337 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4338 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4339 RTE_CRYPTO_AUTH_OP_GENERATE,
4340 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4341 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4342 tdata->key.data, tdata->key.len,
4343 tdata->auth_iv.len, tdata->digest.len,
4344 tdata->cipher_iv.len);
4347 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4349 /* clear mbuf payload */
4350 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4351 rte_pktmbuf_tailroom(ut_params->ibuf));
4353 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4354 /* Append data which is padded to a multiple of */
4355 /* the algorithms block size */
4356 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4357 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4359 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4361 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4363 /* Create SNOW 3G operation */
4364 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4365 tdata->digest.len, tdata->auth_iv.data,
4367 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4368 tdata->cipher_iv.data, tdata->cipher_iv.len,
4369 tdata->validCipherLenInBits.len,
4371 tdata->validAuthLenInBits.len,
4377 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4379 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4380 ut_params->obuf = ut_params->op->sym->m_src;
4381 if (ut_params->obuf)
4382 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4384 ciphertext = plaintext;
4386 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4388 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4390 tdata->ciphertext.data,
4391 tdata->validDataLenInBits.len,
4392 "SNOW 3G Ciphertext data not as expected");
4394 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4395 + plaintext_pad_len;
4398 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4401 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4402 "SNOW 3G Generated auth tag not as expected");
4407 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4408 uint8_t op_mode, uint8_t verify)
4410 struct crypto_testsuite_params *ts_params = &testsuite_params;
4411 struct crypto_unittest_params *ut_params = &unittest_params;
4415 uint8_t *plaintext = NULL, *ciphertext = NULL;
4416 unsigned int plaintext_pad_len;
4417 unsigned int plaintext_len;
4418 unsigned int ciphertext_pad_len;
4419 unsigned int ciphertext_len;
4421 struct rte_cryptodev_info dev_info;
4423 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4425 uint64_t feat_flags = dev_info.feature_flags;
4427 if (op_mode == OUT_OF_PLACE) {
4428 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4429 printf("Device doesn't support digest encrypted.\n");
4434 /* Create SNOW 3G session */
4435 retval = create_wireless_algo_auth_cipher_session(
4436 ts_params->valid_devs[0],
4437 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4438 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4439 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4440 : RTE_CRYPTO_AUTH_OP_GENERATE),
4441 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4442 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4443 tdata->key.data, tdata->key.len,
4444 tdata->auth_iv.len, tdata->digest.len,
4445 tdata->cipher_iv.len);
4450 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4451 if (op_mode == OUT_OF_PLACE)
4452 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4454 /* clear mbuf payload */
4455 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4456 rte_pktmbuf_tailroom(ut_params->ibuf));
4457 if (op_mode == OUT_OF_PLACE)
4458 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4459 rte_pktmbuf_tailroom(ut_params->obuf));
4461 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4462 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4463 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4464 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4467 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4468 ciphertext_pad_len);
4469 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4470 if (op_mode == OUT_OF_PLACE)
4471 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4472 debug_hexdump(stdout, "ciphertext:", ciphertext,
4475 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4477 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4478 if (op_mode == OUT_OF_PLACE)
4479 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4480 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4483 /* Create SNOW 3G operation */
4484 retval = create_wireless_algo_auth_cipher_operation(
4486 tdata->cipher_iv.data, tdata->cipher_iv.len,
4487 tdata->auth_iv.data, tdata->auth_iv.len,
4488 (tdata->digest.offset_bytes == 0 ?
4489 (verify ? ciphertext_pad_len : plaintext_pad_len)
4490 : tdata->digest.offset_bytes),
4491 tdata->validCipherLenInBits.len,
4492 tdata->cipher.offset_bits,
4493 tdata->validAuthLenInBits.len,
4494 tdata->auth.offset_bits,
4500 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4503 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4505 ut_params->obuf = (op_mode == IN_PLACE ?
4506 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4509 if (ut_params->obuf)
4510 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4513 plaintext = ciphertext +
4514 (tdata->cipher.offset_bits >> 3);
4516 debug_hexdump(stdout, "plaintext:", plaintext,
4517 (tdata->plaintext.len >> 3) - tdata->digest.len);
4518 debug_hexdump(stdout, "plaintext expected:",
4519 tdata->plaintext.data,
4520 (tdata->plaintext.len >> 3) - tdata->digest.len);
4522 if (ut_params->obuf)
4523 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4526 ciphertext = plaintext;
4528 debug_hexdump(stdout, "ciphertext:", ciphertext,
4530 debug_hexdump(stdout, "ciphertext expected:",
4531 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4533 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4534 + (tdata->digest.offset_bytes == 0 ?
4535 plaintext_pad_len : tdata->digest.offset_bytes);
4537 debug_hexdump(stdout, "digest:", ut_params->digest,
4539 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4545 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4547 tdata->plaintext.data,
4548 tdata->plaintext.len >> 3,
4549 "SNOW 3G Plaintext data not as expected");
4551 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4553 tdata->ciphertext.data,
4554 tdata->validDataLenInBits.len,
4555 "SNOW 3G Ciphertext data not as expected");
4557 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4560 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4561 "SNOW 3G Generated auth tag not as expected");
4567 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4568 uint8_t op_mode, uint8_t verify)
4570 struct crypto_testsuite_params *ts_params = &testsuite_params;
4571 struct crypto_unittest_params *ut_params = &unittest_params;
4575 const uint8_t *plaintext = NULL;
4576 const uint8_t *ciphertext = NULL;
4577 const uint8_t *digest = NULL;
4578 unsigned int plaintext_pad_len;
4579 unsigned int plaintext_len;
4580 unsigned int ciphertext_pad_len;
4581 unsigned int ciphertext_len;
4582 uint8_t buffer[10000];
4583 uint8_t digest_buffer[10000];
4585 struct rte_cryptodev_info dev_info;
4587 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4589 uint64_t feat_flags = dev_info.feature_flags;
4591 if (op_mode == IN_PLACE) {
4592 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4593 printf("Device doesn't support in-place scatter-gather "
4594 "in both input and output mbufs.\n");
4598 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4599 printf("Device doesn't support out-of-place scatter-gather "
4600 "in both input and output mbufs.\n");
4603 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4604 printf("Device doesn't support digest encrypted.\n");
4609 /* Create SNOW 3G session */
4610 retval = create_wireless_algo_auth_cipher_session(
4611 ts_params->valid_devs[0],
4612 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4613 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4614 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4615 : RTE_CRYPTO_AUTH_OP_GENERATE),
4616 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4617 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4618 tdata->key.data, tdata->key.len,
4619 tdata->auth_iv.len, tdata->digest.len,
4620 tdata->cipher_iv.len);
4625 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4626 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4627 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4628 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4630 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4631 plaintext_pad_len, 15, 0);
4632 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4633 "Failed to allocate input buffer in mempool");
4635 if (op_mode == OUT_OF_PLACE) {
4636 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4637 plaintext_pad_len, 15, 0);
4638 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4639 "Failed to allocate output buffer in mempool");
4643 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4644 tdata->ciphertext.data);
4645 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4646 ciphertext_len, buffer);
4647 debug_hexdump(stdout, "ciphertext:", ciphertext,
4650 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4651 tdata->plaintext.data);
4652 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4653 plaintext_len, buffer);
4654 debug_hexdump(stdout, "plaintext:", plaintext,
4657 memset(buffer, 0, sizeof(buffer));
4659 /* Create SNOW 3G operation */
4660 retval = create_wireless_algo_auth_cipher_operation(
4662 tdata->cipher_iv.data, tdata->cipher_iv.len,
4663 tdata->auth_iv.data, tdata->auth_iv.len,
4664 (tdata->digest.offset_bytes == 0 ?
4665 (verify ? ciphertext_pad_len : plaintext_pad_len)
4666 : tdata->digest.offset_bytes),
4667 tdata->validCipherLenInBits.len,
4668 tdata->cipher.offset_bits,
4669 tdata->validAuthLenInBits.len,
4670 tdata->auth.offset_bits,
4676 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4679 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4681 ut_params->obuf = (op_mode == IN_PLACE ?
4682 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4685 if (ut_params->obuf)
4686 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4687 plaintext_len, buffer);
4689 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4690 plaintext_len, buffer);
4692 debug_hexdump(stdout, "plaintext:", plaintext,
4693 (tdata->plaintext.len >> 3) - tdata->digest.len);
4694 debug_hexdump(stdout, "plaintext expected:",
4695 tdata->plaintext.data,
4696 (tdata->plaintext.len >> 3) - tdata->digest.len);
4698 if (ut_params->obuf)
4699 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4700 ciphertext_len, buffer);
4702 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4703 ciphertext_len, buffer);
4705 debug_hexdump(stdout, "ciphertext:", ciphertext,
4707 debug_hexdump(stdout, "ciphertext expected:",
4708 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4710 if (ut_params->obuf)
4711 digest = rte_pktmbuf_read(ut_params->obuf,
4712 (tdata->digest.offset_bytes == 0 ?
4713 plaintext_pad_len : tdata->digest.offset_bytes),
4714 tdata->digest.len, digest_buffer);
4716 digest = rte_pktmbuf_read(ut_params->ibuf,
4717 (tdata->digest.offset_bytes == 0 ?
4718 plaintext_pad_len : tdata->digest.offset_bytes),
4719 tdata->digest.len, digest_buffer);
4721 debug_hexdump(stdout, "digest:", digest,
4723 debug_hexdump(stdout, "digest expected:",
4724 tdata->digest.data, tdata->digest.len);
4729 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4731 tdata->plaintext.data,
4732 tdata->plaintext.len >> 3,
4733 "SNOW 3G Plaintext data not as expected");
4735 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4737 tdata->ciphertext.data,
4738 tdata->validDataLenInBits.len,
4739 "SNOW 3G Ciphertext data not as expected");
4741 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4744 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4745 "SNOW 3G Generated auth tag not as expected");
4751 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4752 uint8_t op_mode, uint8_t verify)
4754 struct crypto_testsuite_params *ts_params = &testsuite_params;
4755 struct crypto_unittest_params *ut_params = &unittest_params;
4759 uint8_t *plaintext = NULL, *ciphertext = NULL;
4760 unsigned int plaintext_pad_len;
4761 unsigned int plaintext_len;
4762 unsigned int ciphertext_pad_len;
4763 unsigned int ciphertext_len;
4765 struct rte_cryptodev_info dev_info;
4767 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4769 uint64_t feat_flags = dev_info.feature_flags;
4771 if (op_mode == OUT_OF_PLACE) {
4772 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4773 printf("Device doesn't support digest encrypted.\n");
4778 /* Create KASUMI session */
4779 retval = create_wireless_algo_auth_cipher_session(
4780 ts_params->valid_devs[0],
4781 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4782 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4783 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4784 : RTE_CRYPTO_AUTH_OP_GENERATE),
4785 RTE_CRYPTO_AUTH_KASUMI_F9,
4786 RTE_CRYPTO_CIPHER_KASUMI_F8,
4787 tdata->key.data, tdata->key.len,
4788 0, tdata->digest.len,
4789 tdata->cipher_iv.len);
4794 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4795 if (op_mode == OUT_OF_PLACE)
4796 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4798 /* clear mbuf payload */
4799 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4800 rte_pktmbuf_tailroom(ut_params->ibuf));
4801 if (op_mode == OUT_OF_PLACE)
4802 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4803 rte_pktmbuf_tailroom(ut_params->obuf));
4805 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4806 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4807 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4808 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4811 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4812 ciphertext_pad_len);
4813 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4814 if (op_mode == OUT_OF_PLACE)
4815 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4816 debug_hexdump(stdout, "ciphertext:", ciphertext,
4819 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4821 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4822 if (op_mode == OUT_OF_PLACE)
4823 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4824 debug_hexdump(stdout, "plaintext:", plaintext,
4828 /* Create KASUMI operation */
4829 retval = create_wireless_algo_auth_cipher_operation(
4831 tdata->cipher_iv.data, tdata->cipher_iv.len,
4833 (tdata->digest.offset_bytes == 0 ?
4834 (verify ? ciphertext_pad_len : plaintext_pad_len)
4835 : tdata->digest.offset_bytes),
4836 tdata->validCipherLenInBits.len,
4837 tdata->validCipherOffsetInBits.len,
4838 tdata->validAuthLenInBits.len,
4845 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4848 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4850 ut_params->obuf = (op_mode == IN_PLACE ?
4851 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4855 if (ut_params->obuf)
4856 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4859 plaintext = ciphertext;
4861 debug_hexdump(stdout, "plaintext:", plaintext,
4862 (tdata->plaintext.len >> 3) - tdata->digest.len);
4863 debug_hexdump(stdout, "plaintext expected:",
4864 tdata->plaintext.data,
4865 (tdata->plaintext.len >> 3) - tdata->digest.len);
4867 if (ut_params->obuf)
4868 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4871 ciphertext = plaintext;
4873 debug_hexdump(stdout, "ciphertext:", ciphertext,
4875 debug_hexdump(stdout, "ciphertext expected:",
4876 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4878 ut_params->digest = rte_pktmbuf_mtod(
4879 ut_params->obuf, uint8_t *) +
4880 (tdata->digest.offset_bytes == 0 ?
4881 plaintext_pad_len : tdata->digest.offset_bytes);
4883 debug_hexdump(stdout, "digest:", ut_params->digest,
4885 debug_hexdump(stdout, "digest expected:",
4886 tdata->digest.data, tdata->digest.len);
4891 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4893 tdata->plaintext.data,
4894 tdata->plaintext.len >> 3,
4895 "KASUMI Plaintext data not as expected");
4897 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4899 tdata->ciphertext.data,
4900 tdata->ciphertext.len >> 3,
4901 "KASUMI Ciphertext data not as expected");
4903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4906 DIGEST_BYTE_LENGTH_KASUMI_F9,
4907 "KASUMI Generated auth tag not as expected");
4913 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4914 uint8_t op_mode, uint8_t verify)
4916 struct crypto_testsuite_params *ts_params = &testsuite_params;
4917 struct crypto_unittest_params *ut_params = &unittest_params;
4921 const uint8_t *plaintext = NULL;
4922 const uint8_t *ciphertext = NULL;
4923 const uint8_t *digest = NULL;
4924 unsigned int plaintext_pad_len;
4925 unsigned int plaintext_len;
4926 unsigned int ciphertext_pad_len;
4927 unsigned int ciphertext_len;
4928 uint8_t buffer[10000];
4929 uint8_t digest_buffer[10000];
4931 struct rte_cryptodev_info dev_info;
4933 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4935 uint64_t feat_flags = dev_info.feature_flags;
4937 if (op_mode == IN_PLACE) {
4938 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4939 printf("Device doesn't support in-place scatter-gather "
4940 "in both input and output mbufs.\n");
4944 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4945 printf("Device doesn't support out-of-place scatter-gather "
4946 "in both input and output mbufs.\n");
4949 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4950 printf("Device doesn't support digest encrypted.\n");
4955 /* Create KASUMI session */
4956 retval = create_wireless_algo_auth_cipher_session(
4957 ts_params->valid_devs[0],
4958 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4959 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4960 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4961 : RTE_CRYPTO_AUTH_OP_GENERATE),
4962 RTE_CRYPTO_AUTH_KASUMI_F9,
4963 RTE_CRYPTO_CIPHER_KASUMI_F8,
4964 tdata->key.data, tdata->key.len,
4965 0, tdata->digest.len,
4966 tdata->cipher_iv.len);
4971 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4972 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4973 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4974 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4976 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4977 plaintext_pad_len, 15, 0);
4978 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4979 "Failed to allocate input buffer in mempool");
4981 if (op_mode == OUT_OF_PLACE) {
4982 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4983 plaintext_pad_len, 15, 0);
4984 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4985 "Failed to allocate output buffer in mempool");
4989 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4990 tdata->ciphertext.data);
4991 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4992 ciphertext_len, buffer);
4993 debug_hexdump(stdout, "ciphertext:", ciphertext,
4996 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4997 tdata->plaintext.data);
4998 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4999 plaintext_len, buffer);
5000 debug_hexdump(stdout, "plaintext:", plaintext,
5003 memset(buffer, 0, sizeof(buffer));
5005 /* Create SNOW 3G operation */
5006 retval = create_wireless_algo_auth_cipher_operation(
5008 tdata->cipher_iv.data, tdata->cipher_iv.len,
5010 (tdata->digest.offset_bytes == 0 ?
5011 (verify ? ciphertext_pad_len : plaintext_pad_len)
5012 : tdata->digest.offset_bytes),
5013 tdata->validCipherLenInBits.len,
5014 tdata->validCipherOffsetInBits.len,
5015 tdata->validAuthLenInBits.len,
5022 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5025 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5027 ut_params->obuf = (op_mode == IN_PLACE ?
5028 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5031 if (ut_params->obuf)
5032 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5033 plaintext_len, buffer);
5035 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5036 plaintext_len, buffer);
5038 debug_hexdump(stdout, "plaintext:", plaintext,
5039 (tdata->plaintext.len >> 3) - tdata->digest.len);
5040 debug_hexdump(stdout, "plaintext expected:",
5041 tdata->plaintext.data,
5042 (tdata->plaintext.len >> 3) - tdata->digest.len);
5044 if (ut_params->obuf)
5045 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5046 ciphertext_len, buffer);
5048 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5049 ciphertext_len, buffer);
5051 debug_hexdump(stdout, "ciphertext:", ciphertext,
5053 debug_hexdump(stdout, "ciphertext expected:",
5054 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5056 if (ut_params->obuf)
5057 digest = rte_pktmbuf_read(ut_params->obuf,
5058 (tdata->digest.offset_bytes == 0 ?
5059 plaintext_pad_len : tdata->digest.offset_bytes),
5060 tdata->digest.len, digest_buffer);
5062 digest = rte_pktmbuf_read(ut_params->ibuf,
5063 (tdata->digest.offset_bytes == 0 ?
5064 plaintext_pad_len : tdata->digest.offset_bytes),
5065 tdata->digest.len, digest_buffer);
5067 debug_hexdump(stdout, "digest:", digest,
5069 debug_hexdump(stdout, "digest expected:",
5070 tdata->digest.data, tdata->digest.len);
5075 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5077 tdata->plaintext.data,
5078 tdata->plaintext.len >> 3,
5079 "KASUMI Plaintext data not as expected");
5081 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5083 tdata->ciphertext.data,
5084 tdata->validDataLenInBits.len,
5085 "KASUMI Ciphertext data not as expected");
5087 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5090 DIGEST_BYTE_LENGTH_KASUMI_F9,
5091 "KASUMI Generated auth tag not as expected");
5097 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5099 struct crypto_testsuite_params *ts_params = &testsuite_params;
5100 struct crypto_unittest_params *ut_params = &unittest_params;
5104 uint8_t *plaintext, *ciphertext;
5105 unsigned plaintext_pad_len;
5106 unsigned plaintext_len;
5108 /* Create KASUMI session */
5109 retval = create_wireless_algo_cipher_auth_session(
5110 ts_params->valid_devs[0],
5111 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5112 RTE_CRYPTO_AUTH_OP_GENERATE,
5113 RTE_CRYPTO_AUTH_KASUMI_F9,
5114 RTE_CRYPTO_CIPHER_KASUMI_F8,
5115 tdata->key.data, tdata->key.len,
5116 0, tdata->digest.len,
5117 tdata->cipher_iv.len);
5121 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5123 /* clear mbuf payload */
5124 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5125 rte_pktmbuf_tailroom(ut_params->ibuf));
5127 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5128 /* Append data which is padded to a multiple of */
5129 /* the algorithms block size */
5130 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5131 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5133 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5135 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5137 /* Create KASUMI operation */
5138 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5139 tdata->digest.len, NULL, 0,
5140 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5141 tdata->cipher_iv.data, tdata->cipher_iv.len,
5142 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5143 tdata->validCipherOffsetInBits.len,
5144 tdata->validAuthLenInBits.len,
5150 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5152 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5154 if (ut_params->op->sym->m_dst)
5155 ut_params->obuf = ut_params->op->sym->m_dst;
5157 ut_params->obuf = ut_params->op->sym->m_src;
5159 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5160 tdata->validCipherOffsetInBits.len >> 3);
5162 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5163 + plaintext_pad_len;
5165 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5166 (tdata->validCipherOffsetInBits.len >> 3);
5168 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5170 reference_ciphertext,
5171 tdata->validCipherLenInBits.len,
5172 "KASUMI Ciphertext data not as expected");
5175 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5178 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5179 "KASUMI Generated auth tag not as expected");
5184 test_zuc_encryption(const struct wireless_test_data *tdata)
5186 struct crypto_testsuite_params *ts_params = &testsuite_params;
5187 struct crypto_unittest_params *ut_params = &unittest_params;
5190 uint8_t *plaintext, *ciphertext;
5191 unsigned plaintext_pad_len;
5192 unsigned plaintext_len;
5194 struct rte_cryptodev_sym_capability_idx cap_idx;
5196 /* Check if device supports ZUC EEA3 */
5197 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5198 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5200 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5204 /* Create ZUC session */
5205 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5206 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5207 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5208 tdata->key.data, tdata->key.len,
5209 tdata->cipher_iv.len);
5213 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5215 /* Clear mbuf payload */
5216 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5217 rte_pktmbuf_tailroom(ut_params->ibuf));
5219 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5220 /* Append data which is padded to a multiple */
5221 /* of the algorithms block size */
5222 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5223 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5225 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5227 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5229 /* Create ZUC operation */
5230 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5231 tdata->cipher_iv.len,
5232 tdata->plaintext.len,
5237 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5239 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5241 ut_params->obuf = ut_params->op->sym->m_dst;
5242 if (ut_params->obuf)
5243 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5245 ciphertext = plaintext;
5247 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5250 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5252 tdata->ciphertext.data,
5253 tdata->validCipherLenInBits.len,
5254 "ZUC Ciphertext data not as expected");
5259 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5261 struct crypto_testsuite_params *ts_params = &testsuite_params;
5262 struct crypto_unittest_params *ut_params = &unittest_params;
5266 unsigned int plaintext_pad_len;
5267 unsigned int plaintext_len;
5268 const uint8_t *ciphertext;
5269 uint8_t ciphertext_buffer[2048];
5270 struct rte_cryptodev_info dev_info;
5272 struct rte_cryptodev_sym_capability_idx cap_idx;
5274 /* Check if device supports ZUC EEA3 */
5275 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5276 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5278 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5282 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5284 uint64_t feat_flags = dev_info.feature_flags;
5286 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5287 printf("Device doesn't support in-place scatter-gather. "
5292 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5294 /* Append data which is padded to a multiple */
5295 /* of the algorithms block size */
5296 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5298 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5299 plaintext_pad_len, 10, 0);
5301 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5302 tdata->plaintext.data);
5304 /* Create ZUC session */
5305 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5306 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5307 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5308 tdata->key.data, tdata->key.len,
5309 tdata->cipher_iv.len);
5313 /* Clear mbuf payload */
5315 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5317 /* Create ZUC operation */
5318 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5319 tdata->cipher_iv.len, tdata->plaintext.len,
5324 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5326 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5328 ut_params->obuf = ut_params->op->sym->m_dst;
5329 if (ut_params->obuf)
5330 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5331 0, plaintext_len, ciphertext_buffer);
5333 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5334 0, plaintext_len, ciphertext_buffer);
5337 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5340 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5342 tdata->ciphertext.data,
5343 tdata->validCipherLenInBits.len,
5344 "ZUC Ciphertext data not as expected");
5350 test_zuc_authentication(const struct wireless_test_data *tdata)
5352 struct crypto_testsuite_params *ts_params = &testsuite_params;
5353 struct crypto_unittest_params *ut_params = &unittest_params;
5356 unsigned plaintext_pad_len;
5357 unsigned plaintext_len;
5360 struct rte_cryptodev_sym_capability_idx cap_idx;
5362 /* Check if device supports ZUC EIA3 */
5363 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5364 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5366 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5370 /* Create ZUC session */
5371 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5372 tdata->key.data, tdata->key.len,
5373 tdata->auth_iv.len, tdata->digest.len,
5374 RTE_CRYPTO_AUTH_OP_GENERATE,
5375 RTE_CRYPTO_AUTH_ZUC_EIA3);
5379 /* alloc mbuf and set payload */
5380 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5382 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5383 rte_pktmbuf_tailroom(ut_params->ibuf));
5385 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5386 /* Append data which is padded to a multiple of */
5387 /* the algorithms block size */
5388 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5389 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5391 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5393 /* Create ZUC operation */
5394 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5395 tdata->auth_iv.data, tdata->auth_iv.len,
5396 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5397 tdata->validAuthLenInBits.len,
5402 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5404 ut_params->obuf = ut_params->op->sym->m_src;
5405 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5406 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5407 + plaintext_pad_len;
5410 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5413 DIGEST_BYTE_LENGTH_KASUMI_F9,
5414 "ZUC Generated auth tag not as expected");
5420 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5421 uint8_t op_mode, uint8_t verify)
5423 struct crypto_testsuite_params *ts_params = &testsuite_params;
5424 struct crypto_unittest_params *ut_params = &unittest_params;
5428 uint8_t *plaintext = NULL, *ciphertext = NULL;
5429 unsigned int plaintext_pad_len;
5430 unsigned int plaintext_len;
5431 unsigned int ciphertext_pad_len;
5432 unsigned int ciphertext_len;
5434 struct rte_cryptodev_info dev_info;
5436 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5438 uint64_t feat_flags = dev_info.feature_flags;
5440 if (op_mode == OUT_OF_PLACE) {
5441 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5442 printf("Device doesn't support digest encrypted.\n");
5447 /* Create KASUMI session */
5448 retval = create_wireless_algo_auth_cipher_session(
5449 ts_params->valid_devs[0],
5450 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5451 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5452 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5453 : RTE_CRYPTO_AUTH_OP_GENERATE),
5454 RTE_CRYPTO_AUTH_ZUC_EIA3,
5455 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5456 tdata->key.data, tdata->key.len,
5457 tdata->auth_iv.len, tdata->digest.len,
5458 tdata->cipher_iv.len);
5463 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5464 if (op_mode == OUT_OF_PLACE)
5465 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5467 /* clear mbuf payload */
5468 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5469 rte_pktmbuf_tailroom(ut_params->ibuf));
5470 if (op_mode == OUT_OF_PLACE)
5471 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5472 rte_pktmbuf_tailroom(ut_params->obuf));
5474 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5475 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5476 /* Append data which is padded to a multiple of */
5477 /* the algorithms block size */
5478 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5479 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5482 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5483 ciphertext_pad_len);
5484 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5485 if (op_mode == OUT_OF_PLACE)
5486 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5487 debug_hexdump(stdout, "ciphertext:", ciphertext,
5490 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5492 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5493 if (op_mode == OUT_OF_PLACE)
5494 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5495 debug_hexdump(stdout, "plaintext:", plaintext,
5499 /* Create ZUC operation */
5500 retval = create_wireless_algo_auth_cipher_operation(
5502 tdata->cipher_iv.data, tdata->cipher_iv.len,
5503 tdata->auth_iv.data, tdata->auth_iv.len,
5504 (tdata->digest.offset_bytes == 0 ?
5505 (verify ? ciphertext_pad_len : plaintext_pad_len)
5506 : tdata->digest.offset_bytes),
5507 tdata->validCipherLenInBits.len,
5508 tdata->validCipherOffsetInBits.len,
5509 tdata->validAuthLenInBits.len,
5516 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5519 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5521 ut_params->obuf = (op_mode == IN_PLACE ?
5522 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5526 if (ut_params->obuf)
5527 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5530 plaintext = ciphertext;
5532 debug_hexdump(stdout, "plaintext:", plaintext,
5533 (tdata->plaintext.len >> 3) - tdata->digest.len);
5534 debug_hexdump(stdout, "plaintext expected:",
5535 tdata->plaintext.data,
5536 (tdata->plaintext.len >> 3) - tdata->digest.len);
5538 if (ut_params->obuf)
5539 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5542 ciphertext = plaintext;
5544 debug_hexdump(stdout, "ciphertext:", ciphertext,
5546 debug_hexdump(stdout, "ciphertext expected:",
5547 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5549 ut_params->digest = rte_pktmbuf_mtod(
5550 ut_params->obuf, uint8_t *) +
5551 (tdata->digest.offset_bytes == 0 ?
5552 plaintext_pad_len : tdata->digest.offset_bytes);
5554 debug_hexdump(stdout, "digest:", ut_params->digest,
5556 debug_hexdump(stdout, "digest expected:",
5557 tdata->digest.data, tdata->digest.len);
5562 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5564 tdata->plaintext.data,
5565 tdata->plaintext.len >> 3,
5566 "ZUC Plaintext data not as expected");
5568 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5570 tdata->ciphertext.data,
5571 tdata->ciphertext.len >> 3,
5572 "ZUC Ciphertext data not as expected");
5574 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5577 DIGEST_BYTE_LENGTH_KASUMI_F9,
5578 "ZUC Generated auth tag not as expected");
5584 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5585 uint8_t op_mode, uint8_t verify)
5587 struct crypto_testsuite_params *ts_params = &testsuite_params;
5588 struct crypto_unittest_params *ut_params = &unittest_params;
5592 const uint8_t *plaintext = NULL;
5593 const uint8_t *ciphertext = NULL;
5594 const uint8_t *digest = NULL;
5595 unsigned int plaintext_pad_len;
5596 unsigned int plaintext_len;
5597 unsigned int ciphertext_pad_len;
5598 unsigned int ciphertext_len;
5599 uint8_t buffer[10000];
5600 uint8_t digest_buffer[10000];
5602 struct rte_cryptodev_info dev_info;
5604 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5606 uint64_t feat_flags = dev_info.feature_flags;
5608 if (op_mode == IN_PLACE) {
5609 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5610 printf("Device doesn't support in-place scatter-gather "
5611 "in both input and output mbufs.\n");
5615 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5616 printf("Device doesn't support out-of-place scatter-gather "
5617 "in both input and output mbufs.\n");
5620 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5621 printf("Device doesn't support digest encrypted.\n");
5626 /* Create ZUC session */
5627 retval = create_wireless_algo_auth_cipher_session(
5628 ts_params->valid_devs[0],
5629 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5630 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5631 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5632 : RTE_CRYPTO_AUTH_OP_GENERATE),
5633 RTE_CRYPTO_AUTH_ZUC_EIA3,
5634 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5635 tdata->key.data, tdata->key.len,
5636 tdata->auth_iv.len, tdata->digest.len,
5637 tdata->cipher_iv.len);
5642 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5643 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5644 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5645 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5647 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5648 plaintext_pad_len, 15, 0);
5649 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5650 "Failed to allocate input buffer in mempool");
5652 if (op_mode == OUT_OF_PLACE) {
5653 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5654 plaintext_pad_len, 15, 0);
5655 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5656 "Failed to allocate output buffer in mempool");
5660 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5661 tdata->ciphertext.data);
5662 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5663 ciphertext_len, buffer);
5664 debug_hexdump(stdout, "ciphertext:", ciphertext,
5667 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5668 tdata->plaintext.data);
5669 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5670 plaintext_len, buffer);
5671 debug_hexdump(stdout, "plaintext:", plaintext,
5674 memset(buffer, 0, sizeof(buffer));
5676 /* Create ZUC operation */
5677 retval = create_wireless_algo_auth_cipher_operation(
5679 tdata->cipher_iv.data, tdata->cipher_iv.len,
5681 (tdata->digest.offset_bytes == 0 ?
5682 (verify ? ciphertext_pad_len : plaintext_pad_len)
5683 : tdata->digest.offset_bytes),
5684 tdata->validCipherLenInBits.len,
5685 tdata->validCipherOffsetInBits.len,
5686 tdata->validAuthLenInBits.len,
5693 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5696 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5698 ut_params->obuf = (op_mode == IN_PLACE ?
5699 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5702 if (ut_params->obuf)
5703 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5704 plaintext_len, buffer);
5706 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5707 plaintext_len, buffer);
5709 debug_hexdump(stdout, "plaintext:", plaintext,
5710 (tdata->plaintext.len >> 3) - tdata->digest.len);
5711 debug_hexdump(stdout, "plaintext expected:",
5712 tdata->plaintext.data,
5713 (tdata->plaintext.len >> 3) - tdata->digest.len);
5715 if (ut_params->obuf)
5716 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5717 ciphertext_len, buffer);
5719 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5720 ciphertext_len, buffer);
5722 debug_hexdump(stdout, "ciphertext:", ciphertext,
5724 debug_hexdump(stdout, "ciphertext expected:",
5725 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5727 if (ut_params->obuf)
5728 digest = rte_pktmbuf_read(ut_params->obuf,
5729 (tdata->digest.offset_bytes == 0 ?
5730 plaintext_pad_len : tdata->digest.offset_bytes),
5731 tdata->digest.len, digest_buffer);
5733 digest = rte_pktmbuf_read(ut_params->ibuf,
5734 (tdata->digest.offset_bytes == 0 ?
5735 plaintext_pad_len : tdata->digest.offset_bytes),
5736 tdata->digest.len, digest_buffer);
5738 debug_hexdump(stdout, "digest:", digest,
5740 debug_hexdump(stdout, "digest expected:",
5741 tdata->digest.data, tdata->digest.len);
5746 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5748 tdata->plaintext.data,
5749 tdata->plaintext.len >> 3,
5750 "ZUC Plaintext data not as expected");
5752 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5754 tdata->ciphertext.data,
5755 tdata->validDataLenInBits.len,
5756 "ZUC Ciphertext data not as expected");
5758 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5761 DIGEST_BYTE_LENGTH_KASUMI_F9,
5762 "ZUC Generated auth tag not as expected");
5768 test_kasumi_encryption_test_case_1(void)
5770 return test_kasumi_encryption(&kasumi_test_case_1);
5774 test_kasumi_encryption_test_case_1_sgl(void)
5776 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5780 test_kasumi_encryption_test_case_1_oop(void)
5782 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5786 test_kasumi_encryption_test_case_1_oop_sgl(void)
5788 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5792 test_kasumi_encryption_test_case_2(void)
5794 return test_kasumi_encryption(&kasumi_test_case_2);
5798 test_kasumi_encryption_test_case_3(void)
5800 return test_kasumi_encryption(&kasumi_test_case_3);
5804 test_kasumi_encryption_test_case_4(void)
5806 return test_kasumi_encryption(&kasumi_test_case_4);
5810 test_kasumi_encryption_test_case_5(void)
5812 return test_kasumi_encryption(&kasumi_test_case_5);
5816 test_kasumi_decryption_test_case_1(void)
5818 return test_kasumi_decryption(&kasumi_test_case_1);
5822 test_kasumi_decryption_test_case_1_oop(void)
5824 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5828 test_kasumi_decryption_test_case_2(void)
5830 return test_kasumi_decryption(&kasumi_test_case_2);
5834 test_kasumi_decryption_test_case_3(void)
5836 return test_kasumi_decryption(&kasumi_test_case_3);
5840 test_kasumi_decryption_test_case_4(void)
5842 return test_kasumi_decryption(&kasumi_test_case_4);
5846 test_kasumi_decryption_test_case_5(void)
5848 return test_kasumi_decryption(&kasumi_test_case_5);
5851 test_snow3g_encryption_test_case_1(void)
5853 return test_snow3g_encryption(&snow3g_test_case_1);
5857 test_snow3g_encryption_test_case_1_oop(void)
5859 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5863 test_snow3g_encryption_test_case_1_oop_sgl(void)
5865 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5870 test_snow3g_encryption_test_case_1_offset_oop(void)
5872 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5876 test_snow3g_encryption_test_case_2(void)
5878 return test_snow3g_encryption(&snow3g_test_case_2);
5882 test_snow3g_encryption_test_case_3(void)
5884 return test_snow3g_encryption(&snow3g_test_case_3);
5888 test_snow3g_encryption_test_case_4(void)
5890 return test_snow3g_encryption(&snow3g_test_case_4);
5894 test_snow3g_encryption_test_case_5(void)
5896 return test_snow3g_encryption(&snow3g_test_case_5);
5900 test_snow3g_decryption_test_case_1(void)
5902 return test_snow3g_decryption(&snow3g_test_case_1);
5906 test_snow3g_decryption_test_case_1_oop(void)
5908 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5912 test_snow3g_decryption_test_case_2(void)
5914 return test_snow3g_decryption(&snow3g_test_case_2);
5918 test_snow3g_decryption_test_case_3(void)
5920 return test_snow3g_decryption(&snow3g_test_case_3);
5924 test_snow3g_decryption_test_case_4(void)
5926 return test_snow3g_decryption(&snow3g_test_case_4);
5930 test_snow3g_decryption_test_case_5(void)
5932 return test_snow3g_decryption(&snow3g_test_case_5);
5936 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5937 * Pattern digest from snow3g_test_data must be allocated as
5938 * 4 last bytes in plaintext.
5941 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5942 struct snow3g_hash_test_data *output)
5944 if ((pattern != NULL) && (output != NULL)) {
5945 output->key.len = pattern->key.len;
5947 memcpy(output->key.data,
5948 pattern->key.data, pattern->key.len);
5950 output->auth_iv.len = pattern->auth_iv.len;
5952 memcpy(output->auth_iv.data,
5953 pattern->auth_iv.data, pattern->auth_iv.len);
5955 output->plaintext.len = pattern->plaintext.len;
5957 memcpy(output->plaintext.data,
5958 pattern->plaintext.data, pattern->plaintext.len >> 3);
5960 output->digest.len = pattern->digest.len;
5962 memcpy(output->digest.data,
5963 &pattern->plaintext.data[pattern->digest.offset_bytes],
5964 pattern->digest.len);
5966 output->validAuthLenInBits.len =
5967 pattern->validAuthLenInBits.len;
5972 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5975 test_snow3g_decryption_with_digest_test_case_1(void)
5977 struct snow3g_hash_test_data snow3g_hash_data;
5980 * Function prepare data for hash veryfication test case.
5981 * Digest is allocated in 4 last bytes in plaintext, pattern.
5983 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5985 return test_snow3g_decryption(&snow3g_test_case_7) &
5986 test_snow3g_authentication_verify(&snow3g_hash_data);
5990 test_snow3g_cipher_auth_test_case_1(void)
5992 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5996 test_snow3g_auth_cipher_test_case_1(void)
5998 return test_snow3g_auth_cipher(
5999 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6003 test_snow3g_auth_cipher_test_case_2(void)
6005 return test_snow3g_auth_cipher(
6006 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6010 test_snow3g_auth_cipher_test_case_2_oop(void)
6012 return test_snow3g_auth_cipher(
6013 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6017 test_snow3g_auth_cipher_part_digest_enc(void)
6019 return test_snow3g_auth_cipher(
6020 &snow3g_auth_cipher_partial_digest_encryption,
6025 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6027 return test_snow3g_auth_cipher(
6028 &snow3g_auth_cipher_partial_digest_encryption,
6033 test_snow3g_auth_cipher_test_case_3_sgl(void)
6035 return test_snow3g_auth_cipher_sgl(
6036 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6040 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6042 return test_snow3g_auth_cipher_sgl(
6043 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6047 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6049 return test_snow3g_auth_cipher_sgl(
6050 &snow3g_auth_cipher_partial_digest_encryption,
6055 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6057 return test_snow3g_auth_cipher_sgl(
6058 &snow3g_auth_cipher_partial_digest_encryption,
6063 test_snow3g_auth_cipher_verify_test_case_1(void)
6065 return test_snow3g_auth_cipher(
6066 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6070 test_snow3g_auth_cipher_verify_test_case_2(void)
6072 return test_snow3g_auth_cipher(
6073 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6077 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6079 return test_snow3g_auth_cipher(
6080 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6084 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6086 return test_snow3g_auth_cipher(
6087 &snow3g_auth_cipher_partial_digest_encryption,
6092 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6094 return test_snow3g_auth_cipher(
6095 &snow3g_auth_cipher_partial_digest_encryption,
6100 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6102 return test_snow3g_auth_cipher_sgl(
6103 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6107 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6109 return test_snow3g_auth_cipher_sgl(
6110 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6114 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6116 return test_snow3g_auth_cipher_sgl(
6117 &snow3g_auth_cipher_partial_digest_encryption,
6122 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6124 return test_snow3g_auth_cipher_sgl(
6125 &snow3g_auth_cipher_partial_digest_encryption,
6130 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6132 return test_snow3g_auth_cipher(
6133 &snow3g_test_case_7, IN_PLACE, 0);
6137 test_kasumi_auth_cipher_test_case_1(void)
6139 return test_kasumi_auth_cipher(
6140 &kasumi_test_case_3, IN_PLACE, 0);
6144 test_kasumi_auth_cipher_test_case_2(void)
6146 return test_kasumi_auth_cipher(
6147 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6151 test_kasumi_auth_cipher_test_case_2_oop(void)
6153 return test_kasumi_auth_cipher(
6154 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6158 test_kasumi_auth_cipher_test_case_2_sgl(void)
6160 return test_kasumi_auth_cipher_sgl(
6161 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6165 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6167 return test_kasumi_auth_cipher_sgl(
6168 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6172 test_kasumi_auth_cipher_verify_test_case_1(void)
6174 return test_kasumi_auth_cipher(
6175 &kasumi_test_case_3, IN_PLACE, 1);
6179 test_kasumi_auth_cipher_verify_test_case_2(void)
6181 return test_kasumi_auth_cipher(
6182 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6186 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6188 return test_kasumi_auth_cipher(
6189 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6193 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6195 return test_kasumi_auth_cipher_sgl(
6196 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6200 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6202 return test_kasumi_auth_cipher_sgl(
6203 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6207 test_kasumi_cipher_auth_test_case_1(void)
6209 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6213 test_zuc_encryption_test_case_1(void)
6215 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6219 test_zuc_encryption_test_case_2(void)
6221 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6225 test_zuc_encryption_test_case_3(void)
6227 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6231 test_zuc_encryption_test_case_4(void)
6233 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6237 test_zuc_encryption_test_case_5(void)
6239 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6243 test_zuc_encryption_test_case_6_sgl(void)
6245 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6249 test_zuc_hash_generate_test_case_1(void)
6251 return test_zuc_authentication(&zuc_test_case_auth_1b);
6255 test_zuc_hash_generate_test_case_2(void)
6257 return test_zuc_authentication(&zuc_test_case_auth_90b);
6261 test_zuc_hash_generate_test_case_3(void)
6263 return test_zuc_authentication(&zuc_test_case_auth_577b);
6267 test_zuc_hash_generate_test_case_4(void)
6269 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6273 test_zuc_hash_generate_test_case_5(void)
6275 return test_zuc_authentication(&zuc_test_auth_5670b);
6279 test_zuc_hash_generate_test_case_6(void)
6281 return test_zuc_authentication(&zuc_test_case_auth_128b);
6285 test_zuc_hash_generate_test_case_7(void)
6287 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6291 test_zuc_hash_generate_test_case_8(void)
6293 return test_zuc_authentication(&zuc_test_case_auth_584b);
6297 test_zuc_cipher_auth_test_case_1(void)
6299 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6303 test_zuc_cipher_auth_test_case_2(void)
6305 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6309 test_zuc_auth_cipher_test_case_1(void)
6311 return test_zuc_auth_cipher(
6312 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6316 test_zuc_auth_cipher_test_case_1_oop(void)
6318 return test_zuc_auth_cipher(
6319 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6323 test_zuc_auth_cipher_test_case_1_sgl(void)
6325 return test_zuc_auth_cipher_sgl(
6326 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6330 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6332 return test_zuc_auth_cipher_sgl(
6333 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6337 test_zuc_auth_cipher_verify_test_case_1(void)
6339 return test_zuc_auth_cipher(
6340 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6344 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6346 return test_zuc_auth_cipher(
6347 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6351 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6353 return test_zuc_auth_cipher_sgl(
6354 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6358 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6360 return test_zuc_auth_cipher_sgl(
6361 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6365 test_3DES_chain_qat_all(void)
6367 struct crypto_testsuite_params *ts_params = &testsuite_params;
6370 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6371 ts_params->op_mpool,
6372 ts_params->session_mpool, ts_params->session_priv_mpool,
6373 ts_params->valid_devs[0],
6374 rte_cryptodev_driver_id_get(
6375 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6376 BLKCIPHER_3DES_CHAIN_TYPE);
6378 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6380 return TEST_SUCCESS;
6384 test_DES_cipheronly_qat_all(void)
6386 struct crypto_testsuite_params *ts_params = &testsuite_params;
6389 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6390 ts_params->op_mpool,
6391 ts_params->session_mpool, ts_params->session_priv_mpool,
6392 ts_params->valid_devs[0],
6393 rte_cryptodev_driver_id_get(
6394 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6395 BLKCIPHER_DES_CIPHERONLY_TYPE);
6397 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6399 return TEST_SUCCESS;
6403 test_DES_cipheronly_openssl_all(void)
6405 struct crypto_testsuite_params *ts_params = &testsuite_params;
6408 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6409 ts_params->op_mpool,
6410 ts_params->session_mpool, ts_params->session_priv_mpool,
6411 ts_params->valid_devs[0],
6412 rte_cryptodev_driver_id_get(
6413 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6414 BLKCIPHER_DES_CIPHERONLY_TYPE);
6416 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6418 return TEST_SUCCESS;
6422 test_DES_docsis_openssl_all(void)
6424 struct crypto_testsuite_params *ts_params = &testsuite_params;
6427 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6428 ts_params->op_mpool,
6429 ts_params->session_mpool, ts_params->session_priv_mpool,
6430 ts_params->valid_devs[0],
6431 rte_cryptodev_driver_id_get(
6432 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6433 BLKCIPHER_DES_DOCSIS_TYPE);
6435 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6437 return TEST_SUCCESS;
6441 test_DES_cipheronly_mb_all(void)
6443 struct crypto_testsuite_params *ts_params = &testsuite_params;
6446 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6447 ts_params->op_mpool,
6448 ts_params->session_mpool, ts_params->session_priv_mpool,
6449 ts_params->valid_devs[0],
6450 rte_cryptodev_driver_id_get(
6451 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6452 BLKCIPHER_DES_CIPHERONLY_TYPE);
6454 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6456 return TEST_SUCCESS;
6459 test_3DES_cipheronly_mb_all(void)
6461 struct crypto_testsuite_params *ts_params = &testsuite_params;
6464 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6465 ts_params->op_mpool,
6466 ts_params->session_mpool, ts_params->session_priv_mpool,
6467 ts_params->valid_devs[0],
6468 rte_cryptodev_driver_id_get(
6469 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6470 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6472 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6474 return TEST_SUCCESS;
6478 test_DES_docsis_mb_all(void)
6480 struct crypto_testsuite_params *ts_params = &testsuite_params;
6483 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6484 ts_params->op_mpool,
6485 ts_params->session_mpool, ts_params->session_priv_mpool,
6486 ts_params->valid_devs[0],
6487 rte_cryptodev_driver_id_get(
6488 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6489 BLKCIPHER_DES_DOCSIS_TYPE);
6491 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6493 return TEST_SUCCESS;
6497 test_3DES_chain_caam_jr_all(void)
6499 struct crypto_testsuite_params *ts_params = &testsuite_params;
6502 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6503 ts_params->op_mpool,
6504 ts_params->session_mpool, ts_params->session_priv_mpool,
6505 ts_params->valid_devs[0],
6506 rte_cryptodev_driver_id_get(
6507 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6508 BLKCIPHER_3DES_CHAIN_TYPE);
6510 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6512 return TEST_SUCCESS;
6516 test_3DES_cipheronly_caam_jr_all(void)
6518 struct crypto_testsuite_params *ts_params = &testsuite_params;
6521 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6522 ts_params->op_mpool,
6523 ts_params->session_mpool, ts_params->session_priv_mpool,
6524 ts_params->valid_devs[0],
6525 rte_cryptodev_driver_id_get(
6526 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6527 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6531 return TEST_SUCCESS;
6535 test_3DES_chain_dpaa_sec_all(void)
6537 struct crypto_testsuite_params *ts_params = &testsuite_params;
6540 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6541 ts_params->op_mpool,
6542 ts_params->session_mpool, ts_params->session_priv_mpool,
6543 ts_params->valid_devs[0],
6544 rte_cryptodev_driver_id_get(
6545 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
6546 BLKCIPHER_3DES_CHAIN_TYPE);
6548 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6550 return TEST_SUCCESS;
6554 test_3DES_cipheronly_dpaa_sec_all(void)
6556 struct crypto_testsuite_params *ts_params = &testsuite_params;
6559 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6560 ts_params->op_mpool,
6561 ts_params->session_mpool, ts_params->session_priv_mpool,
6562 ts_params->valid_devs[0],
6563 rte_cryptodev_driver_id_get(
6564 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
6565 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6567 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6569 return TEST_SUCCESS;
6573 test_3DES_chain_dpaa2_sec_all(void)
6575 struct crypto_testsuite_params *ts_params = &testsuite_params;
6578 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6579 ts_params->op_mpool,
6580 ts_params->session_mpool, ts_params->session_priv_mpool,
6581 ts_params->valid_devs[0],
6582 rte_cryptodev_driver_id_get(
6583 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
6584 BLKCIPHER_3DES_CHAIN_TYPE);
6586 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6588 return TEST_SUCCESS;
6592 test_3DES_cipheronly_dpaa2_sec_all(void)
6594 struct crypto_testsuite_params *ts_params = &testsuite_params;
6597 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6598 ts_params->op_mpool,
6599 ts_params->session_mpool, ts_params->session_priv_mpool,
6600 ts_params->valid_devs[0],
6601 rte_cryptodev_driver_id_get(
6602 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
6603 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6605 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6607 return TEST_SUCCESS;
6611 test_3DES_chain_ccp_all(void)
6613 struct crypto_testsuite_params *ts_params = &testsuite_params;
6616 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6617 ts_params->op_mpool,
6618 ts_params->session_mpool, ts_params->session_priv_mpool,
6619 ts_params->valid_devs[0],
6620 rte_cryptodev_driver_id_get(
6621 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
6622 BLKCIPHER_3DES_CHAIN_TYPE);
6624 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6626 return TEST_SUCCESS;
6630 test_3DES_cipheronly_ccp_all(void)
6632 struct crypto_testsuite_params *ts_params = &testsuite_params;
6635 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6636 ts_params->op_mpool,
6637 ts_params->session_mpool, ts_params->session_priv_mpool,
6638 ts_params->valid_devs[0],
6639 rte_cryptodev_driver_id_get(
6640 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
6641 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6643 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6645 return TEST_SUCCESS;
6649 test_3DES_cipheronly_qat_all(void)
6651 struct crypto_testsuite_params *ts_params = &testsuite_params;
6654 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6655 ts_params->op_mpool,
6656 ts_params->session_mpool, ts_params->session_priv_mpool,
6657 ts_params->valid_devs[0],
6658 rte_cryptodev_driver_id_get(
6659 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6660 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6662 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6664 return TEST_SUCCESS;
6668 test_3DES_chain_openssl_all(void)
6670 struct crypto_testsuite_params *ts_params = &testsuite_params;
6673 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6674 ts_params->op_mpool,
6675 ts_params->session_mpool, ts_params->session_priv_mpool,
6676 ts_params->valid_devs[0],
6677 rte_cryptodev_driver_id_get(
6678 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6679 BLKCIPHER_3DES_CHAIN_TYPE);
6681 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6683 return TEST_SUCCESS;
6687 test_3DES_cipheronly_openssl_all(void)
6689 struct crypto_testsuite_params *ts_params = &testsuite_params;
6692 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6693 ts_params->op_mpool,
6694 ts_params->session_mpool, ts_params->session_priv_mpool,
6695 ts_params->valid_devs[0],
6696 rte_cryptodev_driver_id_get(
6697 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6698 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6700 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6702 return TEST_SUCCESS;
6705 /* ***** AEAD algorithm Tests ***** */
6708 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6709 enum rte_crypto_aead_operation op,
6710 const uint8_t *key, const uint8_t key_len,
6711 const uint16_t aad_len, const uint8_t auth_len,
6714 uint8_t aead_key[key_len];
6716 struct crypto_testsuite_params *ts_params = &testsuite_params;
6717 struct crypto_unittest_params *ut_params = &unittest_params;
6719 memcpy(aead_key, key, key_len);
6721 /* Setup AEAD Parameters */
6722 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6723 ut_params->aead_xform.next = NULL;
6724 ut_params->aead_xform.aead.algo = algo;
6725 ut_params->aead_xform.aead.op = op;
6726 ut_params->aead_xform.aead.key.data = aead_key;
6727 ut_params->aead_xform.aead.key.length = key_len;
6728 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6729 ut_params->aead_xform.aead.iv.length = iv_len;
6730 ut_params->aead_xform.aead.digest_length = auth_len;
6731 ut_params->aead_xform.aead.aad_length = aad_len;
6733 debug_hexdump(stdout, "key:", key, key_len);
6735 /* Create Crypto session*/
6736 ut_params->sess = rte_cryptodev_sym_session_create(
6737 ts_params->session_mpool);
6739 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6740 &ut_params->aead_xform,
6741 ts_params->session_priv_mpool);
6743 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6749 create_aead_xform(struct rte_crypto_op *op,
6750 enum rte_crypto_aead_algorithm algo,
6751 enum rte_crypto_aead_operation aead_op,
6752 uint8_t *key, const uint8_t key_len,
6753 const uint8_t aad_len, const uint8_t auth_len,
6756 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6757 "failed to allocate space for crypto transform");
6759 struct rte_crypto_sym_op *sym_op = op->sym;
6761 /* Setup AEAD Parameters */
6762 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6763 sym_op->xform->next = NULL;
6764 sym_op->xform->aead.algo = algo;
6765 sym_op->xform->aead.op = aead_op;
6766 sym_op->xform->aead.key.data = key;
6767 sym_op->xform->aead.key.length = key_len;
6768 sym_op->xform->aead.iv.offset = IV_OFFSET;
6769 sym_op->xform->aead.iv.length = iv_len;
6770 sym_op->xform->aead.digest_length = auth_len;
6771 sym_op->xform->aead.aad_length = aad_len;
6773 debug_hexdump(stdout, "key:", key, key_len);
6779 create_aead_operation(enum rte_crypto_aead_operation op,
6780 const struct aead_test_data *tdata)
6782 struct crypto_testsuite_params *ts_params = &testsuite_params;
6783 struct crypto_unittest_params *ut_params = &unittest_params;
6785 uint8_t *plaintext, *ciphertext;
6786 unsigned int aad_pad_len, plaintext_pad_len;
6788 /* Generate Crypto op data structure */
6789 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6790 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6791 TEST_ASSERT_NOT_NULL(ut_params->op,
6792 "Failed to allocate symmetric crypto operation struct");
6794 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6796 /* Append aad data */
6797 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6798 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6799 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6801 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6802 "no room to append aad");
6804 sym_op->aead.aad.phys_addr =
6805 rte_pktmbuf_iova(ut_params->ibuf);
6806 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6807 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6808 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6811 /* Append IV at the end of the crypto operation*/
6812 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6813 uint8_t *, IV_OFFSET);
6815 /* Copy IV 1 byte after the IV pointer, according to the API */
6816 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6817 debug_hexdump(stdout, "iv:", iv_ptr,
6820 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6821 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6823 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6824 "no room to append aad");
6826 sym_op->aead.aad.phys_addr =
6827 rte_pktmbuf_iova(ut_params->ibuf);
6828 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6829 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6832 /* Append IV at the end of the crypto operation*/
6833 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6834 uint8_t *, IV_OFFSET);
6836 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6837 debug_hexdump(stdout, "iv:", iv_ptr,
6841 /* Append plaintext/ciphertext */
6842 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6843 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6844 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6846 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6848 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6849 debug_hexdump(stdout, "plaintext:", plaintext,
6850 tdata->plaintext.len);
6852 if (ut_params->obuf) {
6853 ciphertext = (uint8_t *)rte_pktmbuf_append(
6855 plaintext_pad_len + aad_pad_len);
6856 TEST_ASSERT_NOT_NULL(ciphertext,
6857 "no room to append ciphertext");
6859 memset(ciphertext + aad_pad_len, 0,
6860 tdata->ciphertext.len);
6863 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6864 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6866 TEST_ASSERT_NOT_NULL(ciphertext,
6867 "no room to append ciphertext");
6869 memcpy(ciphertext, tdata->ciphertext.data,
6870 tdata->ciphertext.len);
6871 debug_hexdump(stdout, "ciphertext:", ciphertext,
6872 tdata->ciphertext.len);
6874 if (ut_params->obuf) {
6875 plaintext = (uint8_t *)rte_pktmbuf_append(
6877 plaintext_pad_len + aad_pad_len);
6878 TEST_ASSERT_NOT_NULL(plaintext,
6879 "no room to append plaintext");
6881 memset(plaintext + aad_pad_len, 0,
6882 tdata->plaintext.len);
6886 /* Append digest data */
6887 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6888 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6889 ut_params->obuf ? ut_params->obuf :
6891 tdata->auth_tag.len);
6892 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6893 "no room to append digest");
6894 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6895 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6896 ut_params->obuf ? ut_params->obuf :
6901 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6902 ut_params->ibuf, tdata->auth_tag.len);
6903 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6904 "no room to append digest");
6905 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6907 plaintext_pad_len + aad_pad_len);
6909 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6910 tdata->auth_tag.len);
6911 debug_hexdump(stdout, "digest:",
6912 sym_op->aead.digest.data,
6913 tdata->auth_tag.len);
6916 sym_op->aead.data.length = tdata->plaintext.len;
6917 sym_op->aead.data.offset = aad_pad_len;
6923 test_authenticated_encryption(const struct aead_test_data *tdata)
6925 struct crypto_testsuite_params *ts_params = &testsuite_params;
6926 struct crypto_unittest_params *ut_params = &unittest_params;
6929 uint8_t *ciphertext, *auth_tag;
6930 uint16_t plaintext_pad_len;
6933 /* Create AEAD session */
6934 retval = create_aead_session(ts_params->valid_devs[0],
6936 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6937 tdata->key.data, tdata->key.len,
6938 tdata->aad.len, tdata->auth_tag.len,
6943 if (tdata->aad.len > MBUF_SIZE) {
6944 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6945 /* Populate full size of add data */
6946 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6947 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6949 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6951 /* clear mbuf payload */
6952 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6953 rte_pktmbuf_tailroom(ut_params->ibuf));
6955 /* Create AEAD operation */
6956 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6960 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6962 ut_params->op->sym->m_src = ut_params->ibuf;
6964 /* Process crypto operation */
6965 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6966 ut_params->op), "failed to process sym crypto op");
6968 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6969 "crypto op processing failed");
6971 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6973 if (ut_params->op->sym->m_dst) {
6974 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6976 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6977 uint8_t *, plaintext_pad_len);
6979 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6981 ut_params->op->sym->cipher.data.offset);
6982 auth_tag = ciphertext + plaintext_pad_len;
6985 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6986 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6989 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6991 tdata->ciphertext.data,
6992 tdata->ciphertext.len,
6993 "Ciphertext data not as expected");
6995 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6997 tdata->auth_tag.data,
6998 tdata->auth_tag.len,
6999 "Generated auth tag not as expected");
7006 test_AES_GCM_authenticated_encryption_test_case_1(void)
7008 return test_authenticated_encryption(&gcm_test_case_1);
7012 test_AES_GCM_authenticated_encryption_test_case_2(void)
7014 return test_authenticated_encryption(&gcm_test_case_2);
7018 test_AES_GCM_authenticated_encryption_test_case_3(void)
7020 return test_authenticated_encryption(&gcm_test_case_3);
7024 test_AES_GCM_authenticated_encryption_test_case_4(void)
7026 return test_authenticated_encryption(&gcm_test_case_4);
7030 test_AES_GCM_authenticated_encryption_test_case_5(void)
7032 return test_authenticated_encryption(&gcm_test_case_5);
7036 test_AES_GCM_authenticated_encryption_test_case_6(void)
7038 return test_authenticated_encryption(&gcm_test_case_6);
7042 test_AES_GCM_authenticated_encryption_test_case_7(void)
7044 return test_authenticated_encryption(&gcm_test_case_7);
7048 test_AES_GCM_auth_encryption_test_case_192_1(void)
7050 return test_authenticated_encryption(&gcm_test_case_192_1);
7054 test_AES_GCM_auth_encryption_test_case_192_2(void)
7056 return test_authenticated_encryption(&gcm_test_case_192_2);
7060 test_AES_GCM_auth_encryption_test_case_192_3(void)
7062 return test_authenticated_encryption(&gcm_test_case_192_3);
7066 test_AES_GCM_auth_encryption_test_case_192_4(void)
7068 return test_authenticated_encryption(&gcm_test_case_192_4);
7072 test_AES_GCM_auth_encryption_test_case_192_5(void)
7074 return test_authenticated_encryption(&gcm_test_case_192_5);
7078 test_AES_GCM_auth_encryption_test_case_192_6(void)
7080 return test_authenticated_encryption(&gcm_test_case_192_6);
7084 test_AES_GCM_auth_encryption_test_case_192_7(void)
7086 return test_authenticated_encryption(&gcm_test_case_192_7);
7090 test_AES_GCM_auth_encryption_test_case_256_1(void)
7092 return test_authenticated_encryption(&gcm_test_case_256_1);
7096 test_AES_GCM_auth_encryption_test_case_256_2(void)
7098 return test_authenticated_encryption(&gcm_test_case_256_2);
7102 test_AES_GCM_auth_encryption_test_case_256_3(void)
7104 return test_authenticated_encryption(&gcm_test_case_256_3);
7108 test_AES_GCM_auth_encryption_test_case_256_4(void)
7110 return test_authenticated_encryption(&gcm_test_case_256_4);
7114 test_AES_GCM_auth_encryption_test_case_256_5(void)
7116 return test_authenticated_encryption(&gcm_test_case_256_5);
7120 test_AES_GCM_auth_encryption_test_case_256_6(void)
7122 return test_authenticated_encryption(&gcm_test_case_256_6);
7126 test_AES_GCM_auth_encryption_test_case_256_7(void)
7128 return test_authenticated_encryption(&gcm_test_case_256_7);
7132 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7134 return test_authenticated_encryption(&gcm_test_case_aad_1);
7138 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7140 return test_authenticated_encryption(&gcm_test_case_aad_2);
7144 test_authenticated_decryption(const struct aead_test_data *tdata)
7146 struct crypto_testsuite_params *ts_params = &testsuite_params;
7147 struct crypto_unittest_params *ut_params = &unittest_params;
7153 /* Create AEAD session */
7154 retval = create_aead_session(ts_params->valid_devs[0],
7156 RTE_CRYPTO_AEAD_OP_DECRYPT,
7157 tdata->key.data, tdata->key.len,
7158 tdata->aad.len, tdata->auth_tag.len,
7163 /* alloc mbuf and set payload */
7164 if (tdata->aad.len > MBUF_SIZE) {
7165 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7166 /* Populate full size of add data */
7167 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7168 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7170 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7172 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7173 rte_pktmbuf_tailroom(ut_params->ibuf));
7175 /* Create AEAD operation */
7176 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7180 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7182 ut_params->op->sym->m_src = ut_params->ibuf;
7184 /* Process crypto operation */
7185 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7186 ut_params->op), "failed to process sym crypto op");
7188 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7189 "crypto op processing failed");
7191 if (ut_params->op->sym->m_dst)
7192 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7195 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7197 ut_params->op->sym->cipher.data.offset);
7199 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7202 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7204 tdata->plaintext.data,
7205 tdata->plaintext.len,
7206 "Plaintext data not as expected");
7208 TEST_ASSERT_EQUAL(ut_params->op->status,
7209 RTE_CRYPTO_OP_STATUS_SUCCESS,
7210 "Authentication failed");
7215 test_AES_GCM_authenticated_decryption_test_case_1(void)
7217 return test_authenticated_decryption(&gcm_test_case_1);
7221 test_AES_GCM_authenticated_decryption_test_case_2(void)
7223 return test_authenticated_decryption(&gcm_test_case_2);
7227 test_AES_GCM_authenticated_decryption_test_case_3(void)
7229 return test_authenticated_decryption(&gcm_test_case_3);
7233 test_AES_GCM_authenticated_decryption_test_case_4(void)
7235 return test_authenticated_decryption(&gcm_test_case_4);
7239 test_AES_GCM_authenticated_decryption_test_case_5(void)
7241 return test_authenticated_decryption(&gcm_test_case_5);
7245 test_AES_GCM_authenticated_decryption_test_case_6(void)
7247 return test_authenticated_decryption(&gcm_test_case_6);
7251 test_AES_GCM_authenticated_decryption_test_case_7(void)
7253 return test_authenticated_decryption(&gcm_test_case_7);
7257 test_AES_GCM_auth_decryption_test_case_192_1(void)
7259 return test_authenticated_decryption(&gcm_test_case_192_1);
7263 test_AES_GCM_auth_decryption_test_case_192_2(void)
7265 return test_authenticated_decryption(&gcm_test_case_192_2);
7269 test_AES_GCM_auth_decryption_test_case_192_3(void)
7271 return test_authenticated_decryption(&gcm_test_case_192_3);
7275 test_AES_GCM_auth_decryption_test_case_192_4(void)
7277 return test_authenticated_decryption(&gcm_test_case_192_4);
7281 test_AES_GCM_auth_decryption_test_case_192_5(void)
7283 return test_authenticated_decryption(&gcm_test_case_192_5);
7287 test_AES_GCM_auth_decryption_test_case_192_6(void)
7289 return test_authenticated_decryption(&gcm_test_case_192_6);
7293 test_AES_GCM_auth_decryption_test_case_192_7(void)
7295 return test_authenticated_decryption(&gcm_test_case_192_7);
7299 test_AES_GCM_auth_decryption_test_case_256_1(void)
7301 return test_authenticated_decryption(&gcm_test_case_256_1);
7305 test_AES_GCM_auth_decryption_test_case_256_2(void)
7307 return test_authenticated_decryption(&gcm_test_case_256_2);
7311 test_AES_GCM_auth_decryption_test_case_256_3(void)
7313 return test_authenticated_decryption(&gcm_test_case_256_3);
7317 test_AES_GCM_auth_decryption_test_case_256_4(void)
7319 return test_authenticated_decryption(&gcm_test_case_256_4);
7323 test_AES_GCM_auth_decryption_test_case_256_5(void)
7325 return test_authenticated_decryption(&gcm_test_case_256_5);
7329 test_AES_GCM_auth_decryption_test_case_256_6(void)
7331 return test_authenticated_decryption(&gcm_test_case_256_6);
7335 test_AES_GCM_auth_decryption_test_case_256_7(void)
7337 return test_authenticated_decryption(&gcm_test_case_256_7);
7341 test_AES_GCM_auth_decryption_test_case_aad_1(void)
7343 return test_authenticated_decryption(&gcm_test_case_aad_1);
7347 test_AES_GCM_auth_decryption_test_case_aad_2(void)
7349 return test_authenticated_decryption(&gcm_test_case_aad_2);
7353 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
7355 struct crypto_testsuite_params *ts_params = &testsuite_params;
7356 struct crypto_unittest_params *ut_params = &unittest_params;
7359 uint8_t *ciphertext, *auth_tag;
7360 uint16_t plaintext_pad_len;
7362 /* Create AEAD session */
7363 retval = create_aead_session(ts_params->valid_devs[0],
7365 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7366 tdata->key.data, tdata->key.len,
7367 tdata->aad.len, tdata->auth_tag.len,
7372 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7373 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7375 /* clear mbuf payload */
7376 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7377 rte_pktmbuf_tailroom(ut_params->ibuf));
7378 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7379 rte_pktmbuf_tailroom(ut_params->obuf));
7381 /* Create AEAD operation */
7382 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7386 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7388 ut_params->op->sym->m_src = ut_params->ibuf;
7389 ut_params->op->sym->m_dst = ut_params->obuf;
7391 /* Process crypto operation */
7392 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7393 ut_params->op), "failed to process sym crypto op");
7395 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7396 "crypto op processing failed");
7398 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7400 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
7401 ut_params->op->sym->cipher.data.offset);
7402 auth_tag = ciphertext + plaintext_pad_len;
7404 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7405 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7408 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7410 tdata->ciphertext.data,
7411 tdata->ciphertext.len,
7412 "Ciphertext data not as expected");
7414 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7416 tdata->auth_tag.data,
7417 tdata->auth_tag.len,
7418 "Generated auth tag not as expected");
7425 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
7427 return test_authenticated_encryption_oop(&gcm_test_case_5);
7431 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
7433 struct crypto_testsuite_params *ts_params = &testsuite_params;
7434 struct crypto_unittest_params *ut_params = &unittest_params;
7439 /* Create AEAD session */
7440 retval = create_aead_session(ts_params->valid_devs[0],
7442 RTE_CRYPTO_AEAD_OP_DECRYPT,
7443 tdata->key.data, tdata->key.len,
7444 tdata->aad.len, tdata->auth_tag.len,
7449 /* alloc mbuf and set payload */
7450 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7451 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7453 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7454 rte_pktmbuf_tailroom(ut_params->ibuf));
7455 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7456 rte_pktmbuf_tailroom(ut_params->obuf));
7458 /* Create AEAD operation */
7459 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7463 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7465 ut_params->op->sym->m_src = ut_params->ibuf;
7466 ut_params->op->sym->m_dst = ut_params->obuf;
7468 /* Process crypto operation */
7469 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7470 ut_params->op), "failed to process sym crypto op");
7472 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7473 "crypto op processing failed");
7475 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
7476 ut_params->op->sym->cipher.data.offset);
7478 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7481 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7483 tdata->plaintext.data,
7484 tdata->plaintext.len,
7485 "Plaintext data not as expected");
7487 TEST_ASSERT_EQUAL(ut_params->op->status,
7488 RTE_CRYPTO_OP_STATUS_SUCCESS,
7489 "Authentication failed");
7494 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
7496 return test_authenticated_decryption_oop(&gcm_test_case_5);
7500 test_authenticated_encryption_sessionless(
7501 const struct aead_test_data *tdata)
7503 struct crypto_testsuite_params *ts_params = &testsuite_params;
7504 struct crypto_unittest_params *ut_params = &unittest_params;
7507 uint8_t *ciphertext, *auth_tag;
7508 uint16_t plaintext_pad_len;
7509 uint8_t key[tdata->key.len + 1];
7511 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7513 /* clear mbuf payload */
7514 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7515 rte_pktmbuf_tailroom(ut_params->ibuf));
7517 /* Create AEAD operation */
7518 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7522 /* Create GCM xform */
7523 memcpy(key, tdata->key.data, tdata->key.len);
7524 retval = create_aead_xform(ut_params->op,
7526 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7527 key, tdata->key.len,
7528 tdata->aad.len, tdata->auth_tag.len,
7533 ut_params->op->sym->m_src = ut_params->ibuf;
7535 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
7536 RTE_CRYPTO_OP_SESSIONLESS,
7537 "crypto op session type not sessionless");
7539 /* Process crypto operation */
7540 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7541 ut_params->op), "failed to process sym crypto op");
7543 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7545 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7546 "crypto op status not success");
7548 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7550 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7551 ut_params->op->sym->cipher.data.offset);
7552 auth_tag = ciphertext + plaintext_pad_len;
7554 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7555 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7558 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7560 tdata->ciphertext.data,
7561 tdata->ciphertext.len,
7562 "Ciphertext data not as expected");
7564 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7566 tdata->auth_tag.data,
7567 tdata->auth_tag.len,
7568 "Generated auth tag not as expected");
7575 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
7577 return test_authenticated_encryption_sessionless(
7582 test_authenticated_decryption_sessionless(
7583 const struct aead_test_data *tdata)
7585 struct crypto_testsuite_params *ts_params = &testsuite_params;
7586 struct crypto_unittest_params *ut_params = &unittest_params;
7590 uint8_t key[tdata->key.len + 1];
7592 /* alloc mbuf and set payload */
7593 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7595 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7596 rte_pktmbuf_tailroom(ut_params->ibuf));
7598 /* Create AEAD operation */
7599 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7603 /* Create AEAD xform */
7604 memcpy(key, tdata->key.data, tdata->key.len);
7605 retval = create_aead_xform(ut_params->op,
7607 RTE_CRYPTO_AEAD_OP_DECRYPT,
7608 key, tdata->key.len,
7609 tdata->aad.len, tdata->auth_tag.len,
7614 ut_params->op->sym->m_src = ut_params->ibuf;
7616 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
7617 RTE_CRYPTO_OP_SESSIONLESS,
7618 "crypto op session type not sessionless");
7620 /* Process crypto operation */
7621 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7622 ut_params->op), "failed to process sym crypto op");
7624 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7626 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7627 "crypto op status not success");
7629 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7630 ut_params->op->sym->cipher.data.offset);
7632 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7635 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7637 tdata->plaintext.data,
7638 tdata->plaintext.len,
7639 "Plaintext data not as expected");
7641 TEST_ASSERT_EQUAL(ut_params->op->status,
7642 RTE_CRYPTO_OP_STATUS_SUCCESS,
7643 "Authentication failed");
7648 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
7650 return test_authenticated_decryption_sessionless(
7655 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
7657 return test_authenticated_encryption(&ccm_test_case_128_1);
7661 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
7663 return test_authenticated_encryption(&ccm_test_case_128_2);
7667 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
7669 return test_authenticated_encryption(&ccm_test_case_128_3);
7673 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
7675 return test_authenticated_decryption(&ccm_test_case_128_1);
7679 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
7681 return test_authenticated_decryption(&ccm_test_case_128_2);
7685 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
7687 return test_authenticated_decryption(&ccm_test_case_128_3);
7691 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
7693 return test_authenticated_encryption(&ccm_test_case_192_1);
7697 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
7699 return test_authenticated_encryption(&ccm_test_case_192_2);
7703 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
7705 return test_authenticated_encryption(&ccm_test_case_192_3);
7709 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
7711 return test_authenticated_decryption(&ccm_test_case_192_1);
7715 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
7717 return test_authenticated_decryption(&ccm_test_case_192_2);
7721 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
7723 return test_authenticated_decryption(&ccm_test_case_192_3);
7727 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
7729 return test_authenticated_encryption(&ccm_test_case_256_1);
7733 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
7735 return test_authenticated_encryption(&ccm_test_case_256_2);
7739 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
7741 return test_authenticated_encryption(&ccm_test_case_256_3);
7745 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
7747 return test_authenticated_decryption(&ccm_test_case_256_1);
7751 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
7753 return test_authenticated_decryption(&ccm_test_case_256_2);
7757 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
7759 return test_authenticated_decryption(&ccm_test_case_256_3);
7765 struct crypto_testsuite_params *ts_params = &testsuite_params;
7766 struct rte_cryptodev_stats stats;
7767 struct rte_cryptodev *dev;
7768 cryptodev_stats_get_t temp_pfn;
7770 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7771 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
7772 &stats) == -ENODEV),
7773 "rte_cryptodev_stats_get invalid dev failed");
7774 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
7775 "rte_cryptodev_stats_get invalid Param failed");
7776 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
7777 temp_pfn = dev->dev_ops->stats_get;
7778 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
7779 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
7781 "rte_cryptodev_stats_get invalid Param failed");
7782 dev->dev_ops->stats_get = temp_pfn;
7784 /* Test expected values */
7786 test_AES_CBC_HMAC_SHA1_encrypt_digest();
7788 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7790 "rte_cryptodev_stats_get failed");
7791 TEST_ASSERT((stats.enqueued_count == 1),
7792 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7793 TEST_ASSERT((stats.dequeued_count == 1),
7794 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7795 TEST_ASSERT((stats.enqueue_err_count == 0),
7796 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7797 TEST_ASSERT((stats.dequeue_err_count == 0),
7798 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7800 /* invalid device but should ignore and not reset device stats*/
7801 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
7802 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7804 "rte_cryptodev_stats_get failed");
7805 TEST_ASSERT((stats.enqueued_count == 1),
7806 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7808 /* check that a valid reset clears stats */
7809 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7810 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7812 "rte_cryptodev_stats_get failed");
7813 TEST_ASSERT((stats.enqueued_count == 0),
7814 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7815 TEST_ASSERT((stats.dequeued_count == 0),
7816 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7818 return TEST_SUCCESS;
7821 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
7822 struct crypto_unittest_params *ut_params,
7823 enum rte_crypto_auth_operation op,
7824 const struct HMAC_MD5_vector *test_case)
7828 memcpy(key, test_case->key.data, test_case->key.len);
7830 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7831 ut_params->auth_xform.next = NULL;
7832 ut_params->auth_xform.auth.op = op;
7834 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
7836 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
7837 ut_params->auth_xform.auth.key.length = test_case->key.len;
7838 ut_params->auth_xform.auth.key.data = key;
7840 ut_params->sess = rte_cryptodev_sym_session_create(
7841 ts_params->session_mpool);
7843 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7844 ut_params->sess, &ut_params->auth_xform,
7845 ts_params->session_priv_mpool);
7847 if (ut_params->sess == NULL)
7850 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7852 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7853 rte_pktmbuf_tailroom(ut_params->ibuf));
7858 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
7859 const struct HMAC_MD5_vector *test_case,
7860 uint8_t **plaintext)
7862 uint16_t plaintext_pad_len;
7864 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7866 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7869 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7871 memcpy(*plaintext, test_case->plaintext.data,
7872 test_case->plaintext.len);
7874 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7875 ut_params->ibuf, MD5_DIGEST_LEN);
7876 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7877 "no room to append digest");
7878 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7879 ut_params->ibuf, plaintext_pad_len);
7881 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7882 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
7883 test_case->auth_tag.len);
7886 sym_op->auth.data.offset = 0;
7887 sym_op->auth.data.length = test_case->plaintext.len;
7889 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7890 ut_params->op->sym->m_src = ut_params->ibuf;
7896 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
7898 uint16_t plaintext_pad_len;
7899 uint8_t *plaintext, *auth_tag;
7901 struct crypto_testsuite_params *ts_params = &testsuite_params;
7902 struct crypto_unittest_params *ut_params = &unittest_params;
7904 if (MD5_HMAC_create_session(ts_params, ut_params,
7905 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
7908 /* Generate Crypto op data structure */
7909 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7910 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7911 TEST_ASSERT_NOT_NULL(ut_params->op,
7912 "Failed to allocate symmetric crypto operation struct");
7914 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7917 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7920 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7921 ut_params->op), "failed to process sym crypto op");
7923 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7924 "crypto op processing failed");
7926 if (ut_params->op->sym->m_dst) {
7927 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7928 uint8_t *, plaintext_pad_len);
7930 auth_tag = plaintext + plaintext_pad_len;
7933 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7935 test_case->auth_tag.data,
7936 test_case->auth_tag.len,
7937 "HMAC_MD5 generated tag not as expected");
7939 return TEST_SUCCESS;
7943 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
7947 struct crypto_testsuite_params *ts_params = &testsuite_params;
7948 struct crypto_unittest_params *ut_params = &unittest_params;
7950 if (MD5_HMAC_create_session(ts_params, ut_params,
7951 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
7955 /* Generate Crypto op data structure */
7956 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7957 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7958 TEST_ASSERT_NOT_NULL(ut_params->op,
7959 "Failed to allocate symmetric crypto operation struct");
7961 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7964 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7965 ut_params->op), "failed to process sym crypto op");
7967 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7968 "HMAC_MD5 crypto op processing failed");
7970 return TEST_SUCCESS;
7974 test_MD5_HMAC_generate_case_1(void)
7976 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
7980 test_MD5_HMAC_verify_case_1(void)
7982 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
7986 test_MD5_HMAC_generate_case_2(void)
7988 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
7992 test_MD5_HMAC_verify_case_2(void)
7994 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
7998 test_multi_session(void)
8000 struct crypto_testsuite_params *ts_params = &testsuite_params;
8001 struct crypto_unittest_params *ut_params = &unittest_params;
8003 struct rte_cryptodev_info dev_info;
8004 struct rte_cryptodev_sym_session **sessions;
8008 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8009 aes_cbc_key, hmac_sha512_key);
8012 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8014 sessions = rte_malloc(NULL,
8015 (sizeof(struct rte_cryptodev_sym_session *) *
8016 MAX_NB_SESSIONS) + 1, 0);
8018 /* Create multiple crypto sessions*/
8019 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8021 sessions[i] = rte_cryptodev_sym_session_create(
8022 ts_params->session_mpool);
8024 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8025 sessions[i], &ut_params->auth_xform,
8026 ts_params->session_priv_mpool);
8027 TEST_ASSERT_NOT_NULL(sessions[i],
8028 "Session creation failed at session number %u",
8031 /* Attempt to send a request on each session */
8032 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
8036 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
8037 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
8039 "Failed to perform decrypt on request number %u.", i);
8040 /* free crypto operation structure */
8042 rte_crypto_op_free(ut_params->op);
8045 * free mbuf - both obuf and ibuf are usually the same,
8046 * so check if they point at the same address is necessary,
8047 * to avoid freeing the mbuf twice.
8049 if (ut_params->obuf) {
8050 rte_pktmbuf_free(ut_params->obuf);
8051 if (ut_params->ibuf == ut_params->obuf)
8052 ut_params->ibuf = 0;
8053 ut_params->obuf = 0;
8055 if (ut_params->ibuf) {
8056 rte_pktmbuf_free(ut_params->ibuf);
8057 ut_params->ibuf = 0;
8061 /* Next session create should fail */
8062 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8063 sessions[i], &ut_params->auth_xform,
8064 ts_params->session_priv_mpool);
8065 TEST_ASSERT_NULL(sessions[i],
8066 "Session creation succeeded unexpectedly!");
8068 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8069 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8071 rte_cryptodev_sym_session_free(sessions[i]);
8076 return TEST_SUCCESS;
8079 struct multi_session_params {
8080 struct crypto_unittest_params ut_params;
8081 uint8_t *cipher_key;
8083 const uint8_t *cipher;
8084 const uint8_t *digest;
8088 #define MB_SESSION_NUMBER 3
8091 test_multi_session_random_usage(void)
8093 struct crypto_testsuite_params *ts_params = &testsuite_params;
8094 struct rte_cryptodev_info dev_info;
8095 struct rte_cryptodev_sym_session **sessions;
8097 struct multi_session_params ut_paramz[] = {
8100 .cipher_key = ms_aes_cbc_key0,
8101 .hmac_key = ms_hmac_key0,
8102 .cipher = ms_aes_cbc_cipher0,
8103 .digest = ms_hmac_digest0,
8104 .iv = ms_aes_cbc_iv0
8107 .cipher_key = ms_aes_cbc_key1,
8108 .hmac_key = ms_hmac_key1,
8109 .cipher = ms_aes_cbc_cipher1,
8110 .digest = ms_hmac_digest1,
8111 .iv = ms_aes_cbc_iv1
8114 .cipher_key = ms_aes_cbc_key2,
8115 .hmac_key = ms_hmac_key2,
8116 .cipher = ms_aes_cbc_cipher2,
8117 .digest = ms_hmac_digest2,
8118 .iv = ms_aes_cbc_iv2
8123 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8125 sessions = rte_malloc(NULL,
8126 (sizeof(struct rte_cryptodev_sym_session *)
8127 * MAX_NB_SESSIONS) + 1, 0);
8129 for (i = 0; i < MB_SESSION_NUMBER; i++) {
8130 sessions[i] = rte_cryptodev_sym_session_create(
8131 ts_params->session_mpool);
8133 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
8134 sizeof(struct crypto_unittest_params));
8136 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
8137 &ut_paramz[i].ut_params,
8138 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
8140 /* Create multiple crypto sessions*/
8141 rte_cryptodev_sym_session_init(
8142 ts_params->valid_devs[0],
8144 &ut_paramz[i].ut_params.auth_xform,
8145 ts_params->session_priv_mpool);
8147 TEST_ASSERT_NOT_NULL(sessions[i],
8148 "Session creation failed at session number %u",
8154 for (i = 0; i < 40000; i++) {
8156 j = rand() % MB_SESSION_NUMBER;
8158 TEST_ASSERT_SUCCESS(
8159 test_AES_CBC_HMAC_SHA512_decrypt_perform(
8161 &ut_paramz[j].ut_params,
8162 ts_params, ut_paramz[j].cipher,
8163 ut_paramz[j].digest,
8165 "Failed to perform decrypt on request number %u.", i);
8167 if (ut_paramz[j].ut_params.op)
8168 rte_crypto_op_free(ut_paramz[j].ut_params.op);
8171 * free mbuf - both obuf and ibuf are usually the same,
8172 * so check if they point at the same address is necessary,
8173 * to avoid freeing the mbuf twice.
8175 if (ut_paramz[j].ut_params.obuf) {
8176 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
8177 if (ut_paramz[j].ut_params.ibuf
8178 == ut_paramz[j].ut_params.obuf)
8179 ut_paramz[j].ut_params.ibuf = 0;
8180 ut_paramz[j].ut_params.obuf = 0;
8182 if (ut_paramz[j].ut_params.ibuf) {
8183 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
8184 ut_paramz[j].ut_params.ibuf = 0;
8188 for (i = 0; i < MB_SESSION_NUMBER; i++) {
8189 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8191 rte_cryptodev_sym_session_free(sessions[i]);
8196 return TEST_SUCCESS;
8200 test_null_cipher_only_operation(void)
8202 struct crypto_testsuite_params *ts_params = &testsuite_params;
8203 struct crypto_unittest_params *ut_params = &unittest_params;
8205 /* Generate test mbuf data and space for digest */
8206 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8207 catch_22_quote, QUOTE_512_BYTES, 0);
8209 /* Setup Cipher Parameters */
8210 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8211 ut_params->cipher_xform.next = NULL;
8213 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8214 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8216 ut_params->sess = rte_cryptodev_sym_session_create(
8217 ts_params->session_mpool);
8219 /* Create Crypto session*/
8220 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8222 &ut_params->cipher_xform,
8223 ts_params->session_priv_mpool);
8224 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8226 /* Generate Crypto op data structure */
8227 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8228 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8229 TEST_ASSERT_NOT_NULL(ut_params->op,
8230 "Failed to allocate symmetric crypto operation struct");
8232 /* Set crypto operation data parameters */
8233 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8235 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8237 /* set crypto operation source mbuf */
8238 sym_op->m_src = ut_params->ibuf;
8240 sym_op->cipher.data.offset = 0;
8241 sym_op->cipher.data.length = QUOTE_512_BYTES;
8243 /* Process crypto operation */
8244 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8246 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8248 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8249 "crypto operation processing failed");
8252 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8253 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8256 "Ciphertext data not as expected");
8258 return TEST_SUCCESS;
8260 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
8261 0xab, 0xab, 0xab, 0xab,
8262 0xab, 0xab, 0xab, 0xab,
8263 0xab, 0xab, 0xab, 0xab};
8265 test_null_auth_only_operation(void)
8267 struct crypto_testsuite_params *ts_params = &testsuite_params;
8268 struct crypto_unittest_params *ut_params = &unittest_params;
8271 /* Generate test mbuf data and space for digest */
8272 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8273 catch_22_quote, QUOTE_512_BYTES, 0);
8275 /* create a pointer for digest, but don't expect anything to be written
8276 * here in a NULL auth algo so no mbuf append done.
8278 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8280 /* prefill the memory pointed to by digest */
8281 memcpy(digest, orig_data, sizeof(orig_data));
8283 /* Setup HMAC Parameters */
8284 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8285 ut_params->auth_xform.next = NULL;
8287 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8288 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8290 ut_params->sess = rte_cryptodev_sym_session_create(
8291 ts_params->session_mpool);
8293 /* Create Crypto session*/
8294 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8295 ut_params->sess, &ut_params->auth_xform,
8296 ts_params->session_priv_mpool);
8297 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8299 /* Generate Crypto op data structure */
8300 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8301 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8302 TEST_ASSERT_NOT_NULL(ut_params->op,
8303 "Failed to allocate symmetric crypto operation struct");
8305 /* Set crypto operation data parameters */
8306 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8308 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8310 sym_op->m_src = ut_params->ibuf;
8312 sym_op->auth.data.offset = 0;
8313 sym_op->auth.data.length = QUOTE_512_BYTES;
8314 sym_op->auth.digest.data = digest;
8315 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8318 /* Process crypto operation */
8319 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8321 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8323 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8324 "crypto operation processing failed");
8325 /* Make sure memory pointed to by digest hasn't been overwritten */
8326 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8330 "Memory at digest ptr overwritten unexpectedly");
8332 return TEST_SUCCESS;
8337 test_null_cipher_auth_operation(void)
8339 struct crypto_testsuite_params *ts_params = &testsuite_params;
8340 struct crypto_unittest_params *ut_params = &unittest_params;
8343 /* Generate test mbuf data and space for digest */
8344 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8345 catch_22_quote, QUOTE_512_BYTES, 0);
8347 /* create a pointer for digest, but don't expect anything to be written
8348 * here in a NULL auth algo so no mbuf append done.
8350 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8352 /* prefill the memory pointed to by digest */
8353 memcpy(digest, orig_data, sizeof(orig_data));
8355 /* Setup Cipher Parameters */
8356 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8357 ut_params->cipher_xform.next = &ut_params->auth_xform;
8359 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8360 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8362 /* Setup HMAC Parameters */
8363 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8364 ut_params->auth_xform.next = NULL;
8366 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8367 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8369 ut_params->sess = rte_cryptodev_sym_session_create(
8370 ts_params->session_mpool);
8372 /* Create Crypto session*/
8373 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8374 ut_params->sess, &ut_params->cipher_xform,
8375 ts_params->session_priv_mpool);
8376 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8378 /* Generate Crypto op data structure */
8379 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8380 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8381 TEST_ASSERT_NOT_NULL(ut_params->op,
8382 "Failed to allocate symmetric crypto operation struct");
8384 /* Set crypto operation data parameters */
8385 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8387 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8389 sym_op->m_src = ut_params->ibuf;
8391 sym_op->cipher.data.offset = 0;
8392 sym_op->cipher.data.length = QUOTE_512_BYTES;
8394 sym_op->auth.data.offset = 0;
8395 sym_op->auth.data.length = QUOTE_512_BYTES;
8396 sym_op->auth.digest.data = digest;
8397 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8400 /* Process crypto operation */
8401 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8403 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8405 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8406 "crypto operation processing failed");
8409 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8410 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8413 "Ciphertext data not as expected");
8414 /* Make sure memory pointed to by digest hasn't been overwritten */
8415 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8419 "Memory at digest ptr overwritten unexpectedly");
8421 return TEST_SUCCESS;
8425 test_null_auth_cipher_operation(void)
8427 struct crypto_testsuite_params *ts_params = &testsuite_params;
8428 struct crypto_unittest_params *ut_params = &unittest_params;
8431 /* Generate test mbuf data */
8432 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8433 catch_22_quote, QUOTE_512_BYTES, 0);
8435 /* create a pointer for digest, but don't expect anything to be written
8436 * here in a NULL auth algo so no mbuf append done.
8438 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8440 /* prefill the memory pointed to by digest */
8441 memcpy(digest, orig_data, sizeof(orig_data));
8443 /* Setup Cipher Parameters */
8444 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8445 ut_params->cipher_xform.next = NULL;
8447 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8448 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8450 /* Setup HMAC Parameters */
8451 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8452 ut_params->auth_xform.next = &ut_params->cipher_xform;
8454 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8455 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8457 ut_params->sess = rte_cryptodev_sym_session_create(
8458 ts_params->session_mpool);
8460 /* Create Crypto session*/
8461 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8462 ut_params->sess, &ut_params->cipher_xform,
8463 ts_params->session_priv_mpool);
8464 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8466 /* Generate Crypto op data structure */
8467 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8468 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8469 TEST_ASSERT_NOT_NULL(ut_params->op,
8470 "Failed to allocate symmetric crypto operation struct");
8472 /* Set crypto operation data parameters */
8473 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8475 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8477 sym_op->m_src = ut_params->ibuf;
8479 sym_op->cipher.data.offset = 0;
8480 sym_op->cipher.data.length = QUOTE_512_BYTES;
8482 sym_op->auth.data.offset = 0;
8483 sym_op->auth.data.length = QUOTE_512_BYTES;
8484 sym_op->auth.digest.data = digest;
8485 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8488 /* Process crypto operation */
8489 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8491 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8493 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8494 "crypto operation processing failed");
8497 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8498 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8501 "Ciphertext data not as expected");
8502 /* Make sure memory pointed to by digest hasn't been overwritten */
8503 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8507 "Memory at digest ptr overwritten unexpectedly");
8509 return TEST_SUCCESS;
8514 test_null_invalid_operation(void)
8516 struct crypto_testsuite_params *ts_params = &testsuite_params;
8517 struct crypto_unittest_params *ut_params = &unittest_params;
8520 /* Setup Cipher Parameters */
8521 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8522 ut_params->cipher_xform.next = NULL;
8524 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
8525 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8527 ut_params->sess = rte_cryptodev_sym_session_create(
8528 ts_params->session_mpool);
8530 /* Create Crypto session*/
8531 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8532 ut_params->sess, &ut_params->cipher_xform,
8533 ts_params->session_priv_mpool);
8534 TEST_ASSERT(ret < 0,
8535 "Session creation succeeded unexpectedly");
8538 /* Setup HMAC Parameters */
8539 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8540 ut_params->auth_xform.next = NULL;
8542 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
8543 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8545 ut_params->sess = rte_cryptodev_sym_session_create(
8546 ts_params->session_mpool);
8548 /* Create Crypto session*/
8549 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8550 ut_params->sess, &ut_params->auth_xform,
8551 ts_params->session_priv_mpool);
8552 TEST_ASSERT(ret < 0,
8553 "Session creation succeeded unexpectedly");
8555 return TEST_SUCCESS;
8559 #define NULL_BURST_LENGTH (32)
8562 test_null_burst_operation(void)
8564 struct crypto_testsuite_params *ts_params = &testsuite_params;
8565 struct crypto_unittest_params *ut_params = &unittest_params;
8567 unsigned i, burst_len = NULL_BURST_LENGTH;
8569 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
8570 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
8572 /* Setup Cipher Parameters */
8573 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8574 ut_params->cipher_xform.next = &ut_params->auth_xform;
8576 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8577 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8579 /* Setup HMAC Parameters */
8580 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8581 ut_params->auth_xform.next = NULL;
8583 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8584 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8586 ut_params->sess = rte_cryptodev_sym_session_create(
8587 ts_params->session_mpool);
8589 /* Create Crypto session*/
8590 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8591 ut_params->sess, &ut_params->cipher_xform,
8592 ts_params->session_priv_mpool);
8593 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8595 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
8596 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
8597 burst_len, "failed to generate burst of crypto ops");
8599 /* Generate an operation for each mbuf in burst */
8600 for (i = 0; i < burst_len; i++) {
8601 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8603 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
8605 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
8609 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
8611 burst[i]->sym->m_src = m;
8614 /* Process crypto operation */
8615 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
8616 0, burst, burst_len),
8618 "Error enqueuing burst");
8620 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
8621 0, burst_dequeued, burst_len),
8623 "Error dequeuing burst");
8626 for (i = 0; i < burst_len; i++) {
8628 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
8629 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
8631 "data not as expected");
8633 rte_pktmbuf_free(burst[i]->sym->m_src);
8634 rte_crypto_op_free(burst[i]);
8637 return TEST_SUCCESS;
8641 generate_gmac_large_plaintext(uint8_t *data)
8645 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
8646 memcpy(&data[i], &data[0], 32);
8650 create_gmac_operation(enum rte_crypto_auth_operation op,
8651 const struct gmac_test_data *tdata)
8653 struct crypto_testsuite_params *ts_params = &testsuite_params;
8654 struct crypto_unittest_params *ut_params = &unittest_params;
8655 struct rte_crypto_sym_op *sym_op;
8657 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8659 /* Generate Crypto op data structure */
8660 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8661 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8662 TEST_ASSERT_NOT_NULL(ut_params->op,
8663 "Failed to allocate symmetric crypto operation struct");
8665 sym_op = ut_params->op->sym;
8667 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8668 ut_params->ibuf, tdata->gmac_tag.len);
8669 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8670 "no room to append digest");
8672 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8673 ut_params->ibuf, plaintext_pad_len);
8675 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8676 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
8677 tdata->gmac_tag.len);
8678 debug_hexdump(stdout, "digest:",
8679 sym_op->auth.digest.data,
8680 tdata->gmac_tag.len);
8683 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8684 uint8_t *, IV_OFFSET);
8686 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8688 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
8690 sym_op->cipher.data.length = 0;
8691 sym_op->cipher.data.offset = 0;
8693 sym_op->auth.data.offset = 0;
8694 sym_op->auth.data.length = tdata->plaintext.len;
8699 static int create_gmac_session(uint8_t dev_id,
8700 const struct gmac_test_data *tdata,
8701 enum rte_crypto_auth_operation auth_op)
8703 uint8_t auth_key[tdata->key.len];
8705 struct crypto_testsuite_params *ts_params = &testsuite_params;
8706 struct crypto_unittest_params *ut_params = &unittest_params;
8708 memcpy(auth_key, tdata->key.data, tdata->key.len);
8710 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8711 ut_params->auth_xform.next = NULL;
8713 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
8714 ut_params->auth_xform.auth.op = auth_op;
8715 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
8716 ut_params->auth_xform.auth.key.length = tdata->key.len;
8717 ut_params->auth_xform.auth.key.data = auth_key;
8718 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
8719 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
8722 ut_params->sess = rte_cryptodev_sym_session_create(
8723 ts_params->session_mpool);
8725 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8726 &ut_params->auth_xform,
8727 ts_params->session_priv_mpool);
8729 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8735 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
8737 struct crypto_testsuite_params *ts_params = &testsuite_params;
8738 struct crypto_unittest_params *ut_params = &unittest_params;
8742 uint8_t *auth_tag, *plaintext;
8743 uint16_t plaintext_pad_len;
8745 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8746 "No GMAC length in the source data");
8748 retval = create_gmac_session(ts_params->valid_devs[0],
8749 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
8754 if (tdata->plaintext.len > MBUF_SIZE)
8755 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8757 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8758 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8759 "Failed to allocate input buffer in mempool");
8761 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8762 rte_pktmbuf_tailroom(ut_params->ibuf));
8764 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8766 * Runtime generate the large plain text instead of use hard code
8767 * plain text vector. It is done to avoid create huge source file
8768 * with the test vector.
8770 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8771 generate_gmac_large_plaintext(tdata->plaintext.data);
8773 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8775 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8777 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8778 debug_hexdump(stdout, "plaintext:", plaintext,
8779 tdata->plaintext.len);
8781 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
8787 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8789 ut_params->op->sym->m_src = ut_params->ibuf;
8791 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8792 ut_params->op), "failed to process sym crypto op");
8794 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8795 "crypto op processing failed");
8797 if (ut_params->op->sym->m_dst) {
8798 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8799 uint8_t *, plaintext_pad_len);
8801 auth_tag = plaintext + plaintext_pad_len;
8804 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
8806 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8808 tdata->gmac_tag.data,
8809 tdata->gmac_tag.len,
8810 "GMAC Generated auth tag not as expected");
8816 test_AES_GMAC_authentication_test_case_1(void)
8818 return test_AES_GMAC_authentication(&gmac_test_case_1);
8822 test_AES_GMAC_authentication_test_case_2(void)
8824 return test_AES_GMAC_authentication(&gmac_test_case_2);
8828 test_AES_GMAC_authentication_test_case_3(void)
8830 return test_AES_GMAC_authentication(&gmac_test_case_3);
8834 test_AES_GMAC_authentication_test_case_4(void)
8836 return test_AES_GMAC_authentication(&gmac_test_case_4);
8840 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
8842 struct crypto_testsuite_params *ts_params = &testsuite_params;
8843 struct crypto_unittest_params *ut_params = &unittest_params;
8845 uint32_t plaintext_pad_len;
8848 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8849 "No GMAC length in the source data");
8851 retval = create_gmac_session(ts_params->valid_devs[0],
8852 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
8857 if (tdata->plaintext.len > MBUF_SIZE)
8858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8860 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8861 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8862 "Failed to allocate input buffer in mempool");
8864 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8865 rte_pktmbuf_tailroom(ut_params->ibuf));
8867 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8870 * Runtime generate the large plain text instead of use hard code
8871 * plain text vector. It is done to avoid create huge source file
8872 * with the test vector.
8874 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8875 generate_gmac_large_plaintext(tdata->plaintext.data);
8877 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8879 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8881 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8882 debug_hexdump(stdout, "plaintext:", plaintext,
8883 tdata->plaintext.len);
8885 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
8891 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8893 ut_params->op->sym->m_src = ut_params->ibuf;
8895 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8896 ut_params->op), "failed to process sym crypto op");
8898 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8899 "crypto op processing failed");
8906 test_AES_GMAC_authentication_verify_test_case_1(void)
8908 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
8912 test_AES_GMAC_authentication_verify_test_case_2(void)
8914 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
8918 test_AES_GMAC_authentication_verify_test_case_3(void)
8920 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
8924 test_AES_GMAC_authentication_verify_test_case_4(void)
8926 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
8929 struct test_crypto_vector {
8930 enum rte_crypto_cipher_algorithm crypto_algo;
8943 const uint8_t *data;
8948 const uint8_t *data;
8952 enum rte_crypto_auth_algorithm auth_algo;
8960 const uint8_t *data;
8970 static const struct test_crypto_vector
8971 hmac_sha1_test_crypto_vector = {
8972 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
8974 .data = plaintext_hash,
8979 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
8980 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
8981 0xDE, 0xF4, 0xDE, 0xAD
8987 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
8988 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
8989 0x3F, 0x91, 0x64, 0x59
8995 static const struct test_crypto_vector
8996 aes128_gmac_test_vector = {
8997 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
8999 .data = plaintext_hash,
9004 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9005 0x08, 0x09, 0x0A, 0x0B
9011 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9012 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
9018 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
9019 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
9025 static const struct test_crypto_vector
9026 aes128cbc_hmac_sha1_test_vector = {
9027 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9030 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9031 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9037 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9038 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
9043 .data = plaintext_hash,
9047 .data = ciphertext512_aes128cbc,
9050 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9053 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9054 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9055 0xDE, 0xF4, 0xDE, 0xAD
9061 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
9062 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9063 0x18, 0x8C, 0x1D, 0x32
9070 data_corruption(uint8_t *data)
9076 tag_corruption(uint8_t *data, unsigned int tag_offset)
9078 data[tag_offset] += 1;
9082 create_auth_session(struct crypto_unittest_params *ut_params,
9084 const struct test_crypto_vector *reference,
9085 enum rte_crypto_auth_operation auth_op)
9087 struct crypto_testsuite_params *ts_params = &testsuite_params;
9088 uint8_t auth_key[reference->auth_key.len + 1];
9090 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9092 /* Setup Authentication Parameters */
9093 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9094 ut_params->auth_xform.auth.op = auth_op;
9095 ut_params->auth_xform.next = NULL;
9096 ut_params->auth_xform.auth.algo = reference->auth_algo;
9097 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9098 ut_params->auth_xform.auth.key.data = auth_key;
9099 ut_params->auth_xform.auth.digest_length = reference->digest.len;
9101 /* Create Crypto session*/
9102 ut_params->sess = rte_cryptodev_sym_session_create(
9103 ts_params->session_mpool);
9105 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9106 &ut_params->auth_xform,
9107 ts_params->session_priv_mpool);
9109 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9115 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
9117 const struct test_crypto_vector *reference,
9118 enum rte_crypto_auth_operation auth_op,
9119 enum rte_crypto_cipher_operation cipher_op)
9121 struct crypto_testsuite_params *ts_params = &testsuite_params;
9122 uint8_t cipher_key[reference->cipher_key.len + 1];
9123 uint8_t auth_key[reference->auth_key.len + 1];
9125 memcpy(cipher_key, reference->cipher_key.data,
9126 reference->cipher_key.len);
9127 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9129 /* Setup Authentication Parameters */
9130 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9131 ut_params->auth_xform.auth.op = auth_op;
9132 ut_params->auth_xform.auth.algo = reference->auth_algo;
9133 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9134 ut_params->auth_xform.auth.key.data = auth_key;
9135 ut_params->auth_xform.auth.digest_length = reference->digest.len;
9137 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
9138 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9139 ut_params->auth_xform.auth.iv.length = reference->iv.len;
9141 ut_params->auth_xform.next = &ut_params->cipher_xform;
9143 /* Setup Cipher Parameters */
9144 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9145 ut_params->cipher_xform.next = NULL;
9146 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
9147 ut_params->cipher_xform.cipher.op = cipher_op;
9148 ut_params->cipher_xform.cipher.key.data = cipher_key;
9149 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
9150 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9151 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
9154 /* Create Crypto session*/
9155 ut_params->sess = rte_cryptodev_sym_session_create(
9156 ts_params->session_mpool);
9158 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9159 &ut_params->auth_xform,
9160 ts_params->session_priv_mpool);
9162 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9168 create_auth_operation(struct crypto_testsuite_params *ts_params,
9169 struct crypto_unittest_params *ut_params,
9170 const struct test_crypto_vector *reference,
9171 unsigned int auth_generate)
9173 /* Generate Crypto op data structure */
9174 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9175 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9176 TEST_ASSERT_NOT_NULL(ut_params->op,
9177 "Failed to allocate pktmbuf offload");
9179 /* Set crypto operation data parameters */
9180 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9182 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9184 /* set crypto operation source mbuf */
9185 sym_op->m_src = ut_params->ibuf;
9188 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9189 ut_params->ibuf, reference->digest.len);
9191 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9192 "no room to append auth tag");
9194 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9195 ut_params->ibuf, reference->plaintext.len);
9198 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9200 memcpy(sym_op->auth.digest.data,
9201 reference->digest.data,
9202 reference->digest.len);
9204 debug_hexdump(stdout, "digest:",
9205 sym_op->auth.digest.data,
9206 reference->digest.len);
9208 sym_op->auth.data.length = reference->plaintext.len;
9209 sym_op->auth.data.offset = 0;
9215 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
9216 struct crypto_unittest_params *ut_params,
9217 const struct test_crypto_vector *reference,
9218 unsigned int auth_generate)
9220 /* Generate Crypto op data structure */
9221 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9222 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9223 TEST_ASSERT_NOT_NULL(ut_params->op,
9224 "Failed to allocate pktmbuf offload");
9226 /* Set crypto operation data parameters */
9227 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9229 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9231 /* set crypto operation source mbuf */
9232 sym_op->m_src = ut_params->ibuf;
9235 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9236 ut_params->ibuf, reference->digest.len);
9238 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9239 "no room to append auth tag");
9241 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9242 ut_params->ibuf, reference->ciphertext.len);
9245 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9247 memcpy(sym_op->auth.digest.data,
9248 reference->digest.data,
9249 reference->digest.len);
9251 debug_hexdump(stdout, "digest:",
9252 sym_op->auth.digest.data,
9253 reference->digest.len);
9255 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
9256 reference->iv.data, reference->iv.len);
9258 sym_op->cipher.data.length = 0;
9259 sym_op->cipher.data.offset = 0;
9261 sym_op->auth.data.length = reference->plaintext.len;
9262 sym_op->auth.data.offset = 0;
9268 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
9269 struct crypto_unittest_params *ut_params,
9270 const struct test_crypto_vector *reference,
9271 unsigned int auth_generate)
9273 /* Generate Crypto op data structure */
9274 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9275 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9276 TEST_ASSERT_NOT_NULL(ut_params->op,
9277 "Failed to allocate pktmbuf offload");
9279 /* Set crypto operation data parameters */
9280 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9282 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9284 /* set crypto operation source mbuf */
9285 sym_op->m_src = ut_params->ibuf;
9288 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9289 ut_params->ibuf, reference->digest.len);
9291 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9292 "no room to append auth tag");
9294 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9295 ut_params->ibuf, reference->ciphertext.len);
9298 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9300 memcpy(sym_op->auth.digest.data,
9301 reference->digest.data,
9302 reference->digest.len);
9304 debug_hexdump(stdout, "digest:",
9305 sym_op->auth.digest.data,
9306 reference->digest.len);
9308 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
9309 reference->iv.data, reference->iv.len);
9311 sym_op->cipher.data.length = reference->ciphertext.len;
9312 sym_op->cipher.data.offset = 0;
9314 sym_op->auth.data.length = reference->ciphertext.len;
9315 sym_op->auth.data.offset = 0;
9321 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
9322 struct crypto_unittest_params *ut_params,
9323 const struct test_crypto_vector *reference)
9325 return create_auth_operation(ts_params, ut_params, reference, 0);
9329 create_auth_verify_GMAC_operation(
9330 struct crypto_testsuite_params *ts_params,
9331 struct crypto_unittest_params *ut_params,
9332 const struct test_crypto_vector *reference)
9334 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
9338 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
9339 struct crypto_unittest_params *ut_params,
9340 const struct test_crypto_vector *reference)
9342 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
9346 test_authentication_verify_fail_when_data_corruption(
9347 struct crypto_testsuite_params *ts_params,
9348 struct crypto_unittest_params *ut_params,
9349 const struct test_crypto_vector *reference,
9350 unsigned int data_corrupted)
9356 /* Create session */
9357 retval = create_auth_session(ut_params,
9358 ts_params->valid_devs[0],
9360 RTE_CRYPTO_AUTH_OP_VERIFY);
9364 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9365 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9366 "Failed to allocate input buffer in mempool");
9368 /* clear mbuf payload */
9369 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9370 rte_pktmbuf_tailroom(ut_params->ibuf));
9372 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9373 reference->plaintext.len);
9374 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9375 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
9377 debug_hexdump(stdout, "plaintext:", plaintext,
9378 reference->plaintext.len);
9380 /* Create operation */
9381 retval = create_auth_verify_operation(ts_params, ut_params, reference);
9387 data_corruption(plaintext);
9389 tag_corruption(plaintext, reference->plaintext.len);
9391 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9393 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9394 TEST_ASSERT_EQUAL(ut_params->op->status,
9395 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9396 "authentication not failed");
9398 ut_params->obuf = ut_params->op->sym->m_src;
9399 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9405 test_authentication_verify_GMAC_fail_when_corruption(
9406 struct crypto_testsuite_params *ts_params,
9407 struct crypto_unittest_params *ut_params,
9408 const struct test_crypto_vector *reference,
9409 unsigned int data_corrupted)
9414 /* Create session */
9415 retval = create_auth_cipher_session(ut_params,
9416 ts_params->valid_devs[0],
9418 RTE_CRYPTO_AUTH_OP_VERIFY,
9419 RTE_CRYPTO_CIPHER_OP_DECRYPT);
9423 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9424 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9425 "Failed to allocate input buffer in mempool");
9427 /* clear mbuf payload */
9428 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9429 rte_pktmbuf_tailroom(ut_params->ibuf));
9431 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9432 reference->plaintext.len);
9433 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9434 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
9436 debug_hexdump(stdout, "plaintext:", plaintext,
9437 reference->plaintext.len);
9439 /* Create operation */
9440 retval = create_auth_verify_GMAC_operation(ts_params,
9448 data_corruption(plaintext);
9450 tag_corruption(plaintext, reference->aad.len);
9452 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9454 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9455 TEST_ASSERT_EQUAL(ut_params->op->status,
9456 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9457 "authentication not failed");
9459 ut_params->obuf = ut_params->op->sym->m_src;
9460 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9466 test_authenticated_decryption_fail_when_corruption(
9467 struct crypto_testsuite_params *ts_params,
9468 struct crypto_unittest_params *ut_params,
9469 const struct test_crypto_vector *reference,
9470 unsigned int data_corrupted)
9474 uint8_t *ciphertext;
9476 /* Create session */
9477 retval = create_auth_cipher_session(ut_params,
9478 ts_params->valid_devs[0],
9480 RTE_CRYPTO_AUTH_OP_VERIFY,
9481 RTE_CRYPTO_CIPHER_OP_DECRYPT);
9485 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9486 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9487 "Failed to allocate input buffer in mempool");
9489 /* clear mbuf payload */
9490 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9491 rte_pktmbuf_tailroom(ut_params->ibuf));
9493 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9494 reference->ciphertext.len);
9495 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
9496 memcpy(ciphertext, reference->ciphertext.data,
9497 reference->ciphertext.len);
9499 /* Create operation */
9500 retval = create_cipher_auth_verify_operation(ts_params,
9508 data_corruption(ciphertext);
9510 tag_corruption(ciphertext, reference->ciphertext.len);
9512 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9515 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9516 TEST_ASSERT_EQUAL(ut_params->op->status,
9517 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9518 "authentication not failed");
9520 ut_params->obuf = ut_params->op->sym->m_src;
9521 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9527 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
9528 const struct aead_test_data *tdata,
9529 void *digest_mem, uint64_t digest_phys)
9531 struct crypto_testsuite_params *ts_params = &testsuite_params;
9532 struct crypto_unittest_params *ut_params = &unittest_params;
9534 const unsigned int auth_tag_len = tdata->auth_tag.len;
9535 const unsigned int iv_len = tdata->iv.len;
9536 unsigned int aad_len = tdata->aad.len;
9538 /* Generate Crypto op data structure */
9539 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9540 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9541 TEST_ASSERT_NOT_NULL(ut_params->op,
9542 "Failed to allocate symmetric crypto operation struct");
9544 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9546 sym_op->aead.digest.data = digest_mem;
9548 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9549 "no room to append digest");
9551 sym_op->aead.digest.phys_addr = digest_phys;
9553 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
9554 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9556 debug_hexdump(stdout, "digest:",
9557 sym_op->aead.digest.data,
9561 /* Append aad data */
9562 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9563 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9564 uint8_t *, IV_OFFSET);
9566 /* Copy IV 1 byte after the IV pointer, according to the API */
9567 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
9569 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
9571 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
9572 ut_params->ibuf, aad_len);
9573 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9574 "no room to prepend aad");
9575 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
9578 memset(sym_op->aead.aad.data, 0, aad_len);
9579 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
9580 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
9582 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
9583 debug_hexdump(stdout, "aad:",
9584 sym_op->aead.aad.data, aad_len);
9586 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9587 uint8_t *, IV_OFFSET);
9589 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
9591 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
9592 ut_params->ibuf, aad_len);
9593 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9594 "no room to prepend aad");
9595 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
9598 memset(sym_op->aead.aad.data, 0, aad_len);
9599 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
9601 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
9602 debug_hexdump(stdout, "aad:",
9603 sym_op->aead.aad.data, aad_len);
9606 sym_op->aead.data.length = tdata->plaintext.len;
9607 sym_op->aead.data.offset = aad_len;
9612 #define SGL_MAX_NO 16
9615 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
9616 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
9618 struct crypto_testsuite_params *ts_params = &testsuite_params;
9619 struct crypto_unittest_params *ut_params = &unittest_params;
9620 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
9623 int to_trn_tbl[SGL_MAX_NO];
9625 unsigned int trn_data = 0;
9626 uint8_t *plaintext, *ciphertext, *auth_tag;
9628 if (fragsz > tdata->plaintext.len)
9629 fragsz = tdata->plaintext.len;
9631 uint16_t plaintext_len = fragsz;
9632 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9634 if (fragsz_oop > tdata->plaintext.len)
9635 frag_size_oop = tdata->plaintext.len;
9638 void *digest_mem = NULL;
9640 uint32_t prepend_len = tdata->aad.len;
9642 if (tdata->plaintext.len % fragsz != 0) {
9643 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
9646 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
9651 * For out-op-place we need to alloc another mbuf
9654 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9655 rte_pktmbuf_append(ut_params->obuf,
9656 frag_size_oop + prepend_len);
9657 buf_oop = ut_params->obuf;
9660 /* Create AEAD session */
9661 retval = create_aead_session(ts_params->valid_devs[0],
9663 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9664 tdata->key.data, tdata->key.len,
9665 tdata->aad.len, tdata->auth_tag.len,
9670 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9672 /* clear mbuf payload */
9673 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9674 rte_pktmbuf_tailroom(ut_params->ibuf));
9676 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9679 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
9681 trn_data += plaintext_len;
9683 buf = ut_params->ibuf;
9686 * Loop until no more fragments
9689 while (trn_data < tdata->plaintext.len) {
9691 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
9692 (tdata->plaintext.len - trn_data) : fragsz;
9694 to_trn_tbl[ecx++] = to_trn;
9696 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9699 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9700 rte_pktmbuf_tailroom(buf));
9703 if (oop && !fragsz_oop) {
9704 buf_last_oop = buf_oop->next =
9705 rte_pktmbuf_alloc(ts_params->mbuf_pool);
9706 buf_oop = buf_oop->next;
9707 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9708 0, rte_pktmbuf_tailroom(buf_oop));
9709 rte_pktmbuf_append(buf_oop, to_trn);
9712 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9715 memcpy(plaintext, tdata->plaintext.data + trn_data,
9718 if (trn_data == tdata->plaintext.len) {
9721 digest_mem = rte_pktmbuf_append(buf_oop,
9722 tdata->auth_tag.len);
9724 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
9725 tdata->auth_tag.len);
9729 uint64_t digest_phys = 0;
9731 ut_params->ibuf->nb_segs = segs;
9734 if (fragsz_oop && oop) {
9738 if (frag_size_oop == tdata->plaintext.len) {
9739 digest_mem = rte_pktmbuf_append(ut_params->obuf,
9740 tdata->auth_tag.len);
9742 digest_phys = rte_pktmbuf_iova_offset(
9744 tdata->plaintext.len + prepend_len);
9747 trn_data = frag_size_oop;
9748 while (trn_data < tdata->plaintext.len) {
9751 (tdata->plaintext.len - trn_data <
9753 (tdata->plaintext.len - trn_data) :
9756 to_trn_tbl[ecx++] = to_trn;
9758 buf_last_oop = buf_oop->next =
9759 rte_pktmbuf_alloc(ts_params->mbuf_pool);
9760 buf_oop = buf_oop->next;
9761 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9762 0, rte_pktmbuf_tailroom(buf_oop));
9763 rte_pktmbuf_append(buf_oop, to_trn);
9767 if (trn_data == tdata->plaintext.len) {
9768 digest_mem = rte_pktmbuf_append(buf_oop,
9769 tdata->auth_tag.len);
9773 ut_params->obuf->nb_segs = segs;
9777 * Place digest at the end of the last buffer
9780 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
9781 if (oop && buf_last_oop)
9782 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
9784 if (!digest_mem && !oop) {
9785 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9786 + tdata->auth_tag.len);
9787 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
9788 tdata->plaintext.len);
9791 /* Create AEAD operation */
9792 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
9793 tdata, digest_mem, digest_phys);
9798 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9800 ut_params->op->sym->m_src = ut_params->ibuf;
9802 ut_params->op->sym->m_dst = ut_params->obuf;
9804 /* Process crypto operation */
9805 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9806 ut_params->op), "failed to process sym crypto op");
9808 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9809 "crypto op processing failed");
9812 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9813 uint8_t *, prepend_len);
9815 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9816 uint8_t *, prepend_len);
9820 fragsz = fragsz_oop;
9822 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9824 tdata->ciphertext.data,
9826 "Ciphertext data not as expected");
9828 buf = ut_params->op->sym->m_src->next;
9830 buf = ut_params->op->sym->m_dst->next;
9832 unsigned int off = fragsz;
9836 ciphertext = rte_pktmbuf_mtod(buf,
9839 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9841 tdata->ciphertext.data + off,
9843 "Ciphertext data not as expected");
9845 off += to_trn_tbl[ecx++];
9849 auth_tag = digest_mem;
9850 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9852 tdata->auth_tag.data,
9853 tdata->auth_tag.len,
9854 "Generated auth tag not as expected");
9860 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
9862 return test_authenticated_encryption_SGL(
9863 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
9867 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
9869 return test_authenticated_encryption_SGL(
9870 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
9874 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
9876 return test_authenticated_encryption_SGL(
9877 &gcm_test_case_8, OUT_OF_PLACE, 400,
9878 gcm_test_case_8.plaintext.len);
9882 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
9885 return test_authenticated_encryption_SGL(
9886 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
9890 test_authentication_verify_fail_when_data_corrupted(
9891 struct crypto_testsuite_params *ts_params,
9892 struct crypto_unittest_params *ut_params,
9893 const struct test_crypto_vector *reference)
9895 return test_authentication_verify_fail_when_data_corruption(
9896 ts_params, ut_params, reference, 1);
9900 test_authentication_verify_fail_when_tag_corrupted(
9901 struct crypto_testsuite_params *ts_params,
9902 struct crypto_unittest_params *ut_params,
9903 const struct test_crypto_vector *reference)
9905 return test_authentication_verify_fail_when_data_corruption(
9906 ts_params, ut_params, reference, 0);
9910 test_authentication_verify_GMAC_fail_when_data_corrupted(
9911 struct crypto_testsuite_params *ts_params,
9912 struct crypto_unittest_params *ut_params,
9913 const struct test_crypto_vector *reference)
9915 return test_authentication_verify_GMAC_fail_when_corruption(
9916 ts_params, ut_params, reference, 1);
9920 test_authentication_verify_GMAC_fail_when_tag_corrupted(
9921 struct crypto_testsuite_params *ts_params,
9922 struct crypto_unittest_params *ut_params,
9923 const struct test_crypto_vector *reference)
9925 return test_authentication_verify_GMAC_fail_when_corruption(
9926 ts_params, ut_params, reference, 0);
9930 test_authenticated_decryption_fail_when_data_corrupted(
9931 struct crypto_testsuite_params *ts_params,
9932 struct crypto_unittest_params *ut_params,
9933 const struct test_crypto_vector *reference)
9935 return test_authenticated_decryption_fail_when_corruption(
9936 ts_params, ut_params, reference, 1);
9940 test_authenticated_decryption_fail_when_tag_corrupted(
9941 struct crypto_testsuite_params *ts_params,
9942 struct crypto_unittest_params *ut_params,
9943 const struct test_crypto_vector *reference)
9945 return test_authenticated_decryption_fail_when_corruption(
9946 ts_params, ut_params, reference, 0);
9950 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
9952 return test_authentication_verify_fail_when_data_corrupted(
9953 &testsuite_params, &unittest_params,
9954 &hmac_sha1_test_crypto_vector);
9958 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
9960 return test_authentication_verify_fail_when_tag_corrupted(
9961 &testsuite_params, &unittest_params,
9962 &hmac_sha1_test_crypto_vector);
9966 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
9968 return test_authentication_verify_GMAC_fail_when_data_corrupted(
9969 &testsuite_params, &unittest_params,
9970 &aes128_gmac_test_vector);
9974 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
9976 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
9977 &testsuite_params, &unittest_params,
9978 &aes128_gmac_test_vector);
9982 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
9984 return test_authenticated_decryption_fail_when_data_corrupted(
9987 &aes128cbc_hmac_sha1_test_vector);
9991 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
9993 return test_authenticated_decryption_fail_when_tag_corrupted(
9996 &aes128cbc_hmac_sha1_test_vector);
9999 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10001 /* global AESNI slave IDs for the scheduler test */
10002 uint8_t aesni_ids[2];
10005 test_scheduler_attach_slave_op(void)
10007 struct crypto_testsuite_params *ts_params = &testsuite_params;
10008 uint8_t sched_id = ts_params->valid_devs[0];
10009 uint32_t nb_devs, i, nb_devs_attached = 0;
10011 char vdev_name[32];
10013 /* create 2 AESNI_MB if necessary */
10014 nb_devs = rte_cryptodev_device_count_by_driver(
10015 rte_cryptodev_driver_id_get(
10016 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
10018 for (i = nb_devs; i < 2; i++) {
10019 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
10020 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
10022 ret = rte_vdev_init(vdev_name, NULL);
10024 TEST_ASSERT(ret == 0,
10025 "Failed to create instance %u of"
10027 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10031 /* attach 2 AESNI_MB cdevs */
10032 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
10034 struct rte_cryptodev_info info;
10035 unsigned int session_size;
10037 rte_cryptodev_info_get(i, &info);
10038 if (info.driver_id != rte_cryptodev_driver_id_get(
10039 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
10042 session_size = rte_cryptodev_sym_get_private_session_size(i);
10044 * Create the session mempool again, since now there are new devices
10045 * to use the mempool.
10047 if (ts_params->session_mpool) {
10048 rte_mempool_free(ts_params->session_mpool);
10049 ts_params->session_mpool = NULL;
10051 if (ts_params->session_priv_mpool) {
10052 rte_mempool_free(ts_params->session_priv_mpool);
10053 ts_params->session_priv_mpool = NULL;
10056 if (info.sym.max_nb_sessions != 0 &&
10057 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
10058 RTE_LOG(ERR, USER1,
10059 "Device does not support "
10060 "at least %u sessions\n",
10062 return TEST_FAILED;
10065 * Create mempool with maximum number of sessions,
10066 * to include the session headers
10068 if (ts_params->session_mpool == NULL) {
10069 ts_params->session_mpool =
10070 rte_cryptodev_sym_session_pool_create(
10072 MAX_NB_SESSIONS, 0, 0, 0,
10074 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
10075 "session mempool allocation failed");
10079 * Create mempool with maximum number of sessions,
10080 * to include device specific session private data
10082 if (ts_params->session_priv_mpool == NULL) {
10083 ts_params->session_priv_mpool = rte_mempool_create(
10084 "test_sess_mp_priv",
10087 0, 0, NULL, NULL, NULL,
10088 NULL, SOCKET_ID_ANY,
10091 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
10092 "session mempool allocation failed");
10095 ts_params->qp_conf.mp_session = ts_params->session_mpool;
10096 ts_params->qp_conf.mp_session_private =
10097 ts_params->session_priv_mpool;
10099 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
10102 TEST_ASSERT(ret == 0,
10103 "Failed to attach device %u of pmd : %s", i,
10104 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10106 aesni_ids[nb_devs_attached] = (uint8_t)i;
10108 nb_devs_attached++;
10115 test_scheduler_detach_slave_op(void)
10117 struct crypto_testsuite_params *ts_params = &testsuite_params;
10118 uint8_t sched_id = ts_params->valid_devs[0];
10122 for (i = 0; i < 2; i++) {
10123 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
10125 TEST_ASSERT(ret == 0,
10126 "Failed to detach device %u", aesni_ids[i]);
10133 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
10135 struct crypto_testsuite_params *ts_params = &testsuite_params;
10136 uint8_t sched_id = ts_params->valid_devs[0];
10138 return rte_cryptodev_scheduler_mode_set(sched_id,
10143 test_scheduler_mode_roundrobin_op(void)
10145 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
10146 0, "Failed to set roundrobin mode");
10152 test_scheduler_mode_multicore_op(void)
10154 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
10155 0, "Failed to set multicore mode");
10161 test_scheduler_mode_failover_op(void)
10163 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
10164 0, "Failed to set failover mode");
10170 test_scheduler_mode_pkt_size_distr_op(void)
10172 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
10173 0, "Failed to set pktsize mode");
10178 static struct unit_test_suite cryptodev_scheduler_testsuite = {
10179 .suite_name = "Crypto Device Scheduler Unit Test Suite",
10180 .setup = testsuite_setup,
10181 .teardown = testsuite_teardown,
10182 .unit_test_cases = {
10184 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10185 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
10186 TEST_CASE_ST(ut_setup, ut_teardown,
10187 test_AES_chain_scheduler_all),
10188 TEST_CASE_ST(ut_setup, ut_teardown,
10189 test_AES_cipheronly_scheduler_all),
10190 TEST_CASE_ST(ut_setup, ut_teardown,
10191 test_authonly_scheduler_all),
10192 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10195 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10196 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
10197 TEST_CASE_ST(ut_setup, ut_teardown,
10198 test_AES_chain_scheduler_all),
10199 TEST_CASE_ST(ut_setup, ut_teardown,
10200 test_AES_cipheronly_scheduler_all),
10201 TEST_CASE_ST(ut_setup, ut_teardown,
10202 test_authonly_scheduler_all),
10203 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10206 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10207 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
10208 TEST_CASE_ST(ut_setup, ut_teardown,
10209 test_AES_chain_scheduler_all),
10210 TEST_CASE_ST(ut_setup, ut_teardown,
10211 test_AES_cipheronly_scheduler_all),
10212 TEST_CASE_ST(ut_setup, ut_teardown,
10213 test_authonly_scheduler_all),
10214 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10217 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10218 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
10219 TEST_CASE_ST(ut_setup, ut_teardown,
10220 test_AES_chain_scheduler_all),
10221 TEST_CASE_ST(ut_setup, ut_teardown,
10222 test_AES_cipheronly_scheduler_all),
10223 TEST_CASE_ST(ut_setup, ut_teardown,
10224 test_authonly_scheduler_all),
10225 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10227 TEST_CASES_END() /**< NULL terminate unit test array */
10231 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
10233 static struct unit_test_suite cryptodev_qat_testsuite = {
10234 .suite_name = "Crypto QAT Unit Test Suite",
10235 .setup = testsuite_setup,
10236 .teardown = testsuite_teardown,
10237 .unit_test_cases = {
10238 TEST_CASE_ST(ut_setup, ut_teardown,
10239 test_device_configure_invalid_dev_id),
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 test_device_configure_invalid_queue_pair_ids),
10242 TEST_CASE_ST(ut_setup, ut_teardown,
10243 test_queue_pair_descriptor_setup),
10244 TEST_CASE_ST(ut_setup, ut_teardown,
10245 test_multi_session),
10247 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
10248 TEST_CASE_ST(ut_setup, ut_teardown,
10249 test_AES_cipheronly_qat_all),
10250 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
10251 TEST_CASE_ST(ut_setup, ut_teardown,
10252 test_3DES_cipheronly_qat_all),
10253 TEST_CASE_ST(ut_setup, ut_teardown,
10254 test_DES_cipheronly_qat_all),
10255 TEST_CASE_ST(ut_setup, ut_teardown,
10256 test_AES_docsis_qat_all),
10257 TEST_CASE_ST(ut_setup, ut_teardown,
10258 test_DES_docsis_qat_all),
10259 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
10260 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
10262 /** AES CCM Authenticated Encryption 128 bits key */
10263 TEST_CASE_ST(ut_setup, ut_teardown,
10264 test_AES_CCM_authenticated_encryption_test_case_128_1),
10265 TEST_CASE_ST(ut_setup, ut_teardown,
10266 test_AES_CCM_authenticated_encryption_test_case_128_2),
10267 TEST_CASE_ST(ut_setup, ut_teardown,
10268 test_AES_CCM_authenticated_encryption_test_case_128_3),
10270 /** AES CCM Authenticated Decryption 128 bits key*/
10271 TEST_CASE_ST(ut_setup, ut_teardown,
10272 test_AES_CCM_authenticated_decryption_test_case_128_1),
10273 TEST_CASE_ST(ut_setup, ut_teardown,
10274 test_AES_CCM_authenticated_decryption_test_case_128_2),
10275 TEST_CASE_ST(ut_setup, ut_teardown,
10276 test_AES_CCM_authenticated_decryption_test_case_128_3),
10278 /** AES GCM Authenticated Encryption */
10279 TEST_CASE_ST(ut_setup, ut_teardown,
10280 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10281 TEST_CASE_ST(ut_setup, ut_teardown,
10282 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10283 TEST_CASE_ST(ut_setup, ut_teardown,
10284 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10285 TEST_CASE_ST(ut_setup, ut_teardown,
10286 test_AES_GCM_authenticated_encryption_test_case_1),
10287 TEST_CASE_ST(ut_setup, ut_teardown,
10288 test_AES_GCM_authenticated_encryption_test_case_2),
10289 TEST_CASE_ST(ut_setup, ut_teardown,
10290 test_AES_GCM_authenticated_encryption_test_case_3),
10291 TEST_CASE_ST(ut_setup, ut_teardown,
10292 test_AES_GCM_authenticated_encryption_test_case_4),
10293 TEST_CASE_ST(ut_setup, ut_teardown,
10294 test_AES_GCM_authenticated_encryption_test_case_5),
10295 TEST_CASE_ST(ut_setup, ut_teardown,
10296 test_AES_GCM_authenticated_encryption_test_case_6),
10297 TEST_CASE_ST(ut_setup, ut_teardown,
10298 test_AES_GCM_authenticated_encryption_test_case_7),
10300 /** AES GCM Authenticated Decryption */
10301 TEST_CASE_ST(ut_setup, ut_teardown,
10302 test_AES_GCM_authenticated_decryption_test_case_1),
10303 TEST_CASE_ST(ut_setup, ut_teardown,
10304 test_AES_GCM_authenticated_decryption_test_case_2),
10305 TEST_CASE_ST(ut_setup, ut_teardown,
10306 test_AES_GCM_authenticated_decryption_test_case_3),
10307 TEST_CASE_ST(ut_setup, ut_teardown,
10308 test_AES_GCM_authenticated_decryption_test_case_4),
10309 TEST_CASE_ST(ut_setup, ut_teardown,
10310 test_AES_GCM_authenticated_decryption_test_case_5),
10311 TEST_CASE_ST(ut_setup, ut_teardown,
10312 test_AES_GCM_authenticated_decryption_test_case_6),
10313 TEST_CASE_ST(ut_setup, ut_teardown,
10314 test_AES_GCM_authenticated_decryption_test_case_7),
10316 /** AES GCM Authenticated Encryption 192 bits key */
10317 TEST_CASE_ST(ut_setup, ut_teardown,
10318 test_AES_GCM_auth_encryption_test_case_192_1),
10319 TEST_CASE_ST(ut_setup, ut_teardown,
10320 test_AES_GCM_auth_encryption_test_case_192_2),
10321 TEST_CASE_ST(ut_setup, ut_teardown,
10322 test_AES_GCM_auth_encryption_test_case_192_3),
10323 TEST_CASE_ST(ut_setup, ut_teardown,
10324 test_AES_GCM_auth_encryption_test_case_192_4),
10325 TEST_CASE_ST(ut_setup, ut_teardown,
10326 test_AES_GCM_auth_encryption_test_case_192_5),
10327 TEST_CASE_ST(ut_setup, ut_teardown,
10328 test_AES_GCM_auth_encryption_test_case_192_6),
10329 TEST_CASE_ST(ut_setup, ut_teardown,
10330 test_AES_GCM_auth_encryption_test_case_192_7),
10332 /** AES GCM Authenticated Decryption 192 bits key */
10333 TEST_CASE_ST(ut_setup, ut_teardown,
10334 test_AES_GCM_auth_decryption_test_case_192_1),
10335 TEST_CASE_ST(ut_setup, ut_teardown,
10336 test_AES_GCM_auth_decryption_test_case_192_2),
10337 TEST_CASE_ST(ut_setup, ut_teardown,
10338 test_AES_GCM_auth_decryption_test_case_192_3),
10339 TEST_CASE_ST(ut_setup, ut_teardown,
10340 test_AES_GCM_auth_decryption_test_case_192_4),
10341 TEST_CASE_ST(ut_setup, ut_teardown,
10342 test_AES_GCM_auth_decryption_test_case_192_5),
10343 TEST_CASE_ST(ut_setup, ut_teardown,
10344 test_AES_GCM_auth_decryption_test_case_192_6),
10345 TEST_CASE_ST(ut_setup, ut_teardown,
10346 test_AES_GCM_auth_decryption_test_case_192_7),
10348 /** AES GCM Authenticated Encryption 256 bits key */
10349 TEST_CASE_ST(ut_setup, ut_teardown,
10350 test_AES_GCM_auth_encryption_test_case_256_1),
10351 TEST_CASE_ST(ut_setup, ut_teardown,
10352 test_AES_GCM_auth_encryption_test_case_256_2),
10353 TEST_CASE_ST(ut_setup, ut_teardown,
10354 test_AES_GCM_auth_encryption_test_case_256_3),
10355 TEST_CASE_ST(ut_setup, ut_teardown,
10356 test_AES_GCM_auth_encryption_test_case_256_4),
10357 TEST_CASE_ST(ut_setup, ut_teardown,
10358 test_AES_GCM_auth_encryption_test_case_256_5),
10359 TEST_CASE_ST(ut_setup, ut_teardown,
10360 test_AES_GCM_auth_encryption_test_case_256_6),
10361 TEST_CASE_ST(ut_setup, ut_teardown,
10362 test_AES_GCM_auth_encryption_test_case_256_7),
10364 /** AES GMAC Authentication */
10365 TEST_CASE_ST(ut_setup, ut_teardown,
10366 test_AES_GMAC_authentication_test_case_1),
10367 TEST_CASE_ST(ut_setup, ut_teardown,
10368 test_AES_GMAC_authentication_verify_test_case_1),
10369 TEST_CASE_ST(ut_setup, ut_teardown,
10370 test_AES_GMAC_authentication_test_case_2),
10371 TEST_CASE_ST(ut_setup, ut_teardown,
10372 test_AES_GMAC_authentication_verify_test_case_2),
10373 TEST_CASE_ST(ut_setup, ut_teardown,
10374 test_AES_GMAC_authentication_test_case_3),
10375 TEST_CASE_ST(ut_setup, ut_teardown,
10376 test_AES_GMAC_authentication_verify_test_case_3),
10378 /** SNOW 3G encrypt only (UEA2) */
10379 TEST_CASE_ST(ut_setup, ut_teardown,
10380 test_snow3g_encryption_test_case_1),
10381 TEST_CASE_ST(ut_setup, ut_teardown,
10382 test_snow3g_encryption_test_case_2),
10383 TEST_CASE_ST(ut_setup, ut_teardown,
10384 test_snow3g_encryption_test_case_3),
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 test_snow3g_encryption_test_case_4),
10387 TEST_CASE_ST(ut_setup, ut_teardown,
10388 test_snow3g_encryption_test_case_5),
10390 TEST_CASE_ST(ut_setup, ut_teardown,
10391 test_snow3g_encryption_test_case_1_oop),
10392 TEST_CASE_ST(ut_setup, ut_teardown,
10393 test_snow3g_decryption_test_case_1_oop),
10395 /** SNOW 3G generate auth, then encrypt (UEA2) */
10396 TEST_CASE_ST(ut_setup, ut_teardown,
10397 test_snow3g_auth_cipher_test_case_1),
10398 TEST_CASE_ST(ut_setup, ut_teardown,
10399 test_snow3g_auth_cipher_test_case_2),
10400 TEST_CASE_ST(ut_setup, ut_teardown,
10401 test_snow3g_auth_cipher_test_case_2_oop),
10402 TEST_CASE_ST(ut_setup, ut_teardown,
10403 test_snow3g_auth_cipher_part_digest_enc),
10404 TEST_CASE_ST(ut_setup, ut_teardown,
10405 test_snow3g_auth_cipher_part_digest_enc_oop),
10406 TEST_CASE_ST(ut_setup, ut_teardown,
10407 test_snow3g_auth_cipher_test_case_3_sgl),
10408 TEST_CASE_ST(ut_setup, ut_teardown,
10409 test_snow3g_auth_cipher_test_case_3_oop_sgl),
10410 TEST_CASE_ST(ut_setup, ut_teardown,
10411 test_snow3g_auth_cipher_part_digest_enc_sgl),
10412 TEST_CASE_ST(ut_setup, ut_teardown,
10413 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
10415 /** SNOW 3G decrypt (UEA2), then verify auth */
10416 TEST_CASE_ST(ut_setup, ut_teardown,
10417 test_snow3g_auth_cipher_verify_test_case_1),
10418 TEST_CASE_ST(ut_setup, ut_teardown,
10419 test_snow3g_auth_cipher_verify_test_case_2),
10420 TEST_CASE_ST(ut_setup, ut_teardown,
10421 test_snow3g_auth_cipher_verify_test_case_2_oop),
10422 TEST_CASE_ST(ut_setup, ut_teardown,
10423 test_snow3g_auth_cipher_verify_part_digest_enc),
10424 TEST_CASE_ST(ut_setup, ut_teardown,
10425 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
10426 TEST_CASE_ST(ut_setup, ut_teardown,
10427 test_snow3g_auth_cipher_verify_test_case_3_sgl),
10428 TEST_CASE_ST(ut_setup, ut_teardown,
10429 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
10430 TEST_CASE_ST(ut_setup, ut_teardown,
10431 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
10432 TEST_CASE_ST(ut_setup, ut_teardown,
10433 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
10435 /** SNOW 3G decrypt only (UEA2) */
10436 TEST_CASE_ST(ut_setup, ut_teardown,
10437 test_snow3g_decryption_test_case_1),
10438 TEST_CASE_ST(ut_setup, ut_teardown,
10439 test_snow3g_decryption_test_case_2),
10440 TEST_CASE_ST(ut_setup, ut_teardown,
10441 test_snow3g_decryption_test_case_3),
10442 TEST_CASE_ST(ut_setup, ut_teardown,
10443 test_snow3g_decryption_test_case_4),
10444 TEST_CASE_ST(ut_setup, ut_teardown,
10445 test_snow3g_decryption_test_case_5),
10446 TEST_CASE_ST(ut_setup, ut_teardown,
10447 test_snow3g_decryption_with_digest_test_case_1),
10448 TEST_CASE_ST(ut_setup, ut_teardown,
10449 test_snow3g_hash_generate_test_case_1),
10450 TEST_CASE_ST(ut_setup, ut_teardown,
10451 test_snow3g_hash_generate_test_case_2),
10452 TEST_CASE_ST(ut_setup, ut_teardown,
10453 test_snow3g_hash_generate_test_case_3),
10454 TEST_CASE_ST(ut_setup, ut_teardown,
10455 test_snow3g_hash_verify_test_case_1),
10456 TEST_CASE_ST(ut_setup, ut_teardown,
10457 test_snow3g_hash_verify_test_case_2),
10458 TEST_CASE_ST(ut_setup, ut_teardown,
10459 test_snow3g_hash_verify_test_case_3),
10460 TEST_CASE_ST(ut_setup, ut_teardown,
10461 test_snow3g_cipher_auth_test_case_1),
10462 TEST_CASE_ST(ut_setup, ut_teardown,
10463 test_snow3g_auth_cipher_with_digest_test_case_1),
10465 /** ZUC encrypt only (EEA3) */
10466 TEST_CASE_ST(ut_setup, ut_teardown,
10467 test_zuc_encryption_test_case_1),
10468 TEST_CASE_ST(ut_setup, ut_teardown,
10469 test_zuc_encryption_test_case_2),
10470 TEST_CASE_ST(ut_setup, ut_teardown,
10471 test_zuc_encryption_test_case_3),
10472 TEST_CASE_ST(ut_setup, ut_teardown,
10473 test_zuc_encryption_test_case_4),
10474 TEST_CASE_ST(ut_setup, ut_teardown,
10475 test_zuc_encryption_test_case_5),
10477 /** ZUC authenticate (EIA3) */
10478 TEST_CASE_ST(ut_setup, ut_teardown,
10479 test_zuc_hash_generate_test_case_6),
10480 TEST_CASE_ST(ut_setup, ut_teardown,
10481 test_zuc_hash_generate_test_case_7),
10482 TEST_CASE_ST(ut_setup, ut_teardown,
10483 test_zuc_hash_generate_test_case_8),
10485 /** ZUC alg-chain (EEA3/EIA3) */
10486 TEST_CASE_ST(ut_setup, ut_teardown,
10487 test_zuc_cipher_auth_test_case_1),
10488 TEST_CASE_ST(ut_setup, ut_teardown,
10489 test_zuc_cipher_auth_test_case_2),
10491 /** ZUC generate auth, then encrypt (EEA3) */
10492 TEST_CASE_ST(ut_setup, ut_teardown,
10493 test_zuc_auth_cipher_test_case_1),
10494 TEST_CASE_ST(ut_setup, ut_teardown,
10495 test_zuc_auth_cipher_test_case_1_oop),
10496 TEST_CASE_ST(ut_setup, ut_teardown,
10497 test_zuc_auth_cipher_test_case_1_sgl),
10498 TEST_CASE_ST(ut_setup, ut_teardown,
10499 test_zuc_auth_cipher_test_case_1_oop_sgl),
10501 /** ZUC decrypt (EEA3), then verify auth */
10502 TEST_CASE_ST(ut_setup, ut_teardown,
10503 test_zuc_auth_cipher_verify_test_case_1),
10504 TEST_CASE_ST(ut_setup, ut_teardown,
10505 test_zuc_auth_cipher_verify_test_case_1_oop),
10506 TEST_CASE_ST(ut_setup, ut_teardown,
10507 test_zuc_auth_cipher_verify_test_case_1_sgl),
10508 TEST_CASE_ST(ut_setup, ut_teardown,
10509 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
10511 /** HMAC_MD5 Authentication */
10512 TEST_CASE_ST(ut_setup, ut_teardown,
10513 test_MD5_HMAC_generate_case_1),
10514 TEST_CASE_ST(ut_setup, ut_teardown,
10515 test_MD5_HMAC_verify_case_1),
10516 TEST_CASE_ST(ut_setup, ut_teardown,
10517 test_MD5_HMAC_generate_case_2),
10518 TEST_CASE_ST(ut_setup, ut_teardown,
10519 test_MD5_HMAC_verify_case_2),
10521 /** NULL algo tests done in chain_all,
10522 * cipheronly and authonly suites
10525 /** KASUMI tests */
10526 TEST_CASE_ST(ut_setup, ut_teardown,
10527 test_kasumi_hash_generate_test_case_1),
10528 TEST_CASE_ST(ut_setup, ut_teardown,
10529 test_kasumi_hash_generate_test_case_2),
10530 TEST_CASE_ST(ut_setup, ut_teardown,
10531 test_kasumi_hash_generate_test_case_3),
10532 TEST_CASE_ST(ut_setup, ut_teardown,
10533 test_kasumi_hash_generate_test_case_4),
10534 TEST_CASE_ST(ut_setup, ut_teardown,
10535 test_kasumi_hash_generate_test_case_5),
10536 TEST_CASE_ST(ut_setup, ut_teardown,
10537 test_kasumi_hash_generate_test_case_6),
10539 TEST_CASE_ST(ut_setup, ut_teardown,
10540 test_kasumi_hash_verify_test_case_1),
10541 TEST_CASE_ST(ut_setup, ut_teardown,
10542 test_kasumi_hash_verify_test_case_2),
10543 TEST_CASE_ST(ut_setup, ut_teardown,
10544 test_kasumi_hash_verify_test_case_3),
10545 TEST_CASE_ST(ut_setup, ut_teardown,
10546 test_kasumi_hash_verify_test_case_4),
10547 TEST_CASE_ST(ut_setup, ut_teardown,
10548 test_kasumi_hash_verify_test_case_5),
10550 TEST_CASE_ST(ut_setup, ut_teardown,
10551 test_kasumi_encryption_test_case_1),
10552 TEST_CASE_ST(ut_setup, ut_teardown,
10553 test_kasumi_encryption_test_case_3),
10554 TEST_CASE_ST(ut_setup, ut_teardown,
10555 test_kasumi_cipher_auth_test_case_1),
10557 /** KASUMI generate auth, then encrypt (F8) */
10558 TEST_CASE_ST(ut_setup, ut_teardown,
10559 test_kasumi_auth_cipher_test_case_1),
10560 TEST_CASE_ST(ut_setup, ut_teardown,
10561 test_kasumi_auth_cipher_test_case_2),
10562 TEST_CASE_ST(ut_setup, ut_teardown,
10563 test_kasumi_auth_cipher_test_case_2_oop),
10564 TEST_CASE_ST(ut_setup, ut_teardown,
10565 test_kasumi_auth_cipher_test_case_2_sgl),
10566 TEST_CASE_ST(ut_setup, ut_teardown,
10567 test_kasumi_auth_cipher_test_case_2_oop_sgl),
10569 /** KASUMI decrypt (F8), then verify auth */
10570 TEST_CASE_ST(ut_setup, ut_teardown,
10571 test_kasumi_auth_cipher_verify_test_case_1),
10572 TEST_CASE_ST(ut_setup, ut_teardown,
10573 test_kasumi_auth_cipher_verify_test_case_2),
10574 TEST_CASE_ST(ut_setup, ut_teardown,
10575 test_kasumi_auth_cipher_verify_test_case_2_oop),
10576 TEST_CASE_ST(ut_setup, ut_teardown,
10577 test_kasumi_auth_cipher_verify_test_case_2_sgl),
10578 TEST_CASE_ST(ut_setup, ut_teardown,
10579 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
10581 /** Negative tests */
10582 TEST_CASE_ST(ut_setup, ut_teardown,
10583 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10584 TEST_CASE_ST(ut_setup, ut_teardown,
10585 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10586 TEST_CASE_ST(ut_setup, ut_teardown,
10587 authentication_verify_AES128_GMAC_fail_data_corrupt),
10588 TEST_CASE_ST(ut_setup, ut_teardown,
10589 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10590 TEST_CASE_ST(ut_setup, ut_teardown,
10591 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10592 TEST_CASE_ST(ut_setup, ut_teardown,
10593 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10595 TEST_CASES_END() /**< NULL terminate unit test array */
10599 static struct unit_test_suite cryptodev_virtio_testsuite = {
10600 .suite_name = "Crypto VIRTIO Unit Test Suite",
10601 .setup = testsuite_setup,
10602 .teardown = testsuite_teardown,
10603 .unit_test_cases = {
10604 TEST_CASE_ST(ut_setup, ut_teardown,
10605 test_AES_cipheronly_virtio_all),
10607 TEST_CASES_END() /**< NULL terminate unit test array */
10611 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
10612 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
10613 .setup = testsuite_setup,
10614 .teardown = testsuite_teardown,
10615 .unit_test_cases = {
10616 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
10617 TEST_CASE_ST(ut_setup, ut_teardown,
10618 test_AES_GCM_authenticated_encryption_test_case_1),
10619 TEST_CASE_ST(ut_setup, ut_teardown,
10620 test_AES_GCM_authenticated_encryption_test_case_2),
10621 TEST_CASE_ST(ut_setup, ut_teardown,
10622 test_AES_GCM_authenticated_encryption_test_case_3),
10623 TEST_CASE_ST(ut_setup, ut_teardown,
10624 test_AES_GCM_authenticated_encryption_test_case_4),
10625 TEST_CASE_ST(ut_setup, ut_teardown,
10626 test_AES_GCM_authenticated_encryption_test_case_5),
10627 TEST_CASE_ST(ut_setup, ut_teardown,
10628 test_AES_GCM_authenticated_encryption_test_case_6),
10629 TEST_CASE_ST(ut_setup, ut_teardown,
10630 test_AES_GCM_authenticated_encryption_test_case_7),
10632 /** AES GCM Authenticated Decryption */
10633 TEST_CASE_ST(ut_setup, ut_teardown,
10634 test_AES_GCM_authenticated_decryption_test_case_1),
10635 TEST_CASE_ST(ut_setup, ut_teardown,
10636 test_AES_GCM_authenticated_decryption_test_case_2),
10637 TEST_CASE_ST(ut_setup, ut_teardown,
10638 test_AES_GCM_authenticated_decryption_test_case_3),
10639 TEST_CASE_ST(ut_setup, ut_teardown,
10640 test_AES_GCM_authenticated_decryption_test_case_4),
10641 TEST_CASE_ST(ut_setup, ut_teardown,
10642 test_AES_GCM_authenticated_decryption_test_case_5),
10643 TEST_CASE_ST(ut_setup, ut_teardown,
10644 test_AES_GCM_authenticated_decryption_test_case_6),
10645 TEST_CASE_ST(ut_setup, ut_teardown,
10646 test_AES_GCM_authenticated_decryption_test_case_7),
10648 /** AES GCM Authenticated Encryption 192 bits key */
10649 TEST_CASE_ST(ut_setup, ut_teardown,
10650 test_AES_GCM_auth_encryption_test_case_192_1),
10651 TEST_CASE_ST(ut_setup, ut_teardown,
10652 test_AES_GCM_auth_encryption_test_case_192_2),
10653 TEST_CASE_ST(ut_setup, ut_teardown,
10654 test_AES_GCM_auth_encryption_test_case_192_3),
10655 TEST_CASE_ST(ut_setup, ut_teardown,
10656 test_AES_GCM_auth_encryption_test_case_192_4),
10657 TEST_CASE_ST(ut_setup, ut_teardown,
10658 test_AES_GCM_auth_encryption_test_case_192_5),
10659 TEST_CASE_ST(ut_setup, ut_teardown,
10660 test_AES_GCM_auth_encryption_test_case_192_6),
10661 TEST_CASE_ST(ut_setup, ut_teardown,
10662 test_AES_GCM_auth_encryption_test_case_192_7),
10664 /** AES GCM Authenticated Decryption 192 bits key */
10665 TEST_CASE_ST(ut_setup, ut_teardown,
10666 test_AES_GCM_auth_decryption_test_case_192_1),
10667 TEST_CASE_ST(ut_setup, ut_teardown,
10668 test_AES_GCM_auth_decryption_test_case_192_2),
10669 TEST_CASE_ST(ut_setup, ut_teardown,
10670 test_AES_GCM_auth_decryption_test_case_192_3),
10671 TEST_CASE_ST(ut_setup, ut_teardown,
10672 test_AES_GCM_auth_decryption_test_case_192_4),
10673 TEST_CASE_ST(ut_setup, ut_teardown,
10674 test_AES_GCM_auth_decryption_test_case_192_5),
10675 TEST_CASE_ST(ut_setup, ut_teardown,
10676 test_AES_GCM_auth_decryption_test_case_192_6),
10677 TEST_CASE_ST(ut_setup, ut_teardown,
10678 test_AES_GCM_auth_decryption_test_case_192_7),
10680 /** AES GCM Authenticated Encryption 256 bits key */
10681 TEST_CASE_ST(ut_setup, ut_teardown,
10682 test_AES_GCM_auth_encryption_test_case_256_1),
10683 TEST_CASE_ST(ut_setup, ut_teardown,
10684 test_AES_GCM_auth_encryption_test_case_256_2),
10685 TEST_CASE_ST(ut_setup, ut_teardown,
10686 test_AES_GCM_auth_encryption_test_case_256_3),
10687 TEST_CASE_ST(ut_setup, ut_teardown,
10688 test_AES_GCM_auth_encryption_test_case_256_4),
10689 TEST_CASE_ST(ut_setup, ut_teardown,
10690 test_AES_GCM_auth_encryption_test_case_256_5),
10691 TEST_CASE_ST(ut_setup, ut_teardown,
10692 test_AES_GCM_auth_encryption_test_case_256_6),
10693 TEST_CASE_ST(ut_setup, ut_teardown,
10694 test_AES_GCM_auth_encryption_test_case_256_7),
10696 /** AES GCM Authenticated Decryption 256 bits key */
10697 TEST_CASE_ST(ut_setup, ut_teardown,
10698 test_AES_GCM_auth_decryption_test_case_256_1),
10699 TEST_CASE_ST(ut_setup, ut_teardown,
10700 test_AES_GCM_auth_decryption_test_case_256_2),
10701 TEST_CASE_ST(ut_setup, ut_teardown,
10702 test_AES_GCM_auth_decryption_test_case_256_3),
10703 TEST_CASE_ST(ut_setup, ut_teardown,
10704 test_AES_GCM_auth_decryption_test_case_256_4),
10705 TEST_CASE_ST(ut_setup, ut_teardown,
10706 test_AES_GCM_auth_decryption_test_case_256_5),
10707 TEST_CASE_ST(ut_setup, ut_teardown,
10708 test_AES_GCM_auth_decryption_test_case_256_6),
10709 TEST_CASE_ST(ut_setup, ut_teardown,
10710 test_AES_GCM_auth_decryption_test_case_256_7),
10712 /** AES GCM Authenticated Encryption big aad size */
10713 TEST_CASE_ST(ut_setup, ut_teardown,
10714 test_AES_GCM_auth_encryption_test_case_aad_1),
10715 TEST_CASE_ST(ut_setup, ut_teardown,
10716 test_AES_GCM_auth_encryption_test_case_aad_2),
10718 /** AES GCM Authenticated Decryption big aad size */
10719 TEST_CASE_ST(ut_setup, ut_teardown,
10720 test_AES_GCM_auth_decryption_test_case_aad_1),
10721 TEST_CASE_ST(ut_setup, ut_teardown,
10722 test_AES_GCM_auth_decryption_test_case_aad_2),
10724 /** Session-less tests */
10725 TEST_CASE_ST(ut_setup, ut_teardown,
10726 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
10727 TEST_CASE_ST(ut_setup, ut_teardown,
10728 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
10730 /** AES GMAC Authentication */
10731 TEST_CASE_ST(ut_setup, ut_teardown,
10732 test_AES_GMAC_authentication_test_case_1),
10733 TEST_CASE_ST(ut_setup, ut_teardown,
10734 test_AES_GMAC_authentication_verify_test_case_1),
10735 TEST_CASE_ST(ut_setup, ut_teardown,
10736 test_AES_GMAC_authentication_test_case_2),
10737 TEST_CASE_ST(ut_setup, ut_teardown,
10738 test_AES_GMAC_authentication_verify_test_case_2),
10739 TEST_CASE_ST(ut_setup, ut_teardown,
10740 test_AES_GMAC_authentication_test_case_3),
10741 TEST_CASE_ST(ut_setup, ut_teardown,
10742 test_AES_GMAC_authentication_verify_test_case_3),
10743 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
10745 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
10746 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
10747 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
10748 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
10749 TEST_CASE_ST(ut_setup, ut_teardown,
10750 test_DES_cipheronly_mb_all),
10751 TEST_CASE_ST(ut_setup, ut_teardown,
10752 test_DES_docsis_mb_all),
10753 TEST_CASE_ST(ut_setup, ut_teardown,
10754 test_3DES_cipheronly_mb_all),
10755 TEST_CASE_ST(ut_setup, ut_teardown,
10756 test_AES_CCM_authenticated_encryption_test_case_128_1),
10757 TEST_CASE_ST(ut_setup, ut_teardown,
10758 test_AES_CCM_authenticated_decryption_test_case_128_1),
10759 TEST_CASE_ST(ut_setup, ut_teardown,
10760 test_AES_CCM_authenticated_encryption_test_case_128_2),
10761 TEST_CASE_ST(ut_setup, ut_teardown,
10762 test_AES_CCM_authenticated_decryption_test_case_128_2),
10763 TEST_CASE_ST(ut_setup, ut_teardown,
10764 test_AES_CCM_authenticated_encryption_test_case_128_3),
10765 TEST_CASE_ST(ut_setup, ut_teardown,
10766 test_AES_CCM_authenticated_decryption_test_case_128_3),
10768 TEST_CASES_END() /**< NULL terminate unit test array */
10772 static struct unit_test_suite cryptodev_openssl_testsuite = {
10773 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
10774 .setup = testsuite_setup,
10775 .teardown = testsuite_teardown,
10776 .unit_test_cases = {
10777 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10778 TEST_CASE_ST(ut_setup, ut_teardown,
10779 test_multi_session_random_usage),
10780 TEST_CASE_ST(ut_setup, ut_teardown,
10781 test_AES_chain_openssl_all),
10782 TEST_CASE_ST(ut_setup, ut_teardown,
10783 test_AES_cipheronly_openssl_all),
10784 TEST_CASE_ST(ut_setup, ut_teardown,
10785 test_3DES_chain_openssl_all),
10786 TEST_CASE_ST(ut_setup, ut_teardown,
10787 test_3DES_cipheronly_openssl_all),
10788 TEST_CASE_ST(ut_setup, ut_teardown,
10789 test_DES_cipheronly_openssl_all),
10790 TEST_CASE_ST(ut_setup, ut_teardown,
10791 test_DES_docsis_openssl_all),
10792 TEST_CASE_ST(ut_setup, ut_teardown,
10793 test_authonly_openssl_all),
10795 /** AES GCM Authenticated Encryption */
10796 TEST_CASE_ST(ut_setup, ut_teardown,
10797 test_AES_GCM_authenticated_encryption_test_case_1),
10798 TEST_CASE_ST(ut_setup, ut_teardown,
10799 test_AES_GCM_authenticated_encryption_test_case_2),
10800 TEST_CASE_ST(ut_setup, ut_teardown,
10801 test_AES_GCM_authenticated_encryption_test_case_3),
10802 TEST_CASE_ST(ut_setup, ut_teardown,
10803 test_AES_GCM_authenticated_encryption_test_case_4),
10804 TEST_CASE_ST(ut_setup, ut_teardown,
10805 test_AES_GCM_authenticated_encryption_test_case_5),
10806 TEST_CASE_ST(ut_setup, ut_teardown,
10807 test_AES_GCM_authenticated_encryption_test_case_6),
10808 TEST_CASE_ST(ut_setup, ut_teardown,
10809 test_AES_GCM_authenticated_encryption_test_case_7),
10811 /** AES GCM Authenticated Decryption */
10812 TEST_CASE_ST(ut_setup, ut_teardown,
10813 test_AES_GCM_authenticated_decryption_test_case_1),
10814 TEST_CASE_ST(ut_setup, ut_teardown,
10815 test_AES_GCM_authenticated_decryption_test_case_2),
10816 TEST_CASE_ST(ut_setup, ut_teardown,
10817 test_AES_GCM_authenticated_decryption_test_case_3),
10818 TEST_CASE_ST(ut_setup, ut_teardown,
10819 test_AES_GCM_authenticated_decryption_test_case_4),
10820 TEST_CASE_ST(ut_setup, ut_teardown,
10821 test_AES_GCM_authenticated_decryption_test_case_5),
10822 TEST_CASE_ST(ut_setup, ut_teardown,
10823 test_AES_GCM_authenticated_decryption_test_case_6),
10824 TEST_CASE_ST(ut_setup, ut_teardown,
10825 test_AES_GCM_authenticated_decryption_test_case_7),
10828 /** AES GCM Authenticated Encryption 192 bits key */
10829 TEST_CASE_ST(ut_setup, ut_teardown,
10830 test_AES_GCM_auth_encryption_test_case_192_1),
10831 TEST_CASE_ST(ut_setup, ut_teardown,
10832 test_AES_GCM_auth_encryption_test_case_192_2),
10833 TEST_CASE_ST(ut_setup, ut_teardown,
10834 test_AES_GCM_auth_encryption_test_case_192_3),
10835 TEST_CASE_ST(ut_setup, ut_teardown,
10836 test_AES_GCM_auth_encryption_test_case_192_4),
10837 TEST_CASE_ST(ut_setup, ut_teardown,
10838 test_AES_GCM_auth_encryption_test_case_192_5),
10839 TEST_CASE_ST(ut_setup, ut_teardown,
10840 test_AES_GCM_auth_encryption_test_case_192_6),
10841 TEST_CASE_ST(ut_setup, ut_teardown,
10842 test_AES_GCM_auth_encryption_test_case_192_7),
10844 /** AES GCM Authenticated Decryption 192 bits key */
10845 TEST_CASE_ST(ut_setup, ut_teardown,
10846 test_AES_GCM_auth_decryption_test_case_192_1),
10847 TEST_CASE_ST(ut_setup, ut_teardown,
10848 test_AES_GCM_auth_decryption_test_case_192_2),
10849 TEST_CASE_ST(ut_setup, ut_teardown,
10850 test_AES_GCM_auth_decryption_test_case_192_3),
10851 TEST_CASE_ST(ut_setup, ut_teardown,
10852 test_AES_GCM_auth_decryption_test_case_192_4),
10853 TEST_CASE_ST(ut_setup, ut_teardown,
10854 test_AES_GCM_auth_decryption_test_case_192_5),
10855 TEST_CASE_ST(ut_setup, ut_teardown,
10856 test_AES_GCM_auth_decryption_test_case_192_6),
10857 TEST_CASE_ST(ut_setup, ut_teardown,
10858 test_AES_GCM_auth_decryption_test_case_192_7),
10860 /** AES GCM Authenticated Encryption 256 bits key */
10861 TEST_CASE_ST(ut_setup, ut_teardown,
10862 test_AES_GCM_auth_encryption_test_case_256_1),
10863 TEST_CASE_ST(ut_setup, ut_teardown,
10864 test_AES_GCM_auth_encryption_test_case_256_2),
10865 TEST_CASE_ST(ut_setup, ut_teardown,
10866 test_AES_GCM_auth_encryption_test_case_256_3),
10867 TEST_CASE_ST(ut_setup, ut_teardown,
10868 test_AES_GCM_auth_encryption_test_case_256_4),
10869 TEST_CASE_ST(ut_setup, ut_teardown,
10870 test_AES_GCM_auth_encryption_test_case_256_5),
10871 TEST_CASE_ST(ut_setup, ut_teardown,
10872 test_AES_GCM_auth_encryption_test_case_256_6),
10873 TEST_CASE_ST(ut_setup, ut_teardown,
10874 test_AES_GCM_auth_encryption_test_case_256_7),
10876 /** AES GCM Authenticated Decryption 256 bits key */
10877 TEST_CASE_ST(ut_setup, ut_teardown,
10878 test_AES_GCM_auth_decryption_test_case_256_1),
10879 TEST_CASE_ST(ut_setup, ut_teardown,
10880 test_AES_GCM_auth_decryption_test_case_256_2),
10881 TEST_CASE_ST(ut_setup, ut_teardown,
10882 test_AES_GCM_auth_decryption_test_case_256_3),
10883 TEST_CASE_ST(ut_setup, ut_teardown,
10884 test_AES_GCM_auth_decryption_test_case_256_4),
10885 TEST_CASE_ST(ut_setup, ut_teardown,
10886 test_AES_GCM_auth_decryption_test_case_256_5),
10887 TEST_CASE_ST(ut_setup, ut_teardown,
10888 test_AES_GCM_auth_decryption_test_case_256_6),
10889 TEST_CASE_ST(ut_setup, ut_teardown,
10890 test_AES_GCM_auth_decryption_test_case_256_7),
10892 /** AES GMAC Authentication */
10893 TEST_CASE_ST(ut_setup, ut_teardown,
10894 test_AES_GMAC_authentication_test_case_1),
10895 TEST_CASE_ST(ut_setup, ut_teardown,
10896 test_AES_GMAC_authentication_verify_test_case_1),
10897 TEST_CASE_ST(ut_setup, ut_teardown,
10898 test_AES_GMAC_authentication_test_case_2),
10899 TEST_CASE_ST(ut_setup, ut_teardown,
10900 test_AES_GMAC_authentication_verify_test_case_2),
10901 TEST_CASE_ST(ut_setup, ut_teardown,
10902 test_AES_GMAC_authentication_test_case_3),
10903 TEST_CASE_ST(ut_setup, ut_teardown,
10904 test_AES_GMAC_authentication_verify_test_case_3),
10905 TEST_CASE_ST(ut_setup, ut_teardown,
10906 test_AES_GMAC_authentication_test_case_4),
10907 TEST_CASE_ST(ut_setup, ut_teardown,
10908 test_AES_GMAC_authentication_verify_test_case_4),
10910 /** AES CCM Authenticated Encryption 128 bits key */
10911 TEST_CASE_ST(ut_setup, ut_teardown,
10912 test_AES_CCM_authenticated_encryption_test_case_128_1),
10913 TEST_CASE_ST(ut_setup, ut_teardown,
10914 test_AES_CCM_authenticated_encryption_test_case_128_2),
10915 TEST_CASE_ST(ut_setup, ut_teardown,
10916 test_AES_CCM_authenticated_encryption_test_case_128_3),
10918 /** AES CCM Authenticated Decryption 128 bits key*/
10919 TEST_CASE_ST(ut_setup, ut_teardown,
10920 test_AES_CCM_authenticated_decryption_test_case_128_1),
10921 TEST_CASE_ST(ut_setup, ut_teardown,
10922 test_AES_CCM_authenticated_decryption_test_case_128_2),
10923 TEST_CASE_ST(ut_setup, ut_teardown,
10924 test_AES_CCM_authenticated_decryption_test_case_128_3),
10926 /** AES CCM Authenticated Encryption 192 bits key */
10927 TEST_CASE_ST(ut_setup, ut_teardown,
10928 test_AES_CCM_authenticated_encryption_test_case_192_1),
10929 TEST_CASE_ST(ut_setup, ut_teardown,
10930 test_AES_CCM_authenticated_encryption_test_case_192_2),
10931 TEST_CASE_ST(ut_setup, ut_teardown,
10932 test_AES_CCM_authenticated_encryption_test_case_192_3),
10934 /** AES CCM Authenticated Decryption 192 bits key*/
10935 TEST_CASE_ST(ut_setup, ut_teardown,
10936 test_AES_CCM_authenticated_decryption_test_case_192_1),
10937 TEST_CASE_ST(ut_setup, ut_teardown,
10938 test_AES_CCM_authenticated_decryption_test_case_192_2),
10939 TEST_CASE_ST(ut_setup, ut_teardown,
10940 test_AES_CCM_authenticated_decryption_test_case_192_3),
10942 /** AES CCM Authenticated Encryption 256 bits key */
10943 TEST_CASE_ST(ut_setup, ut_teardown,
10944 test_AES_CCM_authenticated_encryption_test_case_256_1),
10945 TEST_CASE_ST(ut_setup, ut_teardown,
10946 test_AES_CCM_authenticated_encryption_test_case_256_2),
10947 TEST_CASE_ST(ut_setup, ut_teardown,
10948 test_AES_CCM_authenticated_encryption_test_case_256_3),
10950 /** AES CCM Authenticated Decryption 256 bits key*/
10951 TEST_CASE_ST(ut_setup, ut_teardown,
10952 test_AES_CCM_authenticated_decryption_test_case_256_1),
10953 TEST_CASE_ST(ut_setup, ut_teardown,
10954 test_AES_CCM_authenticated_decryption_test_case_256_2),
10955 TEST_CASE_ST(ut_setup, ut_teardown,
10956 test_AES_CCM_authenticated_decryption_test_case_256_3),
10958 /** Scatter-Gather */
10959 TEST_CASE_ST(ut_setup, ut_teardown,
10960 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10962 /** Negative tests */
10963 TEST_CASE_ST(ut_setup, ut_teardown,
10964 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10965 TEST_CASE_ST(ut_setup, ut_teardown,
10966 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10967 TEST_CASE_ST(ut_setup, ut_teardown,
10968 authentication_verify_AES128_GMAC_fail_data_corrupt),
10969 TEST_CASE_ST(ut_setup, ut_teardown,
10970 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10971 TEST_CASE_ST(ut_setup, ut_teardown,
10972 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10973 TEST_CASE_ST(ut_setup, ut_teardown,
10974 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10976 TEST_CASES_END() /**< NULL terminate unit test array */
10980 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
10981 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
10982 .setup = testsuite_setup,
10983 .teardown = testsuite_teardown,
10984 .unit_test_cases = {
10985 /** AES GCM Authenticated Encryption */
10986 TEST_CASE_ST(ut_setup, ut_teardown,
10987 test_AES_GCM_authenticated_encryption_test_case_1),
10988 TEST_CASE_ST(ut_setup, ut_teardown,
10989 test_AES_GCM_authenticated_encryption_test_case_2),
10990 TEST_CASE_ST(ut_setup, ut_teardown,
10991 test_AES_GCM_authenticated_encryption_test_case_3),
10992 TEST_CASE_ST(ut_setup, ut_teardown,
10993 test_AES_GCM_authenticated_encryption_test_case_4),
10994 TEST_CASE_ST(ut_setup, ut_teardown,
10995 test_AES_GCM_authenticated_encryption_test_case_5),
10996 TEST_CASE_ST(ut_setup, ut_teardown,
10997 test_AES_GCM_authenticated_encryption_test_case_6),
10998 TEST_CASE_ST(ut_setup, ut_teardown,
10999 test_AES_GCM_authenticated_encryption_test_case_7),
11001 /** AES GCM Authenticated Decryption */
11002 TEST_CASE_ST(ut_setup, ut_teardown,
11003 test_AES_GCM_authenticated_decryption_test_case_1),
11004 TEST_CASE_ST(ut_setup, ut_teardown,
11005 test_AES_GCM_authenticated_decryption_test_case_2),
11006 TEST_CASE_ST(ut_setup, ut_teardown,
11007 test_AES_GCM_authenticated_decryption_test_case_3),
11008 TEST_CASE_ST(ut_setup, ut_teardown,
11009 test_AES_GCM_authenticated_decryption_test_case_4),
11010 TEST_CASE_ST(ut_setup, ut_teardown,
11011 test_AES_GCM_authenticated_decryption_test_case_5),
11012 TEST_CASE_ST(ut_setup, ut_teardown,
11013 test_AES_GCM_authenticated_decryption_test_case_6),
11014 TEST_CASE_ST(ut_setup, ut_teardown,
11015 test_AES_GCM_authenticated_decryption_test_case_7),
11017 /** AES GCM Authenticated Encryption 192 bits key */
11018 TEST_CASE_ST(ut_setup, ut_teardown,
11019 test_AES_GCM_auth_encryption_test_case_192_1),
11020 TEST_CASE_ST(ut_setup, ut_teardown,
11021 test_AES_GCM_auth_encryption_test_case_192_2),
11022 TEST_CASE_ST(ut_setup, ut_teardown,
11023 test_AES_GCM_auth_encryption_test_case_192_3),
11024 TEST_CASE_ST(ut_setup, ut_teardown,
11025 test_AES_GCM_auth_encryption_test_case_192_4),
11026 TEST_CASE_ST(ut_setup, ut_teardown,
11027 test_AES_GCM_auth_encryption_test_case_192_5),
11028 TEST_CASE_ST(ut_setup, ut_teardown,
11029 test_AES_GCM_auth_encryption_test_case_192_6),
11030 TEST_CASE_ST(ut_setup, ut_teardown,
11031 test_AES_GCM_auth_encryption_test_case_192_7),
11033 /** AES GCM Authenticated Decryption 192 bits key */
11034 TEST_CASE_ST(ut_setup, ut_teardown,
11035 test_AES_GCM_auth_decryption_test_case_192_1),
11036 TEST_CASE_ST(ut_setup, ut_teardown,
11037 test_AES_GCM_auth_decryption_test_case_192_2),
11038 TEST_CASE_ST(ut_setup, ut_teardown,
11039 test_AES_GCM_auth_decryption_test_case_192_3),
11040 TEST_CASE_ST(ut_setup, ut_teardown,
11041 test_AES_GCM_auth_decryption_test_case_192_4),
11042 TEST_CASE_ST(ut_setup, ut_teardown,
11043 test_AES_GCM_auth_decryption_test_case_192_5),
11044 TEST_CASE_ST(ut_setup, ut_teardown,
11045 test_AES_GCM_auth_decryption_test_case_192_6),
11046 TEST_CASE_ST(ut_setup, ut_teardown,
11047 test_AES_GCM_auth_decryption_test_case_192_7),
11049 /** AES GCM Authenticated Encryption 256 bits key */
11050 TEST_CASE_ST(ut_setup, ut_teardown,
11051 test_AES_GCM_auth_encryption_test_case_256_1),
11052 TEST_CASE_ST(ut_setup, ut_teardown,
11053 test_AES_GCM_auth_encryption_test_case_256_2),
11054 TEST_CASE_ST(ut_setup, ut_teardown,
11055 test_AES_GCM_auth_encryption_test_case_256_3),
11056 TEST_CASE_ST(ut_setup, ut_teardown,
11057 test_AES_GCM_auth_encryption_test_case_256_4),
11058 TEST_CASE_ST(ut_setup, ut_teardown,
11059 test_AES_GCM_auth_encryption_test_case_256_5),
11060 TEST_CASE_ST(ut_setup, ut_teardown,
11061 test_AES_GCM_auth_encryption_test_case_256_6),
11062 TEST_CASE_ST(ut_setup, ut_teardown,
11063 test_AES_GCM_auth_encryption_test_case_256_7),
11065 /** AES GCM Authenticated Decryption 256 bits key */
11066 TEST_CASE_ST(ut_setup, ut_teardown,
11067 test_AES_GCM_auth_decryption_test_case_256_1),
11068 TEST_CASE_ST(ut_setup, ut_teardown,
11069 test_AES_GCM_auth_decryption_test_case_256_2),
11070 TEST_CASE_ST(ut_setup, ut_teardown,
11071 test_AES_GCM_auth_decryption_test_case_256_3),
11072 TEST_CASE_ST(ut_setup, ut_teardown,
11073 test_AES_GCM_auth_decryption_test_case_256_4),
11074 TEST_CASE_ST(ut_setup, ut_teardown,
11075 test_AES_GCM_auth_decryption_test_case_256_5),
11076 TEST_CASE_ST(ut_setup, ut_teardown,
11077 test_AES_GCM_auth_decryption_test_case_256_6),
11078 TEST_CASE_ST(ut_setup, ut_teardown,
11079 test_AES_GCM_auth_decryption_test_case_256_7),
11081 /** AES GCM Authenticated Encryption big aad size */
11082 TEST_CASE_ST(ut_setup, ut_teardown,
11083 test_AES_GCM_auth_encryption_test_case_aad_1),
11084 TEST_CASE_ST(ut_setup, ut_teardown,
11085 test_AES_GCM_auth_encryption_test_case_aad_2),
11087 /** AES GCM Authenticated Decryption big aad size */
11088 TEST_CASE_ST(ut_setup, ut_teardown,
11089 test_AES_GCM_auth_decryption_test_case_aad_1),
11090 TEST_CASE_ST(ut_setup, ut_teardown,
11091 test_AES_GCM_auth_decryption_test_case_aad_2),
11093 /** AES GMAC Authentication */
11094 TEST_CASE_ST(ut_setup, ut_teardown,
11095 test_AES_GMAC_authentication_test_case_1),
11096 TEST_CASE_ST(ut_setup, ut_teardown,
11097 test_AES_GMAC_authentication_verify_test_case_1),
11098 TEST_CASE_ST(ut_setup, ut_teardown,
11099 test_AES_GMAC_authentication_test_case_3),
11100 TEST_CASE_ST(ut_setup, ut_teardown,
11101 test_AES_GMAC_authentication_verify_test_case_3),
11102 TEST_CASE_ST(ut_setup, ut_teardown,
11103 test_AES_GMAC_authentication_test_case_4),
11104 TEST_CASE_ST(ut_setup, ut_teardown,
11105 test_AES_GMAC_authentication_verify_test_case_4),
11107 /** Negative tests */
11108 TEST_CASE_ST(ut_setup, ut_teardown,
11109 authentication_verify_AES128_GMAC_fail_data_corrupt),
11110 TEST_CASE_ST(ut_setup, ut_teardown,
11111 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11113 /** Out of place tests */
11114 TEST_CASE_ST(ut_setup, ut_teardown,
11115 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11116 TEST_CASE_ST(ut_setup, ut_teardown,
11117 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11119 /** Session-less tests */
11120 TEST_CASE_ST(ut_setup, ut_teardown,
11121 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11122 TEST_CASE_ST(ut_setup, ut_teardown,
11123 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11125 /** Scatter-Gather */
11126 TEST_CASE_ST(ut_setup, ut_teardown,
11127 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11129 TEST_CASES_END() /**< NULL terminate unit test array */
11133 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
11134 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
11135 .setup = testsuite_setup,
11136 .teardown = testsuite_teardown,
11137 .unit_test_cases = {
11138 /** KASUMI encrypt only (UEA1) */
11139 TEST_CASE_ST(ut_setup, ut_teardown,
11140 test_kasumi_encryption_test_case_1),
11141 TEST_CASE_ST(ut_setup, ut_teardown,
11142 test_kasumi_encryption_test_case_1_sgl),
11143 TEST_CASE_ST(ut_setup, ut_teardown,
11144 test_kasumi_encryption_test_case_2),
11145 TEST_CASE_ST(ut_setup, ut_teardown,
11146 test_kasumi_encryption_test_case_3),
11147 TEST_CASE_ST(ut_setup, ut_teardown,
11148 test_kasumi_encryption_test_case_4),
11149 TEST_CASE_ST(ut_setup, ut_teardown,
11150 test_kasumi_encryption_test_case_5),
11151 /** KASUMI decrypt only (UEA1) */
11152 TEST_CASE_ST(ut_setup, ut_teardown,
11153 test_kasumi_decryption_test_case_1),
11154 TEST_CASE_ST(ut_setup, ut_teardown,
11155 test_kasumi_decryption_test_case_2),
11156 TEST_CASE_ST(ut_setup, ut_teardown,
11157 test_kasumi_decryption_test_case_3),
11158 TEST_CASE_ST(ut_setup, ut_teardown,
11159 test_kasumi_decryption_test_case_4),
11160 TEST_CASE_ST(ut_setup, ut_teardown,
11161 test_kasumi_decryption_test_case_5),
11163 TEST_CASE_ST(ut_setup, ut_teardown,
11164 test_kasumi_encryption_test_case_1_oop),
11165 TEST_CASE_ST(ut_setup, ut_teardown,
11166 test_kasumi_encryption_test_case_1_oop_sgl),
11169 TEST_CASE_ST(ut_setup, ut_teardown,
11170 test_kasumi_decryption_test_case_1_oop),
11172 /** KASUMI hash only (UIA1) */
11173 TEST_CASE_ST(ut_setup, ut_teardown,
11174 test_kasumi_hash_generate_test_case_1),
11175 TEST_CASE_ST(ut_setup, ut_teardown,
11176 test_kasumi_hash_generate_test_case_2),
11177 TEST_CASE_ST(ut_setup, ut_teardown,
11178 test_kasumi_hash_generate_test_case_3),
11179 TEST_CASE_ST(ut_setup, ut_teardown,
11180 test_kasumi_hash_generate_test_case_4),
11181 TEST_CASE_ST(ut_setup, ut_teardown,
11182 test_kasumi_hash_generate_test_case_5),
11183 TEST_CASE_ST(ut_setup, ut_teardown,
11184 test_kasumi_hash_generate_test_case_6),
11185 TEST_CASE_ST(ut_setup, ut_teardown,
11186 test_kasumi_hash_verify_test_case_1),
11187 TEST_CASE_ST(ut_setup, ut_teardown,
11188 test_kasumi_hash_verify_test_case_2),
11189 TEST_CASE_ST(ut_setup, ut_teardown,
11190 test_kasumi_hash_verify_test_case_3),
11191 TEST_CASE_ST(ut_setup, ut_teardown,
11192 test_kasumi_hash_verify_test_case_4),
11193 TEST_CASE_ST(ut_setup, ut_teardown,
11194 test_kasumi_hash_verify_test_case_5),
11195 TEST_CASE_ST(ut_setup, ut_teardown,
11196 test_kasumi_cipher_auth_test_case_1),
11198 /** KASUMI generate auth, then encrypt (F8) */
11199 TEST_CASE_ST(ut_setup, ut_teardown,
11200 test_kasumi_auth_cipher_test_case_1),
11201 TEST_CASE_ST(ut_setup, ut_teardown,
11202 test_kasumi_auth_cipher_test_case_2),
11203 TEST_CASE_ST(ut_setup, ut_teardown,
11204 test_kasumi_auth_cipher_test_case_2_oop),
11205 TEST_CASE_ST(ut_setup, ut_teardown,
11206 test_kasumi_auth_cipher_test_case_2_sgl),
11207 TEST_CASE_ST(ut_setup, ut_teardown,
11208 test_kasumi_auth_cipher_test_case_2_oop_sgl),
11210 /** KASUMI decrypt (F8), then verify auth */
11211 TEST_CASE_ST(ut_setup, ut_teardown,
11212 test_kasumi_auth_cipher_verify_test_case_1),
11213 TEST_CASE_ST(ut_setup, ut_teardown,
11214 test_kasumi_auth_cipher_verify_test_case_2),
11215 TEST_CASE_ST(ut_setup, ut_teardown,
11216 test_kasumi_auth_cipher_verify_test_case_2_oop),
11217 TEST_CASE_ST(ut_setup, ut_teardown,
11218 test_kasumi_auth_cipher_verify_test_case_2_sgl),
11219 TEST_CASE_ST(ut_setup, ut_teardown,
11220 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
11221 TEST_CASES_END() /**< NULL terminate unit test array */
11224 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
11225 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
11226 .setup = testsuite_setup,
11227 .teardown = testsuite_teardown,
11228 .unit_test_cases = {
11229 /** SNOW 3G encrypt only (UEA2) */
11230 TEST_CASE_ST(ut_setup, ut_teardown,
11231 test_snow3g_encryption_test_case_1),
11232 TEST_CASE_ST(ut_setup, ut_teardown,
11233 test_snow3g_encryption_test_case_2),
11234 TEST_CASE_ST(ut_setup, ut_teardown,
11235 test_snow3g_encryption_test_case_3),
11236 TEST_CASE_ST(ut_setup, ut_teardown,
11237 test_snow3g_encryption_test_case_4),
11238 TEST_CASE_ST(ut_setup, ut_teardown,
11239 test_snow3g_encryption_test_case_5),
11240 TEST_CASE_ST(ut_setup, ut_teardown,
11241 test_snow3g_auth_cipher_with_digest_test_case_1),
11243 TEST_CASE_ST(ut_setup, ut_teardown,
11244 test_snow3g_encryption_test_case_1_oop),
11245 TEST_CASE_ST(ut_setup, ut_teardown,
11246 test_snow3g_encryption_test_case_1_oop_sgl),
11247 TEST_CASE_ST(ut_setup, ut_teardown,
11248 test_snow3g_decryption_test_case_1_oop),
11250 TEST_CASE_ST(ut_setup, ut_teardown,
11251 test_snow3g_encryption_test_case_1_offset_oop),
11253 /** SNOW 3G decrypt only (UEA2) */
11254 TEST_CASE_ST(ut_setup, ut_teardown,
11255 test_snow3g_decryption_test_case_1),
11256 TEST_CASE_ST(ut_setup, ut_teardown,
11257 test_snow3g_decryption_test_case_2),
11258 TEST_CASE_ST(ut_setup, ut_teardown,
11259 test_snow3g_decryption_test_case_3),
11260 TEST_CASE_ST(ut_setup, ut_teardown,
11261 test_snow3g_decryption_test_case_4),
11262 TEST_CASE_ST(ut_setup, ut_teardown,
11263 test_snow3g_decryption_test_case_5),
11264 TEST_CASE_ST(ut_setup, ut_teardown,
11265 test_snow3g_decryption_with_digest_test_case_1),
11266 TEST_CASE_ST(ut_setup, ut_teardown,
11267 test_snow3g_hash_generate_test_case_1),
11268 TEST_CASE_ST(ut_setup, ut_teardown,
11269 test_snow3g_hash_generate_test_case_2),
11270 TEST_CASE_ST(ut_setup, ut_teardown,
11271 test_snow3g_hash_generate_test_case_3),
11272 /* Tests with buffers which length is not byte-aligned */
11273 TEST_CASE_ST(ut_setup, ut_teardown,
11274 test_snow3g_hash_generate_test_case_4),
11275 TEST_CASE_ST(ut_setup, ut_teardown,
11276 test_snow3g_hash_generate_test_case_5),
11277 TEST_CASE_ST(ut_setup, ut_teardown,
11278 test_snow3g_hash_generate_test_case_6),
11279 TEST_CASE_ST(ut_setup, ut_teardown,
11280 test_snow3g_hash_verify_test_case_1),
11281 TEST_CASE_ST(ut_setup, ut_teardown,
11282 test_snow3g_hash_verify_test_case_2),
11283 TEST_CASE_ST(ut_setup, ut_teardown,
11284 test_snow3g_hash_verify_test_case_3),
11285 /* Tests with buffers which length is not byte-aligned */
11286 TEST_CASE_ST(ut_setup, ut_teardown,
11287 test_snow3g_hash_verify_test_case_4),
11288 TEST_CASE_ST(ut_setup, ut_teardown,
11289 test_snow3g_hash_verify_test_case_5),
11290 TEST_CASE_ST(ut_setup, ut_teardown,
11291 test_snow3g_hash_verify_test_case_6),
11292 TEST_CASE_ST(ut_setup, ut_teardown,
11293 test_snow3g_cipher_auth_test_case_1),
11295 /** SNOW 3G generate auth, then encrypt (UEA2) */
11296 TEST_CASE_ST(ut_setup, ut_teardown,
11297 test_snow3g_auth_cipher_test_case_1),
11298 TEST_CASE_ST(ut_setup, ut_teardown,
11299 test_snow3g_auth_cipher_test_case_2),
11300 TEST_CASE_ST(ut_setup, ut_teardown,
11301 test_snow3g_auth_cipher_test_case_2_oop),
11302 TEST_CASE_ST(ut_setup, ut_teardown,
11303 test_snow3g_auth_cipher_part_digest_enc),
11304 TEST_CASE_ST(ut_setup, ut_teardown,
11305 test_snow3g_auth_cipher_part_digest_enc_oop),
11306 TEST_CASE_ST(ut_setup, ut_teardown,
11307 test_snow3g_auth_cipher_test_case_3_sgl),
11308 TEST_CASE_ST(ut_setup, ut_teardown,
11309 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11310 TEST_CASE_ST(ut_setup, ut_teardown,
11311 test_snow3g_auth_cipher_part_digest_enc_sgl),
11312 TEST_CASE_ST(ut_setup, ut_teardown,
11313 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11315 /** SNOW 3G decrypt (UEA2), then verify auth */
11316 TEST_CASE_ST(ut_setup, ut_teardown,
11317 test_snow3g_auth_cipher_verify_test_case_1),
11318 TEST_CASE_ST(ut_setup, ut_teardown,
11319 test_snow3g_auth_cipher_verify_test_case_2),
11320 TEST_CASE_ST(ut_setup, ut_teardown,
11321 test_snow3g_auth_cipher_verify_test_case_2_oop),
11322 TEST_CASE_ST(ut_setup, ut_teardown,
11323 test_snow3g_auth_cipher_verify_part_digest_enc),
11324 TEST_CASE_ST(ut_setup, ut_teardown,
11325 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11326 TEST_CASE_ST(ut_setup, ut_teardown,
11327 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11328 TEST_CASE_ST(ut_setup, ut_teardown,
11329 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11330 TEST_CASE_ST(ut_setup, ut_teardown,
11331 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11332 TEST_CASE_ST(ut_setup, ut_teardown,
11333 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11335 TEST_CASES_END() /**< NULL terminate unit test array */
11339 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
11340 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
11341 .setup = testsuite_setup,
11342 .teardown = testsuite_teardown,
11343 .unit_test_cases = {
11344 /** ZUC encrypt only (EEA3) */
11345 TEST_CASE_ST(ut_setup, ut_teardown,
11346 test_zuc_encryption_test_case_1),
11347 TEST_CASE_ST(ut_setup, ut_teardown,
11348 test_zuc_encryption_test_case_2),
11349 TEST_CASE_ST(ut_setup, ut_teardown,
11350 test_zuc_encryption_test_case_3),
11351 TEST_CASE_ST(ut_setup, ut_teardown,
11352 test_zuc_encryption_test_case_4),
11353 TEST_CASE_ST(ut_setup, ut_teardown,
11354 test_zuc_encryption_test_case_5),
11355 TEST_CASE_ST(ut_setup, ut_teardown,
11356 test_zuc_hash_generate_test_case_1),
11357 TEST_CASE_ST(ut_setup, ut_teardown,
11358 test_zuc_hash_generate_test_case_2),
11359 TEST_CASE_ST(ut_setup, ut_teardown,
11360 test_zuc_hash_generate_test_case_3),
11361 TEST_CASE_ST(ut_setup, ut_teardown,
11362 test_zuc_hash_generate_test_case_4),
11363 TEST_CASE_ST(ut_setup, ut_teardown,
11364 test_zuc_hash_generate_test_case_5),
11365 TEST_CASE_ST(ut_setup, ut_teardown,
11366 test_zuc_encryption_test_case_6_sgl),
11367 TEST_CASES_END() /**< NULL terminate unit test array */
11371 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
11372 .suite_name = "Crypto CAAM JR Unit Test Suite",
11373 .setup = testsuite_setup,
11374 .teardown = testsuite_teardown,
11375 .unit_test_cases = {
11376 TEST_CASE_ST(ut_setup, ut_teardown,
11377 test_device_configure_invalid_dev_id),
11378 TEST_CASE_ST(ut_setup, ut_teardown,
11379 test_multi_session),
11381 TEST_CASE_ST(ut_setup, ut_teardown,
11382 test_AES_chain_caam_jr_all),
11383 TEST_CASE_ST(ut_setup, ut_teardown,
11384 test_3DES_chain_caam_jr_all),
11385 TEST_CASE_ST(ut_setup, ut_teardown,
11386 test_AES_cipheronly_caam_jr_all),
11387 TEST_CASE_ST(ut_setup, ut_teardown,
11388 test_3DES_cipheronly_caam_jr_all),
11389 TEST_CASE_ST(ut_setup, ut_teardown,
11390 test_authonly_caam_jr_all),
11392 TEST_CASES_END() /**< NULL terminate unit test array */
11396 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
11397 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
11398 .setup = testsuite_setup,
11399 .teardown = testsuite_teardown,
11400 .unit_test_cases = {
11401 TEST_CASE_ST(ut_setup, ut_teardown,
11402 test_device_configure_invalid_dev_id),
11403 TEST_CASE_ST(ut_setup, ut_teardown,
11404 test_multi_session),
11406 TEST_CASE_ST(ut_setup, ut_teardown,
11407 test_AES_chain_dpaa_sec_all),
11408 TEST_CASE_ST(ut_setup, ut_teardown,
11409 test_3DES_chain_dpaa_sec_all),
11410 TEST_CASE_ST(ut_setup, ut_teardown,
11411 test_AES_cipheronly_dpaa_sec_all),
11412 TEST_CASE_ST(ut_setup, ut_teardown,
11413 test_3DES_cipheronly_dpaa_sec_all),
11414 TEST_CASE_ST(ut_setup, ut_teardown,
11415 test_authonly_dpaa_sec_all),
11417 /** AES GCM Authenticated Encryption */
11418 TEST_CASE_ST(ut_setup, ut_teardown,
11419 test_AES_GCM_authenticated_encryption_test_case_1),
11420 TEST_CASE_ST(ut_setup, ut_teardown,
11421 test_AES_GCM_authenticated_encryption_test_case_2),
11422 TEST_CASE_ST(ut_setup, ut_teardown,
11423 test_AES_GCM_authenticated_encryption_test_case_3),
11424 TEST_CASE_ST(ut_setup, ut_teardown,
11425 test_AES_GCM_authenticated_encryption_test_case_4),
11426 TEST_CASE_ST(ut_setup, ut_teardown,
11427 test_AES_GCM_authenticated_encryption_test_case_5),
11428 TEST_CASE_ST(ut_setup, ut_teardown,
11429 test_AES_GCM_authenticated_encryption_test_case_6),
11430 TEST_CASE_ST(ut_setup, ut_teardown,
11431 test_AES_GCM_authenticated_encryption_test_case_7),
11433 /** AES GCM Authenticated Decryption */
11434 TEST_CASE_ST(ut_setup, ut_teardown,
11435 test_AES_GCM_authenticated_decryption_test_case_1),
11436 TEST_CASE_ST(ut_setup, ut_teardown,
11437 test_AES_GCM_authenticated_decryption_test_case_2),
11438 TEST_CASE_ST(ut_setup, ut_teardown,
11439 test_AES_GCM_authenticated_decryption_test_case_3),
11440 TEST_CASE_ST(ut_setup, ut_teardown,
11441 test_AES_GCM_authenticated_decryption_test_case_4),
11442 TEST_CASE_ST(ut_setup, ut_teardown,
11443 test_AES_GCM_authenticated_decryption_test_case_5),
11444 TEST_CASE_ST(ut_setup, ut_teardown,
11445 test_AES_GCM_authenticated_decryption_test_case_6),
11446 TEST_CASE_ST(ut_setup, ut_teardown,
11447 test_AES_GCM_authenticated_decryption_test_case_7),
11449 /** AES GCM Authenticated Encryption 256 bits key */
11450 TEST_CASE_ST(ut_setup, ut_teardown,
11451 test_AES_GCM_auth_encryption_test_case_256_1),
11452 TEST_CASE_ST(ut_setup, ut_teardown,
11453 test_AES_GCM_auth_encryption_test_case_256_2),
11454 TEST_CASE_ST(ut_setup, ut_teardown,
11455 test_AES_GCM_auth_encryption_test_case_256_3),
11456 TEST_CASE_ST(ut_setup, ut_teardown,
11457 test_AES_GCM_auth_encryption_test_case_256_4),
11458 TEST_CASE_ST(ut_setup, ut_teardown,
11459 test_AES_GCM_auth_encryption_test_case_256_5),
11460 TEST_CASE_ST(ut_setup, ut_teardown,
11461 test_AES_GCM_auth_encryption_test_case_256_6),
11462 TEST_CASE_ST(ut_setup, ut_teardown,
11463 test_AES_GCM_auth_encryption_test_case_256_7),
11465 /** AES GCM Authenticated Decryption 256 bits key */
11466 TEST_CASE_ST(ut_setup, ut_teardown,
11467 test_AES_GCM_auth_decryption_test_case_256_1),
11468 TEST_CASE_ST(ut_setup, ut_teardown,
11469 test_AES_GCM_auth_decryption_test_case_256_2),
11470 TEST_CASE_ST(ut_setup, ut_teardown,
11471 test_AES_GCM_auth_decryption_test_case_256_3),
11472 TEST_CASE_ST(ut_setup, ut_teardown,
11473 test_AES_GCM_auth_decryption_test_case_256_4),
11474 TEST_CASE_ST(ut_setup, ut_teardown,
11475 test_AES_GCM_auth_decryption_test_case_256_5),
11476 TEST_CASE_ST(ut_setup, ut_teardown,
11477 test_AES_GCM_auth_decryption_test_case_256_6),
11478 TEST_CASE_ST(ut_setup, ut_teardown,
11479 test_AES_GCM_auth_decryption_test_case_256_7),
11481 /** Out of place tests */
11482 TEST_CASE_ST(ut_setup, ut_teardown,
11483 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11484 TEST_CASE_ST(ut_setup, ut_teardown,
11485 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11487 /** Scatter-Gather */
11488 TEST_CASE_ST(ut_setup, ut_teardown,
11489 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11490 TEST_CASE_ST(ut_setup, ut_teardown,
11491 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11492 TEST_CASE_ST(ut_setup, ut_teardown,
11493 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11494 TEST_CASE_ST(ut_setup, ut_teardown,
11495 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11497 TEST_CASES_END() /**< NULL terminate unit test array */
11501 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
11502 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
11503 .setup = testsuite_setup,
11504 .teardown = testsuite_teardown,
11505 .unit_test_cases = {
11506 TEST_CASE_ST(ut_setup, ut_teardown,
11507 test_device_configure_invalid_dev_id),
11508 TEST_CASE_ST(ut_setup, ut_teardown,
11509 test_multi_session),
11511 TEST_CASE_ST(ut_setup, ut_teardown,
11512 test_AES_chain_dpaa2_sec_all),
11513 TEST_CASE_ST(ut_setup, ut_teardown,
11514 test_3DES_chain_dpaa2_sec_all),
11515 TEST_CASE_ST(ut_setup, ut_teardown,
11516 test_AES_cipheronly_dpaa2_sec_all),
11517 TEST_CASE_ST(ut_setup, ut_teardown,
11518 test_3DES_cipheronly_dpaa2_sec_all),
11519 TEST_CASE_ST(ut_setup, ut_teardown,
11520 test_authonly_dpaa2_sec_all),
11522 /** AES GCM Authenticated Encryption */
11523 TEST_CASE_ST(ut_setup, ut_teardown,
11524 test_AES_GCM_authenticated_encryption_test_case_1),
11525 TEST_CASE_ST(ut_setup, ut_teardown,
11526 test_AES_GCM_authenticated_encryption_test_case_2),
11527 TEST_CASE_ST(ut_setup, ut_teardown,
11528 test_AES_GCM_authenticated_encryption_test_case_3),
11529 TEST_CASE_ST(ut_setup, ut_teardown,
11530 test_AES_GCM_authenticated_encryption_test_case_4),
11531 TEST_CASE_ST(ut_setup, ut_teardown,
11532 test_AES_GCM_authenticated_encryption_test_case_5),
11533 TEST_CASE_ST(ut_setup, ut_teardown,
11534 test_AES_GCM_authenticated_encryption_test_case_6),
11535 TEST_CASE_ST(ut_setup, ut_teardown,
11536 test_AES_GCM_authenticated_encryption_test_case_7),
11538 /** AES GCM Authenticated Decryption */
11539 TEST_CASE_ST(ut_setup, ut_teardown,
11540 test_AES_GCM_authenticated_decryption_test_case_1),
11541 TEST_CASE_ST(ut_setup, ut_teardown,
11542 test_AES_GCM_authenticated_decryption_test_case_2),
11543 TEST_CASE_ST(ut_setup, ut_teardown,
11544 test_AES_GCM_authenticated_decryption_test_case_3),
11545 TEST_CASE_ST(ut_setup, ut_teardown,
11546 test_AES_GCM_authenticated_decryption_test_case_4),
11547 TEST_CASE_ST(ut_setup, ut_teardown,
11548 test_AES_GCM_authenticated_decryption_test_case_5),
11549 TEST_CASE_ST(ut_setup, ut_teardown,
11550 test_AES_GCM_authenticated_decryption_test_case_6),
11551 TEST_CASE_ST(ut_setup, ut_teardown,
11552 test_AES_GCM_authenticated_decryption_test_case_7),
11554 /** AES GCM Authenticated Encryption 192 bits key */
11555 TEST_CASE_ST(ut_setup, ut_teardown,
11556 test_AES_GCM_auth_encryption_test_case_192_1),
11557 TEST_CASE_ST(ut_setup, ut_teardown,
11558 test_AES_GCM_auth_encryption_test_case_192_2),
11559 TEST_CASE_ST(ut_setup, ut_teardown,
11560 test_AES_GCM_auth_encryption_test_case_192_3),
11561 TEST_CASE_ST(ut_setup, ut_teardown,
11562 test_AES_GCM_auth_encryption_test_case_192_4),
11563 TEST_CASE_ST(ut_setup, ut_teardown,
11564 test_AES_GCM_auth_encryption_test_case_192_5),
11565 TEST_CASE_ST(ut_setup, ut_teardown,
11566 test_AES_GCM_auth_encryption_test_case_192_6),
11567 TEST_CASE_ST(ut_setup, ut_teardown,
11568 test_AES_GCM_auth_encryption_test_case_192_7),
11570 /** AES GCM Authenticated Decryption 192 bits key */
11571 TEST_CASE_ST(ut_setup, ut_teardown,
11572 test_AES_GCM_auth_decryption_test_case_192_1),
11573 TEST_CASE_ST(ut_setup, ut_teardown,
11574 test_AES_GCM_auth_decryption_test_case_192_2),
11575 TEST_CASE_ST(ut_setup, ut_teardown,
11576 test_AES_GCM_auth_decryption_test_case_192_3),
11577 TEST_CASE_ST(ut_setup, ut_teardown,
11578 test_AES_GCM_auth_decryption_test_case_192_4),
11579 TEST_CASE_ST(ut_setup, ut_teardown,
11580 test_AES_GCM_auth_decryption_test_case_192_5),
11581 TEST_CASE_ST(ut_setup, ut_teardown,
11582 test_AES_GCM_auth_decryption_test_case_192_6),
11583 TEST_CASE_ST(ut_setup, ut_teardown,
11584 test_AES_GCM_auth_decryption_test_case_192_7),
11586 /** AES GCM Authenticated Encryption 256 bits key */
11587 TEST_CASE_ST(ut_setup, ut_teardown,
11588 test_AES_GCM_auth_encryption_test_case_256_1),
11589 TEST_CASE_ST(ut_setup, ut_teardown,
11590 test_AES_GCM_auth_encryption_test_case_256_2),
11591 TEST_CASE_ST(ut_setup, ut_teardown,
11592 test_AES_GCM_auth_encryption_test_case_256_3),
11593 TEST_CASE_ST(ut_setup, ut_teardown,
11594 test_AES_GCM_auth_encryption_test_case_256_4),
11595 TEST_CASE_ST(ut_setup, ut_teardown,
11596 test_AES_GCM_auth_encryption_test_case_256_5),
11597 TEST_CASE_ST(ut_setup, ut_teardown,
11598 test_AES_GCM_auth_encryption_test_case_256_6),
11599 TEST_CASE_ST(ut_setup, ut_teardown,
11600 test_AES_GCM_auth_encryption_test_case_256_7),
11602 /** AES GCM Authenticated Decryption 256 bits key */
11603 TEST_CASE_ST(ut_setup, ut_teardown,
11604 test_AES_GCM_auth_decryption_test_case_256_1),
11605 TEST_CASE_ST(ut_setup, ut_teardown,
11606 test_AES_GCM_auth_decryption_test_case_256_2),
11607 TEST_CASE_ST(ut_setup, ut_teardown,
11608 test_AES_GCM_auth_decryption_test_case_256_3),
11609 TEST_CASE_ST(ut_setup, ut_teardown,
11610 test_AES_GCM_auth_decryption_test_case_256_4),
11611 TEST_CASE_ST(ut_setup, ut_teardown,
11612 test_AES_GCM_auth_decryption_test_case_256_5),
11613 TEST_CASE_ST(ut_setup, ut_teardown,
11614 test_AES_GCM_auth_decryption_test_case_256_6),
11615 TEST_CASE_ST(ut_setup, ut_teardown,
11616 test_AES_GCM_auth_decryption_test_case_256_7),
11618 /** Out of place tests */
11619 TEST_CASE_ST(ut_setup, ut_teardown,
11620 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11621 TEST_CASE_ST(ut_setup, ut_teardown,
11622 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11624 /** Scatter-Gather */
11625 TEST_CASE_ST(ut_setup, ut_teardown,
11626 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11627 TEST_CASE_ST(ut_setup, ut_teardown,
11628 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11629 TEST_CASE_ST(ut_setup, ut_teardown,
11630 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11631 TEST_CASE_ST(ut_setup, ut_teardown,
11632 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11634 TEST_CASES_END() /**< NULL terminate unit test array */
11638 static struct unit_test_suite cryptodev_null_testsuite = {
11639 .suite_name = "Crypto Device NULL Unit Test Suite",
11640 .setup = testsuite_setup,
11641 .teardown = testsuite_teardown,
11642 .unit_test_cases = {
11643 TEST_CASE_ST(ut_setup, ut_teardown,
11644 test_null_invalid_operation),
11645 TEST_CASE_ST(ut_setup, ut_teardown,
11646 test_null_burst_operation),
11647 TEST_CASE_ST(ut_setup, ut_teardown,
11648 test_AES_chain_null_all),
11649 TEST_CASE_ST(ut_setup, ut_teardown,
11650 test_AES_cipheronly_null_all),
11651 TEST_CASE_ST(ut_setup, ut_teardown,
11652 test_authonly_null_all),
11654 TEST_CASES_END() /**< NULL terminate unit test array */
11658 static struct unit_test_suite cryptodev_armv8_testsuite = {
11659 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
11660 .setup = testsuite_setup,
11661 .teardown = testsuite_teardown,
11662 .unit_test_cases = {
11663 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
11665 /** Negative tests */
11666 TEST_CASE_ST(ut_setup, ut_teardown,
11667 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11668 TEST_CASE_ST(ut_setup, ut_teardown,
11669 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11671 TEST_CASES_END() /**< NULL terminate unit test array */
11675 static struct unit_test_suite cryptodev_mrvl_testsuite = {
11676 .suite_name = "Crypto Device Marvell Component Test Suite",
11677 .setup = testsuite_setup,
11678 .teardown = testsuite_teardown,
11679 .unit_test_cases = {
11680 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11681 TEST_CASE_ST(ut_setup, ut_teardown,
11682 test_multi_session_random_usage),
11683 TEST_CASE_ST(ut_setup, ut_teardown,
11684 test_AES_chain_mrvl_all),
11685 TEST_CASE_ST(ut_setup, ut_teardown,
11686 test_AES_cipheronly_mrvl_all),
11687 TEST_CASE_ST(ut_setup, ut_teardown,
11688 test_authonly_mrvl_all),
11689 TEST_CASE_ST(ut_setup, ut_teardown,
11690 test_3DES_chain_mrvl_all),
11691 TEST_CASE_ST(ut_setup, ut_teardown,
11692 test_3DES_cipheronly_mrvl_all),
11694 /** Negative tests */
11695 TEST_CASE_ST(ut_setup, ut_teardown,
11696 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11697 TEST_CASE_ST(ut_setup, ut_teardown,
11698 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11699 TEST_CASE_ST(ut_setup, ut_teardown,
11700 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11701 TEST_CASE_ST(ut_setup, ut_teardown,
11702 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11704 TEST_CASES_END() /**< NULL terminate unit test array */
11708 static struct unit_test_suite cryptodev_ccp_testsuite = {
11709 .suite_name = "Crypto Device CCP Unit Test Suite",
11710 .setup = testsuite_setup,
11711 .teardown = testsuite_teardown,
11712 .unit_test_cases = {
11713 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11714 TEST_CASE_ST(ut_setup, ut_teardown,
11715 test_multi_session_random_usage),
11716 TEST_CASE_ST(ut_setup, ut_teardown,
11717 test_AES_chain_ccp_all),
11718 TEST_CASE_ST(ut_setup, ut_teardown,
11719 test_AES_cipheronly_ccp_all),
11720 TEST_CASE_ST(ut_setup, ut_teardown,
11721 test_3DES_chain_ccp_all),
11722 TEST_CASE_ST(ut_setup, ut_teardown,
11723 test_3DES_cipheronly_ccp_all),
11724 TEST_CASE_ST(ut_setup, ut_teardown,
11725 test_authonly_ccp_all),
11727 /** Negative tests */
11728 TEST_CASE_ST(ut_setup, ut_teardown,
11729 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11730 TEST_CASE_ST(ut_setup, ut_teardown,
11731 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11732 TEST_CASE_ST(ut_setup, ut_teardown,
11733 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11734 TEST_CASE_ST(ut_setup, ut_teardown,
11735 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11737 TEST_CASES_END() /**< NULL terminate unit test array */
11741 static struct unit_test_suite cryptodev_octeontx_testsuite = {
11742 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
11743 .setup = testsuite_setup,
11744 .teardown = testsuite_teardown,
11745 .unit_test_cases = {
11746 TEST_CASE_ST(ut_setup, ut_teardown,
11747 test_AES_chain_octeontx_all),
11748 TEST_CASE_ST(ut_setup, ut_teardown,
11749 test_AES_cipheronly_octeontx_all),
11750 TEST_CASE_ST(ut_setup, ut_teardown,
11751 test_3DES_chain_octeontx_all),
11752 TEST_CASE_ST(ut_setup, ut_teardown,
11753 test_3DES_cipheronly_octeontx_all),
11754 TEST_CASE_ST(ut_setup, ut_teardown,
11755 test_authonly_octeontx_all),
11757 /** AES GCM Authenticated Encryption */
11758 TEST_CASE_ST(ut_setup, ut_teardown,
11759 test_AES_GCM_authenticated_encryption_test_case_1),
11760 TEST_CASE_ST(ut_setup, ut_teardown,
11761 test_AES_GCM_authenticated_encryption_test_case_2),
11762 TEST_CASE_ST(ut_setup, ut_teardown,
11763 test_AES_GCM_authenticated_encryption_test_case_3),
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_AES_GCM_authenticated_encryption_test_case_4),
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_AES_GCM_authenticated_encryption_test_case_5),
11768 TEST_CASE_ST(ut_setup, ut_teardown,
11769 test_AES_GCM_authenticated_encryption_test_case_6),
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_AES_GCM_authenticated_encryption_test_case_7),
11773 /** AES GCM Authenticated Decryption */
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_AES_GCM_authenticated_decryption_test_case_1),
11776 TEST_CASE_ST(ut_setup, ut_teardown,
11777 test_AES_GCM_authenticated_decryption_test_case_2),
11778 TEST_CASE_ST(ut_setup, ut_teardown,
11779 test_AES_GCM_authenticated_decryption_test_case_3),
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_GCM_authenticated_decryption_test_case_4),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_GCM_authenticated_decryption_test_case_5),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_AES_GCM_authenticated_decryption_test_case_6),
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_AES_GCM_authenticated_decryption_test_case_7),
11788 /** AES GMAC Authentication */
11789 TEST_CASE_ST(ut_setup, ut_teardown,
11790 test_AES_GMAC_authentication_test_case_1),
11791 TEST_CASE_ST(ut_setup, ut_teardown,
11792 test_AES_GMAC_authentication_verify_test_case_1),
11793 TEST_CASE_ST(ut_setup, ut_teardown,
11794 test_AES_GMAC_authentication_test_case_2),
11795 TEST_CASE_ST(ut_setup, ut_teardown,
11796 test_AES_GMAC_authentication_verify_test_case_2),
11797 TEST_CASE_ST(ut_setup, ut_teardown,
11798 test_AES_GMAC_authentication_test_case_3),
11799 TEST_CASE_ST(ut_setup, ut_teardown,
11800 test_AES_GMAC_authentication_verify_test_case_3),
11802 /** SNOW 3G encrypt only (UEA2) */
11803 TEST_CASE_ST(ut_setup, ut_teardown,
11804 test_snow3g_encryption_test_case_1),
11805 TEST_CASE_ST(ut_setup, ut_teardown,
11806 test_snow3g_encryption_test_case_2),
11807 TEST_CASE_ST(ut_setup, ut_teardown,
11808 test_snow3g_encryption_test_case_3),
11809 TEST_CASE_ST(ut_setup, ut_teardown,
11810 test_snow3g_encryption_test_case_4),
11811 TEST_CASE_ST(ut_setup, ut_teardown,
11812 test_snow3g_encryption_test_case_5),
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_snow3g_encryption_test_case_1_oop),
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_snow3g_decryption_test_case_1_oop),
11818 TEST_CASE_ST(ut_setup, ut_teardown,
11819 test_snow3g_encryption_test_case_1_oop_sgl),
11821 /** SNOW 3G decrypt only (UEA2) */
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_snow3g_decryption_test_case_1),
11824 TEST_CASE_ST(ut_setup, ut_teardown,
11825 test_snow3g_decryption_test_case_2),
11826 TEST_CASE_ST(ut_setup, ut_teardown,
11827 test_snow3g_decryption_test_case_3),
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_snow3g_decryption_test_case_4),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_snow3g_decryption_test_case_5),
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_snow3g_hash_generate_test_case_1),
11835 TEST_CASE_ST(ut_setup, ut_teardown,
11836 test_snow3g_hash_generate_test_case_2),
11837 TEST_CASE_ST(ut_setup, ut_teardown,
11838 test_snow3g_hash_generate_test_case_3),
11839 TEST_CASE_ST(ut_setup, ut_teardown,
11840 test_snow3g_hash_verify_test_case_1),
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_snow3g_hash_verify_test_case_2),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_snow3g_hash_verify_test_case_3),
11846 /** ZUC encrypt only (EEA3) */
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_zuc_encryption_test_case_1),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_zuc_encryption_test_case_2),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_zuc_encryption_test_case_3),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_zuc_encryption_test_case_4),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_zuc_encryption_test_case_5),
11857 TEST_CASE_ST(ut_setup, ut_teardown,
11858 test_zuc_hash_generate_test_case_1),
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_zuc_hash_generate_test_case_2),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_zuc_hash_generate_test_case_3),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_zuc_hash_generate_test_case_4),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_zuc_hash_generate_test_case_5),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_zuc_encryption_test_case_6_sgl),
11870 /** KASUMI encrypt only (UEA1) */
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_kasumi_encryption_test_case_1),
11873 TEST_CASE_ST(ut_setup, ut_teardown,
11874 test_kasumi_encryption_test_case_2),
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_kasumi_encryption_test_case_3),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_kasumi_encryption_test_case_4),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_kasumi_encryption_test_case_5),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_kasumi_encryption_test_case_1_sgl),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_kasumi_encryption_test_case_1_oop_sgl),
11885 /** KASUMI decrypt only (UEA1) */
11886 TEST_CASE_ST(ut_setup, ut_teardown,
11887 test_kasumi_decryption_test_case_1),
11888 TEST_CASE_ST(ut_setup, ut_teardown,
11889 test_kasumi_decryption_test_case_2),
11890 TEST_CASE_ST(ut_setup, ut_teardown,
11891 test_kasumi_decryption_test_case_3),
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_kasumi_decryption_test_case_4),
11894 TEST_CASE_ST(ut_setup, ut_teardown,
11895 test_kasumi_decryption_test_case_5),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_kasumi_encryption_test_case_1_oop),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_kasumi_decryption_test_case_1_oop),
11902 /** KASUMI hash only (UIA1) */
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_kasumi_hash_generate_test_case_1),
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_kasumi_hash_generate_test_case_2),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_kasumi_hash_generate_test_case_3),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_kasumi_hash_generate_test_case_4),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_kasumi_hash_generate_test_case_5),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_kasumi_hash_generate_test_case_6),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_kasumi_hash_verify_test_case_1),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_kasumi_hash_verify_test_case_2),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_kasumi_hash_verify_test_case_3),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_kasumi_hash_verify_test_case_4),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_kasumi_hash_verify_test_case_5),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_null_cipher_only_operation),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_null_auth_only_operation),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_null_cipher_auth_operation),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_null_auth_cipher_operation),
11936 /** Negative tests */
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 authentication_verify_AES128_GMAC_fail_data_corrupt),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11949 TEST_CASES_END() /**< NULL terminate unit test array */
11954 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
11956 gbl_driver_id = rte_cryptodev_driver_id_get(
11957 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
11959 if (gbl_driver_id == -1) {
11960 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
11961 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
11962 "are enabled in config file to run this testsuite.\n");
11963 return TEST_SKIPPED;
11966 return unit_test_suite_runner(&cryptodev_qat_testsuite);
11970 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
11972 gbl_driver_id = rte_cryptodev_driver_id_get(
11973 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
11975 if (gbl_driver_id == -1) {
11976 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
11977 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
11978 "in config file to run this testsuite.\n");
11979 return TEST_FAILED;
11982 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
11986 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
11988 gbl_driver_id = rte_cryptodev_driver_id_get(
11989 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11991 if (gbl_driver_id == -1) {
11992 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
11993 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
11994 "in config file to run this testsuite.\n");
11995 return TEST_SKIPPED;
11998 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
12002 test_cryptodev_openssl(void)
12004 gbl_driver_id = rte_cryptodev_driver_id_get(
12005 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
12007 if (gbl_driver_id == -1) {
12008 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
12009 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
12010 "in config file to run this testsuite.\n");
12011 return TEST_SKIPPED;
12014 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
12018 test_cryptodev_aesni_gcm(void)
12020 gbl_driver_id = rte_cryptodev_driver_id_get(
12021 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12023 if (gbl_driver_id == -1) {
12024 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
12025 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
12026 "in config file to run this testsuite.\n");
12027 return TEST_SKIPPED;
12030 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
12034 test_cryptodev_null(void)
12036 gbl_driver_id = rte_cryptodev_driver_id_get(
12037 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
12039 if (gbl_driver_id == -1) {
12040 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
12041 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
12042 "in config file to run this testsuite.\n");
12043 return TEST_SKIPPED;
12046 return unit_test_suite_runner(&cryptodev_null_testsuite);
12050 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
12052 gbl_driver_id = rte_cryptodev_driver_id_get(
12053 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
12055 if (gbl_driver_id == -1) {
12056 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
12057 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
12058 "in config file to run this testsuite.\n");
12059 return TEST_SKIPPED;
12062 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
12066 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
12068 gbl_driver_id = rte_cryptodev_driver_id_get(
12069 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
12071 if (gbl_driver_id == -1) {
12072 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12073 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
12074 "in config file to run this testsuite.\n");
12075 return TEST_SKIPPED;
12078 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
12082 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
12084 gbl_driver_id = rte_cryptodev_driver_id_get(
12085 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
12087 if (gbl_driver_id == -1) {
12088 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12089 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
12090 "in config file to run this testsuite.\n");
12091 return TEST_SKIPPED;
12094 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
12098 test_cryptodev_armv8(void)
12100 gbl_driver_id = rte_cryptodev_driver_id_get(
12101 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
12103 if (gbl_driver_id == -1) {
12104 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
12105 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
12106 "in config file to run this testsuite.\n");
12107 return TEST_SKIPPED;
12110 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
12114 test_cryptodev_mrvl(void)
12116 gbl_driver_id = rte_cryptodev_driver_id_get(
12117 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
12119 if (gbl_driver_id == -1) {
12120 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
12121 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
12122 "in config file to run this testsuite.\n");
12123 return TEST_SKIPPED;
12126 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
12129 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12132 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
12134 gbl_driver_id = rte_cryptodev_driver_id_get(
12135 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
12137 if (gbl_driver_id == -1) {
12138 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
12139 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
12140 "in config file to run this testsuite.\n");
12141 return TEST_SKIPPED;
12144 if (rte_cryptodev_driver_id_get(
12145 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
12146 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
12147 " enabled in config file to run this testsuite.\n");
12148 return TEST_SKIPPED;
12150 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
12153 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
12158 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12160 gbl_driver_id = rte_cryptodev_driver_id_get(
12161 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
12163 if (gbl_driver_id == -1) {
12164 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
12165 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
12166 "in config file to run this testsuite.\n");
12167 return TEST_SKIPPED;
12170 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
12174 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12176 gbl_driver_id = rte_cryptodev_driver_id_get(
12177 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
12179 if (gbl_driver_id == -1) {
12180 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
12181 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
12182 "in config file to run this testsuite.\n");
12183 return TEST_SKIPPED;
12186 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
12190 test_cryptodev_ccp(void)
12192 gbl_driver_id = rte_cryptodev_driver_id_get(
12193 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
12195 if (gbl_driver_id == -1) {
12196 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
12197 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
12198 "in config file to run this testsuite.\n");
12199 return TEST_FAILED;
12202 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
12206 test_cryptodev_octeontx(void)
12208 gbl_driver_id = rte_cryptodev_driver_id_get(
12209 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
12210 if (gbl_driver_id == -1) {
12211 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
12212 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
12213 "enabled in config file to run this "
12215 return TEST_FAILED;
12217 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
12221 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
12223 gbl_driver_id = rte_cryptodev_driver_id_get(
12224 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
12226 if (gbl_driver_id == -1) {
12227 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
12228 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
12229 "in config file to run this testsuite.\n");
12230 return TEST_FAILED;
12233 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
12236 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
12237 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
12238 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
12239 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
12240 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
12241 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
12242 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
12243 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
12244 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
12245 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
12246 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
12247 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
12248 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
12249 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
12250 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
12251 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);