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];
2382 struct crypto_testsuite_params *ts_params = &testsuite_params;
2383 struct crypto_unittest_params *ut_params = &unittest_params;
2385 memcpy(hash_key, key, key_len);
2387 debug_hexdump(stdout, "key:", key, key_len);
2389 /* Setup Authentication Parameters */
2390 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2391 ut_params->auth_xform.next = NULL;
2393 ut_params->auth_xform.auth.op = op;
2394 ut_params->auth_xform.auth.algo = algo;
2395 ut_params->auth_xform.auth.key.length = key_len;
2396 ut_params->auth_xform.auth.key.data = hash_key;
2397 ut_params->auth_xform.auth.digest_length = auth_len;
2398 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2399 ut_params->auth_xform.auth.iv.length = iv_len;
2400 ut_params->sess = rte_cryptodev_sym_session_create(
2401 ts_params->session_mpool);
2403 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2404 &ut_params->auth_xform,
2405 ts_params->session_priv_mpool);
2406 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2407 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2412 create_wireless_algo_cipher_session(uint8_t dev_id,
2413 enum rte_crypto_cipher_operation op,
2414 enum rte_crypto_cipher_algorithm algo,
2415 const uint8_t *key, const uint8_t key_len,
2418 uint8_t cipher_key[key_len];
2420 struct crypto_testsuite_params *ts_params = &testsuite_params;
2421 struct crypto_unittest_params *ut_params = &unittest_params;
2423 memcpy(cipher_key, key, key_len);
2425 /* Setup Cipher Parameters */
2426 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2427 ut_params->cipher_xform.next = NULL;
2429 ut_params->cipher_xform.cipher.algo = algo;
2430 ut_params->cipher_xform.cipher.op = op;
2431 ut_params->cipher_xform.cipher.key.data = cipher_key;
2432 ut_params->cipher_xform.cipher.key.length = key_len;
2433 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2434 ut_params->cipher_xform.cipher.iv.length = iv_len;
2436 debug_hexdump(stdout, "key:", key, key_len);
2438 /* Create Crypto session */
2439 ut_params->sess = rte_cryptodev_sym_session_create(
2440 ts_params->session_mpool);
2442 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2443 &ut_params->cipher_xform,
2444 ts_params->session_priv_mpool);
2445 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2446 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2451 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2452 unsigned int cipher_len,
2453 unsigned int cipher_offset)
2455 struct crypto_testsuite_params *ts_params = &testsuite_params;
2456 struct crypto_unittest_params *ut_params = &unittest_params;
2458 /* Generate Crypto op data structure */
2459 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2460 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2461 TEST_ASSERT_NOT_NULL(ut_params->op,
2462 "Failed to allocate pktmbuf offload");
2464 /* Set crypto operation data parameters */
2465 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2467 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2469 /* set crypto operation source mbuf */
2470 sym_op->m_src = ut_params->ibuf;
2473 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2475 sym_op->cipher.data.length = cipher_len;
2476 sym_op->cipher.data.offset = cipher_offset;
2481 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2482 unsigned int cipher_len,
2483 unsigned int cipher_offset)
2485 struct crypto_testsuite_params *ts_params = &testsuite_params;
2486 struct crypto_unittest_params *ut_params = &unittest_params;
2488 /* Generate Crypto op data structure */
2489 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2490 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2491 TEST_ASSERT_NOT_NULL(ut_params->op,
2492 "Failed to allocate pktmbuf offload");
2494 /* Set crypto operation data parameters */
2495 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2497 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2499 /* set crypto operation source mbuf */
2500 sym_op->m_src = ut_params->ibuf;
2501 sym_op->m_dst = ut_params->obuf;
2504 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2506 sym_op->cipher.data.length = cipher_len;
2507 sym_op->cipher.data.offset = cipher_offset;
2512 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2513 enum rte_crypto_cipher_operation cipher_op,
2514 enum rte_crypto_auth_operation auth_op,
2515 enum rte_crypto_auth_algorithm auth_algo,
2516 enum rte_crypto_cipher_algorithm cipher_algo,
2517 const uint8_t *key, uint8_t key_len,
2518 uint8_t auth_iv_len, uint8_t auth_len,
2519 uint8_t cipher_iv_len)
2522 uint8_t cipher_auth_key[key_len];
2525 struct crypto_testsuite_params *ts_params = &testsuite_params;
2526 struct crypto_unittest_params *ut_params = &unittest_params;
2528 memcpy(cipher_auth_key, key, key_len);
2530 /* Setup Authentication Parameters */
2531 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2532 ut_params->auth_xform.next = NULL;
2534 ut_params->auth_xform.auth.op = auth_op;
2535 ut_params->auth_xform.auth.algo = auth_algo;
2536 ut_params->auth_xform.auth.key.length = key_len;
2537 /* Hash key = cipher key */
2538 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2539 ut_params->auth_xform.auth.digest_length = auth_len;
2540 /* Auth IV will be after cipher IV */
2541 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2542 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2544 /* Setup Cipher Parameters */
2545 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2546 ut_params->cipher_xform.next = &ut_params->auth_xform;
2548 ut_params->cipher_xform.cipher.algo = cipher_algo;
2549 ut_params->cipher_xform.cipher.op = cipher_op;
2550 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2551 ut_params->cipher_xform.cipher.key.length = key_len;
2552 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2553 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2555 debug_hexdump(stdout, "key:", key, key_len);
2557 /* Create Crypto session*/
2558 ut_params->sess = rte_cryptodev_sym_session_create(
2559 ts_params->session_mpool);
2561 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2562 &ut_params->cipher_xform,
2563 ts_params->session_priv_mpool);
2565 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2566 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2571 create_wireless_cipher_auth_session(uint8_t dev_id,
2572 enum rte_crypto_cipher_operation cipher_op,
2573 enum rte_crypto_auth_operation auth_op,
2574 enum rte_crypto_auth_algorithm auth_algo,
2575 enum rte_crypto_cipher_algorithm cipher_algo,
2576 const struct wireless_test_data *tdata)
2578 const uint8_t key_len = tdata->key.len;
2579 uint8_t cipher_auth_key[key_len];
2582 struct crypto_testsuite_params *ts_params = &testsuite_params;
2583 struct crypto_unittest_params *ut_params = &unittest_params;
2584 const uint8_t *key = tdata->key.data;
2585 const uint8_t auth_len = tdata->digest.len;
2586 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2587 uint8_t auth_iv_len = tdata->auth_iv.len;
2589 memcpy(cipher_auth_key, key, key_len);
2591 /* Setup Authentication Parameters */
2592 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2593 ut_params->auth_xform.next = NULL;
2595 ut_params->auth_xform.auth.op = auth_op;
2596 ut_params->auth_xform.auth.algo = auth_algo;
2597 ut_params->auth_xform.auth.key.length = key_len;
2598 /* Hash key = cipher key */
2599 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2600 ut_params->auth_xform.auth.digest_length = auth_len;
2601 /* Auth IV will be after cipher IV */
2602 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2603 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2605 /* Setup Cipher Parameters */
2606 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2607 ut_params->cipher_xform.next = &ut_params->auth_xform;
2609 ut_params->cipher_xform.cipher.algo = cipher_algo;
2610 ut_params->cipher_xform.cipher.op = cipher_op;
2611 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2612 ut_params->cipher_xform.cipher.key.length = key_len;
2613 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2614 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2617 debug_hexdump(stdout, "key:", key, key_len);
2619 /* Create Crypto session*/
2620 ut_params->sess = rte_cryptodev_sym_session_create(
2621 ts_params->session_mpool);
2623 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2624 &ut_params->cipher_xform,
2625 ts_params->session_priv_mpool);
2627 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2628 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2633 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2634 const struct wireless_test_data *tdata)
2636 return create_wireless_cipher_auth_session(dev_id,
2637 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2638 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2639 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2643 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2644 enum rte_crypto_cipher_operation cipher_op,
2645 enum rte_crypto_auth_operation auth_op,
2646 enum rte_crypto_auth_algorithm auth_algo,
2647 enum rte_crypto_cipher_algorithm cipher_algo,
2648 const uint8_t *key, const uint8_t key_len,
2649 uint8_t auth_iv_len, uint8_t auth_len,
2650 uint8_t cipher_iv_len)
2652 uint8_t auth_cipher_key[key_len];
2654 struct crypto_testsuite_params *ts_params = &testsuite_params;
2655 struct crypto_unittest_params *ut_params = &unittest_params;
2657 memcpy(auth_cipher_key, key, key_len);
2659 /* Setup Authentication Parameters */
2660 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2661 ut_params->auth_xform.auth.op = auth_op;
2662 ut_params->auth_xform.next = &ut_params->cipher_xform;
2663 ut_params->auth_xform.auth.algo = auth_algo;
2664 ut_params->auth_xform.auth.key.length = key_len;
2665 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2666 ut_params->auth_xform.auth.digest_length = auth_len;
2667 /* Auth IV will be after cipher IV */
2668 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2669 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2671 /* Setup Cipher Parameters */
2672 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2673 ut_params->cipher_xform.next = NULL;
2674 ut_params->cipher_xform.cipher.algo = cipher_algo;
2675 ut_params->cipher_xform.cipher.op = cipher_op;
2676 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2677 ut_params->cipher_xform.cipher.key.length = key_len;
2678 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2679 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2681 debug_hexdump(stdout, "key:", key, key_len);
2683 /* Create Crypto session*/
2684 ut_params->sess = rte_cryptodev_sym_session_create(
2685 ts_params->session_mpool);
2687 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2688 &ut_params->auth_xform,
2689 ts_params->session_priv_mpool);
2690 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2691 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2697 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2698 unsigned int auth_tag_len,
2699 const uint8_t *iv, unsigned int iv_len,
2700 unsigned int data_pad_len,
2701 enum rte_crypto_auth_operation op,
2702 unsigned int auth_len, unsigned int auth_offset)
2704 struct crypto_testsuite_params *ts_params = &testsuite_params;
2706 struct crypto_unittest_params *ut_params = &unittest_params;
2708 /* Generate Crypto op data structure */
2709 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2710 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2711 TEST_ASSERT_NOT_NULL(ut_params->op,
2712 "Failed to allocate pktmbuf offload");
2714 /* Set crypto operation data parameters */
2715 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2717 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2719 /* set crypto operation source mbuf */
2720 sym_op->m_src = ut_params->ibuf;
2723 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2726 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2727 ut_params->ibuf, auth_tag_len);
2729 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2730 "no room to append auth tag");
2731 ut_params->digest = sym_op->auth.digest.data;
2732 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2733 ut_params->ibuf, data_pad_len);
2734 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2735 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2737 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2739 debug_hexdump(stdout, "digest:",
2740 sym_op->auth.digest.data,
2743 sym_op->auth.data.length = auth_len;
2744 sym_op->auth.data.offset = auth_offset;
2750 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2751 enum rte_crypto_auth_operation op)
2753 struct crypto_testsuite_params *ts_params = &testsuite_params;
2754 struct crypto_unittest_params *ut_params = &unittest_params;
2756 const uint8_t *auth_tag = tdata->digest.data;
2757 const unsigned int auth_tag_len = tdata->digest.len;
2758 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2759 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2761 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2762 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2763 const uint8_t *auth_iv = tdata->auth_iv.data;
2764 const uint8_t auth_iv_len = tdata->auth_iv.len;
2765 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2766 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2768 /* Generate Crypto op data structure */
2769 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2770 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2771 TEST_ASSERT_NOT_NULL(ut_params->op,
2772 "Failed to allocate pktmbuf offload");
2773 /* Set crypto operation data parameters */
2774 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2776 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2778 /* set crypto operation source mbuf */
2779 sym_op->m_src = ut_params->ibuf;
2782 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2783 ut_params->ibuf, auth_tag_len);
2785 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2786 "no room to append auth tag");
2787 ut_params->digest = sym_op->auth.digest.data;
2788 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2789 ut_params->ibuf, data_pad_len);
2790 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2791 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2793 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2795 debug_hexdump(stdout, "digest:",
2796 sym_op->auth.digest.data,
2799 /* Copy cipher and auth IVs at the end of the crypto operation */
2800 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2802 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2803 iv_ptr += cipher_iv_len;
2804 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2806 sym_op->cipher.data.length = cipher_len;
2807 sym_op->cipher.data.offset = 0;
2808 sym_op->auth.data.length = auth_len;
2809 sym_op->auth.data.offset = 0;
2815 create_zuc_cipher_hash_generate_operation(
2816 const struct wireless_test_data *tdata)
2818 return create_wireless_cipher_hash_operation(tdata,
2819 RTE_CRYPTO_AUTH_OP_GENERATE);
2823 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2824 const unsigned auth_tag_len,
2825 const uint8_t *auth_iv, uint8_t auth_iv_len,
2826 unsigned data_pad_len,
2827 enum rte_crypto_auth_operation op,
2828 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2829 const unsigned cipher_len, const unsigned cipher_offset,
2830 const unsigned auth_len, const unsigned auth_offset)
2832 struct crypto_testsuite_params *ts_params = &testsuite_params;
2833 struct crypto_unittest_params *ut_params = &unittest_params;
2835 /* Generate Crypto op data structure */
2836 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2837 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2838 TEST_ASSERT_NOT_NULL(ut_params->op,
2839 "Failed to allocate pktmbuf offload");
2840 /* Set crypto operation data parameters */
2841 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2843 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2845 /* set crypto operation source mbuf */
2846 sym_op->m_src = ut_params->ibuf;
2849 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2850 ut_params->ibuf, auth_tag_len);
2852 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2853 "no room to append auth tag");
2854 ut_params->digest = sym_op->auth.digest.data;
2855 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2856 ut_params->ibuf, data_pad_len);
2857 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2858 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2860 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2862 debug_hexdump(stdout, "digest:",
2863 sym_op->auth.digest.data,
2866 /* Copy cipher and auth IVs at the end of the crypto operation */
2867 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2869 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2870 iv_ptr += cipher_iv_len;
2871 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2873 sym_op->cipher.data.length = cipher_len;
2874 sym_op->cipher.data.offset = cipher_offset;
2875 sym_op->auth.data.length = auth_len;
2876 sym_op->auth.data.offset = auth_offset;
2882 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2883 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2884 const uint8_t *auth_iv, uint8_t auth_iv_len,
2885 unsigned int data_pad_len,
2886 unsigned int cipher_len, unsigned int cipher_offset,
2887 unsigned int auth_len, unsigned int auth_offset,
2888 uint8_t op_mode, uint8_t do_sgl)
2890 struct crypto_testsuite_params *ts_params = &testsuite_params;
2891 struct crypto_unittest_params *ut_params = &unittest_params;
2893 /* Generate Crypto op data structure */
2894 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2895 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2896 TEST_ASSERT_NOT_NULL(ut_params->op,
2897 "Failed to allocate pktmbuf offload");
2899 /* Set crypto operation data parameters */
2900 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2902 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2904 /* set crypto operation mbufs */
2905 sym_op->m_src = ut_params->ibuf;
2906 if (op_mode == OUT_OF_PLACE)
2907 sym_op->m_dst = ut_params->obuf;
2911 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2912 (op_mode == IN_PLACE ?
2913 ut_params->ibuf : ut_params->obuf),
2914 uint8_t *, data_pad_len);
2915 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2916 (op_mode == IN_PLACE ?
2917 ut_params->ibuf : ut_params->obuf),
2919 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2921 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2922 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2923 sym_op->m_src : sym_op->m_dst);
2924 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2925 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2926 sgl_buf = sgl_buf->next;
2928 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2929 uint8_t *, remaining_off);
2930 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2932 memset(sym_op->auth.digest.data, 0, remaining_off);
2933 while (sgl_buf->next != NULL) {
2934 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2935 0, rte_pktmbuf_data_len(sgl_buf));
2936 sgl_buf = sgl_buf->next;
2940 /* Copy cipher and auth IVs at the end of the crypto operation */
2941 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2942 ut_params->op, uint8_t *, IV_OFFSET);
2944 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2945 iv_ptr += cipher_iv_len;
2946 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2948 sym_op->cipher.data.length = cipher_len;
2949 sym_op->cipher.data.offset = cipher_offset;
2951 sym_op->auth.data.length = auth_len;
2952 sym_op->auth.data.offset = auth_offset;
2958 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2960 struct crypto_testsuite_params *ts_params = &testsuite_params;
2961 struct crypto_unittest_params *ut_params = &unittest_params;
2964 unsigned plaintext_pad_len;
2965 unsigned plaintext_len;
2968 /* Create SNOW 3G session */
2969 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2970 tdata->key.data, tdata->key.len,
2971 tdata->auth_iv.len, tdata->digest.len,
2972 RTE_CRYPTO_AUTH_OP_GENERATE,
2973 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2977 /* alloc mbuf and set payload */
2978 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2980 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2981 rte_pktmbuf_tailroom(ut_params->ibuf));
2983 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2984 /* Append data which is padded to a multiple of */
2985 /* the algorithms block size */
2986 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2987 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2989 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2991 /* Create SNOW 3G operation */
2992 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2993 tdata->auth_iv.data, tdata->auth_iv.len,
2994 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2995 tdata->validAuthLenInBits.len,
3000 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3002 ut_params->obuf = ut_params->op->sym->m_src;
3003 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3004 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3005 + plaintext_pad_len;
3008 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3011 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3012 "SNOW 3G Generated auth tag not as expected");
3018 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3020 struct crypto_testsuite_params *ts_params = &testsuite_params;
3021 struct crypto_unittest_params *ut_params = &unittest_params;
3024 unsigned plaintext_pad_len;
3025 unsigned plaintext_len;
3028 /* Create SNOW 3G session */
3029 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3030 tdata->key.data, tdata->key.len,
3031 tdata->auth_iv.len, tdata->digest.len,
3032 RTE_CRYPTO_AUTH_OP_VERIFY,
3033 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3036 /* alloc mbuf and set payload */
3037 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3039 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3040 rte_pktmbuf_tailroom(ut_params->ibuf));
3042 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3043 /* Append data which is padded to a multiple of */
3044 /* the algorithms block size */
3045 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3046 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3048 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3050 /* Create SNOW 3G operation */
3051 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3053 tdata->auth_iv.data, tdata->auth_iv.len,
3055 RTE_CRYPTO_AUTH_OP_VERIFY,
3056 tdata->validAuthLenInBits.len,
3061 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3063 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3064 ut_params->obuf = ut_params->op->sym->m_src;
3065 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3066 + plaintext_pad_len;
3069 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3078 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3080 struct crypto_testsuite_params *ts_params = &testsuite_params;
3081 struct crypto_unittest_params *ut_params = &unittest_params;
3084 unsigned plaintext_pad_len;
3085 unsigned plaintext_len;
3088 /* Create KASUMI session */
3089 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3090 tdata->key.data, tdata->key.len,
3091 0, tdata->digest.len,
3092 RTE_CRYPTO_AUTH_OP_GENERATE,
3093 RTE_CRYPTO_AUTH_KASUMI_F9);
3097 /* alloc mbuf and set payload */
3098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3100 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3101 rte_pktmbuf_tailroom(ut_params->ibuf));
3103 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3104 /* Append data which is padded to a multiple of */
3105 /* the algorithms block size */
3106 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3107 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3109 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3111 /* Create KASUMI operation */
3112 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3114 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3115 tdata->plaintext.len,
3120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3122 ut_params->obuf = ut_params->op->sym->m_src;
3123 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3124 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3125 + plaintext_pad_len;
3128 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3131 DIGEST_BYTE_LENGTH_KASUMI_F9,
3132 "KASUMI Generated auth tag not as expected");
3138 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3140 struct crypto_testsuite_params *ts_params = &testsuite_params;
3141 struct crypto_unittest_params *ut_params = &unittest_params;
3144 unsigned plaintext_pad_len;
3145 unsigned plaintext_len;
3148 /* Create KASUMI session */
3149 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3150 tdata->key.data, tdata->key.len,
3151 0, tdata->digest.len,
3152 RTE_CRYPTO_AUTH_OP_VERIFY,
3153 RTE_CRYPTO_AUTH_KASUMI_F9);
3156 /* alloc mbuf and set payload */
3157 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3159 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3160 rte_pktmbuf_tailroom(ut_params->ibuf));
3162 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3163 /* Append data which is padded to a multiple */
3164 /* of the algorithms block size */
3165 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3166 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3168 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3170 /* Create KASUMI operation */
3171 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3175 RTE_CRYPTO_AUTH_OP_VERIFY,
3176 tdata->plaintext.len,
3181 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3183 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3184 ut_params->obuf = ut_params->op->sym->m_src;
3185 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3186 + plaintext_pad_len;
3189 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3198 test_snow3g_hash_generate_test_case_1(void)
3200 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3204 test_snow3g_hash_generate_test_case_2(void)
3206 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3210 test_snow3g_hash_generate_test_case_3(void)
3212 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3216 test_snow3g_hash_generate_test_case_4(void)
3218 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3222 test_snow3g_hash_generate_test_case_5(void)
3224 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3228 test_snow3g_hash_generate_test_case_6(void)
3230 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3234 test_snow3g_hash_verify_test_case_1(void)
3236 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3241 test_snow3g_hash_verify_test_case_2(void)
3243 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3247 test_snow3g_hash_verify_test_case_3(void)
3249 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3253 test_snow3g_hash_verify_test_case_4(void)
3255 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3259 test_snow3g_hash_verify_test_case_5(void)
3261 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3265 test_snow3g_hash_verify_test_case_6(void)
3267 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3271 test_kasumi_hash_generate_test_case_1(void)
3273 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3277 test_kasumi_hash_generate_test_case_2(void)
3279 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3283 test_kasumi_hash_generate_test_case_3(void)
3285 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3289 test_kasumi_hash_generate_test_case_4(void)
3291 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3295 test_kasumi_hash_generate_test_case_5(void)
3297 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3301 test_kasumi_hash_generate_test_case_6(void)
3303 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3307 test_kasumi_hash_verify_test_case_1(void)
3309 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3313 test_kasumi_hash_verify_test_case_2(void)
3315 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3319 test_kasumi_hash_verify_test_case_3(void)
3321 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3325 test_kasumi_hash_verify_test_case_4(void)
3327 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3331 test_kasumi_hash_verify_test_case_5(void)
3333 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3337 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3339 struct crypto_testsuite_params *ts_params = &testsuite_params;
3340 struct crypto_unittest_params *ut_params = &unittest_params;
3343 uint8_t *plaintext, *ciphertext;
3344 unsigned plaintext_pad_len;
3345 unsigned plaintext_len;
3347 /* Create KASUMI session */
3348 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3349 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3350 RTE_CRYPTO_CIPHER_KASUMI_F8,
3351 tdata->key.data, tdata->key.len,
3352 tdata->cipher_iv.len);
3356 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3358 /* Clear mbuf payload */
3359 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3360 rte_pktmbuf_tailroom(ut_params->ibuf));
3362 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3363 /* Append data which is padded to a multiple */
3364 /* of the algorithms block size */
3365 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3366 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3368 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3370 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3372 /* Create KASUMI operation */
3373 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3374 tdata->cipher_iv.len,
3375 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3376 tdata->validCipherOffsetInBits.len);
3380 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3382 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3384 ut_params->obuf = ut_params->op->sym->m_dst;
3385 if (ut_params->obuf)
3386 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3388 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3390 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3392 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3393 (tdata->validCipherOffsetInBits.len >> 3);
3395 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3397 reference_ciphertext,
3398 tdata->validCipherLenInBits.len,
3399 "KASUMI Ciphertext data not as expected");
3404 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3406 struct crypto_testsuite_params *ts_params = &testsuite_params;
3407 struct crypto_unittest_params *ut_params = &unittest_params;
3411 unsigned int plaintext_pad_len;
3412 unsigned int plaintext_len;
3414 uint8_t buffer[10000];
3415 const uint8_t *ciphertext;
3417 struct rte_cryptodev_info dev_info;
3419 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3421 uint64_t feat_flags = dev_info.feature_flags;
3423 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3424 printf("Device doesn't support in-place scatter-gather. "
3429 /* Create KASUMI session */
3430 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3431 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3432 RTE_CRYPTO_CIPHER_KASUMI_F8,
3433 tdata->key.data, tdata->key.len,
3434 tdata->cipher_iv.len);
3438 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3441 /* Append data which is padded to a multiple */
3442 /* of the algorithms block size */
3443 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3445 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3446 plaintext_pad_len, 10, 0);
3448 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3450 /* Create KASUMI operation */
3451 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3452 tdata->cipher_iv.len,
3453 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3454 tdata->validCipherOffsetInBits.len);
3458 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3460 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3462 ut_params->obuf = ut_params->op->sym->m_dst;
3464 if (ut_params->obuf)
3465 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3466 plaintext_len, buffer);
3468 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3469 tdata->validCipherOffsetInBits.len >> 3,
3470 plaintext_len, buffer);
3473 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3475 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3476 (tdata->validCipherOffsetInBits.len >> 3);
3478 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3480 reference_ciphertext,
3481 tdata->validCipherLenInBits.len,
3482 "KASUMI Ciphertext data not as expected");
3487 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3489 struct crypto_testsuite_params *ts_params = &testsuite_params;
3490 struct crypto_unittest_params *ut_params = &unittest_params;
3493 uint8_t *plaintext, *ciphertext;
3494 unsigned plaintext_pad_len;
3495 unsigned plaintext_len;
3497 /* Create KASUMI session */
3498 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3499 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3500 RTE_CRYPTO_CIPHER_KASUMI_F8,
3501 tdata->key.data, tdata->key.len,
3502 tdata->cipher_iv.len);
3506 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3507 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3509 /* Clear mbuf payload */
3510 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3511 rte_pktmbuf_tailroom(ut_params->ibuf));
3513 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3514 /* Append data which is padded to a multiple */
3515 /* of the algorithms block size */
3516 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3517 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3519 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3520 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3522 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3524 /* Create KASUMI operation */
3525 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3526 tdata->cipher_iv.len,
3527 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3528 tdata->validCipherOffsetInBits.len);
3532 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3534 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3536 ut_params->obuf = ut_params->op->sym->m_dst;
3537 if (ut_params->obuf)
3538 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3540 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3542 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3544 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3545 (tdata->validCipherOffsetInBits.len >> 3);
3547 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3549 reference_ciphertext,
3550 tdata->validCipherLenInBits.len,
3551 "KASUMI Ciphertext data not as expected");
3556 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3558 struct crypto_testsuite_params *ts_params = &testsuite_params;
3559 struct crypto_unittest_params *ut_params = &unittest_params;
3562 unsigned int plaintext_pad_len;
3563 unsigned int plaintext_len;
3565 const uint8_t *ciphertext;
3566 uint8_t buffer[2048];
3568 struct rte_cryptodev_info dev_info;
3570 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3572 uint64_t feat_flags = dev_info.feature_flags;
3573 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3574 printf("Device doesn't support out-of-place scatter-gather "
3575 "in both input and output mbufs. "
3580 /* Create KASUMI session */
3581 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3582 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3583 RTE_CRYPTO_CIPHER_KASUMI_F8,
3584 tdata->key.data, tdata->key.len,
3585 tdata->cipher_iv.len);
3589 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3590 /* Append data which is padded to a multiple */
3591 /* of the algorithms block size */
3592 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3594 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3595 plaintext_pad_len, 10, 0);
3596 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3597 plaintext_pad_len, 3, 0);
3599 /* Append data which is padded to a multiple */
3600 /* of the algorithms block size */
3601 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3603 /* Create KASUMI operation */
3604 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3605 tdata->cipher_iv.len,
3606 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3607 tdata->validCipherOffsetInBits.len);
3611 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3613 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3615 ut_params->obuf = ut_params->op->sym->m_dst;
3616 if (ut_params->obuf)
3617 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3618 plaintext_pad_len, buffer);
3620 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3621 tdata->validCipherOffsetInBits.len >> 3,
3622 plaintext_pad_len, buffer);
3624 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3625 (tdata->validCipherOffsetInBits.len >> 3);
3627 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3629 reference_ciphertext,
3630 tdata->validCipherLenInBits.len,
3631 "KASUMI Ciphertext data not as expected");
3637 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3639 struct crypto_testsuite_params *ts_params = &testsuite_params;
3640 struct crypto_unittest_params *ut_params = &unittest_params;
3643 uint8_t *ciphertext, *plaintext;
3644 unsigned ciphertext_pad_len;
3645 unsigned ciphertext_len;
3647 /* Create KASUMI session */
3648 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3649 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3650 RTE_CRYPTO_CIPHER_KASUMI_F8,
3651 tdata->key.data, tdata->key.len,
3652 tdata->cipher_iv.len);
3656 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3657 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3659 /* Clear mbuf payload */
3660 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3661 rte_pktmbuf_tailroom(ut_params->ibuf));
3663 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3664 /* Append data which is padded to a multiple */
3665 /* of the algorithms block size */
3666 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3667 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3668 ciphertext_pad_len);
3669 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3670 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3672 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3674 /* Create KASUMI operation */
3675 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3676 tdata->cipher_iv.len,
3677 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3678 tdata->validCipherOffsetInBits.len);
3682 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3684 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3686 ut_params->obuf = ut_params->op->sym->m_dst;
3687 if (ut_params->obuf)
3688 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3690 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3692 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3694 const uint8_t *reference_plaintext = tdata->plaintext.data +
3695 (tdata->validCipherOffsetInBits.len >> 3);
3697 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3699 reference_plaintext,
3700 tdata->validCipherLenInBits.len,
3701 "KASUMI Plaintext data not as expected");
3706 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3708 struct crypto_testsuite_params *ts_params = &testsuite_params;
3709 struct crypto_unittest_params *ut_params = &unittest_params;
3712 uint8_t *ciphertext, *plaintext;
3713 unsigned ciphertext_pad_len;
3714 unsigned ciphertext_len;
3716 /* Create KASUMI session */
3717 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3718 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3719 RTE_CRYPTO_CIPHER_KASUMI_F8,
3720 tdata->key.data, tdata->key.len,
3721 tdata->cipher_iv.len);
3725 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3727 /* Clear mbuf payload */
3728 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3729 rte_pktmbuf_tailroom(ut_params->ibuf));
3731 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3732 /* Append data which is padded to a multiple */
3733 /* of the algorithms block size */
3734 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3735 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3736 ciphertext_pad_len);
3737 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3739 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3741 /* Create KASUMI operation */
3742 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3743 tdata->cipher_iv.len,
3744 tdata->ciphertext.len,
3745 tdata->validCipherOffsetInBits.len);
3749 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3751 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3753 ut_params->obuf = ut_params->op->sym->m_dst;
3754 if (ut_params->obuf)
3755 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3757 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3759 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3761 const uint8_t *reference_plaintext = tdata->plaintext.data +
3762 (tdata->validCipherOffsetInBits.len >> 3);
3764 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3766 reference_plaintext,
3767 tdata->validCipherLenInBits.len,
3768 "KASUMI Plaintext data not as expected");
3773 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3775 struct crypto_testsuite_params *ts_params = &testsuite_params;
3776 struct crypto_unittest_params *ut_params = &unittest_params;
3779 uint8_t *plaintext, *ciphertext;
3780 unsigned plaintext_pad_len;
3781 unsigned plaintext_len;
3783 /* Create SNOW 3G session */
3784 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3785 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3786 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3787 tdata->key.data, tdata->key.len,
3788 tdata->cipher_iv.len);
3792 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3794 /* Clear mbuf payload */
3795 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3796 rte_pktmbuf_tailroom(ut_params->ibuf));
3798 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3799 /* Append data which is padded to a multiple of */
3800 /* the algorithms block size */
3801 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3802 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3804 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3806 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3808 /* Create SNOW 3G operation */
3809 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3810 tdata->cipher_iv.len,
3811 tdata->validCipherLenInBits.len,
3816 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3818 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3820 ut_params->obuf = ut_params->op->sym->m_dst;
3821 if (ut_params->obuf)
3822 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3824 ciphertext = plaintext;
3826 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3829 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3831 tdata->ciphertext.data,
3832 tdata->validDataLenInBits.len,
3833 "SNOW 3G Ciphertext data not as expected");
3839 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3841 struct crypto_testsuite_params *ts_params = &testsuite_params;
3842 struct crypto_unittest_params *ut_params = &unittest_params;
3843 uint8_t *plaintext, *ciphertext;
3846 unsigned plaintext_pad_len;
3847 unsigned plaintext_len;
3849 /* Create SNOW 3G session */
3850 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3851 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3852 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3853 tdata->key.data, tdata->key.len,
3854 tdata->cipher_iv.len);
3858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3859 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3861 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3862 "Failed to allocate input buffer in mempool");
3863 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3864 "Failed to allocate output buffer in mempool");
3866 /* Clear mbuf payload */
3867 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3868 rte_pktmbuf_tailroom(ut_params->ibuf));
3870 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3871 /* Append data which is padded to a multiple of */
3872 /* the algorithms block size */
3873 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3874 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3876 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3877 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3879 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3881 /* Create SNOW 3G operation */
3882 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3883 tdata->cipher_iv.len,
3884 tdata->validCipherLenInBits.len,
3889 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3891 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3893 ut_params->obuf = ut_params->op->sym->m_dst;
3894 if (ut_params->obuf)
3895 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3897 ciphertext = plaintext;
3899 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3902 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3904 tdata->ciphertext.data,
3905 tdata->validDataLenInBits.len,
3906 "SNOW 3G Ciphertext data not as expected");
3911 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3913 struct crypto_testsuite_params *ts_params = &testsuite_params;
3914 struct crypto_unittest_params *ut_params = &unittest_params;
3917 unsigned int plaintext_pad_len;
3918 unsigned int plaintext_len;
3919 uint8_t buffer[10000];
3920 const uint8_t *ciphertext;
3922 struct rte_cryptodev_info dev_info;
3924 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3926 uint64_t feat_flags = dev_info.feature_flags;
3928 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3929 printf("Device doesn't support out-of-place scatter-gather "
3930 "in both input and output mbufs. "
3935 /* Create SNOW 3G session */
3936 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3937 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3938 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3939 tdata->key.data, tdata->key.len,
3940 tdata->cipher_iv.len);
3944 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3945 /* Append data which is padded to a multiple of */
3946 /* the algorithms block size */
3947 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3949 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3950 plaintext_pad_len, 10, 0);
3951 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3952 plaintext_pad_len, 3, 0);
3954 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3955 "Failed to allocate input buffer in mempool");
3956 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3957 "Failed to allocate output buffer in mempool");
3959 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3961 /* Create SNOW 3G operation */
3962 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3963 tdata->cipher_iv.len,
3964 tdata->validCipherLenInBits.len,
3969 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3971 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3973 ut_params->obuf = ut_params->op->sym->m_dst;
3974 if (ut_params->obuf)
3975 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3976 plaintext_len, buffer);
3978 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3979 plaintext_len, buffer);
3981 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3984 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3986 tdata->ciphertext.data,
3987 tdata->validDataLenInBits.len,
3988 "SNOW 3G Ciphertext data not as expected");
3993 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3995 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3997 uint8_t curr_byte, prev_byte;
3998 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3999 uint8_t lower_byte_mask = (1 << offset) - 1;
4002 prev_byte = buffer[0];
4003 buffer[0] >>= offset;
4005 for (i = 1; i < length_in_bytes; i++) {
4006 curr_byte = buffer[i];
4007 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4008 (curr_byte >> offset);
4009 prev_byte = curr_byte;
4014 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4016 struct crypto_testsuite_params *ts_params = &testsuite_params;
4017 struct crypto_unittest_params *ut_params = &unittest_params;
4018 uint8_t *plaintext, *ciphertext;
4020 uint32_t plaintext_len;
4021 uint32_t plaintext_pad_len;
4022 uint8_t extra_offset = 4;
4023 uint8_t *expected_ciphertext_shifted;
4025 /* Create SNOW 3G session */
4026 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4027 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4028 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4029 tdata->key.data, tdata->key.len,
4030 tdata->cipher_iv.len);
4034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4035 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4037 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4038 "Failed to allocate input buffer in mempool");
4039 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4040 "Failed to allocate output buffer in mempool");
4042 /* Clear mbuf payload */
4043 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4044 rte_pktmbuf_tailroom(ut_params->ibuf));
4046 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4048 * Append data which is padded to a
4049 * multiple of the algorithms block size
4051 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4053 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4056 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4058 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4059 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4061 #ifdef RTE_APP_TEST_DEBUG
4062 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4064 /* Create SNOW 3G operation */
4065 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4066 tdata->cipher_iv.len,
4067 tdata->validCipherLenInBits.len,
4072 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4074 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4076 ut_params->obuf = ut_params->op->sym->m_dst;
4077 if (ut_params->obuf)
4078 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4080 ciphertext = plaintext;
4082 #ifdef RTE_APP_TEST_DEBUG
4083 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4086 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4088 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4089 "failed to reserve memory for ciphertext shifted\n");
4091 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4092 ceil_byte_length(tdata->ciphertext.len));
4093 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4096 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4098 expected_ciphertext_shifted,
4099 tdata->validDataLenInBits.len,
4101 "SNOW 3G Ciphertext data not as expected");
4105 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4107 struct crypto_testsuite_params *ts_params = &testsuite_params;
4108 struct crypto_unittest_params *ut_params = &unittest_params;
4112 uint8_t *plaintext, *ciphertext;
4113 unsigned ciphertext_pad_len;
4114 unsigned ciphertext_len;
4116 /* Create SNOW 3G session */
4117 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4118 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4119 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4120 tdata->key.data, tdata->key.len,
4121 tdata->cipher_iv.len);
4125 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4127 /* Clear mbuf payload */
4128 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4129 rte_pktmbuf_tailroom(ut_params->ibuf));
4131 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4132 /* Append data which is padded to a multiple of */
4133 /* the algorithms block size */
4134 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4135 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4136 ciphertext_pad_len);
4137 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4139 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4141 /* Create SNOW 3G operation */
4142 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4143 tdata->cipher_iv.len,
4144 tdata->validCipherLenInBits.len,
4145 tdata->cipher.offset_bits);
4149 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4151 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4152 ut_params->obuf = ut_params->op->sym->m_dst;
4153 if (ut_params->obuf)
4154 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4156 plaintext = ciphertext;
4158 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4161 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4162 tdata->plaintext.data,
4163 tdata->validDataLenInBits.len,
4164 "SNOW 3G Plaintext data not as expected");
4168 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4170 struct crypto_testsuite_params *ts_params = &testsuite_params;
4171 struct crypto_unittest_params *ut_params = &unittest_params;
4175 uint8_t *plaintext, *ciphertext;
4176 unsigned ciphertext_pad_len;
4177 unsigned ciphertext_len;
4179 /* Create SNOW 3G session */
4180 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4181 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4182 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4183 tdata->key.data, tdata->key.len,
4184 tdata->cipher_iv.len);
4188 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4189 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4191 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4192 "Failed to allocate input buffer");
4193 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4194 "Failed to allocate output buffer");
4196 /* Clear mbuf payload */
4197 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4198 rte_pktmbuf_tailroom(ut_params->ibuf));
4200 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4201 rte_pktmbuf_tailroom(ut_params->obuf));
4203 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4204 /* Append data which is padded to a multiple of */
4205 /* the algorithms block size */
4206 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4207 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4208 ciphertext_pad_len);
4209 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4210 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4212 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4214 /* Create SNOW 3G operation */
4215 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4216 tdata->cipher_iv.len,
4217 tdata->validCipherLenInBits.len,
4222 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4224 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4225 ut_params->obuf = ut_params->op->sym->m_dst;
4226 if (ut_params->obuf)
4227 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4229 plaintext = ciphertext;
4231 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4234 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4235 tdata->plaintext.data,
4236 tdata->validDataLenInBits.len,
4237 "SNOW 3G Plaintext data not as expected");
4242 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4244 struct crypto_testsuite_params *ts_params = &testsuite_params;
4245 struct crypto_unittest_params *ut_params = &unittest_params;
4249 uint8_t *plaintext, *ciphertext;
4250 unsigned int plaintext_pad_len;
4251 unsigned int plaintext_len;
4253 struct rte_cryptodev_sym_capability_idx cap_idx;
4255 /* Check if device supports ZUC EEA3 */
4256 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4257 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4259 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4263 /* Check if device supports ZUC EIA3 */
4264 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4265 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4267 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4271 /* Create ZUC session */
4272 retval = create_zuc_cipher_auth_encrypt_generate_session(
4273 ts_params->valid_devs[0],
4277 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4279 /* clear mbuf payload */
4280 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4281 rte_pktmbuf_tailroom(ut_params->ibuf));
4283 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4284 /* Append data which is padded to a multiple of */
4285 /* the algorithms block size */
4286 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4287 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4289 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4291 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4293 /* Create ZUC operation */
4294 retval = create_zuc_cipher_hash_generate_operation(tdata);
4298 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4300 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4301 ut_params->obuf = ut_params->op->sym->m_src;
4302 if (ut_params->obuf)
4303 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4305 ciphertext = plaintext;
4307 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4309 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4311 tdata->ciphertext.data,
4312 tdata->validDataLenInBits.len,
4313 "ZUC Ciphertext data not as expected");
4315 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4316 + plaintext_pad_len;
4319 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4323 "ZUC Generated auth tag not as expected");
4328 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4330 struct crypto_testsuite_params *ts_params = &testsuite_params;
4331 struct crypto_unittest_params *ut_params = &unittest_params;
4335 uint8_t *plaintext, *ciphertext;
4336 unsigned plaintext_pad_len;
4337 unsigned plaintext_len;
4339 /* Create SNOW 3G session */
4340 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4341 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4342 RTE_CRYPTO_AUTH_OP_GENERATE,
4343 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4344 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4345 tdata->key.data, tdata->key.len,
4346 tdata->auth_iv.len, tdata->digest.len,
4347 tdata->cipher_iv.len);
4350 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4352 /* clear mbuf payload */
4353 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4354 rte_pktmbuf_tailroom(ut_params->ibuf));
4356 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4357 /* Append data which is padded to a multiple of */
4358 /* the algorithms block size */
4359 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4360 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4362 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4364 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4366 /* Create SNOW 3G operation */
4367 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4368 tdata->digest.len, tdata->auth_iv.data,
4370 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4371 tdata->cipher_iv.data, tdata->cipher_iv.len,
4372 tdata->validCipherLenInBits.len,
4374 tdata->validAuthLenInBits.len,
4380 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4382 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4383 ut_params->obuf = ut_params->op->sym->m_src;
4384 if (ut_params->obuf)
4385 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4387 ciphertext = plaintext;
4389 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4391 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4393 tdata->ciphertext.data,
4394 tdata->validDataLenInBits.len,
4395 "SNOW 3G Ciphertext data not as expected");
4397 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4398 + plaintext_pad_len;
4401 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4404 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4405 "SNOW 3G Generated auth tag not as expected");
4410 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4411 uint8_t op_mode, uint8_t verify)
4413 struct crypto_testsuite_params *ts_params = &testsuite_params;
4414 struct crypto_unittest_params *ut_params = &unittest_params;
4418 uint8_t *plaintext = NULL, *ciphertext = NULL;
4419 unsigned int plaintext_pad_len;
4420 unsigned int plaintext_len;
4421 unsigned int ciphertext_pad_len;
4422 unsigned int ciphertext_len;
4424 struct rte_cryptodev_info dev_info;
4426 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4428 uint64_t feat_flags = dev_info.feature_flags;
4430 if (op_mode == OUT_OF_PLACE) {
4431 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4432 printf("Device doesn't support digest encrypted.\n");
4437 /* Create SNOW 3G session */
4438 retval = create_wireless_algo_auth_cipher_session(
4439 ts_params->valid_devs[0],
4440 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4441 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4442 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4443 : RTE_CRYPTO_AUTH_OP_GENERATE),
4444 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4445 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4446 tdata->key.data, tdata->key.len,
4447 tdata->auth_iv.len, tdata->digest.len,
4448 tdata->cipher_iv.len);
4453 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4454 if (op_mode == OUT_OF_PLACE)
4455 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4457 /* clear mbuf payload */
4458 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4459 rte_pktmbuf_tailroom(ut_params->ibuf));
4460 if (op_mode == OUT_OF_PLACE)
4461 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4462 rte_pktmbuf_tailroom(ut_params->obuf));
4464 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4465 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4466 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4467 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4470 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4471 ciphertext_pad_len);
4472 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4473 if (op_mode == OUT_OF_PLACE)
4474 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4475 debug_hexdump(stdout, "ciphertext:", ciphertext,
4478 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4480 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4481 if (op_mode == OUT_OF_PLACE)
4482 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4483 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4486 /* Create SNOW 3G operation */
4487 retval = create_wireless_algo_auth_cipher_operation(
4489 tdata->cipher_iv.data, tdata->cipher_iv.len,
4490 tdata->auth_iv.data, tdata->auth_iv.len,
4491 (tdata->digest.offset_bytes == 0 ?
4492 (verify ? ciphertext_pad_len : plaintext_pad_len)
4493 : tdata->digest.offset_bytes),
4494 tdata->validCipherLenInBits.len,
4495 tdata->cipher.offset_bits,
4496 tdata->validAuthLenInBits.len,
4497 tdata->auth.offset_bits,
4503 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4506 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4508 ut_params->obuf = (op_mode == IN_PLACE ?
4509 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4512 if (ut_params->obuf)
4513 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4516 plaintext = ciphertext +
4517 (tdata->cipher.offset_bits >> 3);
4519 debug_hexdump(stdout, "plaintext:", plaintext,
4520 (tdata->plaintext.len >> 3) - tdata->digest.len);
4521 debug_hexdump(stdout, "plaintext expected:",
4522 tdata->plaintext.data,
4523 (tdata->plaintext.len >> 3) - tdata->digest.len);
4525 if (ut_params->obuf)
4526 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4529 ciphertext = plaintext;
4531 debug_hexdump(stdout, "ciphertext:", ciphertext,
4533 debug_hexdump(stdout, "ciphertext expected:",
4534 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4536 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4537 + (tdata->digest.offset_bytes == 0 ?
4538 plaintext_pad_len : tdata->digest.offset_bytes);
4540 debug_hexdump(stdout, "digest:", ut_params->digest,
4542 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4548 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4550 tdata->plaintext.data,
4551 tdata->plaintext.len >> 3,
4552 "SNOW 3G Plaintext data not as expected");
4554 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4556 tdata->ciphertext.data,
4557 tdata->validDataLenInBits.len,
4558 "SNOW 3G Ciphertext data not as expected");
4560 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4563 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4564 "SNOW 3G Generated auth tag not as expected");
4570 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4571 uint8_t op_mode, uint8_t verify)
4573 struct crypto_testsuite_params *ts_params = &testsuite_params;
4574 struct crypto_unittest_params *ut_params = &unittest_params;
4578 const uint8_t *plaintext = NULL;
4579 const uint8_t *ciphertext = NULL;
4580 const uint8_t *digest = NULL;
4581 unsigned int plaintext_pad_len;
4582 unsigned int plaintext_len;
4583 unsigned int ciphertext_pad_len;
4584 unsigned int ciphertext_len;
4585 uint8_t buffer[10000];
4586 uint8_t digest_buffer[10000];
4588 struct rte_cryptodev_info dev_info;
4590 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4592 uint64_t feat_flags = dev_info.feature_flags;
4594 if (op_mode == IN_PLACE) {
4595 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4596 printf("Device doesn't support in-place scatter-gather "
4597 "in both input and output mbufs.\n");
4601 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4602 printf("Device doesn't support out-of-place scatter-gather "
4603 "in both input and output mbufs.\n");
4606 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4607 printf("Device doesn't support digest encrypted.\n");
4612 /* Create SNOW 3G session */
4613 retval = create_wireless_algo_auth_cipher_session(
4614 ts_params->valid_devs[0],
4615 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4616 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4617 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4618 : RTE_CRYPTO_AUTH_OP_GENERATE),
4619 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4620 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4621 tdata->key.data, tdata->key.len,
4622 tdata->auth_iv.len, tdata->digest.len,
4623 tdata->cipher_iv.len);
4628 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4629 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4630 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4631 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4633 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4634 plaintext_pad_len, 15, 0);
4635 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4636 "Failed to allocate input buffer in mempool");
4638 if (op_mode == OUT_OF_PLACE) {
4639 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4640 plaintext_pad_len, 15, 0);
4641 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4642 "Failed to allocate output buffer in mempool");
4646 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4647 tdata->ciphertext.data);
4648 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4649 ciphertext_len, buffer);
4650 debug_hexdump(stdout, "ciphertext:", ciphertext,
4653 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4654 tdata->plaintext.data);
4655 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4656 plaintext_len, buffer);
4657 debug_hexdump(stdout, "plaintext:", plaintext,
4660 memset(buffer, 0, sizeof(buffer));
4662 /* Create SNOW 3G operation */
4663 retval = create_wireless_algo_auth_cipher_operation(
4665 tdata->cipher_iv.data, tdata->cipher_iv.len,
4666 tdata->auth_iv.data, tdata->auth_iv.len,
4667 (tdata->digest.offset_bytes == 0 ?
4668 (verify ? ciphertext_pad_len : plaintext_pad_len)
4669 : tdata->digest.offset_bytes),
4670 tdata->validCipherLenInBits.len,
4671 tdata->cipher.offset_bits,
4672 tdata->validAuthLenInBits.len,
4673 tdata->auth.offset_bits,
4679 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4682 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4684 ut_params->obuf = (op_mode == IN_PLACE ?
4685 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4688 if (ut_params->obuf)
4689 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4690 plaintext_len, buffer);
4692 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4693 plaintext_len, buffer);
4695 debug_hexdump(stdout, "plaintext:", plaintext,
4696 (tdata->plaintext.len >> 3) - tdata->digest.len);
4697 debug_hexdump(stdout, "plaintext expected:",
4698 tdata->plaintext.data,
4699 (tdata->plaintext.len >> 3) - tdata->digest.len);
4701 if (ut_params->obuf)
4702 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4703 ciphertext_len, buffer);
4705 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4706 ciphertext_len, buffer);
4708 debug_hexdump(stdout, "ciphertext:", ciphertext,
4710 debug_hexdump(stdout, "ciphertext expected:",
4711 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4713 if (ut_params->obuf)
4714 digest = rte_pktmbuf_read(ut_params->obuf,
4715 (tdata->digest.offset_bytes == 0 ?
4716 plaintext_pad_len : tdata->digest.offset_bytes),
4717 tdata->digest.len, digest_buffer);
4719 digest = rte_pktmbuf_read(ut_params->ibuf,
4720 (tdata->digest.offset_bytes == 0 ?
4721 plaintext_pad_len : tdata->digest.offset_bytes),
4722 tdata->digest.len, digest_buffer);
4724 debug_hexdump(stdout, "digest:", digest,
4726 debug_hexdump(stdout, "digest expected:",
4727 tdata->digest.data, tdata->digest.len);
4732 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4734 tdata->plaintext.data,
4735 tdata->plaintext.len >> 3,
4736 "SNOW 3G Plaintext data not as expected");
4738 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4740 tdata->ciphertext.data,
4741 tdata->validDataLenInBits.len,
4742 "SNOW 3G Ciphertext data not as expected");
4744 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4747 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4748 "SNOW 3G Generated auth tag not as expected");
4754 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4755 uint8_t op_mode, uint8_t verify)
4757 struct crypto_testsuite_params *ts_params = &testsuite_params;
4758 struct crypto_unittest_params *ut_params = &unittest_params;
4762 uint8_t *plaintext = NULL, *ciphertext = NULL;
4763 unsigned int plaintext_pad_len;
4764 unsigned int plaintext_len;
4765 unsigned int ciphertext_pad_len;
4766 unsigned int ciphertext_len;
4768 struct rte_cryptodev_info dev_info;
4770 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4772 uint64_t feat_flags = dev_info.feature_flags;
4774 if (op_mode == OUT_OF_PLACE) {
4775 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4776 printf("Device doesn't support digest encrypted.\n");
4781 /* Create KASUMI session */
4782 retval = create_wireless_algo_auth_cipher_session(
4783 ts_params->valid_devs[0],
4784 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4785 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4786 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4787 : RTE_CRYPTO_AUTH_OP_GENERATE),
4788 RTE_CRYPTO_AUTH_KASUMI_F9,
4789 RTE_CRYPTO_CIPHER_KASUMI_F8,
4790 tdata->key.data, tdata->key.len,
4791 0, tdata->digest.len,
4792 tdata->cipher_iv.len);
4797 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4798 if (op_mode == OUT_OF_PLACE)
4799 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4801 /* clear mbuf payload */
4802 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4803 rte_pktmbuf_tailroom(ut_params->ibuf));
4804 if (op_mode == OUT_OF_PLACE)
4805 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4806 rte_pktmbuf_tailroom(ut_params->obuf));
4808 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4809 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4810 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4811 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4814 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4815 ciphertext_pad_len);
4816 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4817 if (op_mode == OUT_OF_PLACE)
4818 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4819 debug_hexdump(stdout, "ciphertext:", ciphertext,
4822 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4824 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4825 if (op_mode == OUT_OF_PLACE)
4826 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4827 debug_hexdump(stdout, "plaintext:", plaintext,
4831 /* Create KASUMI operation */
4832 retval = create_wireless_algo_auth_cipher_operation(
4834 tdata->cipher_iv.data, tdata->cipher_iv.len,
4836 (tdata->digest.offset_bytes == 0 ?
4837 (verify ? ciphertext_pad_len : plaintext_pad_len)
4838 : tdata->digest.offset_bytes),
4839 tdata->validCipherLenInBits.len,
4840 tdata->validCipherOffsetInBits.len,
4841 tdata->validAuthLenInBits.len,
4848 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4851 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4853 ut_params->obuf = (op_mode == IN_PLACE ?
4854 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4858 if (ut_params->obuf)
4859 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4862 plaintext = ciphertext;
4864 debug_hexdump(stdout, "plaintext:", plaintext,
4865 (tdata->plaintext.len >> 3) - tdata->digest.len);
4866 debug_hexdump(stdout, "plaintext expected:",
4867 tdata->plaintext.data,
4868 (tdata->plaintext.len >> 3) - tdata->digest.len);
4870 if (ut_params->obuf)
4871 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4874 ciphertext = plaintext;
4876 debug_hexdump(stdout, "ciphertext:", ciphertext,
4878 debug_hexdump(stdout, "ciphertext expected:",
4879 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4881 ut_params->digest = rte_pktmbuf_mtod(
4882 ut_params->obuf, uint8_t *) +
4883 (tdata->digest.offset_bytes == 0 ?
4884 plaintext_pad_len : tdata->digest.offset_bytes);
4886 debug_hexdump(stdout, "digest:", ut_params->digest,
4888 debug_hexdump(stdout, "digest expected:",
4889 tdata->digest.data, tdata->digest.len);
4894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4896 tdata->plaintext.data,
4897 tdata->plaintext.len >> 3,
4898 "KASUMI Plaintext data not as expected");
4900 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4902 tdata->ciphertext.data,
4903 tdata->ciphertext.len >> 3,
4904 "KASUMI Ciphertext data not as expected");
4906 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4909 DIGEST_BYTE_LENGTH_KASUMI_F9,
4910 "KASUMI Generated auth tag not as expected");
4916 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4917 uint8_t op_mode, uint8_t verify)
4919 struct crypto_testsuite_params *ts_params = &testsuite_params;
4920 struct crypto_unittest_params *ut_params = &unittest_params;
4924 const uint8_t *plaintext = NULL;
4925 const uint8_t *ciphertext = NULL;
4926 const uint8_t *digest = NULL;
4927 unsigned int plaintext_pad_len;
4928 unsigned int plaintext_len;
4929 unsigned int ciphertext_pad_len;
4930 unsigned int ciphertext_len;
4931 uint8_t buffer[10000];
4932 uint8_t digest_buffer[10000];
4934 struct rte_cryptodev_info dev_info;
4936 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4938 uint64_t feat_flags = dev_info.feature_flags;
4940 if (op_mode == IN_PLACE) {
4941 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4942 printf("Device doesn't support in-place scatter-gather "
4943 "in both input and output mbufs.\n");
4947 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4948 printf("Device doesn't support out-of-place scatter-gather "
4949 "in both input and output mbufs.\n");
4952 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4953 printf("Device doesn't support digest encrypted.\n");
4958 /* Create KASUMI session */
4959 retval = create_wireless_algo_auth_cipher_session(
4960 ts_params->valid_devs[0],
4961 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4962 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4963 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4964 : RTE_CRYPTO_AUTH_OP_GENERATE),
4965 RTE_CRYPTO_AUTH_KASUMI_F9,
4966 RTE_CRYPTO_CIPHER_KASUMI_F8,
4967 tdata->key.data, tdata->key.len,
4968 0, tdata->digest.len,
4969 tdata->cipher_iv.len);
4974 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4975 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4976 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4977 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4979 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4980 plaintext_pad_len, 15, 0);
4981 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4982 "Failed to allocate input buffer in mempool");
4984 if (op_mode == OUT_OF_PLACE) {
4985 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4986 plaintext_pad_len, 15, 0);
4987 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4988 "Failed to allocate output buffer in mempool");
4992 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4993 tdata->ciphertext.data);
4994 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4995 ciphertext_len, buffer);
4996 debug_hexdump(stdout, "ciphertext:", ciphertext,
4999 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5000 tdata->plaintext.data);
5001 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5002 plaintext_len, buffer);
5003 debug_hexdump(stdout, "plaintext:", plaintext,
5006 memset(buffer, 0, sizeof(buffer));
5008 /* Create KASUMI operation */
5009 retval = create_wireless_algo_auth_cipher_operation(
5011 tdata->cipher_iv.data, tdata->cipher_iv.len,
5013 (tdata->digest.offset_bytes == 0 ?
5014 (verify ? ciphertext_pad_len : plaintext_pad_len)
5015 : tdata->digest.offset_bytes),
5016 tdata->validCipherLenInBits.len,
5017 tdata->validCipherOffsetInBits.len,
5018 tdata->validAuthLenInBits.len,
5025 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5028 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5030 ut_params->obuf = (op_mode == IN_PLACE ?
5031 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5034 if (ut_params->obuf)
5035 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5036 plaintext_len, buffer);
5038 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5039 plaintext_len, buffer);
5041 debug_hexdump(stdout, "plaintext:", plaintext,
5042 (tdata->plaintext.len >> 3) - tdata->digest.len);
5043 debug_hexdump(stdout, "plaintext expected:",
5044 tdata->plaintext.data,
5045 (tdata->plaintext.len >> 3) - tdata->digest.len);
5047 if (ut_params->obuf)
5048 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5049 ciphertext_len, buffer);
5051 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5052 ciphertext_len, buffer);
5054 debug_hexdump(stdout, "ciphertext:", ciphertext,
5056 debug_hexdump(stdout, "ciphertext expected:",
5057 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5059 if (ut_params->obuf)
5060 digest = rte_pktmbuf_read(ut_params->obuf,
5061 (tdata->digest.offset_bytes == 0 ?
5062 plaintext_pad_len : tdata->digest.offset_bytes),
5063 tdata->digest.len, digest_buffer);
5065 digest = rte_pktmbuf_read(ut_params->ibuf,
5066 (tdata->digest.offset_bytes == 0 ?
5067 plaintext_pad_len : tdata->digest.offset_bytes),
5068 tdata->digest.len, digest_buffer);
5070 debug_hexdump(stdout, "digest:", digest,
5072 debug_hexdump(stdout, "digest expected:",
5073 tdata->digest.data, tdata->digest.len);
5078 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5080 tdata->plaintext.data,
5081 tdata->plaintext.len >> 3,
5082 "KASUMI Plaintext data not as expected");
5084 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5086 tdata->ciphertext.data,
5087 tdata->validDataLenInBits.len,
5088 "KASUMI Ciphertext data not as expected");
5090 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5093 DIGEST_BYTE_LENGTH_KASUMI_F9,
5094 "KASUMI Generated auth tag not as expected");
5100 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5102 struct crypto_testsuite_params *ts_params = &testsuite_params;
5103 struct crypto_unittest_params *ut_params = &unittest_params;
5107 uint8_t *plaintext, *ciphertext;
5108 unsigned plaintext_pad_len;
5109 unsigned plaintext_len;
5111 /* Create KASUMI session */
5112 retval = create_wireless_algo_cipher_auth_session(
5113 ts_params->valid_devs[0],
5114 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5115 RTE_CRYPTO_AUTH_OP_GENERATE,
5116 RTE_CRYPTO_AUTH_KASUMI_F9,
5117 RTE_CRYPTO_CIPHER_KASUMI_F8,
5118 tdata->key.data, tdata->key.len,
5119 0, tdata->digest.len,
5120 tdata->cipher_iv.len);
5124 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5126 /* clear mbuf payload */
5127 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5128 rte_pktmbuf_tailroom(ut_params->ibuf));
5130 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5131 /* Append data which is padded to a multiple of */
5132 /* the algorithms block size */
5133 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5134 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5136 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5138 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5140 /* Create KASUMI operation */
5141 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5142 tdata->digest.len, NULL, 0,
5143 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5144 tdata->cipher_iv.data, tdata->cipher_iv.len,
5145 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5146 tdata->validCipherOffsetInBits.len,
5147 tdata->validAuthLenInBits.len,
5153 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5155 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5157 if (ut_params->op->sym->m_dst)
5158 ut_params->obuf = ut_params->op->sym->m_dst;
5160 ut_params->obuf = ut_params->op->sym->m_src;
5162 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5163 tdata->validCipherOffsetInBits.len >> 3);
5165 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5166 + plaintext_pad_len;
5168 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5169 (tdata->validCipherOffsetInBits.len >> 3);
5171 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5173 reference_ciphertext,
5174 tdata->validCipherLenInBits.len,
5175 "KASUMI Ciphertext data not as expected");
5178 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5181 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5182 "KASUMI Generated auth tag not as expected");
5187 test_zuc_encryption(const struct wireless_test_data *tdata)
5189 struct crypto_testsuite_params *ts_params = &testsuite_params;
5190 struct crypto_unittest_params *ut_params = &unittest_params;
5193 uint8_t *plaintext, *ciphertext;
5194 unsigned plaintext_pad_len;
5195 unsigned plaintext_len;
5197 struct rte_cryptodev_sym_capability_idx cap_idx;
5199 /* Check if device supports ZUC EEA3 */
5200 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5201 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5203 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5207 /* Create ZUC session */
5208 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5209 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5210 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5211 tdata->key.data, tdata->key.len,
5212 tdata->cipher_iv.len);
5216 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5218 /* Clear mbuf payload */
5219 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5220 rte_pktmbuf_tailroom(ut_params->ibuf));
5222 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5223 /* Append data which is padded to a multiple */
5224 /* of the algorithms block size */
5225 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5226 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5228 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5230 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5232 /* Create ZUC operation */
5233 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5234 tdata->cipher_iv.len,
5235 tdata->plaintext.len,
5240 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5242 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5244 ut_params->obuf = ut_params->op->sym->m_dst;
5245 if (ut_params->obuf)
5246 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5248 ciphertext = plaintext;
5250 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5253 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5255 tdata->ciphertext.data,
5256 tdata->validCipherLenInBits.len,
5257 "ZUC Ciphertext data not as expected");
5262 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5264 struct crypto_testsuite_params *ts_params = &testsuite_params;
5265 struct crypto_unittest_params *ut_params = &unittest_params;
5269 unsigned int plaintext_pad_len;
5270 unsigned int plaintext_len;
5271 const uint8_t *ciphertext;
5272 uint8_t ciphertext_buffer[2048];
5273 struct rte_cryptodev_info dev_info;
5275 struct rte_cryptodev_sym_capability_idx cap_idx;
5277 /* Check if device supports ZUC EEA3 */
5278 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5279 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5281 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5285 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5287 uint64_t feat_flags = dev_info.feature_flags;
5289 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5290 printf("Device doesn't support in-place scatter-gather. "
5295 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5297 /* Append data which is padded to a multiple */
5298 /* of the algorithms block size */
5299 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5301 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5302 plaintext_pad_len, 10, 0);
5304 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5305 tdata->plaintext.data);
5307 /* Create ZUC session */
5308 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5309 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5310 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5311 tdata->key.data, tdata->key.len,
5312 tdata->cipher_iv.len);
5316 /* Clear mbuf payload */
5318 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5320 /* Create ZUC operation */
5321 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5322 tdata->cipher_iv.len, tdata->plaintext.len,
5327 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5329 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5331 ut_params->obuf = ut_params->op->sym->m_dst;
5332 if (ut_params->obuf)
5333 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5334 0, plaintext_len, ciphertext_buffer);
5336 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5337 0, plaintext_len, ciphertext_buffer);
5340 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5343 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5345 tdata->ciphertext.data,
5346 tdata->validCipherLenInBits.len,
5347 "ZUC Ciphertext data not as expected");
5353 test_zuc_authentication(const struct wireless_test_data *tdata)
5355 struct crypto_testsuite_params *ts_params = &testsuite_params;
5356 struct crypto_unittest_params *ut_params = &unittest_params;
5359 unsigned plaintext_pad_len;
5360 unsigned plaintext_len;
5363 struct rte_cryptodev_sym_capability_idx cap_idx;
5365 /* Check if device supports ZUC EIA3 */
5366 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5367 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5369 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5373 /* Create ZUC session */
5374 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5375 tdata->key.data, tdata->key.len,
5376 tdata->auth_iv.len, tdata->digest.len,
5377 RTE_CRYPTO_AUTH_OP_GENERATE,
5378 RTE_CRYPTO_AUTH_ZUC_EIA3);
5382 /* alloc mbuf and set payload */
5383 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5385 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5386 rte_pktmbuf_tailroom(ut_params->ibuf));
5388 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5389 /* Append data which is padded to a multiple of */
5390 /* the algorithms block size */
5391 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5392 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5394 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5396 /* Create ZUC operation */
5397 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5398 tdata->auth_iv.data, tdata->auth_iv.len,
5399 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5400 tdata->validAuthLenInBits.len,
5405 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5407 ut_params->obuf = ut_params->op->sym->m_src;
5408 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5409 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5410 + plaintext_pad_len;
5413 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5416 DIGEST_BYTE_LENGTH_KASUMI_F9,
5417 "ZUC Generated auth tag not as expected");
5423 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5424 uint8_t op_mode, uint8_t verify)
5426 struct crypto_testsuite_params *ts_params = &testsuite_params;
5427 struct crypto_unittest_params *ut_params = &unittest_params;
5431 uint8_t *plaintext = NULL, *ciphertext = NULL;
5432 unsigned int plaintext_pad_len;
5433 unsigned int plaintext_len;
5434 unsigned int ciphertext_pad_len;
5435 unsigned int ciphertext_len;
5437 struct rte_cryptodev_info dev_info;
5438 struct rte_cryptodev_sym_capability_idx cap_idx;
5440 /* Check if device supports ZUC EIA3 */
5441 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5442 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5444 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5448 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5450 uint64_t feat_flags = dev_info.feature_flags;
5452 if (op_mode == OUT_OF_PLACE) {
5453 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5454 printf("Device doesn't support digest encrypted.\n");
5459 /* Create ZUC session */
5460 retval = create_wireless_algo_auth_cipher_session(
5461 ts_params->valid_devs[0],
5462 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5463 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5464 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5465 : RTE_CRYPTO_AUTH_OP_GENERATE),
5466 RTE_CRYPTO_AUTH_ZUC_EIA3,
5467 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5468 tdata->key.data, tdata->key.len,
5469 tdata->auth_iv.len, tdata->digest.len,
5470 tdata->cipher_iv.len);
5475 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5476 if (op_mode == OUT_OF_PLACE)
5477 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5479 /* clear mbuf payload */
5480 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5481 rte_pktmbuf_tailroom(ut_params->ibuf));
5482 if (op_mode == OUT_OF_PLACE)
5483 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5484 rte_pktmbuf_tailroom(ut_params->obuf));
5486 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5487 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5488 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5489 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5492 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5493 ciphertext_pad_len);
5494 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5495 if (op_mode == OUT_OF_PLACE)
5496 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5497 debug_hexdump(stdout, "ciphertext:", ciphertext,
5500 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5502 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5503 if (op_mode == OUT_OF_PLACE)
5504 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5505 debug_hexdump(stdout, "plaintext:", plaintext,
5509 /* Create ZUC operation */
5510 retval = create_wireless_algo_auth_cipher_operation(
5512 tdata->cipher_iv.data, tdata->cipher_iv.len,
5513 tdata->auth_iv.data, tdata->auth_iv.len,
5514 (tdata->digest.offset_bytes == 0 ?
5515 (verify ? ciphertext_pad_len : plaintext_pad_len)
5516 : tdata->digest.offset_bytes),
5517 tdata->validCipherLenInBits.len,
5518 tdata->validCipherOffsetInBits.len,
5519 tdata->validAuthLenInBits.len,
5526 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5529 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5531 ut_params->obuf = (op_mode == IN_PLACE ?
5532 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5536 if (ut_params->obuf)
5537 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5540 plaintext = ciphertext;
5542 debug_hexdump(stdout, "plaintext:", plaintext,
5543 (tdata->plaintext.len >> 3) - tdata->digest.len);
5544 debug_hexdump(stdout, "plaintext expected:",
5545 tdata->plaintext.data,
5546 (tdata->plaintext.len >> 3) - tdata->digest.len);
5548 if (ut_params->obuf)
5549 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5552 ciphertext = plaintext;
5554 debug_hexdump(stdout, "ciphertext:", ciphertext,
5556 debug_hexdump(stdout, "ciphertext expected:",
5557 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5559 ut_params->digest = rte_pktmbuf_mtod(
5560 ut_params->obuf, uint8_t *) +
5561 (tdata->digest.offset_bytes == 0 ?
5562 plaintext_pad_len : tdata->digest.offset_bytes);
5564 debug_hexdump(stdout, "digest:", ut_params->digest,
5566 debug_hexdump(stdout, "digest expected:",
5567 tdata->digest.data, tdata->digest.len);
5572 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5574 tdata->plaintext.data,
5575 tdata->plaintext.len >> 3,
5576 "ZUC Plaintext data not as expected");
5578 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5580 tdata->ciphertext.data,
5581 tdata->ciphertext.len >> 3,
5582 "ZUC Ciphertext data not as expected");
5584 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5587 DIGEST_BYTE_LENGTH_KASUMI_F9,
5588 "ZUC Generated auth tag not as expected");
5594 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5595 uint8_t op_mode, uint8_t verify)
5597 struct crypto_testsuite_params *ts_params = &testsuite_params;
5598 struct crypto_unittest_params *ut_params = &unittest_params;
5602 const uint8_t *plaintext = NULL;
5603 const uint8_t *ciphertext = NULL;
5604 const uint8_t *digest = NULL;
5605 unsigned int plaintext_pad_len;
5606 unsigned int plaintext_len;
5607 unsigned int ciphertext_pad_len;
5608 unsigned int ciphertext_len;
5609 uint8_t buffer[10000];
5610 uint8_t digest_buffer[10000];
5612 struct rte_cryptodev_info dev_info;
5613 struct rte_cryptodev_sym_capability_idx cap_idx;
5615 /* Check if device supports ZUC EIA3 */
5616 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5617 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5619 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5623 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5625 uint64_t feat_flags = dev_info.feature_flags;
5627 if (op_mode == IN_PLACE) {
5628 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5629 printf("Device doesn't support in-place scatter-gather "
5630 "in both input and output mbufs.\n");
5634 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5635 printf("Device doesn't support out-of-place scatter-gather "
5636 "in both input and output mbufs.\n");
5639 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5640 printf("Device doesn't support digest encrypted.\n");
5645 /* Create ZUC session */
5646 retval = create_wireless_algo_auth_cipher_session(
5647 ts_params->valid_devs[0],
5648 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5649 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5650 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5651 : RTE_CRYPTO_AUTH_OP_GENERATE),
5652 RTE_CRYPTO_AUTH_ZUC_EIA3,
5653 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5654 tdata->key.data, tdata->key.len,
5655 tdata->auth_iv.len, tdata->digest.len,
5656 tdata->cipher_iv.len);
5661 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5662 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5663 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5664 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5666 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5667 plaintext_pad_len, 15, 0);
5668 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5669 "Failed to allocate input buffer in mempool");
5671 if (op_mode == OUT_OF_PLACE) {
5672 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5673 plaintext_pad_len, 15, 0);
5674 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5675 "Failed to allocate output buffer in mempool");
5679 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5680 tdata->ciphertext.data);
5681 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5682 ciphertext_len, buffer);
5683 debug_hexdump(stdout, "ciphertext:", ciphertext,
5686 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5687 tdata->plaintext.data);
5688 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5689 plaintext_len, buffer);
5690 debug_hexdump(stdout, "plaintext:", plaintext,
5693 memset(buffer, 0, sizeof(buffer));
5695 /* Create ZUC operation */
5696 retval = create_wireless_algo_auth_cipher_operation(
5698 tdata->cipher_iv.data, tdata->cipher_iv.len,
5700 (tdata->digest.offset_bytes == 0 ?
5701 (verify ? ciphertext_pad_len : plaintext_pad_len)
5702 : tdata->digest.offset_bytes),
5703 tdata->validCipherLenInBits.len,
5704 tdata->validCipherOffsetInBits.len,
5705 tdata->validAuthLenInBits.len,
5712 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5715 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5717 ut_params->obuf = (op_mode == IN_PLACE ?
5718 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5721 if (ut_params->obuf)
5722 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5723 plaintext_len, buffer);
5725 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5726 plaintext_len, buffer);
5728 debug_hexdump(stdout, "plaintext:", plaintext,
5729 (tdata->plaintext.len >> 3) - tdata->digest.len);
5730 debug_hexdump(stdout, "plaintext expected:",
5731 tdata->plaintext.data,
5732 (tdata->plaintext.len >> 3) - tdata->digest.len);
5734 if (ut_params->obuf)
5735 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5736 ciphertext_len, buffer);
5738 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5739 ciphertext_len, buffer);
5741 debug_hexdump(stdout, "ciphertext:", ciphertext,
5743 debug_hexdump(stdout, "ciphertext expected:",
5744 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5746 if (ut_params->obuf)
5747 digest = rte_pktmbuf_read(ut_params->obuf,
5748 (tdata->digest.offset_bytes == 0 ?
5749 plaintext_pad_len : tdata->digest.offset_bytes),
5750 tdata->digest.len, digest_buffer);
5752 digest = rte_pktmbuf_read(ut_params->ibuf,
5753 (tdata->digest.offset_bytes == 0 ?
5754 plaintext_pad_len : tdata->digest.offset_bytes),
5755 tdata->digest.len, digest_buffer);
5757 debug_hexdump(stdout, "digest:", digest,
5759 debug_hexdump(stdout, "digest expected:",
5760 tdata->digest.data, tdata->digest.len);
5765 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5767 tdata->plaintext.data,
5768 tdata->plaintext.len >> 3,
5769 "ZUC Plaintext data not as expected");
5771 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5773 tdata->ciphertext.data,
5774 tdata->validDataLenInBits.len,
5775 "ZUC Ciphertext data not as expected");
5777 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5780 DIGEST_BYTE_LENGTH_KASUMI_F9,
5781 "ZUC Generated auth tag not as expected");
5787 test_kasumi_encryption_test_case_1(void)
5789 return test_kasumi_encryption(&kasumi_test_case_1);
5793 test_kasumi_encryption_test_case_1_sgl(void)
5795 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5799 test_kasumi_encryption_test_case_1_oop(void)
5801 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5805 test_kasumi_encryption_test_case_1_oop_sgl(void)
5807 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5811 test_kasumi_encryption_test_case_2(void)
5813 return test_kasumi_encryption(&kasumi_test_case_2);
5817 test_kasumi_encryption_test_case_3(void)
5819 return test_kasumi_encryption(&kasumi_test_case_3);
5823 test_kasumi_encryption_test_case_4(void)
5825 return test_kasumi_encryption(&kasumi_test_case_4);
5829 test_kasumi_encryption_test_case_5(void)
5831 return test_kasumi_encryption(&kasumi_test_case_5);
5835 test_kasumi_decryption_test_case_1(void)
5837 return test_kasumi_decryption(&kasumi_test_case_1);
5841 test_kasumi_decryption_test_case_1_oop(void)
5843 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5847 test_kasumi_decryption_test_case_2(void)
5849 return test_kasumi_decryption(&kasumi_test_case_2);
5853 test_kasumi_decryption_test_case_3(void)
5855 return test_kasumi_decryption(&kasumi_test_case_3);
5859 test_kasumi_decryption_test_case_4(void)
5861 return test_kasumi_decryption(&kasumi_test_case_4);
5865 test_kasumi_decryption_test_case_5(void)
5867 return test_kasumi_decryption(&kasumi_test_case_5);
5870 test_snow3g_encryption_test_case_1(void)
5872 return test_snow3g_encryption(&snow3g_test_case_1);
5876 test_snow3g_encryption_test_case_1_oop(void)
5878 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5882 test_snow3g_encryption_test_case_1_oop_sgl(void)
5884 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5889 test_snow3g_encryption_test_case_1_offset_oop(void)
5891 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5895 test_snow3g_encryption_test_case_2(void)
5897 return test_snow3g_encryption(&snow3g_test_case_2);
5901 test_snow3g_encryption_test_case_3(void)
5903 return test_snow3g_encryption(&snow3g_test_case_3);
5907 test_snow3g_encryption_test_case_4(void)
5909 return test_snow3g_encryption(&snow3g_test_case_4);
5913 test_snow3g_encryption_test_case_5(void)
5915 return test_snow3g_encryption(&snow3g_test_case_5);
5919 test_snow3g_decryption_test_case_1(void)
5921 return test_snow3g_decryption(&snow3g_test_case_1);
5925 test_snow3g_decryption_test_case_1_oop(void)
5927 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5931 test_snow3g_decryption_test_case_2(void)
5933 return test_snow3g_decryption(&snow3g_test_case_2);
5937 test_snow3g_decryption_test_case_3(void)
5939 return test_snow3g_decryption(&snow3g_test_case_3);
5943 test_snow3g_decryption_test_case_4(void)
5945 return test_snow3g_decryption(&snow3g_test_case_4);
5949 test_snow3g_decryption_test_case_5(void)
5951 return test_snow3g_decryption(&snow3g_test_case_5);
5955 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5956 * Pattern digest from snow3g_test_data must be allocated as
5957 * 4 last bytes in plaintext.
5960 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5961 struct snow3g_hash_test_data *output)
5963 if ((pattern != NULL) && (output != NULL)) {
5964 output->key.len = pattern->key.len;
5966 memcpy(output->key.data,
5967 pattern->key.data, pattern->key.len);
5969 output->auth_iv.len = pattern->auth_iv.len;
5971 memcpy(output->auth_iv.data,
5972 pattern->auth_iv.data, pattern->auth_iv.len);
5974 output->plaintext.len = pattern->plaintext.len;
5976 memcpy(output->plaintext.data,
5977 pattern->plaintext.data, pattern->plaintext.len >> 3);
5979 output->digest.len = pattern->digest.len;
5981 memcpy(output->digest.data,
5982 &pattern->plaintext.data[pattern->digest.offset_bytes],
5983 pattern->digest.len);
5985 output->validAuthLenInBits.len =
5986 pattern->validAuthLenInBits.len;
5991 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5994 test_snow3g_decryption_with_digest_test_case_1(void)
5996 struct snow3g_hash_test_data snow3g_hash_data;
5999 * Function prepare data for hash veryfication test case.
6000 * Digest is allocated in 4 last bytes in plaintext, pattern.
6002 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6004 return test_snow3g_decryption(&snow3g_test_case_7) &
6005 test_snow3g_authentication_verify(&snow3g_hash_data);
6009 test_snow3g_cipher_auth_test_case_1(void)
6011 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6015 test_snow3g_auth_cipher_test_case_1(void)
6017 return test_snow3g_auth_cipher(
6018 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6022 test_snow3g_auth_cipher_test_case_2(void)
6024 return test_snow3g_auth_cipher(
6025 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6029 test_snow3g_auth_cipher_test_case_2_oop(void)
6031 return test_snow3g_auth_cipher(
6032 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6036 test_snow3g_auth_cipher_part_digest_enc(void)
6038 return test_snow3g_auth_cipher(
6039 &snow3g_auth_cipher_partial_digest_encryption,
6044 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6046 return test_snow3g_auth_cipher(
6047 &snow3g_auth_cipher_partial_digest_encryption,
6052 test_snow3g_auth_cipher_test_case_3_sgl(void)
6054 return test_snow3g_auth_cipher_sgl(
6055 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6059 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6061 return test_snow3g_auth_cipher_sgl(
6062 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6066 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6068 return test_snow3g_auth_cipher_sgl(
6069 &snow3g_auth_cipher_partial_digest_encryption,
6074 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6076 return test_snow3g_auth_cipher_sgl(
6077 &snow3g_auth_cipher_partial_digest_encryption,
6082 test_snow3g_auth_cipher_verify_test_case_1(void)
6084 return test_snow3g_auth_cipher(
6085 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6089 test_snow3g_auth_cipher_verify_test_case_2(void)
6091 return test_snow3g_auth_cipher(
6092 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6096 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6098 return test_snow3g_auth_cipher(
6099 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6103 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6105 return test_snow3g_auth_cipher(
6106 &snow3g_auth_cipher_partial_digest_encryption,
6111 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6113 return test_snow3g_auth_cipher(
6114 &snow3g_auth_cipher_partial_digest_encryption,
6119 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6121 return test_snow3g_auth_cipher_sgl(
6122 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6126 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6128 return test_snow3g_auth_cipher_sgl(
6129 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6133 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6135 return test_snow3g_auth_cipher_sgl(
6136 &snow3g_auth_cipher_partial_digest_encryption,
6141 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6143 return test_snow3g_auth_cipher_sgl(
6144 &snow3g_auth_cipher_partial_digest_encryption,
6149 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6151 return test_snow3g_auth_cipher(
6152 &snow3g_test_case_7, IN_PLACE, 0);
6156 test_kasumi_auth_cipher_test_case_1(void)
6158 return test_kasumi_auth_cipher(
6159 &kasumi_test_case_3, IN_PLACE, 0);
6163 test_kasumi_auth_cipher_test_case_2(void)
6165 return test_kasumi_auth_cipher(
6166 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6170 test_kasumi_auth_cipher_test_case_2_oop(void)
6172 return test_kasumi_auth_cipher(
6173 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6177 test_kasumi_auth_cipher_test_case_2_sgl(void)
6179 return test_kasumi_auth_cipher_sgl(
6180 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6184 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6186 return test_kasumi_auth_cipher_sgl(
6187 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6191 test_kasumi_auth_cipher_verify_test_case_1(void)
6193 return test_kasumi_auth_cipher(
6194 &kasumi_test_case_3, IN_PLACE, 1);
6198 test_kasumi_auth_cipher_verify_test_case_2(void)
6200 return test_kasumi_auth_cipher(
6201 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6205 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6207 return test_kasumi_auth_cipher(
6208 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6212 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6214 return test_kasumi_auth_cipher_sgl(
6215 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6219 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6221 return test_kasumi_auth_cipher_sgl(
6222 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6226 test_kasumi_cipher_auth_test_case_1(void)
6228 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6232 test_zuc_encryption_test_case_1(void)
6234 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6238 test_zuc_encryption_test_case_2(void)
6240 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6244 test_zuc_encryption_test_case_3(void)
6246 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6250 test_zuc_encryption_test_case_4(void)
6252 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6256 test_zuc_encryption_test_case_5(void)
6258 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6262 test_zuc_encryption_test_case_6_sgl(void)
6264 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6268 test_zuc_hash_generate_test_case_1(void)
6270 return test_zuc_authentication(&zuc_test_case_auth_1b);
6274 test_zuc_hash_generate_test_case_2(void)
6276 return test_zuc_authentication(&zuc_test_case_auth_90b);
6280 test_zuc_hash_generate_test_case_3(void)
6282 return test_zuc_authentication(&zuc_test_case_auth_577b);
6286 test_zuc_hash_generate_test_case_4(void)
6288 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6292 test_zuc_hash_generate_test_case_5(void)
6294 return test_zuc_authentication(&zuc_test_auth_5670b);
6298 test_zuc_hash_generate_test_case_6(void)
6300 return test_zuc_authentication(&zuc_test_case_auth_128b);
6304 test_zuc_hash_generate_test_case_7(void)
6306 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6310 test_zuc_hash_generate_test_case_8(void)
6312 return test_zuc_authentication(&zuc_test_case_auth_584b);
6316 test_zuc_cipher_auth_test_case_1(void)
6318 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6322 test_zuc_cipher_auth_test_case_2(void)
6324 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6328 test_zuc_auth_cipher_test_case_1(void)
6330 return test_zuc_auth_cipher(
6331 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6335 test_zuc_auth_cipher_test_case_1_oop(void)
6337 return test_zuc_auth_cipher(
6338 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6342 test_zuc_auth_cipher_test_case_1_sgl(void)
6344 return test_zuc_auth_cipher_sgl(
6345 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6349 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6351 return test_zuc_auth_cipher_sgl(
6352 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6356 test_zuc_auth_cipher_verify_test_case_1(void)
6358 return test_zuc_auth_cipher(
6359 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6363 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6365 return test_zuc_auth_cipher(
6366 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6370 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6372 return test_zuc_auth_cipher_sgl(
6373 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6377 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6379 return test_zuc_auth_cipher_sgl(
6380 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6384 test_3DES_chain_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_3DES_CHAIN_TYPE);
6397 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6399 return TEST_SUCCESS;
6403 test_DES_cipheronly_qat_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_QAT_SYM_PMD)),
6414 BLKCIPHER_DES_CIPHERONLY_TYPE);
6416 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6418 return TEST_SUCCESS;
6422 test_DES_cipheronly_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_CIPHERONLY_TYPE);
6435 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6437 return TEST_SUCCESS;
6441 test_DES_docsis_openssl_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_OPENSSL_PMD)),
6452 BLKCIPHER_DES_DOCSIS_TYPE);
6454 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6456 return TEST_SUCCESS;
6460 test_DES_cipheronly_mb_all(void)
6462 struct crypto_testsuite_params *ts_params = &testsuite_params;
6465 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6466 ts_params->op_mpool,
6467 ts_params->session_mpool, ts_params->session_priv_mpool,
6468 ts_params->valid_devs[0],
6469 rte_cryptodev_driver_id_get(
6470 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6471 BLKCIPHER_DES_CIPHERONLY_TYPE);
6473 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6475 return TEST_SUCCESS;
6478 test_3DES_cipheronly_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_3DES_CIPHERONLY_TYPE);
6491 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6493 return TEST_SUCCESS;
6497 test_DES_docsis_mb_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_AESNI_MB_PMD)),
6508 BLKCIPHER_DES_DOCSIS_TYPE);
6510 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6512 return TEST_SUCCESS;
6516 test_3DES_chain_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_CHAIN_TYPE);
6529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6531 return TEST_SUCCESS;
6535 test_3DES_cipheronly_caam_jr_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_CAAM_JR_PMD)),
6546 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6548 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6550 return TEST_SUCCESS;
6554 test_3DES_chain_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_CHAIN_TYPE);
6567 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6569 return TEST_SUCCESS;
6573 test_3DES_cipheronly_dpaa_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_DPAA_SEC_PMD)),
6584 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6586 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6588 return TEST_SUCCESS;
6592 test_3DES_chain_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_CHAIN_TYPE);
6605 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6607 return TEST_SUCCESS;
6611 test_3DES_cipheronly_dpaa2_sec_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_DPAA2_SEC_PMD)),
6622 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6624 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6626 return TEST_SUCCESS;
6630 test_3DES_chain_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_CHAIN_TYPE);
6643 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6645 return TEST_SUCCESS;
6649 test_3DES_cipheronly_ccp_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_CCP_PMD)),
6660 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6662 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6664 return TEST_SUCCESS;
6668 test_3DES_cipheronly_qat_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_QAT_SYM_PMD)),
6679 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6681 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6683 return TEST_SUCCESS;
6687 test_3DES_chain_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_CHAIN_TYPE);
6700 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6702 return TEST_SUCCESS;
6706 test_3DES_cipheronly_openssl_all(void)
6708 struct crypto_testsuite_params *ts_params = &testsuite_params;
6711 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6712 ts_params->op_mpool,
6713 ts_params->session_mpool, ts_params->session_priv_mpool,
6714 ts_params->valid_devs[0],
6715 rte_cryptodev_driver_id_get(
6716 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6717 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6719 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6721 return TEST_SUCCESS;
6724 /* ***** AEAD algorithm Tests ***** */
6727 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6728 enum rte_crypto_aead_operation op,
6729 const uint8_t *key, const uint8_t key_len,
6730 const uint16_t aad_len, const uint8_t auth_len,
6733 uint8_t aead_key[key_len];
6735 struct crypto_testsuite_params *ts_params = &testsuite_params;
6736 struct crypto_unittest_params *ut_params = &unittest_params;
6738 memcpy(aead_key, key, key_len);
6740 /* Setup AEAD Parameters */
6741 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6742 ut_params->aead_xform.next = NULL;
6743 ut_params->aead_xform.aead.algo = algo;
6744 ut_params->aead_xform.aead.op = op;
6745 ut_params->aead_xform.aead.key.data = aead_key;
6746 ut_params->aead_xform.aead.key.length = key_len;
6747 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6748 ut_params->aead_xform.aead.iv.length = iv_len;
6749 ut_params->aead_xform.aead.digest_length = auth_len;
6750 ut_params->aead_xform.aead.aad_length = aad_len;
6752 debug_hexdump(stdout, "key:", key, key_len);
6754 /* Create Crypto session*/
6755 ut_params->sess = rte_cryptodev_sym_session_create(
6756 ts_params->session_mpool);
6758 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6759 &ut_params->aead_xform,
6760 ts_params->session_priv_mpool);
6762 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6768 create_aead_xform(struct rte_crypto_op *op,
6769 enum rte_crypto_aead_algorithm algo,
6770 enum rte_crypto_aead_operation aead_op,
6771 uint8_t *key, const uint8_t key_len,
6772 const uint8_t aad_len, const uint8_t auth_len,
6775 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6776 "failed to allocate space for crypto transform");
6778 struct rte_crypto_sym_op *sym_op = op->sym;
6780 /* Setup AEAD Parameters */
6781 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6782 sym_op->xform->next = NULL;
6783 sym_op->xform->aead.algo = algo;
6784 sym_op->xform->aead.op = aead_op;
6785 sym_op->xform->aead.key.data = key;
6786 sym_op->xform->aead.key.length = key_len;
6787 sym_op->xform->aead.iv.offset = IV_OFFSET;
6788 sym_op->xform->aead.iv.length = iv_len;
6789 sym_op->xform->aead.digest_length = auth_len;
6790 sym_op->xform->aead.aad_length = aad_len;
6792 debug_hexdump(stdout, "key:", key, key_len);
6798 create_aead_operation(enum rte_crypto_aead_operation op,
6799 const struct aead_test_data *tdata)
6801 struct crypto_testsuite_params *ts_params = &testsuite_params;
6802 struct crypto_unittest_params *ut_params = &unittest_params;
6804 uint8_t *plaintext, *ciphertext;
6805 unsigned int aad_pad_len, plaintext_pad_len;
6807 /* Generate Crypto op data structure */
6808 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6809 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6810 TEST_ASSERT_NOT_NULL(ut_params->op,
6811 "Failed to allocate symmetric crypto operation struct");
6813 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6815 /* Append aad data */
6816 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6817 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6818 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6820 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6821 "no room to append aad");
6823 sym_op->aead.aad.phys_addr =
6824 rte_pktmbuf_iova(ut_params->ibuf);
6825 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6826 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6827 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6830 /* Append IV at the end of the crypto operation*/
6831 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6832 uint8_t *, IV_OFFSET);
6834 /* Copy IV 1 byte after the IV pointer, according to the API */
6835 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6836 debug_hexdump(stdout, "iv:", iv_ptr,
6839 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6840 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6842 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6843 "no room to append aad");
6845 sym_op->aead.aad.phys_addr =
6846 rte_pktmbuf_iova(ut_params->ibuf);
6847 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6848 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6851 /* Append IV at the end of the crypto operation*/
6852 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6853 uint8_t *, IV_OFFSET);
6855 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6856 debug_hexdump(stdout, "iv:", iv_ptr,
6860 /* Append plaintext/ciphertext */
6861 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6862 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6863 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6865 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6867 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6868 debug_hexdump(stdout, "plaintext:", plaintext,
6869 tdata->plaintext.len);
6871 if (ut_params->obuf) {
6872 ciphertext = (uint8_t *)rte_pktmbuf_append(
6874 plaintext_pad_len + aad_pad_len);
6875 TEST_ASSERT_NOT_NULL(ciphertext,
6876 "no room to append ciphertext");
6878 memset(ciphertext + aad_pad_len, 0,
6879 tdata->ciphertext.len);
6882 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6883 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6885 TEST_ASSERT_NOT_NULL(ciphertext,
6886 "no room to append ciphertext");
6888 memcpy(ciphertext, tdata->ciphertext.data,
6889 tdata->ciphertext.len);
6890 debug_hexdump(stdout, "ciphertext:", ciphertext,
6891 tdata->ciphertext.len);
6893 if (ut_params->obuf) {
6894 plaintext = (uint8_t *)rte_pktmbuf_append(
6896 plaintext_pad_len + aad_pad_len);
6897 TEST_ASSERT_NOT_NULL(plaintext,
6898 "no room to append plaintext");
6900 memset(plaintext + aad_pad_len, 0,
6901 tdata->plaintext.len);
6905 /* Append digest data */
6906 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6907 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6908 ut_params->obuf ? ut_params->obuf :
6910 tdata->auth_tag.len);
6911 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6912 "no room to append digest");
6913 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6914 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6915 ut_params->obuf ? ut_params->obuf :
6920 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6921 ut_params->ibuf, tdata->auth_tag.len);
6922 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6923 "no room to append digest");
6924 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6926 plaintext_pad_len + aad_pad_len);
6928 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6929 tdata->auth_tag.len);
6930 debug_hexdump(stdout, "digest:",
6931 sym_op->aead.digest.data,
6932 tdata->auth_tag.len);
6935 sym_op->aead.data.length = tdata->plaintext.len;
6936 sym_op->aead.data.offset = aad_pad_len;
6942 test_authenticated_encryption(const struct aead_test_data *tdata)
6944 struct crypto_testsuite_params *ts_params = &testsuite_params;
6945 struct crypto_unittest_params *ut_params = &unittest_params;
6948 uint8_t *ciphertext, *auth_tag;
6949 uint16_t plaintext_pad_len;
6952 /* Create AEAD session */
6953 retval = create_aead_session(ts_params->valid_devs[0],
6955 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6956 tdata->key.data, tdata->key.len,
6957 tdata->aad.len, tdata->auth_tag.len,
6962 if (tdata->aad.len > MBUF_SIZE) {
6963 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6964 /* Populate full size of add data */
6965 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6966 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6970 /* clear mbuf payload */
6971 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6972 rte_pktmbuf_tailroom(ut_params->ibuf));
6974 /* Create AEAD operation */
6975 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6979 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6981 ut_params->op->sym->m_src = ut_params->ibuf;
6983 /* Process crypto operation */
6984 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6985 ut_params->op), "failed to process sym crypto op");
6987 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6988 "crypto op processing failed");
6990 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6992 if (ut_params->op->sym->m_dst) {
6993 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6995 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6996 uint8_t *, plaintext_pad_len);
6998 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7000 ut_params->op->sym->cipher.data.offset);
7001 auth_tag = ciphertext + plaintext_pad_len;
7004 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7005 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7008 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7010 tdata->ciphertext.data,
7011 tdata->ciphertext.len,
7012 "Ciphertext data not as expected");
7014 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7016 tdata->auth_tag.data,
7017 tdata->auth_tag.len,
7018 "Generated auth tag not as expected");
7025 test_AES_GCM_authenticated_encryption_test_case_1(void)
7027 return test_authenticated_encryption(&gcm_test_case_1);
7031 test_AES_GCM_authenticated_encryption_test_case_2(void)
7033 return test_authenticated_encryption(&gcm_test_case_2);
7037 test_AES_GCM_authenticated_encryption_test_case_3(void)
7039 return test_authenticated_encryption(&gcm_test_case_3);
7043 test_AES_GCM_authenticated_encryption_test_case_4(void)
7045 return test_authenticated_encryption(&gcm_test_case_4);
7049 test_AES_GCM_authenticated_encryption_test_case_5(void)
7051 return test_authenticated_encryption(&gcm_test_case_5);
7055 test_AES_GCM_authenticated_encryption_test_case_6(void)
7057 return test_authenticated_encryption(&gcm_test_case_6);
7061 test_AES_GCM_authenticated_encryption_test_case_7(void)
7063 return test_authenticated_encryption(&gcm_test_case_7);
7067 test_AES_GCM_auth_encryption_test_case_192_1(void)
7069 return test_authenticated_encryption(&gcm_test_case_192_1);
7073 test_AES_GCM_auth_encryption_test_case_192_2(void)
7075 return test_authenticated_encryption(&gcm_test_case_192_2);
7079 test_AES_GCM_auth_encryption_test_case_192_3(void)
7081 return test_authenticated_encryption(&gcm_test_case_192_3);
7085 test_AES_GCM_auth_encryption_test_case_192_4(void)
7087 return test_authenticated_encryption(&gcm_test_case_192_4);
7091 test_AES_GCM_auth_encryption_test_case_192_5(void)
7093 return test_authenticated_encryption(&gcm_test_case_192_5);
7097 test_AES_GCM_auth_encryption_test_case_192_6(void)
7099 return test_authenticated_encryption(&gcm_test_case_192_6);
7103 test_AES_GCM_auth_encryption_test_case_192_7(void)
7105 return test_authenticated_encryption(&gcm_test_case_192_7);
7109 test_AES_GCM_auth_encryption_test_case_256_1(void)
7111 return test_authenticated_encryption(&gcm_test_case_256_1);
7115 test_AES_GCM_auth_encryption_test_case_256_2(void)
7117 return test_authenticated_encryption(&gcm_test_case_256_2);
7121 test_AES_GCM_auth_encryption_test_case_256_3(void)
7123 return test_authenticated_encryption(&gcm_test_case_256_3);
7127 test_AES_GCM_auth_encryption_test_case_256_4(void)
7129 return test_authenticated_encryption(&gcm_test_case_256_4);
7133 test_AES_GCM_auth_encryption_test_case_256_5(void)
7135 return test_authenticated_encryption(&gcm_test_case_256_5);
7139 test_AES_GCM_auth_encryption_test_case_256_6(void)
7141 return test_authenticated_encryption(&gcm_test_case_256_6);
7145 test_AES_GCM_auth_encryption_test_case_256_7(void)
7147 return test_authenticated_encryption(&gcm_test_case_256_7);
7151 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7153 return test_authenticated_encryption(&gcm_test_case_aad_1);
7157 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7159 return test_authenticated_encryption(&gcm_test_case_aad_2);
7163 test_authenticated_decryption(const struct aead_test_data *tdata)
7165 struct crypto_testsuite_params *ts_params = &testsuite_params;
7166 struct crypto_unittest_params *ut_params = &unittest_params;
7172 /* Create AEAD session */
7173 retval = create_aead_session(ts_params->valid_devs[0],
7175 RTE_CRYPTO_AEAD_OP_DECRYPT,
7176 tdata->key.data, tdata->key.len,
7177 tdata->aad.len, tdata->auth_tag.len,
7182 /* alloc mbuf and set payload */
7183 if (tdata->aad.len > MBUF_SIZE) {
7184 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7185 /* Populate full size of add data */
7186 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7187 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7189 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7191 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7192 rte_pktmbuf_tailroom(ut_params->ibuf));
7194 /* Create AEAD operation */
7195 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7199 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7201 ut_params->op->sym->m_src = ut_params->ibuf;
7203 /* Process crypto operation */
7204 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7205 ut_params->op), "failed to process sym crypto op");
7207 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7208 "crypto op processing failed");
7210 if (ut_params->op->sym->m_dst)
7211 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7214 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7216 ut_params->op->sym->cipher.data.offset);
7218 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7221 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7223 tdata->plaintext.data,
7224 tdata->plaintext.len,
7225 "Plaintext data not as expected");
7227 TEST_ASSERT_EQUAL(ut_params->op->status,
7228 RTE_CRYPTO_OP_STATUS_SUCCESS,
7229 "Authentication failed");
7234 test_AES_GCM_authenticated_decryption_test_case_1(void)
7236 return test_authenticated_decryption(&gcm_test_case_1);
7240 test_AES_GCM_authenticated_decryption_test_case_2(void)
7242 return test_authenticated_decryption(&gcm_test_case_2);
7246 test_AES_GCM_authenticated_decryption_test_case_3(void)
7248 return test_authenticated_decryption(&gcm_test_case_3);
7252 test_AES_GCM_authenticated_decryption_test_case_4(void)
7254 return test_authenticated_decryption(&gcm_test_case_4);
7258 test_AES_GCM_authenticated_decryption_test_case_5(void)
7260 return test_authenticated_decryption(&gcm_test_case_5);
7264 test_AES_GCM_authenticated_decryption_test_case_6(void)
7266 return test_authenticated_decryption(&gcm_test_case_6);
7270 test_AES_GCM_authenticated_decryption_test_case_7(void)
7272 return test_authenticated_decryption(&gcm_test_case_7);
7276 test_AES_GCM_auth_decryption_test_case_192_1(void)
7278 return test_authenticated_decryption(&gcm_test_case_192_1);
7282 test_AES_GCM_auth_decryption_test_case_192_2(void)
7284 return test_authenticated_decryption(&gcm_test_case_192_2);
7288 test_AES_GCM_auth_decryption_test_case_192_3(void)
7290 return test_authenticated_decryption(&gcm_test_case_192_3);
7294 test_AES_GCM_auth_decryption_test_case_192_4(void)
7296 return test_authenticated_decryption(&gcm_test_case_192_4);
7300 test_AES_GCM_auth_decryption_test_case_192_5(void)
7302 return test_authenticated_decryption(&gcm_test_case_192_5);
7306 test_AES_GCM_auth_decryption_test_case_192_6(void)
7308 return test_authenticated_decryption(&gcm_test_case_192_6);
7312 test_AES_GCM_auth_decryption_test_case_192_7(void)
7314 return test_authenticated_decryption(&gcm_test_case_192_7);
7318 test_AES_GCM_auth_decryption_test_case_256_1(void)
7320 return test_authenticated_decryption(&gcm_test_case_256_1);
7324 test_AES_GCM_auth_decryption_test_case_256_2(void)
7326 return test_authenticated_decryption(&gcm_test_case_256_2);
7330 test_AES_GCM_auth_decryption_test_case_256_3(void)
7332 return test_authenticated_decryption(&gcm_test_case_256_3);
7336 test_AES_GCM_auth_decryption_test_case_256_4(void)
7338 return test_authenticated_decryption(&gcm_test_case_256_4);
7342 test_AES_GCM_auth_decryption_test_case_256_5(void)
7344 return test_authenticated_decryption(&gcm_test_case_256_5);
7348 test_AES_GCM_auth_decryption_test_case_256_6(void)
7350 return test_authenticated_decryption(&gcm_test_case_256_6);
7354 test_AES_GCM_auth_decryption_test_case_256_7(void)
7356 return test_authenticated_decryption(&gcm_test_case_256_7);
7360 test_AES_GCM_auth_decryption_test_case_aad_1(void)
7362 return test_authenticated_decryption(&gcm_test_case_aad_1);
7366 test_AES_GCM_auth_decryption_test_case_aad_2(void)
7368 return test_authenticated_decryption(&gcm_test_case_aad_2);
7372 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
7374 struct crypto_testsuite_params *ts_params = &testsuite_params;
7375 struct crypto_unittest_params *ut_params = &unittest_params;
7378 uint8_t *ciphertext, *auth_tag;
7379 uint16_t plaintext_pad_len;
7381 /* Create AEAD session */
7382 retval = create_aead_session(ts_params->valid_devs[0],
7384 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7385 tdata->key.data, tdata->key.len,
7386 tdata->aad.len, tdata->auth_tag.len,
7391 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7392 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7394 /* clear mbuf payload */
7395 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7396 rte_pktmbuf_tailroom(ut_params->ibuf));
7397 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7398 rte_pktmbuf_tailroom(ut_params->obuf));
7400 /* Create AEAD operation */
7401 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7405 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7407 ut_params->op->sym->m_src = ut_params->ibuf;
7408 ut_params->op->sym->m_dst = ut_params->obuf;
7410 /* Process crypto operation */
7411 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7412 ut_params->op), "failed to process sym crypto op");
7414 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7415 "crypto op processing failed");
7417 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7419 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
7420 ut_params->op->sym->cipher.data.offset);
7421 auth_tag = ciphertext + plaintext_pad_len;
7423 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7424 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7429 tdata->ciphertext.data,
7430 tdata->ciphertext.len,
7431 "Ciphertext data not as expected");
7433 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7435 tdata->auth_tag.data,
7436 tdata->auth_tag.len,
7437 "Generated auth tag not as expected");
7444 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
7446 return test_authenticated_encryption_oop(&gcm_test_case_5);
7450 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
7452 struct crypto_testsuite_params *ts_params = &testsuite_params;
7453 struct crypto_unittest_params *ut_params = &unittest_params;
7458 /* Create AEAD session */
7459 retval = create_aead_session(ts_params->valid_devs[0],
7461 RTE_CRYPTO_AEAD_OP_DECRYPT,
7462 tdata->key.data, tdata->key.len,
7463 tdata->aad.len, tdata->auth_tag.len,
7468 /* alloc mbuf and set payload */
7469 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7470 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7472 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7473 rte_pktmbuf_tailroom(ut_params->ibuf));
7474 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7475 rte_pktmbuf_tailroom(ut_params->obuf));
7477 /* Create AEAD operation */
7478 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7482 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7484 ut_params->op->sym->m_src = ut_params->ibuf;
7485 ut_params->op->sym->m_dst = ut_params->obuf;
7487 /* Process crypto operation */
7488 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7489 ut_params->op), "failed to process sym crypto op");
7491 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7492 "crypto op processing failed");
7494 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
7495 ut_params->op->sym->cipher.data.offset);
7497 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7500 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7502 tdata->plaintext.data,
7503 tdata->plaintext.len,
7504 "Plaintext data not as expected");
7506 TEST_ASSERT_EQUAL(ut_params->op->status,
7507 RTE_CRYPTO_OP_STATUS_SUCCESS,
7508 "Authentication failed");
7513 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
7515 return test_authenticated_decryption_oop(&gcm_test_case_5);
7519 test_authenticated_encryption_sessionless(
7520 const struct aead_test_data *tdata)
7522 struct crypto_testsuite_params *ts_params = &testsuite_params;
7523 struct crypto_unittest_params *ut_params = &unittest_params;
7526 uint8_t *ciphertext, *auth_tag;
7527 uint16_t plaintext_pad_len;
7528 uint8_t key[tdata->key.len + 1];
7530 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7532 /* clear mbuf payload */
7533 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7534 rte_pktmbuf_tailroom(ut_params->ibuf));
7536 /* Create AEAD operation */
7537 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7541 /* Create GCM xform */
7542 memcpy(key, tdata->key.data, tdata->key.len);
7543 retval = create_aead_xform(ut_params->op,
7545 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7546 key, tdata->key.len,
7547 tdata->aad.len, tdata->auth_tag.len,
7552 ut_params->op->sym->m_src = ut_params->ibuf;
7554 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
7555 RTE_CRYPTO_OP_SESSIONLESS,
7556 "crypto op session type not sessionless");
7558 /* Process crypto operation */
7559 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7560 ut_params->op), "failed to process sym crypto op");
7562 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7564 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7565 "crypto op status not success");
7567 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7569 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7570 ut_params->op->sym->cipher.data.offset);
7571 auth_tag = ciphertext + plaintext_pad_len;
7573 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7574 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7577 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7579 tdata->ciphertext.data,
7580 tdata->ciphertext.len,
7581 "Ciphertext data not as expected");
7583 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7585 tdata->auth_tag.data,
7586 tdata->auth_tag.len,
7587 "Generated auth tag not as expected");
7594 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
7596 return test_authenticated_encryption_sessionless(
7601 test_authenticated_decryption_sessionless(
7602 const struct aead_test_data *tdata)
7604 struct crypto_testsuite_params *ts_params = &testsuite_params;
7605 struct crypto_unittest_params *ut_params = &unittest_params;
7609 uint8_t key[tdata->key.len + 1];
7611 /* alloc mbuf and set payload */
7612 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7614 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7615 rte_pktmbuf_tailroom(ut_params->ibuf));
7617 /* Create AEAD operation */
7618 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7622 /* Create AEAD xform */
7623 memcpy(key, tdata->key.data, tdata->key.len);
7624 retval = create_aead_xform(ut_params->op,
7626 RTE_CRYPTO_AEAD_OP_DECRYPT,
7627 key, tdata->key.len,
7628 tdata->aad.len, tdata->auth_tag.len,
7633 ut_params->op->sym->m_src = ut_params->ibuf;
7635 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
7636 RTE_CRYPTO_OP_SESSIONLESS,
7637 "crypto op session type not sessionless");
7639 /* Process crypto operation */
7640 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7641 ut_params->op), "failed to process sym crypto op");
7643 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7645 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7646 "crypto op status not success");
7648 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7649 ut_params->op->sym->cipher.data.offset);
7651 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7654 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7656 tdata->plaintext.data,
7657 tdata->plaintext.len,
7658 "Plaintext data not as expected");
7660 TEST_ASSERT_EQUAL(ut_params->op->status,
7661 RTE_CRYPTO_OP_STATUS_SUCCESS,
7662 "Authentication failed");
7667 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
7669 return test_authenticated_decryption_sessionless(
7674 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
7676 return test_authenticated_encryption(&ccm_test_case_128_1);
7680 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
7682 return test_authenticated_encryption(&ccm_test_case_128_2);
7686 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
7688 return test_authenticated_encryption(&ccm_test_case_128_3);
7692 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
7694 return test_authenticated_decryption(&ccm_test_case_128_1);
7698 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
7700 return test_authenticated_decryption(&ccm_test_case_128_2);
7704 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
7706 return test_authenticated_decryption(&ccm_test_case_128_3);
7710 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
7712 return test_authenticated_encryption(&ccm_test_case_192_1);
7716 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
7718 return test_authenticated_encryption(&ccm_test_case_192_2);
7722 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
7724 return test_authenticated_encryption(&ccm_test_case_192_3);
7728 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
7730 return test_authenticated_decryption(&ccm_test_case_192_1);
7734 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
7736 return test_authenticated_decryption(&ccm_test_case_192_2);
7740 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
7742 return test_authenticated_decryption(&ccm_test_case_192_3);
7746 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
7748 return test_authenticated_encryption(&ccm_test_case_256_1);
7752 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
7754 return test_authenticated_encryption(&ccm_test_case_256_2);
7758 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
7760 return test_authenticated_encryption(&ccm_test_case_256_3);
7764 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
7766 return test_authenticated_decryption(&ccm_test_case_256_1);
7770 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
7772 return test_authenticated_decryption(&ccm_test_case_256_2);
7776 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
7778 return test_authenticated_decryption(&ccm_test_case_256_3);
7784 struct crypto_testsuite_params *ts_params = &testsuite_params;
7785 struct rte_cryptodev_stats stats;
7786 struct rte_cryptodev *dev;
7787 cryptodev_stats_get_t temp_pfn;
7789 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7790 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
7791 &stats) == -ENODEV),
7792 "rte_cryptodev_stats_get invalid dev failed");
7793 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
7794 "rte_cryptodev_stats_get invalid Param failed");
7795 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
7796 temp_pfn = dev->dev_ops->stats_get;
7797 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
7798 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
7800 "rte_cryptodev_stats_get invalid Param failed");
7801 dev->dev_ops->stats_get = temp_pfn;
7803 /* Test expected values */
7805 test_AES_CBC_HMAC_SHA1_encrypt_digest();
7807 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7809 "rte_cryptodev_stats_get failed");
7810 TEST_ASSERT((stats.enqueued_count == 1),
7811 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7812 TEST_ASSERT((stats.dequeued_count == 1),
7813 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7814 TEST_ASSERT((stats.enqueue_err_count == 0),
7815 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7816 TEST_ASSERT((stats.dequeue_err_count == 0),
7817 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7819 /* invalid device but should ignore and not reset device stats*/
7820 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
7821 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7823 "rte_cryptodev_stats_get failed");
7824 TEST_ASSERT((stats.enqueued_count == 1),
7825 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7827 /* check that a valid reset clears stats */
7828 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7829 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7831 "rte_cryptodev_stats_get failed");
7832 TEST_ASSERT((stats.enqueued_count == 0),
7833 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7834 TEST_ASSERT((stats.dequeued_count == 0),
7835 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7837 return TEST_SUCCESS;
7840 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
7841 struct crypto_unittest_params *ut_params,
7842 enum rte_crypto_auth_operation op,
7843 const struct HMAC_MD5_vector *test_case)
7847 memcpy(key, test_case->key.data, test_case->key.len);
7849 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7850 ut_params->auth_xform.next = NULL;
7851 ut_params->auth_xform.auth.op = op;
7853 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
7855 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
7856 ut_params->auth_xform.auth.key.length = test_case->key.len;
7857 ut_params->auth_xform.auth.key.data = key;
7859 ut_params->sess = rte_cryptodev_sym_session_create(
7860 ts_params->session_mpool);
7862 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7863 ut_params->sess, &ut_params->auth_xform,
7864 ts_params->session_priv_mpool);
7866 if (ut_params->sess == NULL)
7869 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7871 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7872 rte_pktmbuf_tailroom(ut_params->ibuf));
7877 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
7878 const struct HMAC_MD5_vector *test_case,
7879 uint8_t **plaintext)
7881 uint16_t plaintext_pad_len;
7883 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7885 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7888 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7890 memcpy(*plaintext, test_case->plaintext.data,
7891 test_case->plaintext.len);
7893 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7894 ut_params->ibuf, MD5_DIGEST_LEN);
7895 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7896 "no room to append digest");
7897 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7898 ut_params->ibuf, plaintext_pad_len);
7900 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7901 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
7902 test_case->auth_tag.len);
7905 sym_op->auth.data.offset = 0;
7906 sym_op->auth.data.length = test_case->plaintext.len;
7908 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7909 ut_params->op->sym->m_src = ut_params->ibuf;
7915 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
7917 uint16_t plaintext_pad_len;
7918 uint8_t *plaintext, *auth_tag;
7920 struct crypto_testsuite_params *ts_params = &testsuite_params;
7921 struct crypto_unittest_params *ut_params = &unittest_params;
7923 if (MD5_HMAC_create_session(ts_params, ut_params,
7924 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
7927 /* Generate Crypto op data structure */
7928 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7929 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7930 TEST_ASSERT_NOT_NULL(ut_params->op,
7931 "Failed to allocate symmetric crypto operation struct");
7933 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7936 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7939 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7940 ut_params->op), "failed to process sym crypto op");
7942 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7943 "crypto op processing failed");
7945 if (ut_params->op->sym->m_dst) {
7946 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7947 uint8_t *, plaintext_pad_len);
7949 auth_tag = plaintext + plaintext_pad_len;
7952 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7954 test_case->auth_tag.data,
7955 test_case->auth_tag.len,
7956 "HMAC_MD5 generated tag not as expected");
7958 return TEST_SUCCESS;
7962 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
7966 struct crypto_testsuite_params *ts_params = &testsuite_params;
7967 struct crypto_unittest_params *ut_params = &unittest_params;
7969 if (MD5_HMAC_create_session(ts_params, ut_params,
7970 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
7974 /* Generate Crypto op data structure */
7975 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7976 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7977 TEST_ASSERT_NOT_NULL(ut_params->op,
7978 "Failed to allocate symmetric crypto operation struct");
7980 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7983 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7984 ut_params->op), "failed to process sym crypto op");
7986 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7987 "HMAC_MD5 crypto op processing failed");
7989 return TEST_SUCCESS;
7993 test_MD5_HMAC_generate_case_1(void)
7995 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
7999 test_MD5_HMAC_verify_case_1(void)
8001 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
8005 test_MD5_HMAC_generate_case_2(void)
8007 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8011 test_MD5_HMAC_verify_case_2(void)
8013 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8017 test_multi_session(void)
8019 struct crypto_testsuite_params *ts_params = &testsuite_params;
8020 struct crypto_unittest_params *ut_params = &unittest_params;
8022 struct rte_cryptodev_info dev_info;
8023 struct rte_cryptodev_sym_session **sessions;
8027 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8028 aes_cbc_key, hmac_sha512_key);
8031 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8033 sessions = rte_malloc(NULL,
8034 (sizeof(struct rte_cryptodev_sym_session *) *
8035 MAX_NB_SESSIONS) + 1, 0);
8037 /* Create multiple crypto sessions*/
8038 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8040 sessions[i] = rte_cryptodev_sym_session_create(
8041 ts_params->session_mpool);
8043 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8044 sessions[i], &ut_params->auth_xform,
8045 ts_params->session_priv_mpool);
8046 TEST_ASSERT_NOT_NULL(sessions[i],
8047 "Session creation failed at session number %u",
8050 /* Attempt to send a request on each session */
8051 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
8055 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
8056 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
8058 "Failed to perform decrypt on request number %u.", i);
8059 /* free crypto operation structure */
8061 rte_crypto_op_free(ut_params->op);
8064 * free mbuf - both obuf and ibuf are usually the same,
8065 * so check if they point at the same address is necessary,
8066 * to avoid freeing the mbuf twice.
8068 if (ut_params->obuf) {
8069 rte_pktmbuf_free(ut_params->obuf);
8070 if (ut_params->ibuf == ut_params->obuf)
8071 ut_params->ibuf = 0;
8072 ut_params->obuf = 0;
8074 if (ut_params->ibuf) {
8075 rte_pktmbuf_free(ut_params->ibuf);
8076 ut_params->ibuf = 0;
8080 /* Next session create should fail */
8081 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8082 sessions[i], &ut_params->auth_xform,
8083 ts_params->session_priv_mpool);
8084 TEST_ASSERT_NULL(sessions[i],
8085 "Session creation succeeded unexpectedly!");
8087 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8088 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8090 rte_cryptodev_sym_session_free(sessions[i]);
8095 return TEST_SUCCESS;
8098 struct multi_session_params {
8099 struct crypto_unittest_params ut_params;
8100 uint8_t *cipher_key;
8102 const uint8_t *cipher;
8103 const uint8_t *digest;
8107 #define MB_SESSION_NUMBER 3
8110 test_multi_session_random_usage(void)
8112 struct crypto_testsuite_params *ts_params = &testsuite_params;
8113 struct rte_cryptodev_info dev_info;
8114 struct rte_cryptodev_sym_session **sessions;
8116 struct multi_session_params ut_paramz[] = {
8119 .cipher_key = ms_aes_cbc_key0,
8120 .hmac_key = ms_hmac_key0,
8121 .cipher = ms_aes_cbc_cipher0,
8122 .digest = ms_hmac_digest0,
8123 .iv = ms_aes_cbc_iv0
8126 .cipher_key = ms_aes_cbc_key1,
8127 .hmac_key = ms_hmac_key1,
8128 .cipher = ms_aes_cbc_cipher1,
8129 .digest = ms_hmac_digest1,
8130 .iv = ms_aes_cbc_iv1
8133 .cipher_key = ms_aes_cbc_key2,
8134 .hmac_key = ms_hmac_key2,
8135 .cipher = ms_aes_cbc_cipher2,
8136 .digest = ms_hmac_digest2,
8137 .iv = ms_aes_cbc_iv2
8142 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8144 sessions = rte_malloc(NULL,
8145 (sizeof(struct rte_cryptodev_sym_session *)
8146 * MAX_NB_SESSIONS) + 1, 0);
8148 for (i = 0; i < MB_SESSION_NUMBER; i++) {
8149 sessions[i] = rte_cryptodev_sym_session_create(
8150 ts_params->session_mpool);
8152 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
8153 sizeof(struct crypto_unittest_params));
8155 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
8156 &ut_paramz[i].ut_params,
8157 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
8159 /* Create multiple crypto sessions*/
8160 rte_cryptodev_sym_session_init(
8161 ts_params->valid_devs[0],
8163 &ut_paramz[i].ut_params.auth_xform,
8164 ts_params->session_priv_mpool);
8166 TEST_ASSERT_NOT_NULL(sessions[i],
8167 "Session creation failed at session number %u",
8173 for (i = 0; i < 40000; i++) {
8175 j = rand() % MB_SESSION_NUMBER;
8177 TEST_ASSERT_SUCCESS(
8178 test_AES_CBC_HMAC_SHA512_decrypt_perform(
8180 &ut_paramz[j].ut_params,
8181 ts_params, ut_paramz[j].cipher,
8182 ut_paramz[j].digest,
8184 "Failed to perform decrypt on request number %u.", i);
8186 if (ut_paramz[j].ut_params.op)
8187 rte_crypto_op_free(ut_paramz[j].ut_params.op);
8190 * free mbuf - both obuf and ibuf are usually the same,
8191 * so check if they point at the same address is necessary,
8192 * to avoid freeing the mbuf twice.
8194 if (ut_paramz[j].ut_params.obuf) {
8195 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
8196 if (ut_paramz[j].ut_params.ibuf
8197 == ut_paramz[j].ut_params.obuf)
8198 ut_paramz[j].ut_params.ibuf = 0;
8199 ut_paramz[j].ut_params.obuf = 0;
8201 if (ut_paramz[j].ut_params.ibuf) {
8202 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
8203 ut_paramz[j].ut_params.ibuf = 0;
8207 for (i = 0; i < MB_SESSION_NUMBER; i++) {
8208 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8210 rte_cryptodev_sym_session_free(sessions[i]);
8215 return TEST_SUCCESS;
8219 test_null_cipher_only_operation(void)
8221 struct crypto_testsuite_params *ts_params = &testsuite_params;
8222 struct crypto_unittest_params *ut_params = &unittest_params;
8224 /* Generate test mbuf data and space for digest */
8225 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8226 catch_22_quote, QUOTE_512_BYTES, 0);
8228 /* Setup Cipher Parameters */
8229 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8230 ut_params->cipher_xform.next = NULL;
8232 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8233 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8235 ut_params->sess = rte_cryptodev_sym_session_create(
8236 ts_params->session_mpool);
8238 /* Create Crypto session*/
8239 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8241 &ut_params->cipher_xform,
8242 ts_params->session_priv_mpool);
8243 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8245 /* Generate Crypto op data structure */
8246 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8247 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8248 TEST_ASSERT_NOT_NULL(ut_params->op,
8249 "Failed to allocate symmetric crypto operation struct");
8251 /* Set crypto operation data parameters */
8252 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8254 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8256 /* set crypto operation source mbuf */
8257 sym_op->m_src = ut_params->ibuf;
8259 sym_op->cipher.data.offset = 0;
8260 sym_op->cipher.data.length = QUOTE_512_BYTES;
8262 /* Process crypto operation */
8263 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8265 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8267 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8268 "crypto operation processing failed");
8271 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8272 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8275 "Ciphertext data not as expected");
8277 return TEST_SUCCESS;
8279 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
8280 0xab, 0xab, 0xab, 0xab,
8281 0xab, 0xab, 0xab, 0xab,
8282 0xab, 0xab, 0xab, 0xab};
8284 test_null_auth_only_operation(void)
8286 struct crypto_testsuite_params *ts_params = &testsuite_params;
8287 struct crypto_unittest_params *ut_params = &unittest_params;
8290 /* Generate test mbuf data and space for digest */
8291 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8292 catch_22_quote, QUOTE_512_BYTES, 0);
8294 /* create a pointer for digest, but don't expect anything to be written
8295 * here in a NULL auth algo so no mbuf append done.
8297 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8299 /* prefill the memory pointed to by digest */
8300 memcpy(digest, orig_data, sizeof(orig_data));
8302 /* Setup HMAC Parameters */
8303 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8304 ut_params->auth_xform.next = NULL;
8306 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8307 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8309 ut_params->sess = rte_cryptodev_sym_session_create(
8310 ts_params->session_mpool);
8312 /* Create Crypto session*/
8313 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8314 ut_params->sess, &ut_params->auth_xform,
8315 ts_params->session_priv_mpool);
8316 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8318 /* Generate Crypto op data structure */
8319 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8320 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8321 TEST_ASSERT_NOT_NULL(ut_params->op,
8322 "Failed to allocate symmetric crypto operation struct");
8324 /* Set crypto operation data parameters */
8325 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8327 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8329 sym_op->m_src = ut_params->ibuf;
8331 sym_op->auth.data.offset = 0;
8332 sym_op->auth.data.length = QUOTE_512_BYTES;
8333 sym_op->auth.digest.data = digest;
8334 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8337 /* Process crypto operation */
8338 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8340 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8342 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8343 "crypto operation processing failed");
8344 /* Make sure memory pointed to by digest hasn't been overwritten */
8345 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8349 "Memory at digest ptr overwritten unexpectedly");
8351 return TEST_SUCCESS;
8356 test_null_cipher_auth_operation(void)
8358 struct crypto_testsuite_params *ts_params = &testsuite_params;
8359 struct crypto_unittest_params *ut_params = &unittest_params;
8362 /* Generate test mbuf data and space for digest */
8363 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8364 catch_22_quote, QUOTE_512_BYTES, 0);
8366 /* create a pointer for digest, but don't expect anything to be written
8367 * here in a NULL auth algo so no mbuf append done.
8369 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8371 /* prefill the memory pointed to by digest */
8372 memcpy(digest, orig_data, sizeof(orig_data));
8374 /* Setup Cipher Parameters */
8375 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8376 ut_params->cipher_xform.next = &ut_params->auth_xform;
8378 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8379 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8381 /* Setup HMAC Parameters */
8382 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8383 ut_params->auth_xform.next = NULL;
8385 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8386 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8388 ut_params->sess = rte_cryptodev_sym_session_create(
8389 ts_params->session_mpool);
8391 /* Create Crypto session*/
8392 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8393 ut_params->sess, &ut_params->cipher_xform,
8394 ts_params->session_priv_mpool);
8395 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8397 /* Generate Crypto op data structure */
8398 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8399 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8400 TEST_ASSERT_NOT_NULL(ut_params->op,
8401 "Failed to allocate symmetric crypto operation struct");
8403 /* Set crypto operation data parameters */
8404 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8406 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8408 sym_op->m_src = ut_params->ibuf;
8410 sym_op->cipher.data.offset = 0;
8411 sym_op->cipher.data.length = QUOTE_512_BYTES;
8413 sym_op->auth.data.offset = 0;
8414 sym_op->auth.data.length = QUOTE_512_BYTES;
8415 sym_op->auth.digest.data = digest;
8416 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8419 /* Process crypto operation */
8420 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8422 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8424 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8425 "crypto operation processing failed");
8428 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8429 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8432 "Ciphertext data not as expected");
8433 /* Make sure memory pointed to by digest hasn't been overwritten */
8434 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8438 "Memory at digest ptr overwritten unexpectedly");
8440 return TEST_SUCCESS;
8444 test_null_auth_cipher_operation(void)
8446 struct crypto_testsuite_params *ts_params = &testsuite_params;
8447 struct crypto_unittest_params *ut_params = &unittest_params;
8450 /* Generate test mbuf data */
8451 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8452 catch_22_quote, QUOTE_512_BYTES, 0);
8454 /* create a pointer for digest, but don't expect anything to be written
8455 * here in a NULL auth algo so no mbuf append done.
8457 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8459 /* prefill the memory pointed to by digest */
8460 memcpy(digest, orig_data, sizeof(orig_data));
8462 /* Setup Cipher Parameters */
8463 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8464 ut_params->cipher_xform.next = NULL;
8466 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8467 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8469 /* Setup HMAC Parameters */
8470 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8471 ut_params->auth_xform.next = &ut_params->cipher_xform;
8473 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8474 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8476 ut_params->sess = rte_cryptodev_sym_session_create(
8477 ts_params->session_mpool);
8479 /* Create Crypto session*/
8480 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8481 ut_params->sess, &ut_params->cipher_xform,
8482 ts_params->session_priv_mpool);
8483 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8485 /* Generate Crypto op data structure */
8486 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8487 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8488 TEST_ASSERT_NOT_NULL(ut_params->op,
8489 "Failed to allocate symmetric crypto operation struct");
8491 /* Set crypto operation data parameters */
8492 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8494 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8496 sym_op->m_src = ut_params->ibuf;
8498 sym_op->cipher.data.offset = 0;
8499 sym_op->cipher.data.length = QUOTE_512_BYTES;
8501 sym_op->auth.data.offset = 0;
8502 sym_op->auth.data.length = QUOTE_512_BYTES;
8503 sym_op->auth.digest.data = digest;
8504 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8507 /* Process crypto operation */
8508 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8510 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8512 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8513 "crypto operation processing failed");
8516 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8517 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8520 "Ciphertext data not as expected");
8521 /* Make sure memory pointed to by digest hasn't been overwritten */
8522 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8526 "Memory at digest ptr overwritten unexpectedly");
8528 return TEST_SUCCESS;
8533 test_null_invalid_operation(void)
8535 struct crypto_testsuite_params *ts_params = &testsuite_params;
8536 struct crypto_unittest_params *ut_params = &unittest_params;
8539 /* Setup Cipher Parameters */
8540 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8541 ut_params->cipher_xform.next = NULL;
8543 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
8544 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8546 ut_params->sess = rte_cryptodev_sym_session_create(
8547 ts_params->session_mpool);
8549 /* Create Crypto session*/
8550 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8551 ut_params->sess, &ut_params->cipher_xform,
8552 ts_params->session_priv_mpool);
8553 TEST_ASSERT(ret < 0,
8554 "Session creation succeeded unexpectedly");
8557 /* Setup HMAC Parameters */
8558 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8559 ut_params->auth_xform.next = NULL;
8561 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
8562 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8564 ut_params->sess = rte_cryptodev_sym_session_create(
8565 ts_params->session_mpool);
8567 /* Create Crypto session*/
8568 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8569 ut_params->sess, &ut_params->auth_xform,
8570 ts_params->session_priv_mpool);
8571 TEST_ASSERT(ret < 0,
8572 "Session creation succeeded unexpectedly");
8574 return TEST_SUCCESS;
8578 #define NULL_BURST_LENGTH (32)
8581 test_null_burst_operation(void)
8583 struct crypto_testsuite_params *ts_params = &testsuite_params;
8584 struct crypto_unittest_params *ut_params = &unittest_params;
8586 unsigned i, burst_len = NULL_BURST_LENGTH;
8588 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
8589 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
8591 /* Setup Cipher Parameters */
8592 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8593 ut_params->cipher_xform.next = &ut_params->auth_xform;
8595 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8596 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8598 /* Setup HMAC Parameters */
8599 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8600 ut_params->auth_xform.next = NULL;
8602 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8603 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8605 ut_params->sess = rte_cryptodev_sym_session_create(
8606 ts_params->session_mpool);
8608 /* Create Crypto session*/
8609 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8610 ut_params->sess, &ut_params->cipher_xform,
8611 ts_params->session_priv_mpool);
8612 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8614 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
8615 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
8616 burst_len, "failed to generate burst of crypto ops");
8618 /* Generate an operation for each mbuf in burst */
8619 for (i = 0; i < burst_len; i++) {
8620 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8622 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
8624 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
8628 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
8630 burst[i]->sym->m_src = m;
8633 /* Process crypto operation */
8634 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
8635 0, burst, burst_len),
8637 "Error enqueuing burst");
8639 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
8640 0, burst_dequeued, burst_len),
8642 "Error dequeuing burst");
8645 for (i = 0; i < burst_len; i++) {
8647 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
8648 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
8650 "data not as expected");
8652 rte_pktmbuf_free(burst[i]->sym->m_src);
8653 rte_crypto_op_free(burst[i]);
8656 return TEST_SUCCESS;
8660 generate_gmac_large_plaintext(uint8_t *data)
8664 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
8665 memcpy(&data[i], &data[0], 32);
8669 create_gmac_operation(enum rte_crypto_auth_operation op,
8670 const struct gmac_test_data *tdata)
8672 struct crypto_testsuite_params *ts_params = &testsuite_params;
8673 struct crypto_unittest_params *ut_params = &unittest_params;
8674 struct rte_crypto_sym_op *sym_op;
8676 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8678 /* Generate Crypto op data structure */
8679 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8680 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8681 TEST_ASSERT_NOT_NULL(ut_params->op,
8682 "Failed to allocate symmetric crypto operation struct");
8684 sym_op = ut_params->op->sym;
8686 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8687 ut_params->ibuf, tdata->gmac_tag.len);
8688 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8689 "no room to append digest");
8691 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8692 ut_params->ibuf, plaintext_pad_len);
8694 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8695 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
8696 tdata->gmac_tag.len);
8697 debug_hexdump(stdout, "digest:",
8698 sym_op->auth.digest.data,
8699 tdata->gmac_tag.len);
8702 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8703 uint8_t *, IV_OFFSET);
8705 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8707 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
8709 sym_op->cipher.data.length = 0;
8710 sym_op->cipher.data.offset = 0;
8712 sym_op->auth.data.offset = 0;
8713 sym_op->auth.data.length = tdata->plaintext.len;
8718 static int create_gmac_session(uint8_t dev_id,
8719 const struct gmac_test_data *tdata,
8720 enum rte_crypto_auth_operation auth_op)
8722 uint8_t auth_key[tdata->key.len];
8724 struct crypto_testsuite_params *ts_params = &testsuite_params;
8725 struct crypto_unittest_params *ut_params = &unittest_params;
8727 memcpy(auth_key, tdata->key.data, tdata->key.len);
8729 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8730 ut_params->auth_xform.next = NULL;
8732 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
8733 ut_params->auth_xform.auth.op = auth_op;
8734 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
8735 ut_params->auth_xform.auth.key.length = tdata->key.len;
8736 ut_params->auth_xform.auth.key.data = auth_key;
8737 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
8738 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
8741 ut_params->sess = rte_cryptodev_sym_session_create(
8742 ts_params->session_mpool);
8744 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8745 &ut_params->auth_xform,
8746 ts_params->session_priv_mpool);
8748 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8754 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
8756 struct crypto_testsuite_params *ts_params = &testsuite_params;
8757 struct crypto_unittest_params *ut_params = &unittest_params;
8761 uint8_t *auth_tag, *plaintext;
8762 uint16_t plaintext_pad_len;
8764 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8765 "No GMAC length in the source data");
8767 retval = create_gmac_session(ts_params->valid_devs[0],
8768 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
8773 if (tdata->plaintext.len > MBUF_SIZE)
8774 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8776 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8777 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8778 "Failed to allocate input buffer in mempool");
8780 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8781 rte_pktmbuf_tailroom(ut_params->ibuf));
8783 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8785 * Runtime generate the large plain text instead of use hard code
8786 * plain text vector. It is done to avoid create huge source file
8787 * with the test vector.
8789 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8790 generate_gmac_large_plaintext(tdata->plaintext.data);
8792 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8794 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8796 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8797 debug_hexdump(stdout, "plaintext:", plaintext,
8798 tdata->plaintext.len);
8800 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
8806 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8808 ut_params->op->sym->m_src = ut_params->ibuf;
8810 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8811 ut_params->op), "failed to process sym crypto op");
8813 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8814 "crypto op processing failed");
8816 if (ut_params->op->sym->m_dst) {
8817 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8818 uint8_t *, plaintext_pad_len);
8820 auth_tag = plaintext + plaintext_pad_len;
8823 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
8825 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8827 tdata->gmac_tag.data,
8828 tdata->gmac_tag.len,
8829 "GMAC Generated auth tag not as expected");
8835 test_AES_GMAC_authentication_test_case_1(void)
8837 return test_AES_GMAC_authentication(&gmac_test_case_1);
8841 test_AES_GMAC_authentication_test_case_2(void)
8843 return test_AES_GMAC_authentication(&gmac_test_case_2);
8847 test_AES_GMAC_authentication_test_case_3(void)
8849 return test_AES_GMAC_authentication(&gmac_test_case_3);
8853 test_AES_GMAC_authentication_test_case_4(void)
8855 return test_AES_GMAC_authentication(&gmac_test_case_4);
8859 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
8861 struct crypto_testsuite_params *ts_params = &testsuite_params;
8862 struct crypto_unittest_params *ut_params = &unittest_params;
8864 uint32_t plaintext_pad_len;
8867 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8868 "No GMAC length in the source data");
8870 retval = create_gmac_session(ts_params->valid_devs[0],
8871 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
8876 if (tdata->plaintext.len > MBUF_SIZE)
8877 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8879 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8880 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8881 "Failed to allocate input buffer in mempool");
8883 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8884 rte_pktmbuf_tailroom(ut_params->ibuf));
8886 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8889 * Runtime generate the large plain text instead of use hard code
8890 * plain text vector. It is done to avoid create huge source file
8891 * with the test vector.
8893 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8894 generate_gmac_large_plaintext(tdata->plaintext.data);
8896 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8898 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8900 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8901 debug_hexdump(stdout, "plaintext:", plaintext,
8902 tdata->plaintext.len);
8904 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
8910 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8912 ut_params->op->sym->m_src = ut_params->ibuf;
8914 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8915 ut_params->op), "failed to process sym crypto op");
8917 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8918 "crypto op processing failed");
8925 test_AES_GMAC_authentication_verify_test_case_1(void)
8927 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
8931 test_AES_GMAC_authentication_verify_test_case_2(void)
8933 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
8937 test_AES_GMAC_authentication_verify_test_case_3(void)
8939 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
8943 test_AES_GMAC_authentication_verify_test_case_4(void)
8945 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
8948 struct test_crypto_vector {
8949 enum rte_crypto_cipher_algorithm crypto_algo;
8962 const uint8_t *data;
8967 const uint8_t *data;
8971 enum rte_crypto_auth_algorithm auth_algo;
8979 const uint8_t *data;
8989 static const struct test_crypto_vector
8990 hmac_sha1_test_crypto_vector = {
8991 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
8993 .data = plaintext_hash,
8998 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
8999 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9000 0xDE, 0xF4, 0xDE, 0xAD
9006 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
9007 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
9008 0x3F, 0x91, 0x64, 0x59
9014 static const struct test_crypto_vector
9015 aes128_gmac_test_vector = {
9016 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
9018 .data = plaintext_hash,
9023 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9024 0x08, 0x09, 0x0A, 0x0B
9030 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9031 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
9037 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
9038 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
9044 static const struct test_crypto_vector
9045 aes128cbc_hmac_sha1_test_vector = {
9046 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9049 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9050 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9056 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9057 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
9062 .data = plaintext_hash,
9066 .data = ciphertext512_aes128cbc,
9069 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9072 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9073 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9074 0xDE, 0xF4, 0xDE, 0xAD
9080 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
9081 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9082 0x18, 0x8C, 0x1D, 0x32
9089 data_corruption(uint8_t *data)
9095 tag_corruption(uint8_t *data, unsigned int tag_offset)
9097 data[tag_offset] += 1;
9101 create_auth_session(struct crypto_unittest_params *ut_params,
9103 const struct test_crypto_vector *reference,
9104 enum rte_crypto_auth_operation auth_op)
9106 struct crypto_testsuite_params *ts_params = &testsuite_params;
9107 uint8_t auth_key[reference->auth_key.len + 1];
9109 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9111 /* Setup Authentication Parameters */
9112 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9113 ut_params->auth_xform.auth.op = auth_op;
9114 ut_params->auth_xform.next = NULL;
9115 ut_params->auth_xform.auth.algo = reference->auth_algo;
9116 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9117 ut_params->auth_xform.auth.key.data = auth_key;
9118 ut_params->auth_xform.auth.digest_length = reference->digest.len;
9120 /* Create Crypto session*/
9121 ut_params->sess = rte_cryptodev_sym_session_create(
9122 ts_params->session_mpool);
9124 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9125 &ut_params->auth_xform,
9126 ts_params->session_priv_mpool);
9128 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9134 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
9136 const struct test_crypto_vector *reference,
9137 enum rte_crypto_auth_operation auth_op,
9138 enum rte_crypto_cipher_operation cipher_op)
9140 struct crypto_testsuite_params *ts_params = &testsuite_params;
9141 uint8_t cipher_key[reference->cipher_key.len + 1];
9142 uint8_t auth_key[reference->auth_key.len + 1];
9144 memcpy(cipher_key, reference->cipher_key.data,
9145 reference->cipher_key.len);
9146 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9148 /* Setup Authentication Parameters */
9149 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9150 ut_params->auth_xform.auth.op = auth_op;
9151 ut_params->auth_xform.auth.algo = reference->auth_algo;
9152 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9153 ut_params->auth_xform.auth.key.data = auth_key;
9154 ut_params->auth_xform.auth.digest_length = reference->digest.len;
9156 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
9157 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9158 ut_params->auth_xform.auth.iv.length = reference->iv.len;
9160 ut_params->auth_xform.next = &ut_params->cipher_xform;
9162 /* Setup Cipher Parameters */
9163 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9164 ut_params->cipher_xform.next = NULL;
9165 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
9166 ut_params->cipher_xform.cipher.op = cipher_op;
9167 ut_params->cipher_xform.cipher.key.data = cipher_key;
9168 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
9169 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9170 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
9173 /* Create Crypto session*/
9174 ut_params->sess = rte_cryptodev_sym_session_create(
9175 ts_params->session_mpool);
9177 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9178 &ut_params->auth_xform,
9179 ts_params->session_priv_mpool);
9181 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9187 create_auth_operation(struct crypto_testsuite_params *ts_params,
9188 struct crypto_unittest_params *ut_params,
9189 const struct test_crypto_vector *reference,
9190 unsigned int auth_generate)
9192 /* Generate Crypto op data structure */
9193 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9194 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9195 TEST_ASSERT_NOT_NULL(ut_params->op,
9196 "Failed to allocate pktmbuf offload");
9198 /* Set crypto operation data parameters */
9199 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9201 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9203 /* set crypto operation source mbuf */
9204 sym_op->m_src = ut_params->ibuf;
9207 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9208 ut_params->ibuf, reference->digest.len);
9210 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9211 "no room to append auth tag");
9213 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9214 ut_params->ibuf, reference->plaintext.len);
9217 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9219 memcpy(sym_op->auth.digest.data,
9220 reference->digest.data,
9221 reference->digest.len);
9223 debug_hexdump(stdout, "digest:",
9224 sym_op->auth.digest.data,
9225 reference->digest.len);
9227 sym_op->auth.data.length = reference->plaintext.len;
9228 sym_op->auth.data.offset = 0;
9234 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
9235 struct crypto_unittest_params *ut_params,
9236 const struct test_crypto_vector *reference,
9237 unsigned int auth_generate)
9239 /* Generate Crypto op data structure */
9240 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9241 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9242 TEST_ASSERT_NOT_NULL(ut_params->op,
9243 "Failed to allocate pktmbuf offload");
9245 /* Set crypto operation data parameters */
9246 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9248 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9250 /* set crypto operation source mbuf */
9251 sym_op->m_src = ut_params->ibuf;
9254 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9255 ut_params->ibuf, reference->digest.len);
9257 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9258 "no room to append auth tag");
9260 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9261 ut_params->ibuf, reference->ciphertext.len);
9264 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9266 memcpy(sym_op->auth.digest.data,
9267 reference->digest.data,
9268 reference->digest.len);
9270 debug_hexdump(stdout, "digest:",
9271 sym_op->auth.digest.data,
9272 reference->digest.len);
9274 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
9275 reference->iv.data, reference->iv.len);
9277 sym_op->cipher.data.length = 0;
9278 sym_op->cipher.data.offset = 0;
9280 sym_op->auth.data.length = reference->plaintext.len;
9281 sym_op->auth.data.offset = 0;
9287 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
9288 struct crypto_unittest_params *ut_params,
9289 const struct test_crypto_vector *reference,
9290 unsigned int auth_generate)
9292 /* Generate Crypto op data structure */
9293 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9294 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9295 TEST_ASSERT_NOT_NULL(ut_params->op,
9296 "Failed to allocate pktmbuf offload");
9298 /* Set crypto operation data parameters */
9299 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9301 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9303 /* set crypto operation source mbuf */
9304 sym_op->m_src = ut_params->ibuf;
9307 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9308 ut_params->ibuf, reference->digest.len);
9310 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9311 "no room to append auth tag");
9313 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9314 ut_params->ibuf, reference->ciphertext.len);
9317 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9319 memcpy(sym_op->auth.digest.data,
9320 reference->digest.data,
9321 reference->digest.len);
9323 debug_hexdump(stdout, "digest:",
9324 sym_op->auth.digest.data,
9325 reference->digest.len);
9327 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
9328 reference->iv.data, reference->iv.len);
9330 sym_op->cipher.data.length = reference->ciphertext.len;
9331 sym_op->cipher.data.offset = 0;
9333 sym_op->auth.data.length = reference->ciphertext.len;
9334 sym_op->auth.data.offset = 0;
9340 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
9341 struct crypto_unittest_params *ut_params,
9342 const struct test_crypto_vector *reference)
9344 return create_auth_operation(ts_params, ut_params, reference, 0);
9348 create_auth_verify_GMAC_operation(
9349 struct crypto_testsuite_params *ts_params,
9350 struct crypto_unittest_params *ut_params,
9351 const struct test_crypto_vector *reference)
9353 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
9357 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
9358 struct crypto_unittest_params *ut_params,
9359 const struct test_crypto_vector *reference)
9361 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
9365 test_authentication_verify_fail_when_data_corruption(
9366 struct crypto_testsuite_params *ts_params,
9367 struct crypto_unittest_params *ut_params,
9368 const struct test_crypto_vector *reference,
9369 unsigned int data_corrupted)
9375 /* Create session */
9376 retval = create_auth_session(ut_params,
9377 ts_params->valid_devs[0],
9379 RTE_CRYPTO_AUTH_OP_VERIFY);
9383 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9384 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9385 "Failed to allocate input buffer in mempool");
9387 /* clear mbuf payload */
9388 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9389 rte_pktmbuf_tailroom(ut_params->ibuf));
9391 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9392 reference->plaintext.len);
9393 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9394 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
9396 debug_hexdump(stdout, "plaintext:", plaintext,
9397 reference->plaintext.len);
9399 /* Create operation */
9400 retval = create_auth_verify_operation(ts_params, ut_params, reference);
9406 data_corruption(plaintext);
9408 tag_corruption(plaintext, reference->plaintext.len);
9410 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9412 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9413 TEST_ASSERT_EQUAL(ut_params->op->status,
9414 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9415 "authentication not failed");
9417 ut_params->obuf = ut_params->op->sym->m_src;
9418 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9424 test_authentication_verify_GMAC_fail_when_corruption(
9425 struct crypto_testsuite_params *ts_params,
9426 struct crypto_unittest_params *ut_params,
9427 const struct test_crypto_vector *reference,
9428 unsigned int data_corrupted)
9433 /* Create session */
9434 retval = create_auth_cipher_session(ut_params,
9435 ts_params->valid_devs[0],
9437 RTE_CRYPTO_AUTH_OP_VERIFY,
9438 RTE_CRYPTO_CIPHER_OP_DECRYPT);
9442 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9443 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9444 "Failed to allocate input buffer in mempool");
9446 /* clear mbuf payload */
9447 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9448 rte_pktmbuf_tailroom(ut_params->ibuf));
9450 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9451 reference->plaintext.len);
9452 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9453 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
9455 debug_hexdump(stdout, "plaintext:", plaintext,
9456 reference->plaintext.len);
9458 /* Create operation */
9459 retval = create_auth_verify_GMAC_operation(ts_params,
9467 data_corruption(plaintext);
9469 tag_corruption(plaintext, reference->aad.len);
9471 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9473 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9474 TEST_ASSERT_EQUAL(ut_params->op->status,
9475 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9476 "authentication not failed");
9478 ut_params->obuf = ut_params->op->sym->m_src;
9479 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9485 test_authenticated_decryption_fail_when_corruption(
9486 struct crypto_testsuite_params *ts_params,
9487 struct crypto_unittest_params *ut_params,
9488 const struct test_crypto_vector *reference,
9489 unsigned int data_corrupted)
9493 uint8_t *ciphertext;
9495 /* Create session */
9496 retval = create_auth_cipher_session(ut_params,
9497 ts_params->valid_devs[0],
9499 RTE_CRYPTO_AUTH_OP_VERIFY,
9500 RTE_CRYPTO_CIPHER_OP_DECRYPT);
9504 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9505 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9506 "Failed to allocate input buffer in mempool");
9508 /* clear mbuf payload */
9509 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9510 rte_pktmbuf_tailroom(ut_params->ibuf));
9512 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9513 reference->ciphertext.len);
9514 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
9515 memcpy(ciphertext, reference->ciphertext.data,
9516 reference->ciphertext.len);
9518 /* Create operation */
9519 retval = create_cipher_auth_verify_operation(ts_params,
9527 data_corruption(ciphertext);
9529 tag_corruption(ciphertext, reference->ciphertext.len);
9531 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9534 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9535 TEST_ASSERT_EQUAL(ut_params->op->status,
9536 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
9537 "authentication not failed");
9539 ut_params->obuf = ut_params->op->sym->m_src;
9540 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
9546 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
9547 const struct aead_test_data *tdata,
9548 void *digest_mem, uint64_t digest_phys)
9550 struct crypto_testsuite_params *ts_params = &testsuite_params;
9551 struct crypto_unittest_params *ut_params = &unittest_params;
9553 const unsigned int auth_tag_len = tdata->auth_tag.len;
9554 const unsigned int iv_len = tdata->iv.len;
9555 unsigned int aad_len = tdata->aad.len;
9557 /* Generate Crypto op data structure */
9558 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9559 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9560 TEST_ASSERT_NOT_NULL(ut_params->op,
9561 "Failed to allocate symmetric crypto operation struct");
9563 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9565 sym_op->aead.digest.data = digest_mem;
9567 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9568 "no room to append digest");
9570 sym_op->aead.digest.phys_addr = digest_phys;
9572 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
9573 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9575 debug_hexdump(stdout, "digest:",
9576 sym_op->aead.digest.data,
9580 /* Append aad data */
9581 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9582 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9583 uint8_t *, IV_OFFSET);
9585 /* Copy IV 1 byte after the IV pointer, according to the API */
9586 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
9588 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
9590 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
9591 ut_params->ibuf, aad_len);
9592 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9593 "no room to prepend aad");
9594 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
9597 memset(sym_op->aead.aad.data, 0, aad_len);
9598 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
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);
9605 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9606 uint8_t *, IV_OFFSET);
9608 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
9610 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
9611 ut_params->ibuf, aad_len);
9612 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9613 "no room to prepend aad");
9614 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
9617 memset(sym_op->aead.aad.data, 0, aad_len);
9618 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
9620 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
9621 debug_hexdump(stdout, "aad:",
9622 sym_op->aead.aad.data, aad_len);
9625 sym_op->aead.data.length = tdata->plaintext.len;
9626 sym_op->aead.data.offset = aad_len;
9631 #define SGL_MAX_NO 16
9634 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
9635 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
9637 struct crypto_testsuite_params *ts_params = &testsuite_params;
9638 struct crypto_unittest_params *ut_params = &unittest_params;
9639 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
9642 int to_trn_tbl[SGL_MAX_NO];
9644 unsigned int trn_data = 0;
9645 uint8_t *plaintext, *ciphertext, *auth_tag;
9647 if (fragsz > tdata->plaintext.len)
9648 fragsz = tdata->plaintext.len;
9650 uint16_t plaintext_len = fragsz;
9651 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9653 if (fragsz_oop > tdata->plaintext.len)
9654 frag_size_oop = tdata->plaintext.len;
9657 void *digest_mem = NULL;
9659 uint32_t prepend_len = tdata->aad.len;
9661 if (tdata->plaintext.len % fragsz != 0) {
9662 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
9665 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
9670 * For out-op-place we need to alloc another mbuf
9673 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9674 rte_pktmbuf_append(ut_params->obuf,
9675 frag_size_oop + prepend_len);
9676 buf_oop = ut_params->obuf;
9679 /* Create AEAD session */
9680 retval = create_aead_session(ts_params->valid_devs[0],
9682 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9683 tdata->key.data, tdata->key.len,
9684 tdata->aad.len, tdata->auth_tag.len,
9689 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9691 /* clear mbuf payload */
9692 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9693 rte_pktmbuf_tailroom(ut_params->ibuf));
9695 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9698 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
9700 trn_data += plaintext_len;
9702 buf = ut_params->ibuf;
9705 * Loop until no more fragments
9708 while (trn_data < tdata->plaintext.len) {
9710 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
9711 (tdata->plaintext.len - trn_data) : fragsz;
9713 to_trn_tbl[ecx++] = to_trn;
9715 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9718 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9719 rte_pktmbuf_tailroom(buf));
9722 if (oop && !fragsz_oop) {
9723 buf_last_oop = buf_oop->next =
9724 rte_pktmbuf_alloc(ts_params->mbuf_pool);
9725 buf_oop = buf_oop->next;
9726 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9727 0, rte_pktmbuf_tailroom(buf_oop));
9728 rte_pktmbuf_append(buf_oop, to_trn);
9731 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9734 memcpy(plaintext, tdata->plaintext.data + trn_data,
9737 if (trn_data == tdata->plaintext.len) {
9740 digest_mem = rte_pktmbuf_append(buf_oop,
9741 tdata->auth_tag.len);
9743 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
9744 tdata->auth_tag.len);
9748 uint64_t digest_phys = 0;
9750 ut_params->ibuf->nb_segs = segs;
9753 if (fragsz_oop && oop) {
9757 if (frag_size_oop == tdata->plaintext.len) {
9758 digest_mem = rte_pktmbuf_append(ut_params->obuf,
9759 tdata->auth_tag.len);
9761 digest_phys = rte_pktmbuf_iova_offset(
9763 tdata->plaintext.len + prepend_len);
9766 trn_data = frag_size_oop;
9767 while (trn_data < tdata->plaintext.len) {
9770 (tdata->plaintext.len - trn_data <
9772 (tdata->plaintext.len - trn_data) :
9775 to_trn_tbl[ecx++] = to_trn;
9777 buf_last_oop = buf_oop->next =
9778 rte_pktmbuf_alloc(ts_params->mbuf_pool);
9779 buf_oop = buf_oop->next;
9780 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9781 0, rte_pktmbuf_tailroom(buf_oop));
9782 rte_pktmbuf_append(buf_oop, to_trn);
9786 if (trn_data == tdata->plaintext.len) {
9787 digest_mem = rte_pktmbuf_append(buf_oop,
9788 tdata->auth_tag.len);
9792 ut_params->obuf->nb_segs = segs;
9796 * Place digest at the end of the last buffer
9799 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
9800 if (oop && buf_last_oop)
9801 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
9803 if (!digest_mem && !oop) {
9804 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9805 + tdata->auth_tag.len);
9806 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
9807 tdata->plaintext.len);
9810 /* Create AEAD operation */
9811 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
9812 tdata, digest_mem, digest_phys);
9817 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9819 ut_params->op->sym->m_src = ut_params->ibuf;
9821 ut_params->op->sym->m_dst = ut_params->obuf;
9823 /* Process crypto operation */
9824 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9825 ut_params->op), "failed to process sym crypto op");
9827 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9828 "crypto op processing failed");
9831 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9832 uint8_t *, prepend_len);
9834 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9835 uint8_t *, prepend_len);
9839 fragsz = fragsz_oop;
9841 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9843 tdata->ciphertext.data,
9845 "Ciphertext data not as expected");
9847 buf = ut_params->op->sym->m_src->next;
9849 buf = ut_params->op->sym->m_dst->next;
9851 unsigned int off = fragsz;
9855 ciphertext = rte_pktmbuf_mtod(buf,
9858 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9860 tdata->ciphertext.data + off,
9862 "Ciphertext data not as expected");
9864 off += to_trn_tbl[ecx++];
9868 auth_tag = digest_mem;
9869 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9871 tdata->auth_tag.data,
9872 tdata->auth_tag.len,
9873 "Generated auth tag not as expected");
9879 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
9881 return test_authenticated_encryption_SGL(
9882 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
9886 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
9888 return test_authenticated_encryption_SGL(
9889 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
9893 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
9895 return test_authenticated_encryption_SGL(
9896 &gcm_test_case_8, OUT_OF_PLACE, 400,
9897 gcm_test_case_8.plaintext.len);
9901 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
9904 return test_authenticated_encryption_SGL(
9905 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
9909 test_authentication_verify_fail_when_data_corrupted(
9910 struct crypto_testsuite_params *ts_params,
9911 struct crypto_unittest_params *ut_params,
9912 const struct test_crypto_vector *reference)
9914 return test_authentication_verify_fail_when_data_corruption(
9915 ts_params, ut_params, reference, 1);
9919 test_authentication_verify_fail_when_tag_corrupted(
9920 struct crypto_testsuite_params *ts_params,
9921 struct crypto_unittest_params *ut_params,
9922 const struct test_crypto_vector *reference)
9924 return test_authentication_verify_fail_when_data_corruption(
9925 ts_params, ut_params, reference, 0);
9929 test_authentication_verify_GMAC_fail_when_data_corrupted(
9930 struct crypto_testsuite_params *ts_params,
9931 struct crypto_unittest_params *ut_params,
9932 const struct test_crypto_vector *reference)
9934 return test_authentication_verify_GMAC_fail_when_corruption(
9935 ts_params, ut_params, reference, 1);
9939 test_authentication_verify_GMAC_fail_when_tag_corrupted(
9940 struct crypto_testsuite_params *ts_params,
9941 struct crypto_unittest_params *ut_params,
9942 const struct test_crypto_vector *reference)
9944 return test_authentication_verify_GMAC_fail_when_corruption(
9945 ts_params, ut_params, reference, 0);
9949 test_authenticated_decryption_fail_when_data_corrupted(
9950 struct crypto_testsuite_params *ts_params,
9951 struct crypto_unittest_params *ut_params,
9952 const struct test_crypto_vector *reference)
9954 return test_authenticated_decryption_fail_when_corruption(
9955 ts_params, ut_params, reference, 1);
9959 test_authenticated_decryption_fail_when_tag_corrupted(
9960 struct crypto_testsuite_params *ts_params,
9961 struct crypto_unittest_params *ut_params,
9962 const struct test_crypto_vector *reference)
9964 return test_authenticated_decryption_fail_when_corruption(
9965 ts_params, ut_params, reference, 0);
9969 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
9971 return test_authentication_verify_fail_when_data_corrupted(
9972 &testsuite_params, &unittest_params,
9973 &hmac_sha1_test_crypto_vector);
9977 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
9979 return test_authentication_verify_fail_when_tag_corrupted(
9980 &testsuite_params, &unittest_params,
9981 &hmac_sha1_test_crypto_vector);
9985 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
9987 return test_authentication_verify_GMAC_fail_when_data_corrupted(
9988 &testsuite_params, &unittest_params,
9989 &aes128_gmac_test_vector);
9993 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
9995 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
9996 &testsuite_params, &unittest_params,
9997 &aes128_gmac_test_vector);
10001 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
10003 return test_authenticated_decryption_fail_when_data_corrupted(
10006 &aes128cbc_hmac_sha1_test_vector);
10010 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
10012 return test_authenticated_decryption_fail_when_tag_corrupted(
10015 &aes128cbc_hmac_sha1_test_vector);
10018 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10020 /* global AESNI slave IDs for the scheduler test */
10021 uint8_t aesni_ids[2];
10024 test_scheduler_attach_slave_op(void)
10026 struct crypto_testsuite_params *ts_params = &testsuite_params;
10027 uint8_t sched_id = ts_params->valid_devs[0];
10028 uint32_t nb_devs, i, nb_devs_attached = 0;
10030 char vdev_name[32];
10032 /* create 2 AESNI_MB if necessary */
10033 nb_devs = rte_cryptodev_device_count_by_driver(
10034 rte_cryptodev_driver_id_get(
10035 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
10037 for (i = nb_devs; i < 2; i++) {
10038 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
10039 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
10041 ret = rte_vdev_init(vdev_name, NULL);
10043 TEST_ASSERT(ret == 0,
10044 "Failed to create instance %u of"
10046 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10050 /* attach 2 AESNI_MB cdevs */
10051 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
10053 struct rte_cryptodev_info info;
10054 unsigned int session_size;
10056 rte_cryptodev_info_get(i, &info);
10057 if (info.driver_id != rte_cryptodev_driver_id_get(
10058 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
10061 session_size = rte_cryptodev_sym_get_private_session_size(i);
10063 * Create the session mempool again, since now there are new devices
10064 * to use the mempool.
10066 if (ts_params->session_mpool) {
10067 rte_mempool_free(ts_params->session_mpool);
10068 ts_params->session_mpool = NULL;
10070 if (ts_params->session_priv_mpool) {
10071 rte_mempool_free(ts_params->session_priv_mpool);
10072 ts_params->session_priv_mpool = NULL;
10075 if (info.sym.max_nb_sessions != 0 &&
10076 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
10077 RTE_LOG(ERR, USER1,
10078 "Device does not support "
10079 "at least %u sessions\n",
10081 return TEST_FAILED;
10084 * Create mempool with maximum number of sessions,
10085 * to include the session headers
10087 if (ts_params->session_mpool == NULL) {
10088 ts_params->session_mpool =
10089 rte_cryptodev_sym_session_pool_create(
10091 MAX_NB_SESSIONS, 0, 0, 0,
10093 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
10094 "session mempool allocation failed");
10098 * Create mempool with maximum number of sessions,
10099 * to include device specific session private data
10101 if (ts_params->session_priv_mpool == NULL) {
10102 ts_params->session_priv_mpool = rte_mempool_create(
10103 "test_sess_mp_priv",
10106 0, 0, NULL, NULL, NULL,
10107 NULL, SOCKET_ID_ANY,
10110 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
10111 "session mempool allocation failed");
10114 ts_params->qp_conf.mp_session = ts_params->session_mpool;
10115 ts_params->qp_conf.mp_session_private =
10116 ts_params->session_priv_mpool;
10118 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
10121 TEST_ASSERT(ret == 0,
10122 "Failed to attach device %u of pmd : %s", i,
10123 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10125 aesni_ids[nb_devs_attached] = (uint8_t)i;
10127 nb_devs_attached++;
10134 test_scheduler_detach_slave_op(void)
10136 struct crypto_testsuite_params *ts_params = &testsuite_params;
10137 uint8_t sched_id = ts_params->valid_devs[0];
10141 for (i = 0; i < 2; i++) {
10142 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
10144 TEST_ASSERT(ret == 0,
10145 "Failed to detach device %u", aesni_ids[i]);
10152 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
10154 struct crypto_testsuite_params *ts_params = &testsuite_params;
10155 uint8_t sched_id = ts_params->valid_devs[0];
10157 return rte_cryptodev_scheduler_mode_set(sched_id,
10162 test_scheduler_mode_roundrobin_op(void)
10164 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
10165 0, "Failed to set roundrobin mode");
10171 test_scheduler_mode_multicore_op(void)
10173 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
10174 0, "Failed to set multicore mode");
10180 test_scheduler_mode_failover_op(void)
10182 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
10183 0, "Failed to set failover mode");
10189 test_scheduler_mode_pkt_size_distr_op(void)
10191 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
10192 0, "Failed to set pktsize mode");
10197 static struct unit_test_suite cryptodev_scheduler_testsuite = {
10198 .suite_name = "Crypto Device Scheduler Unit Test Suite",
10199 .setup = testsuite_setup,
10200 .teardown = testsuite_teardown,
10201 .unit_test_cases = {
10203 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10204 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
10205 TEST_CASE_ST(ut_setup, ut_teardown,
10206 test_AES_chain_scheduler_all),
10207 TEST_CASE_ST(ut_setup, ut_teardown,
10208 test_AES_cipheronly_scheduler_all),
10209 TEST_CASE_ST(ut_setup, ut_teardown,
10210 test_authonly_scheduler_all),
10211 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10214 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10215 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
10216 TEST_CASE_ST(ut_setup, ut_teardown,
10217 test_AES_chain_scheduler_all),
10218 TEST_CASE_ST(ut_setup, ut_teardown,
10219 test_AES_cipheronly_scheduler_all),
10220 TEST_CASE_ST(ut_setup, ut_teardown,
10221 test_authonly_scheduler_all),
10222 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10225 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10226 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
10227 TEST_CASE_ST(ut_setup, ut_teardown,
10228 test_AES_chain_scheduler_all),
10229 TEST_CASE_ST(ut_setup, ut_teardown,
10230 test_AES_cipheronly_scheduler_all),
10231 TEST_CASE_ST(ut_setup, ut_teardown,
10232 test_authonly_scheduler_all),
10233 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10236 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10237 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
10238 TEST_CASE_ST(ut_setup, ut_teardown,
10239 test_AES_chain_scheduler_all),
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 test_AES_cipheronly_scheduler_all),
10242 TEST_CASE_ST(ut_setup, ut_teardown,
10243 test_authonly_scheduler_all),
10244 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10246 TEST_CASES_END() /**< NULL terminate unit test array */
10250 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
10252 static struct unit_test_suite cryptodev_qat_testsuite = {
10253 .suite_name = "Crypto QAT Unit Test Suite",
10254 .setup = testsuite_setup,
10255 .teardown = testsuite_teardown,
10256 .unit_test_cases = {
10257 TEST_CASE_ST(ut_setup, ut_teardown,
10258 test_device_configure_invalid_dev_id),
10259 TEST_CASE_ST(ut_setup, ut_teardown,
10260 test_device_configure_invalid_queue_pair_ids),
10261 TEST_CASE_ST(ut_setup, ut_teardown,
10262 test_queue_pair_descriptor_setup),
10263 TEST_CASE_ST(ut_setup, ut_teardown,
10264 test_multi_session),
10266 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
10267 TEST_CASE_ST(ut_setup, ut_teardown,
10268 test_AES_cipheronly_qat_all),
10269 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
10270 TEST_CASE_ST(ut_setup, ut_teardown,
10271 test_3DES_cipheronly_qat_all),
10272 TEST_CASE_ST(ut_setup, ut_teardown,
10273 test_DES_cipheronly_qat_all),
10274 TEST_CASE_ST(ut_setup, ut_teardown,
10275 test_AES_docsis_qat_all),
10276 TEST_CASE_ST(ut_setup, ut_teardown,
10277 test_DES_docsis_qat_all),
10278 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
10279 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
10281 /** AES CCM Authenticated Encryption 128 bits key */
10282 TEST_CASE_ST(ut_setup, ut_teardown,
10283 test_AES_CCM_authenticated_encryption_test_case_128_1),
10284 TEST_CASE_ST(ut_setup, ut_teardown,
10285 test_AES_CCM_authenticated_encryption_test_case_128_2),
10286 TEST_CASE_ST(ut_setup, ut_teardown,
10287 test_AES_CCM_authenticated_encryption_test_case_128_3),
10289 /** AES CCM Authenticated Decryption 128 bits key*/
10290 TEST_CASE_ST(ut_setup, ut_teardown,
10291 test_AES_CCM_authenticated_decryption_test_case_128_1),
10292 TEST_CASE_ST(ut_setup, ut_teardown,
10293 test_AES_CCM_authenticated_decryption_test_case_128_2),
10294 TEST_CASE_ST(ut_setup, ut_teardown,
10295 test_AES_CCM_authenticated_decryption_test_case_128_3),
10297 /** AES GCM Authenticated Encryption */
10298 TEST_CASE_ST(ut_setup, ut_teardown,
10299 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10300 TEST_CASE_ST(ut_setup, ut_teardown,
10301 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10302 TEST_CASE_ST(ut_setup, ut_teardown,
10303 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10304 TEST_CASE_ST(ut_setup, ut_teardown,
10305 test_AES_GCM_authenticated_encryption_test_case_1),
10306 TEST_CASE_ST(ut_setup, ut_teardown,
10307 test_AES_GCM_authenticated_encryption_test_case_2),
10308 TEST_CASE_ST(ut_setup, ut_teardown,
10309 test_AES_GCM_authenticated_encryption_test_case_3),
10310 TEST_CASE_ST(ut_setup, ut_teardown,
10311 test_AES_GCM_authenticated_encryption_test_case_4),
10312 TEST_CASE_ST(ut_setup, ut_teardown,
10313 test_AES_GCM_authenticated_encryption_test_case_5),
10314 TEST_CASE_ST(ut_setup, ut_teardown,
10315 test_AES_GCM_authenticated_encryption_test_case_6),
10316 TEST_CASE_ST(ut_setup, ut_teardown,
10317 test_AES_GCM_authenticated_encryption_test_case_7),
10319 /** AES GCM Authenticated Decryption */
10320 TEST_CASE_ST(ut_setup, ut_teardown,
10321 test_AES_GCM_authenticated_decryption_test_case_1),
10322 TEST_CASE_ST(ut_setup, ut_teardown,
10323 test_AES_GCM_authenticated_decryption_test_case_2),
10324 TEST_CASE_ST(ut_setup, ut_teardown,
10325 test_AES_GCM_authenticated_decryption_test_case_3),
10326 TEST_CASE_ST(ut_setup, ut_teardown,
10327 test_AES_GCM_authenticated_decryption_test_case_4),
10328 TEST_CASE_ST(ut_setup, ut_teardown,
10329 test_AES_GCM_authenticated_decryption_test_case_5),
10330 TEST_CASE_ST(ut_setup, ut_teardown,
10331 test_AES_GCM_authenticated_decryption_test_case_6),
10332 TEST_CASE_ST(ut_setup, ut_teardown,
10333 test_AES_GCM_authenticated_decryption_test_case_7),
10335 /** AES GCM Authenticated Encryption 192 bits key */
10336 TEST_CASE_ST(ut_setup, ut_teardown,
10337 test_AES_GCM_auth_encryption_test_case_192_1),
10338 TEST_CASE_ST(ut_setup, ut_teardown,
10339 test_AES_GCM_auth_encryption_test_case_192_2),
10340 TEST_CASE_ST(ut_setup, ut_teardown,
10341 test_AES_GCM_auth_encryption_test_case_192_3),
10342 TEST_CASE_ST(ut_setup, ut_teardown,
10343 test_AES_GCM_auth_encryption_test_case_192_4),
10344 TEST_CASE_ST(ut_setup, ut_teardown,
10345 test_AES_GCM_auth_encryption_test_case_192_5),
10346 TEST_CASE_ST(ut_setup, ut_teardown,
10347 test_AES_GCM_auth_encryption_test_case_192_6),
10348 TEST_CASE_ST(ut_setup, ut_teardown,
10349 test_AES_GCM_auth_encryption_test_case_192_7),
10351 /** AES GCM Authenticated Decryption 192 bits key */
10352 TEST_CASE_ST(ut_setup, ut_teardown,
10353 test_AES_GCM_auth_decryption_test_case_192_1),
10354 TEST_CASE_ST(ut_setup, ut_teardown,
10355 test_AES_GCM_auth_decryption_test_case_192_2),
10356 TEST_CASE_ST(ut_setup, ut_teardown,
10357 test_AES_GCM_auth_decryption_test_case_192_3),
10358 TEST_CASE_ST(ut_setup, ut_teardown,
10359 test_AES_GCM_auth_decryption_test_case_192_4),
10360 TEST_CASE_ST(ut_setup, ut_teardown,
10361 test_AES_GCM_auth_decryption_test_case_192_5),
10362 TEST_CASE_ST(ut_setup, ut_teardown,
10363 test_AES_GCM_auth_decryption_test_case_192_6),
10364 TEST_CASE_ST(ut_setup, ut_teardown,
10365 test_AES_GCM_auth_decryption_test_case_192_7),
10367 /** AES GCM Authenticated Encryption 256 bits key */
10368 TEST_CASE_ST(ut_setup, ut_teardown,
10369 test_AES_GCM_auth_encryption_test_case_256_1),
10370 TEST_CASE_ST(ut_setup, ut_teardown,
10371 test_AES_GCM_auth_encryption_test_case_256_2),
10372 TEST_CASE_ST(ut_setup, ut_teardown,
10373 test_AES_GCM_auth_encryption_test_case_256_3),
10374 TEST_CASE_ST(ut_setup, ut_teardown,
10375 test_AES_GCM_auth_encryption_test_case_256_4),
10376 TEST_CASE_ST(ut_setup, ut_teardown,
10377 test_AES_GCM_auth_encryption_test_case_256_5),
10378 TEST_CASE_ST(ut_setup, ut_teardown,
10379 test_AES_GCM_auth_encryption_test_case_256_6),
10380 TEST_CASE_ST(ut_setup, ut_teardown,
10381 test_AES_GCM_auth_encryption_test_case_256_7),
10383 /** AES GMAC Authentication */
10384 TEST_CASE_ST(ut_setup, ut_teardown,
10385 test_AES_GMAC_authentication_test_case_1),
10386 TEST_CASE_ST(ut_setup, ut_teardown,
10387 test_AES_GMAC_authentication_verify_test_case_1),
10388 TEST_CASE_ST(ut_setup, ut_teardown,
10389 test_AES_GMAC_authentication_test_case_2),
10390 TEST_CASE_ST(ut_setup, ut_teardown,
10391 test_AES_GMAC_authentication_verify_test_case_2),
10392 TEST_CASE_ST(ut_setup, ut_teardown,
10393 test_AES_GMAC_authentication_test_case_3),
10394 TEST_CASE_ST(ut_setup, ut_teardown,
10395 test_AES_GMAC_authentication_verify_test_case_3),
10397 /** SNOW 3G encrypt only (UEA2) */
10398 TEST_CASE_ST(ut_setup, ut_teardown,
10399 test_snow3g_encryption_test_case_1),
10400 TEST_CASE_ST(ut_setup, ut_teardown,
10401 test_snow3g_encryption_test_case_2),
10402 TEST_CASE_ST(ut_setup, ut_teardown,
10403 test_snow3g_encryption_test_case_3),
10404 TEST_CASE_ST(ut_setup, ut_teardown,
10405 test_snow3g_encryption_test_case_4),
10406 TEST_CASE_ST(ut_setup, ut_teardown,
10407 test_snow3g_encryption_test_case_5),
10409 TEST_CASE_ST(ut_setup, ut_teardown,
10410 test_snow3g_encryption_test_case_1_oop),
10411 TEST_CASE_ST(ut_setup, ut_teardown,
10412 test_snow3g_decryption_test_case_1_oop),
10414 /** SNOW 3G generate auth, then encrypt (UEA2) */
10415 TEST_CASE_ST(ut_setup, ut_teardown,
10416 test_snow3g_auth_cipher_test_case_1),
10417 TEST_CASE_ST(ut_setup, ut_teardown,
10418 test_snow3g_auth_cipher_test_case_2),
10419 TEST_CASE_ST(ut_setup, ut_teardown,
10420 test_snow3g_auth_cipher_test_case_2_oop),
10421 TEST_CASE_ST(ut_setup, ut_teardown,
10422 test_snow3g_auth_cipher_part_digest_enc),
10423 TEST_CASE_ST(ut_setup, ut_teardown,
10424 test_snow3g_auth_cipher_part_digest_enc_oop),
10425 TEST_CASE_ST(ut_setup, ut_teardown,
10426 test_snow3g_auth_cipher_test_case_3_sgl),
10427 TEST_CASE_ST(ut_setup, ut_teardown,
10428 test_snow3g_auth_cipher_test_case_3_oop_sgl),
10429 TEST_CASE_ST(ut_setup, ut_teardown,
10430 test_snow3g_auth_cipher_part_digest_enc_sgl),
10431 TEST_CASE_ST(ut_setup, ut_teardown,
10432 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
10434 /** SNOW 3G decrypt (UEA2), then verify auth */
10435 TEST_CASE_ST(ut_setup, ut_teardown,
10436 test_snow3g_auth_cipher_verify_test_case_1),
10437 TEST_CASE_ST(ut_setup, ut_teardown,
10438 test_snow3g_auth_cipher_verify_test_case_2),
10439 TEST_CASE_ST(ut_setup, ut_teardown,
10440 test_snow3g_auth_cipher_verify_test_case_2_oop),
10441 TEST_CASE_ST(ut_setup, ut_teardown,
10442 test_snow3g_auth_cipher_verify_part_digest_enc),
10443 TEST_CASE_ST(ut_setup, ut_teardown,
10444 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
10445 TEST_CASE_ST(ut_setup, ut_teardown,
10446 test_snow3g_auth_cipher_verify_test_case_3_sgl),
10447 TEST_CASE_ST(ut_setup, ut_teardown,
10448 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
10449 TEST_CASE_ST(ut_setup, ut_teardown,
10450 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
10451 TEST_CASE_ST(ut_setup, ut_teardown,
10452 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
10454 /** SNOW 3G decrypt only (UEA2) */
10455 TEST_CASE_ST(ut_setup, ut_teardown,
10456 test_snow3g_decryption_test_case_1),
10457 TEST_CASE_ST(ut_setup, ut_teardown,
10458 test_snow3g_decryption_test_case_2),
10459 TEST_CASE_ST(ut_setup, ut_teardown,
10460 test_snow3g_decryption_test_case_3),
10461 TEST_CASE_ST(ut_setup, ut_teardown,
10462 test_snow3g_decryption_test_case_4),
10463 TEST_CASE_ST(ut_setup, ut_teardown,
10464 test_snow3g_decryption_test_case_5),
10465 TEST_CASE_ST(ut_setup, ut_teardown,
10466 test_snow3g_decryption_with_digest_test_case_1),
10467 TEST_CASE_ST(ut_setup, ut_teardown,
10468 test_snow3g_hash_generate_test_case_1),
10469 TEST_CASE_ST(ut_setup, ut_teardown,
10470 test_snow3g_hash_generate_test_case_2),
10471 TEST_CASE_ST(ut_setup, ut_teardown,
10472 test_snow3g_hash_generate_test_case_3),
10473 TEST_CASE_ST(ut_setup, ut_teardown,
10474 test_snow3g_hash_verify_test_case_1),
10475 TEST_CASE_ST(ut_setup, ut_teardown,
10476 test_snow3g_hash_verify_test_case_2),
10477 TEST_CASE_ST(ut_setup, ut_teardown,
10478 test_snow3g_hash_verify_test_case_3),
10479 TEST_CASE_ST(ut_setup, ut_teardown,
10480 test_snow3g_cipher_auth_test_case_1),
10481 TEST_CASE_ST(ut_setup, ut_teardown,
10482 test_snow3g_auth_cipher_with_digest_test_case_1),
10484 /** ZUC encrypt only (EEA3) */
10485 TEST_CASE_ST(ut_setup, ut_teardown,
10486 test_zuc_encryption_test_case_1),
10487 TEST_CASE_ST(ut_setup, ut_teardown,
10488 test_zuc_encryption_test_case_2),
10489 TEST_CASE_ST(ut_setup, ut_teardown,
10490 test_zuc_encryption_test_case_3),
10491 TEST_CASE_ST(ut_setup, ut_teardown,
10492 test_zuc_encryption_test_case_4),
10493 TEST_CASE_ST(ut_setup, ut_teardown,
10494 test_zuc_encryption_test_case_5),
10496 /** ZUC authenticate (EIA3) */
10497 TEST_CASE_ST(ut_setup, ut_teardown,
10498 test_zuc_hash_generate_test_case_6),
10499 TEST_CASE_ST(ut_setup, ut_teardown,
10500 test_zuc_hash_generate_test_case_7),
10501 TEST_CASE_ST(ut_setup, ut_teardown,
10502 test_zuc_hash_generate_test_case_8),
10504 /** ZUC alg-chain (EEA3/EIA3) */
10505 TEST_CASE_ST(ut_setup, ut_teardown,
10506 test_zuc_cipher_auth_test_case_1),
10507 TEST_CASE_ST(ut_setup, ut_teardown,
10508 test_zuc_cipher_auth_test_case_2),
10510 /** ZUC generate auth, then encrypt (EEA3) */
10511 TEST_CASE_ST(ut_setup, ut_teardown,
10512 test_zuc_auth_cipher_test_case_1),
10513 TEST_CASE_ST(ut_setup, ut_teardown,
10514 test_zuc_auth_cipher_test_case_1_oop),
10515 TEST_CASE_ST(ut_setup, ut_teardown,
10516 test_zuc_auth_cipher_test_case_1_sgl),
10517 TEST_CASE_ST(ut_setup, ut_teardown,
10518 test_zuc_auth_cipher_test_case_1_oop_sgl),
10520 /** ZUC decrypt (EEA3), then verify auth */
10521 TEST_CASE_ST(ut_setup, ut_teardown,
10522 test_zuc_auth_cipher_verify_test_case_1),
10523 TEST_CASE_ST(ut_setup, ut_teardown,
10524 test_zuc_auth_cipher_verify_test_case_1_oop),
10525 TEST_CASE_ST(ut_setup, ut_teardown,
10526 test_zuc_auth_cipher_verify_test_case_1_sgl),
10527 TEST_CASE_ST(ut_setup, ut_teardown,
10528 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
10530 /** HMAC_MD5 Authentication */
10531 TEST_CASE_ST(ut_setup, ut_teardown,
10532 test_MD5_HMAC_generate_case_1),
10533 TEST_CASE_ST(ut_setup, ut_teardown,
10534 test_MD5_HMAC_verify_case_1),
10535 TEST_CASE_ST(ut_setup, ut_teardown,
10536 test_MD5_HMAC_generate_case_2),
10537 TEST_CASE_ST(ut_setup, ut_teardown,
10538 test_MD5_HMAC_verify_case_2),
10540 /** NULL algo tests done in chain_all,
10541 * cipheronly and authonly suites
10544 /** KASUMI tests */
10545 TEST_CASE_ST(ut_setup, ut_teardown,
10546 test_kasumi_hash_generate_test_case_1),
10547 TEST_CASE_ST(ut_setup, ut_teardown,
10548 test_kasumi_hash_generate_test_case_2),
10549 TEST_CASE_ST(ut_setup, ut_teardown,
10550 test_kasumi_hash_generate_test_case_3),
10551 TEST_CASE_ST(ut_setup, ut_teardown,
10552 test_kasumi_hash_generate_test_case_4),
10553 TEST_CASE_ST(ut_setup, ut_teardown,
10554 test_kasumi_hash_generate_test_case_5),
10555 TEST_CASE_ST(ut_setup, ut_teardown,
10556 test_kasumi_hash_generate_test_case_6),
10558 TEST_CASE_ST(ut_setup, ut_teardown,
10559 test_kasumi_hash_verify_test_case_1),
10560 TEST_CASE_ST(ut_setup, ut_teardown,
10561 test_kasumi_hash_verify_test_case_2),
10562 TEST_CASE_ST(ut_setup, ut_teardown,
10563 test_kasumi_hash_verify_test_case_3),
10564 TEST_CASE_ST(ut_setup, ut_teardown,
10565 test_kasumi_hash_verify_test_case_4),
10566 TEST_CASE_ST(ut_setup, ut_teardown,
10567 test_kasumi_hash_verify_test_case_5),
10569 TEST_CASE_ST(ut_setup, ut_teardown,
10570 test_kasumi_encryption_test_case_1),
10571 TEST_CASE_ST(ut_setup, ut_teardown,
10572 test_kasumi_encryption_test_case_3),
10573 TEST_CASE_ST(ut_setup, ut_teardown,
10574 test_kasumi_cipher_auth_test_case_1),
10576 /** KASUMI generate auth, then encrypt (F8) */
10577 TEST_CASE_ST(ut_setup, ut_teardown,
10578 test_kasumi_auth_cipher_test_case_1),
10579 TEST_CASE_ST(ut_setup, ut_teardown,
10580 test_kasumi_auth_cipher_test_case_2),
10581 TEST_CASE_ST(ut_setup, ut_teardown,
10582 test_kasumi_auth_cipher_test_case_2_oop),
10583 TEST_CASE_ST(ut_setup, ut_teardown,
10584 test_kasumi_auth_cipher_test_case_2_sgl),
10585 TEST_CASE_ST(ut_setup, ut_teardown,
10586 test_kasumi_auth_cipher_test_case_2_oop_sgl),
10588 /** KASUMI decrypt (F8), then verify auth */
10589 TEST_CASE_ST(ut_setup, ut_teardown,
10590 test_kasumi_auth_cipher_verify_test_case_1),
10591 TEST_CASE_ST(ut_setup, ut_teardown,
10592 test_kasumi_auth_cipher_verify_test_case_2),
10593 TEST_CASE_ST(ut_setup, ut_teardown,
10594 test_kasumi_auth_cipher_verify_test_case_2_oop),
10595 TEST_CASE_ST(ut_setup, ut_teardown,
10596 test_kasumi_auth_cipher_verify_test_case_2_sgl),
10597 TEST_CASE_ST(ut_setup, ut_teardown,
10598 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
10600 /** Negative tests */
10601 TEST_CASE_ST(ut_setup, ut_teardown,
10602 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10603 TEST_CASE_ST(ut_setup, ut_teardown,
10604 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10605 TEST_CASE_ST(ut_setup, ut_teardown,
10606 authentication_verify_AES128_GMAC_fail_data_corrupt),
10607 TEST_CASE_ST(ut_setup, ut_teardown,
10608 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10609 TEST_CASE_ST(ut_setup, ut_teardown,
10610 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10611 TEST_CASE_ST(ut_setup, ut_teardown,
10612 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10614 TEST_CASES_END() /**< NULL terminate unit test array */
10618 static struct unit_test_suite cryptodev_virtio_testsuite = {
10619 .suite_name = "Crypto VIRTIO Unit Test Suite",
10620 .setup = testsuite_setup,
10621 .teardown = testsuite_teardown,
10622 .unit_test_cases = {
10623 TEST_CASE_ST(ut_setup, ut_teardown,
10624 test_AES_cipheronly_virtio_all),
10626 TEST_CASES_END() /**< NULL terminate unit test array */
10630 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
10631 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
10632 .setup = testsuite_setup,
10633 .teardown = testsuite_teardown,
10634 .unit_test_cases = {
10635 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
10636 TEST_CASE_ST(ut_setup, ut_teardown,
10637 test_AES_GCM_authenticated_encryption_test_case_1),
10638 TEST_CASE_ST(ut_setup, ut_teardown,
10639 test_AES_GCM_authenticated_encryption_test_case_2),
10640 TEST_CASE_ST(ut_setup, ut_teardown,
10641 test_AES_GCM_authenticated_encryption_test_case_3),
10642 TEST_CASE_ST(ut_setup, ut_teardown,
10643 test_AES_GCM_authenticated_encryption_test_case_4),
10644 TEST_CASE_ST(ut_setup, ut_teardown,
10645 test_AES_GCM_authenticated_encryption_test_case_5),
10646 TEST_CASE_ST(ut_setup, ut_teardown,
10647 test_AES_GCM_authenticated_encryption_test_case_6),
10648 TEST_CASE_ST(ut_setup, ut_teardown,
10649 test_AES_GCM_authenticated_encryption_test_case_7),
10651 /** AES GCM Authenticated Decryption */
10652 TEST_CASE_ST(ut_setup, ut_teardown,
10653 test_AES_GCM_authenticated_decryption_test_case_1),
10654 TEST_CASE_ST(ut_setup, ut_teardown,
10655 test_AES_GCM_authenticated_decryption_test_case_2),
10656 TEST_CASE_ST(ut_setup, ut_teardown,
10657 test_AES_GCM_authenticated_decryption_test_case_3),
10658 TEST_CASE_ST(ut_setup, ut_teardown,
10659 test_AES_GCM_authenticated_decryption_test_case_4),
10660 TEST_CASE_ST(ut_setup, ut_teardown,
10661 test_AES_GCM_authenticated_decryption_test_case_5),
10662 TEST_CASE_ST(ut_setup, ut_teardown,
10663 test_AES_GCM_authenticated_decryption_test_case_6),
10664 TEST_CASE_ST(ut_setup, ut_teardown,
10665 test_AES_GCM_authenticated_decryption_test_case_7),
10667 /** AES GCM Authenticated Encryption 192 bits key */
10668 TEST_CASE_ST(ut_setup, ut_teardown,
10669 test_AES_GCM_auth_encryption_test_case_192_1),
10670 TEST_CASE_ST(ut_setup, ut_teardown,
10671 test_AES_GCM_auth_encryption_test_case_192_2),
10672 TEST_CASE_ST(ut_setup, ut_teardown,
10673 test_AES_GCM_auth_encryption_test_case_192_3),
10674 TEST_CASE_ST(ut_setup, ut_teardown,
10675 test_AES_GCM_auth_encryption_test_case_192_4),
10676 TEST_CASE_ST(ut_setup, ut_teardown,
10677 test_AES_GCM_auth_encryption_test_case_192_5),
10678 TEST_CASE_ST(ut_setup, ut_teardown,
10679 test_AES_GCM_auth_encryption_test_case_192_6),
10680 TEST_CASE_ST(ut_setup, ut_teardown,
10681 test_AES_GCM_auth_encryption_test_case_192_7),
10683 /** AES GCM Authenticated Decryption 192 bits key */
10684 TEST_CASE_ST(ut_setup, ut_teardown,
10685 test_AES_GCM_auth_decryption_test_case_192_1),
10686 TEST_CASE_ST(ut_setup, ut_teardown,
10687 test_AES_GCM_auth_decryption_test_case_192_2),
10688 TEST_CASE_ST(ut_setup, ut_teardown,
10689 test_AES_GCM_auth_decryption_test_case_192_3),
10690 TEST_CASE_ST(ut_setup, ut_teardown,
10691 test_AES_GCM_auth_decryption_test_case_192_4),
10692 TEST_CASE_ST(ut_setup, ut_teardown,
10693 test_AES_GCM_auth_decryption_test_case_192_5),
10694 TEST_CASE_ST(ut_setup, ut_teardown,
10695 test_AES_GCM_auth_decryption_test_case_192_6),
10696 TEST_CASE_ST(ut_setup, ut_teardown,
10697 test_AES_GCM_auth_decryption_test_case_192_7),
10699 /** AES GCM Authenticated Encryption 256 bits key */
10700 TEST_CASE_ST(ut_setup, ut_teardown,
10701 test_AES_GCM_auth_encryption_test_case_256_1),
10702 TEST_CASE_ST(ut_setup, ut_teardown,
10703 test_AES_GCM_auth_encryption_test_case_256_2),
10704 TEST_CASE_ST(ut_setup, ut_teardown,
10705 test_AES_GCM_auth_encryption_test_case_256_3),
10706 TEST_CASE_ST(ut_setup, ut_teardown,
10707 test_AES_GCM_auth_encryption_test_case_256_4),
10708 TEST_CASE_ST(ut_setup, ut_teardown,
10709 test_AES_GCM_auth_encryption_test_case_256_5),
10710 TEST_CASE_ST(ut_setup, ut_teardown,
10711 test_AES_GCM_auth_encryption_test_case_256_6),
10712 TEST_CASE_ST(ut_setup, ut_teardown,
10713 test_AES_GCM_auth_encryption_test_case_256_7),
10715 /** AES GCM Authenticated Decryption 256 bits key */
10716 TEST_CASE_ST(ut_setup, ut_teardown,
10717 test_AES_GCM_auth_decryption_test_case_256_1),
10718 TEST_CASE_ST(ut_setup, ut_teardown,
10719 test_AES_GCM_auth_decryption_test_case_256_2),
10720 TEST_CASE_ST(ut_setup, ut_teardown,
10721 test_AES_GCM_auth_decryption_test_case_256_3),
10722 TEST_CASE_ST(ut_setup, ut_teardown,
10723 test_AES_GCM_auth_decryption_test_case_256_4),
10724 TEST_CASE_ST(ut_setup, ut_teardown,
10725 test_AES_GCM_auth_decryption_test_case_256_5),
10726 TEST_CASE_ST(ut_setup, ut_teardown,
10727 test_AES_GCM_auth_decryption_test_case_256_6),
10728 TEST_CASE_ST(ut_setup, ut_teardown,
10729 test_AES_GCM_auth_decryption_test_case_256_7),
10731 /** AES GCM Authenticated Encryption big aad size */
10732 TEST_CASE_ST(ut_setup, ut_teardown,
10733 test_AES_GCM_auth_encryption_test_case_aad_1),
10734 TEST_CASE_ST(ut_setup, ut_teardown,
10735 test_AES_GCM_auth_encryption_test_case_aad_2),
10737 /** AES GCM Authenticated Decryption big aad size */
10738 TEST_CASE_ST(ut_setup, ut_teardown,
10739 test_AES_GCM_auth_decryption_test_case_aad_1),
10740 TEST_CASE_ST(ut_setup, ut_teardown,
10741 test_AES_GCM_auth_decryption_test_case_aad_2),
10743 /** Session-less tests */
10744 TEST_CASE_ST(ut_setup, ut_teardown,
10745 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
10746 TEST_CASE_ST(ut_setup, ut_teardown,
10747 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
10749 /** AES GMAC Authentication */
10750 TEST_CASE_ST(ut_setup, ut_teardown,
10751 test_AES_GMAC_authentication_test_case_1),
10752 TEST_CASE_ST(ut_setup, ut_teardown,
10753 test_AES_GMAC_authentication_verify_test_case_1),
10754 TEST_CASE_ST(ut_setup, ut_teardown,
10755 test_AES_GMAC_authentication_test_case_2),
10756 TEST_CASE_ST(ut_setup, ut_teardown,
10757 test_AES_GMAC_authentication_verify_test_case_2),
10758 TEST_CASE_ST(ut_setup, ut_teardown,
10759 test_AES_GMAC_authentication_test_case_3),
10760 TEST_CASE_ST(ut_setup, ut_teardown,
10761 test_AES_GMAC_authentication_verify_test_case_3),
10762 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
10764 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
10765 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
10766 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
10767 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
10768 TEST_CASE_ST(ut_setup, ut_teardown,
10769 test_DES_cipheronly_mb_all),
10770 TEST_CASE_ST(ut_setup, ut_teardown,
10771 test_DES_docsis_mb_all),
10772 TEST_CASE_ST(ut_setup, ut_teardown,
10773 test_3DES_cipheronly_mb_all),
10774 TEST_CASE_ST(ut_setup, ut_teardown,
10775 test_AES_CCM_authenticated_encryption_test_case_128_1),
10776 TEST_CASE_ST(ut_setup, ut_teardown,
10777 test_AES_CCM_authenticated_decryption_test_case_128_1),
10778 TEST_CASE_ST(ut_setup, ut_teardown,
10779 test_AES_CCM_authenticated_encryption_test_case_128_2),
10780 TEST_CASE_ST(ut_setup, ut_teardown,
10781 test_AES_CCM_authenticated_decryption_test_case_128_2),
10782 TEST_CASE_ST(ut_setup, ut_teardown,
10783 test_AES_CCM_authenticated_encryption_test_case_128_3),
10784 TEST_CASE_ST(ut_setup, ut_teardown,
10785 test_AES_CCM_authenticated_decryption_test_case_128_3),
10787 TEST_CASES_END() /**< NULL terminate unit test array */
10791 static struct unit_test_suite cryptodev_openssl_testsuite = {
10792 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
10793 .setup = testsuite_setup,
10794 .teardown = testsuite_teardown,
10795 .unit_test_cases = {
10796 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10797 TEST_CASE_ST(ut_setup, ut_teardown,
10798 test_multi_session_random_usage),
10799 TEST_CASE_ST(ut_setup, ut_teardown,
10800 test_AES_chain_openssl_all),
10801 TEST_CASE_ST(ut_setup, ut_teardown,
10802 test_AES_cipheronly_openssl_all),
10803 TEST_CASE_ST(ut_setup, ut_teardown,
10804 test_3DES_chain_openssl_all),
10805 TEST_CASE_ST(ut_setup, ut_teardown,
10806 test_3DES_cipheronly_openssl_all),
10807 TEST_CASE_ST(ut_setup, ut_teardown,
10808 test_DES_cipheronly_openssl_all),
10809 TEST_CASE_ST(ut_setup, ut_teardown,
10810 test_DES_docsis_openssl_all),
10811 TEST_CASE_ST(ut_setup, ut_teardown,
10812 test_authonly_openssl_all),
10814 /** AES GCM Authenticated Encryption */
10815 TEST_CASE_ST(ut_setup, ut_teardown,
10816 test_AES_GCM_authenticated_encryption_test_case_1),
10817 TEST_CASE_ST(ut_setup, ut_teardown,
10818 test_AES_GCM_authenticated_encryption_test_case_2),
10819 TEST_CASE_ST(ut_setup, ut_teardown,
10820 test_AES_GCM_authenticated_encryption_test_case_3),
10821 TEST_CASE_ST(ut_setup, ut_teardown,
10822 test_AES_GCM_authenticated_encryption_test_case_4),
10823 TEST_CASE_ST(ut_setup, ut_teardown,
10824 test_AES_GCM_authenticated_encryption_test_case_5),
10825 TEST_CASE_ST(ut_setup, ut_teardown,
10826 test_AES_GCM_authenticated_encryption_test_case_6),
10827 TEST_CASE_ST(ut_setup, ut_teardown,
10828 test_AES_GCM_authenticated_encryption_test_case_7),
10830 /** AES GCM Authenticated Decryption */
10831 TEST_CASE_ST(ut_setup, ut_teardown,
10832 test_AES_GCM_authenticated_decryption_test_case_1),
10833 TEST_CASE_ST(ut_setup, ut_teardown,
10834 test_AES_GCM_authenticated_decryption_test_case_2),
10835 TEST_CASE_ST(ut_setup, ut_teardown,
10836 test_AES_GCM_authenticated_decryption_test_case_3),
10837 TEST_CASE_ST(ut_setup, ut_teardown,
10838 test_AES_GCM_authenticated_decryption_test_case_4),
10839 TEST_CASE_ST(ut_setup, ut_teardown,
10840 test_AES_GCM_authenticated_decryption_test_case_5),
10841 TEST_CASE_ST(ut_setup, ut_teardown,
10842 test_AES_GCM_authenticated_decryption_test_case_6),
10843 TEST_CASE_ST(ut_setup, ut_teardown,
10844 test_AES_GCM_authenticated_decryption_test_case_7),
10847 /** AES GCM Authenticated Encryption 192 bits key */
10848 TEST_CASE_ST(ut_setup, ut_teardown,
10849 test_AES_GCM_auth_encryption_test_case_192_1),
10850 TEST_CASE_ST(ut_setup, ut_teardown,
10851 test_AES_GCM_auth_encryption_test_case_192_2),
10852 TEST_CASE_ST(ut_setup, ut_teardown,
10853 test_AES_GCM_auth_encryption_test_case_192_3),
10854 TEST_CASE_ST(ut_setup, ut_teardown,
10855 test_AES_GCM_auth_encryption_test_case_192_4),
10856 TEST_CASE_ST(ut_setup, ut_teardown,
10857 test_AES_GCM_auth_encryption_test_case_192_5),
10858 TEST_CASE_ST(ut_setup, ut_teardown,
10859 test_AES_GCM_auth_encryption_test_case_192_6),
10860 TEST_CASE_ST(ut_setup, ut_teardown,
10861 test_AES_GCM_auth_encryption_test_case_192_7),
10863 /** AES GCM Authenticated Decryption 192 bits key */
10864 TEST_CASE_ST(ut_setup, ut_teardown,
10865 test_AES_GCM_auth_decryption_test_case_192_1),
10866 TEST_CASE_ST(ut_setup, ut_teardown,
10867 test_AES_GCM_auth_decryption_test_case_192_2),
10868 TEST_CASE_ST(ut_setup, ut_teardown,
10869 test_AES_GCM_auth_decryption_test_case_192_3),
10870 TEST_CASE_ST(ut_setup, ut_teardown,
10871 test_AES_GCM_auth_decryption_test_case_192_4),
10872 TEST_CASE_ST(ut_setup, ut_teardown,
10873 test_AES_GCM_auth_decryption_test_case_192_5),
10874 TEST_CASE_ST(ut_setup, ut_teardown,
10875 test_AES_GCM_auth_decryption_test_case_192_6),
10876 TEST_CASE_ST(ut_setup, ut_teardown,
10877 test_AES_GCM_auth_decryption_test_case_192_7),
10879 /** AES GCM Authenticated Encryption 256 bits key */
10880 TEST_CASE_ST(ut_setup, ut_teardown,
10881 test_AES_GCM_auth_encryption_test_case_256_1),
10882 TEST_CASE_ST(ut_setup, ut_teardown,
10883 test_AES_GCM_auth_encryption_test_case_256_2),
10884 TEST_CASE_ST(ut_setup, ut_teardown,
10885 test_AES_GCM_auth_encryption_test_case_256_3),
10886 TEST_CASE_ST(ut_setup, ut_teardown,
10887 test_AES_GCM_auth_encryption_test_case_256_4),
10888 TEST_CASE_ST(ut_setup, ut_teardown,
10889 test_AES_GCM_auth_encryption_test_case_256_5),
10890 TEST_CASE_ST(ut_setup, ut_teardown,
10891 test_AES_GCM_auth_encryption_test_case_256_6),
10892 TEST_CASE_ST(ut_setup, ut_teardown,
10893 test_AES_GCM_auth_encryption_test_case_256_7),
10895 /** AES GCM Authenticated Decryption 256 bits key */
10896 TEST_CASE_ST(ut_setup, ut_teardown,
10897 test_AES_GCM_auth_decryption_test_case_256_1),
10898 TEST_CASE_ST(ut_setup, ut_teardown,
10899 test_AES_GCM_auth_decryption_test_case_256_2),
10900 TEST_CASE_ST(ut_setup, ut_teardown,
10901 test_AES_GCM_auth_decryption_test_case_256_3),
10902 TEST_CASE_ST(ut_setup, ut_teardown,
10903 test_AES_GCM_auth_decryption_test_case_256_4),
10904 TEST_CASE_ST(ut_setup, ut_teardown,
10905 test_AES_GCM_auth_decryption_test_case_256_5),
10906 TEST_CASE_ST(ut_setup, ut_teardown,
10907 test_AES_GCM_auth_decryption_test_case_256_6),
10908 TEST_CASE_ST(ut_setup, ut_teardown,
10909 test_AES_GCM_auth_decryption_test_case_256_7),
10911 /** AES GMAC Authentication */
10912 TEST_CASE_ST(ut_setup, ut_teardown,
10913 test_AES_GMAC_authentication_test_case_1),
10914 TEST_CASE_ST(ut_setup, ut_teardown,
10915 test_AES_GMAC_authentication_verify_test_case_1),
10916 TEST_CASE_ST(ut_setup, ut_teardown,
10917 test_AES_GMAC_authentication_test_case_2),
10918 TEST_CASE_ST(ut_setup, ut_teardown,
10919 test_AES_GMAC_authentication_verify_test_case_2),
10920 TEST_CASE_ST(ut_setup, ut_teardown,
10921 test_AES_GMAC_authentication_test_case_3),
10922 TEST_CASE_ST(ut_setup, ut_teardown,
10923 test_AES_GMAC_authentication_verify_test_case_3),
10924 TEST_CASE_ST(ut_setup, ut_teardown,
10925 test_AES_GMAC_authentication_test_case_4),
10926 TEST_CASE_ST(ut_setup, ut_teardown,
10927 test_AES_GMAC_authentication_verify_test_case_4),
10929 /** AES CCM Authenticated Encryption 128 bits key */
10930 TEST_CASE_ST(ut_setup, ut_teardown,
10931 test_AES_CCM_authenticated_encryption_test_case_128_1),
10932 TEST_CASE_ST(ut_setup, ut_teardown,
10933 test_AES_CCM_authenticated_encryption_test_case_128_2),
10934 TEST_CASE_ST(ut_setup, ut_teardown,
10935 test_AES_CCM_authenticated_encryption_test_case_128_3),
10937 /** AES CCM Authenticated Decryption 128 bits key*/
10938 TEST_CASE_ST(ut_setup, ut_teardown,
10939 test_AES_CCM_authenticated_decryption_test_case_128_1),
10940 TEST_CASE_ST(ut_setup, ut_teardown,
10941 test_AES_CCM_authenticated_decryption_test_case_128_2),
10942 TEST_CASE_ST(ut_setup, ut_teardown,
10943 test_AES_CCM_authenticated_decryption_test_case_128_3),
10945 /** AES CCM Authenticated Encryption 192 bits key */
10946 TEST_CASE_ST(ut_setup, ut_teardown,
10947 test_AES_CCM_authenticated_encryption_test_case_192_1),
10948 TEST_CASE_ST(ut_setup, ut_teardown,
10949 test_AES_CCM_authenticated_encryption_test_case_192_2),
10950 TEST_CASE_ST(ut_setup, ut_teardown,
10951 test_AES_CCM_authenticated_encryption_test_case_192_3),
10953 /** AES CCM Authenticated Decryption 192 bits key*/
10954 TEST_CASE_ST(ut_setup, ut_teardown,
10955 test_AES_CCM_authenticated_decryption_test_case_192_1),
10956 TEST_CASE_ST(ut_setup, ut_teardown,
10957 test_AES_CCM_authenticated_decryption_test_case_192_2),
10958 TEST_CASE_ST(ut_setup, ut_teardown,
10959 test_AES_CCM_authenticated_decryption_test_case_192_3),
10961 /** AES CCM Authenticated Encryption 256 bits key */
10962 TEST_CASE_ST(ut_setup, ut_teardown,
10963 test_AES_CCM_authenticated_encryption_test_case_256_1),
10964 TEST_CASE_ST(ut_setup, ut_teardown,
10965 test_AES_CCM_authenticated_encryption_test_case_256_2),
10966 TEST_CASE_ST(ut_setup, ut_teardown,
10967 test_AES_CCM_authenticated_encryption_test_case_256_3),
10969 /** AES CCM Authenticated Decryption 256 bits key*/
10970 TEST_CASE_ST(ut_setup, ut_teardown,
10971 test_AES_CCM_authenticated_decryption_test_case_256_1),
10972 TEST_CASE_ST(ut_setup, ut_teardown,
10973 test_AES_CCM_authenticated_decryption_test_case_256_2),
10974 TEST_CASE_ST(ut_setup, ut_teardown,
10975 test_AES_CCM_authenticated_decryption_test_case_256_3),
10977 /** Scatter-Gather */
10978 TEST_CASE_ST(ut_setup, ut_teardown,
10979 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10981 /** Negative tests */
10982 TEST_CASE_ST(ut_setup, ut_teardown,
10983 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10984 TEST_CASE_ST(ut_setup, ut_teardown,
10985 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10986 TEST_CASE_ST(ut_setup, ut_teardown,
10987 authentication_verify_AES128_GMAC_fail_data_corrupt),
10988 TEST_CASE_ST(ut_setup, ut_teardown,
10989 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10990 TEST_CASE_ST(ut_setup, ut_teardown,
10991 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10992 TEST_CASE_ST(ut_setup, ut_teardown,
10993 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10995 TEST_CASES_END() /**< NULL terminate unit test array */
10999 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
11000 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
11001 .setup = testsuite_setup,
11002 .teardown = testsuite_teardown,
11003 .unit_test_cases = {
11004 /** AES GCM Authenticated Encryption */
11005 TEST_CASE_ST(ut_setup, ut_teardown,
11006 test_AES_GCM_authenticated_encryption_test_case_1),
11007 TEST_CASE_ST(ut_setup, ut_teardown,
11008 test_AES_GCM_authenticated_encryption_test_case_2),
11009 TEST_CASE_ST(ut_setup, ut_teardown,
11010 test_AES_GCM_authenticated_encryption_test_case_3),
11011 TEST_CASE_ST(ut_setup, ut_teardown,
11012 test_AES_GCM_authenticated_encryption_test_case_4),
11013 TEST_CASE_ST(ut_setup, ut_teardown,
11014 test_AES_GCM_authenticated_encryption_test_case_5),
11015 TEST_CASE_ST(ut_setup, ut_teardown,
11016 test_AES_GCM_authenticated_encryption_test_case_6),
11017 TEST_CASE_ST(ut_setup, ut_teardown,
11018 test_AES_GCM_authenticated_encryption_test_case_7),
11020 /** AES GCM Authenticated Decryption */
11021 TEST_CASE_ST(ut_setup, ut_teardown,
11022 test_AES_GCM_authenticated_decryption_test_case_1),
11023 TEST_CASE_ST(ut_setup, ut_teardown,
11024 test_AES_GCM_authenticated_decryption_test_case_2),
11025 TEST_CASE_ST(ut_setup, ut_teardown,
11026 test_AES_GCM_authenticated_decryption_test_case_3),
11027 TEST_CASE_ST(ut_setup, ut_teardown,
11028 test_AES_GCM_authenticated_decryption_test_case_4),
11029 TEST_CASE_ST(ut_setup, ut_teardown,
11030 test_AES_GCM_authenticated_decryption_test_case_5),
11031 TEST_CASE_ST(ut_setup, ut_teardown,
11032 test_AES_GCM_authenticated_decryption_test_case_6),
11033 TEST_CASE_ST(ut_setup, ut_teardown,
11034 test_AES_GCM_authenticated_decryption_test_case_7),
11036 /** AES GCM Authenticated Encryption 192 bits key */
11037 TEST_CASE_ST(ut_setup, ut_teardown,
11038 test_AES_GCM_auth_encryption_test_case_192_1),
11039 TEST_CASE_ST(ut_setup, ut_teardown,
11040 test_AES_GCM_auth_encryption_test_case_192_2),
11041 TEST_CASE_ST(ut_setup, ut_teardown,
11042 test_AES_GCM_auth_encryption_test_case_192_3),
11043 TEST_CASE_ST(ut_setup, ut_teardown,
11044 test_AES_GCM_auth_encryption_test_case_192_4),
11045 TEST_CASE_ST(ut_setup, ut_teardown,
11046 test_AES_GCM_auth_encryption_test_case_192_5),
11047 TEST_CASE_ST(ut_setup, ut_teardown,
11048 test_AES_GCM_auth_encryption_test_case_192_6),
11049 TEST_CASE_ST(ut_setup, ut_teardown,
11050 test_AES_GCM_auth_encryption_test_case_192_7),
11052 /** AES GCM Authenticated Decryption 192 bits key */
11053 TEST_CASE_ST(ut_setup, ut_teardown,
11054 test_AES_GCM_auth_decryption_test_case_192_1),
11055 TEST_CASE_ST(ut_setup, ut_teardown,
11056 test_AES_GCM_auth_decryption_test_case_192_2),
11057 TEST_CASE_ST(ut_setup, ut_teardown,
11058 test_AES_GCM_auth_decryption_test_case_192_3),
11059 TEST_CASE_ST(ut_setup, ut_teardown,
11060 test_AES_GCM_auth_decryption_test_case_192_4),
11061 TEST_CASE_ST(ut_setup, ut_teardown,
11062 test_AES_GCM_auth_decryption_test_case_192_5),
11063 TEST_CASE_ST(ut_setup, ut_teardown,
11064 test_AES_GCM_auth_decryption_test_case_192_6),
11065 TEST_CASE_ST(ut_setup, ut_teardown,
11066 test_AES_GCM_auth_decryption_test_case_192_7),
11068 /** AES GCM Authenticated Encryption 256 bits key */
11069 TEST_CASE_ST(ut_setup, ut_teardown,
11070 test_AES_GCM_auth_encryption_test_case_256_1),
11071 TEST_CASE_ST(ut_setup, ut_teardown,
11072 test_AES_GCM_auth_encryption_test_case_256_2),
11073 TEST_CASE_ST(ut_setup, ut_teardown,
11074 test_AES_GCM_auth_encryption_test_case_256_3),
11075 TEST_CASE_ST(ut_setup, ut_teardown,
11076 test_AES_GCM_auth_encryption_test_case_256_4),
11077 TEST_CASE_ST(ut_setup, ut_teardown,
11078 test_AES_GCM_auth_encryption_test_case_256_5),
11079 TEST_CASE_ST(ut_setup, ut_teardown,
11080 test_AES_GCM_auth_encryption_test_case_256_6),
11081 TEST_CASE_ST(ut_setup, ut_teardown,
11082 test_AES_GCM_auth_encryption_test_case_256_7),
11084 /** AES GCM Authenticated Decryption 256 bits key */
11085 TEST_CASE_ST(ut_setup, ut_teardown,
11086 test_AES_GCM_auth_decryption_test_case_256_1),
11087 TEST_CASE_ST(ut_setup, ut_teardown,
11088 test_AES_GCM_auth_decryption_test_case_256_2),
11089 TEST_CASE_ST(ut_setup, ut_teardown,
11090 test_AES_GCM_auth_decryption_test_case_256_3),
11091 TEST_CASE_ST(ut_setup, ut_teardown,
11092 test_AES_GCM_auth_decryption_test_case_256_4),
11093 TEST_CASE_ST(ut_setup, ut_teardown,
11094 test_AES_GCM_auth_decryption_test_case_256_5),
11095 TEST_CASE_ST(ut_setup, ut_teardown,
11096 test_AES_GCM_auth_decryption_test_case_256_6),
11097 TEST_CASE_ST(ut_setup, ut_teardown,
11098 test_AES_GCM_auth_decryption_test_case_256_7),
11100 /** AES GCM Authenticated Encryption big aad size */
11101 TEST_CASE_ST(ut_setup, ut_teardown,
11102 test_AES_GCM_auth_encryption_test_case_aad_1),
11103 TEST_CASE_ST(ut_setup, ut_teardown,
11104 test_AES_GCM_auth_encryption_test_case_aad_2),
11106 /** AES GCM Authenticated Decryption big aad size */
11107 TEST_CASE_ST(ut_setup, ut_teardown,
11108 test_AES_GCM_auth_decryption_test_case_aad_1),
11109 TEST_CASE_ST(ut_setup, ut_teardown,
11110 test_AES_GCM_auth_decryption_test_case_aad_2),
11112 /** AES GMAC Authentication */
11113 TEST_CASE_ST(ut_setup, ut_teardown,
11114 test_AES_GMAC_authentication_test_case_1),
11115 TEST_CASE_ST(ut_setup, ut_teardown,
11116 test_AES_GMAC_authentication_verify_test_case_1),
11117 TEST_CASE_ST(ut_setup, ut_teardown,
11118 test_AES_GMAC_authentication_test_case_3),
11119 TEST_CASE_ST(ut_setup, ut_teardown,
11120 test_AES_GMAC_authentication_verify_test_case_3),
11121 TEST_CASE_ST(ut_setup, ut_teardown,
11122 test_AES_GMAC_authentication_test_case_4),
11123 TEST_CASE_ST(ut_setup, ut_teardown,
11124 test_AES_GMAC_authentication_verify_test_case_4),
11126 /** Negative tests */
11127 TEST_CASE_ST(ut_setup, ut_teardown,
11128 authentication_verify_AES128_GMAC_fail_data_corrupt),
11129 TEST_CASE_ST(ut_setup, ut_teardown,
11130 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11132 /** Out of place tests */
11133 TEST_CASE_ST(ut_setup, ut_teardown,
11134 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11135 TEST_CASE_ST(ut_setup, ut_teardown,
11136 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11138 /** Session-less tests */
11139 TEST_CASE_ST(ut_setup, ut_teardown,
11140 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11141 TEST_CASE_ST(ut_setup, ut_teardown,
11142 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11144 /** Scatter-Gather */
11145 TEST_CASE_ST(ut_setup, ut_teardown,
11146 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11148 TEST_CASES_END() /**< NULL terminate unit test array */
11152 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
11153 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
11154 .setup = testsuite_setup,
11155 .teardown = testsuite_teardown,
11156 .unit_test_cases = {
11157 /** KASUMI encrypt only (UEA1) */
11158 TEST_CASE_ST(ut_setup, ut_teardown,
11159 test_kasumi_encryption_test_case_1),
11160 TEST_CASE_ST(ut_setup, ut_teardown,
11161 test_kasumi_encryption_test_case_1_sgl),
11162 TEST_CASE_ST(ut_setup, ut_teardown,
11163 test_kasumi_encryption_test_case_2),
11164 TEST_CASE_ST(ut_setup, ut_teardown,
11165 test_kasumi_encryption_test_case_3),
11166 TEST_CASE_ST(ut_setup, ut_teardown,
11167 test_kasumi_encryption_test_case_4),
11168 TEST_CASE_ST(ut_setup, ut_teardown,
11169 test_kasumi_encryption_test_case_5),
11170 /** KASUMI decrypt only (UEA1) */
11171 TEST_CASE_ST(ut_setup, ut_teardown,
11172 test_kasumi_decryption_test_case_1),
11173 TEST_CASE_ST(ut_setup, ut_teardown,
11174 test_kasumi_decryption_test_case_2),
11175 TEST_CASE_ST(ut_setup, ut_teardown,
11176 test_kasumi_decryption_test_case_3),
11177 TEST_CASE_ST(ut_setup, ut_teardown,
11178 test_kasumi_decryption_test_case_4),
11179 TEST_CASE_ST(ut_setup, ut_teardown,
11180 test_kasumi_decryption_test_case_5),
11182 TEST_CASE_ST(ut_setup, ut_teardown,
11183 test_kasumi_encryption_test_case_1_oop),
11184 TEST_CASE_ST(ut_setup, ut_teardown,
11185 test_kasumi_encryption_test_case_1_oop_sgl),
11188 TEST_CASE_ST(ut_setup, ut_teardown,
11189 test_kasumi_decryption_test_case_1_oop),
11191 /** KASUMI hash only (UIA1) */
11192 TEST_CASE_ST(ut_setup, ut_teardown,
11193 test_kasumi_hash_generate_test_case_1),
11194 TEST_CASE_ST(ut_setup, ut_teardown,
11195 test_kasumi_hash_generate_test_case_2),
11196 TEST_CASE_ST(ut_setup, ut_teardown,
11197 test_kasumi_hash_generate_test_case_3),
11198 TEST_CASE_ST(ut_setup, ut_teardown,
11199 test_kasumi_hash_generate_test_case_4),
11200 TEST_CASE_ST(ut_setup, ut_teardown,
11201 test_kasumi_hash_generate_test_case_5),
11202 TEST_CASE_ST(ut_setup, ut_teardown,
11203 test_kasumi_hash_generate_test_case_6),
11204 TEST_CASE_ST(ut_setup, ut_teardown,
11205 test_kasumi_hash_verify_test_case_1),
11206 TEST_CASE_ST(ut_setup, ut_teardown,
11207 test_kasumi_hash_verify_test_case_2),
11208 TEST_CASE_ST(ut_setup, ut_teardown,
11209 test_kasumi_hash_verify_test_case_3),
11210 TEST_CASE_ST(ut_setup, ut_teardown,
11211 test_kasumi_hash_verify_test_case_4),
11212 TEST_CASE_ST(ut_setup, ut_teardown,
11213 test_kasumi_hash_verify_test_case_5),
11214 TEST_CASE_ST(ut_setup, ut_teardown,
11215 test_kasumi_cipher_auth_test_case_1),
11217 /** KASUMI generate auth, then encrypt (F8) */
11218 TEST_CASE_ST(ut_setup, ut_teardown,
11219 test_kasumi_auth_cipher_test_case_1),
11220 TEST_CASE_ST(ut_setup, ut_teardown,
11221 test_kasumi_auth_cipher_test_case_2),
11222 TEST_CASE_ST(ut_setup, ut_teardown,
11223 test_kasumi_auth_cipher_test_case_2_oop),
11224 TEST_CASE_ST(ut_setup, ut_teardown,
11225 test_kasumi_auth_cipher_test_case_2_sgl),
11226 TEST_CASE_ST(ut_setup, ut_teardown,
11227 test_kasumi_auth_cipher_test_case_2_oop_sgl),
11229 /** KASUMI decrypt (F8), then verify auth */
11230 TEST_CASE_ST(ut_setup, ut_teardown,
11231 test_kasumi_auth_cipher_verify_test_case_1),
11232 TEST_CASE_ST(ut_setup, ut_teardown,
11233 test_kasumi_auth_cipher_verify_test_case_2),
11234 TEST_CASE_ST(ut_setup, ut_teardown,
11235 test_kasumi_auth_cipher_verify_test_case_2_oop),
11236 TEST_CASE_ST(ut_setup, ut_teardown,
11237 test_kasumi_auth_cipher_verify_test_case_2_sgl),
11238 TEST_CASE_ST(ut_setup, ut_teardown,
11239 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
11240 TEST_CASES_END() /**< NULL terminate unit test array */
11243 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
11244 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
11245 .setup = testsuite_setup,
11246 .teardown = testsuite_teardown,
11247 .unit_test_cases = {
11248 /** SNOW 3G encrypt only (UEA2) */
11249 TEST_CASE_ST(ut_setup, ut_teardown,
11250 test_snow3g_encryption_test_case_1),
11251 TEST_CASE_ST(ut_setup, ut_teardown,
11252 test_snow3g_encryption_test_case_2),
11253 TEST_CASE_ST(ut_setup, ut_teardown,
11254 test_snow3g_encryption_test_case_3),
11255 TEST_CASE_ST(ut_setup, ut_teardown,
11256 test_snow3g_encryption_test_case_4),
11257 TEST_CASE_ST(ut_setup, ut_teardown,
11258 test_snow3g_encryption_test_case_5),
11259 TEST_CASE_ST(ut_setup, ut_teardown,
11260 test_snow3g_auth_cipher_with_digest_test_case_1),
11262 TEST_CASE_ST(ut_setup, ut_teardown,
11263 test_snow3g_encryption_test_case_1_oop),
11264 TEST_CASE_ST(ut_setup, ut_teardown,
11265 test_snow3g_encryption_test_case_1_oop_sgl),
11266 TEST_CASE_ST(ut_setup, ut_teardown,
11267 test_snow3g_decryption_test_case_1_oop),
11269 TEST_CASE_ST(ut_setup, ut_teardown,
11270 test_snow3g_encryption_test_case_1_offset_oop),
11272 /** SNOW 3G decrypt only (UEA2) */
11273 TEST_CASE_ST(ut_setup, ut_teardown,
11274 test_snow3g_decryption_test_case_1),
11275 TEST_CASE_ST(ut_setup, ut_teardown,
11276 test_snow3g_decryption_test_case_2),
11277 TEST_CASE_ST(ut_setup, ut_teardown,
11278 test_snow3g_decryption_test_case_3),
11279 TEST_CASE_ST(ut_setup, ut_teardown,
11280 test_snow3g_decryption_test_case_4),
11281 TEST_CASE_ST(ut_setup, ut_teardown,
11282 test_snow3g_decryption_test_case_5),
11283 TEST_CASE_ST(ut_setup, ut_teardown,
11284 test_snow3g_decryption_with_digest_test_case_1),
11285 TEST_CASE_ST(ut_setup, ut_teardown,
11286 test_snow3g_hash_generate_test_case_1),
11287 TEST_CASE_ST(ut_setup, ut_teardown,
11288 test_snow3g_hash_generate_test_case_2),
11289 TEST_CASE_ST(ut_setup, ut_teardown,
11290 test_snow3g_hash_generate_test_case_3),
11291 /* Tests with buffers which length is not byte-aligned */
11292 TEST_CASE_ST(ut_setup, ut_teardown,
11293 test_snow3g_hash_generate_test_case_4),
11294 TEST_CASE_ST(ut_setup, ut_teardown,
11295 test_snow3g_hash_generate_test_case_5),
11296 TEST_CASE_ST(ut_setup, ut_teardown,
11297 test_snow3g_hash_generate_test_case_6),
11298 TEST_CASE_ST(ut_setup, ut_teardown,
11299 test_snow3g_hash_verify_test_case_1),
11300 TEST_CASE_ST(ut_setup, ut_teardown,
11301 test_snow3g_hash_verify_test_case_2),
11302 TEST_CASE_ST(ut_setup, ut_teardown,
11303 test_snow3g_hash_verify_test_case_3),
11304 /* Tests with buffers which length is not byte-aligned */
11305 TEST_CASE_ST(ut_setup, ut_teardown,
11306 test_snow3g_hash_verify_test_case_4),
11307 TEST_CASE_ST(ut_setup, ut_teardown,
11308 test_snow3g_hash_verify_test_case_5),
11309 TEST_CASE_ST(ut_setup, ut_teardown,
11310 test_snow3g_hash_verify_test_case_6),
11311 TEST_CASE_ST(ut_setup, ut_teardown,
11312 test_snow3g_cipher_auth_test_case_1),
11314 /** SNOW 3G generate auth, then encrypt (UEA2) */
11315 TEST_CASE_ST(ut_setup, ut_teardown,
11316 test_snow3g_auth_cipher_test_case_1),
11317 TEST_CASE_ST(ut_setup, ut_teardown,
11318 test_snow3g_auth_cipher_test_case_2),
11319 TEST_CASE_ST(ut_setup, ut_teardown,
11320 test_snow3g_auth_cipher_test_case_2_oop),
11321 TEST_CASE_ST(ut_setup, ut_teardown,
11322 test_snow3g_auth_cipher_part_digest_enc),
11323 TEST_CASE_ST(ut_setup, ut_teardown,
11324 test_snow3g_auth_cipher_part_digest_enc_oop),
11325 TEST_CASE_ST(ut_setup, ut_teardown,
11326 test_snow3g_auth_cipher_test_case_3_sgl),
11327 TEST_CASE_ST(ut_setup, ut_teardown,
11328 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11329 TEST_CASE_ST(ut_setup, ut_teardown,
11330 test_snow3g_auth_cipher_part_digest_enc_sgl),
11331 TEST_CASE_ST(ut_setup, ut_teardown,
11332 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11334 /** SNOW 3G decrypt (UEA2), then verify auth */
11335 TEST_CASE_ST(ut_setup, ut_teardown,
11336 test_snow3g_auth_cipher_verify_test_case_1),
11337 TEST_CASE_ST(ut_setup, ut_teardown,
11338 test_snow3g_auth_cipher_verify_test_case_2),
11339 TEST_CASE_ST(ut_setup, ut_teardown,
11340 test_snow3g_auth_cipher_verify_test_case_2_oop),
11341 TEST_CASE_ST(ut_setup, ut_teardown,
11342 test_snow3g_auth_cipher_verify_part_digest_enc),
11343 TEST_CASE_ST(ut_setup, ut_teardown,
11344 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11345 TEST_CASE_ST(ut_setup, ut_teardown,
11346 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11347 TEST_CASE_ST(ut_setup, ut_teardown,
11348 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11349 TEST_CASE_ST(ut_setup, ut_teardown,
11350 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11351 TEST_CASE_ST(ut_setup, ut_teardown,
11352 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11354 TEST_CASES_END() /**< NULL terminate unit test array */
11358 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
11359 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
11360 .setup = testsuite_setup,
11361 .teardown = testsuite_teardown,
11362 .unit_test_cases = {
11363 /** ZUC encrypt only (EEA3) */
11364 TEST_CASE_ST(ut_setup, ut_teardown,
11365 test_zuc_encryption_test_case_1),
11366 TEST_CASE_ST(ut_setup, ut_teardown,
11367 test_zuc_encryption_test_case_2),
11368 TEST_CASE_ST(ut_setup, ut_teardown,
11369 test_zuc_encryption_test_case_3),
11370 TEST_CASE_ST(ut_setup, ut_teardown,
11371 test_zuc_encryption_test_case_4),
11372 TEST_CASE_ST(ut_setup, ut_teardown,
11373 test_zuc_encryption_test_case_5),
11374 TEST_CASE_ST(ut_setup, ut_teardown,
11375 test_zuc_hash_generate_test_case_1),
11376 TEST_CASE_ST(ut_setup, ut_teardown,
11377 test_zuc_hash_generate_test_case_2),
11378 TEST_CASE_ST(ut_setup, ut_teardown,
11379 test_zuc_hash_generate_test_case_3),
11380 TEST_CASE_ST(ut_setup, ut_teardown,
11381 test_zuc_hash_generate_test_case_4),
11382 TEST_CASE_ST(ut_setup, ut_teardown,
11383 test_zuc_hash_generate_test_case_5),
11384 TEST_CASE_ST(ut_setup, ut_teardown,
11385 test_zuc_encryption_test_case_6_sgl),
11386 TEST_CASES_END() /**< NULL terminate unit test array */
11390 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
11391 .suite_name = "Crypto CAAM JR Unit Test Suite",
11392 .setup = testsuite_setup,
11393 .teardown = testsuite_teardown,
11394 .unit_test_cases = {
11395 TEST_CASE_ST(ut_setup, ut_teardown,
11396 test_device_configure_invalid_dev_id),
11397 TEST_CASE_ST(ut_setup, ut_teardown,
11398 test_multi_session),
11400 TEST_CASE_ST(ut_setup, ut_teardown,
11401 test_AES_chain_caam_jr_all),
11402 TEST_CASE_ST(ut_setup, ut_teardown,
11403 test_3DES_chain_caam_jr_all),
11404 TEST_CASE_ST(ut_setup, ut_teardown,
11405 test_AES_cipheronly_caam_jr_all),
11406 TEST_CASE_ST(ut_setup, ut_teardown,
11407 test_3DES_cipheronly_caam_jr_all),
11408 TEST_CASE_ST(ut_setup, ut_teardown,
11409 test_authonly_caam_jr_all),
11411 TEST_CASES_END() /**< NULL terminate unit test array */
11415 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
11416 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
11417 .setup = testsuite_setup,
11418 .teardown = testsuite_teardown,
11419 .unit_test_cases = {
11420 TEST_CASE_ST(ut_setup, ut_teardown,
11421 test_device_configure_invalid_dev_id),
11422 TEST_CASE_ST(ut_setup, ut_teardown,
11423 test_multi_session),
11425 TEST_CASE_ST(ut_setup, ut_teardown,
11426 test_AES_chain_dpaa_sec_all),
11427 TEST_CASE_ST(ut_setup, ut_teardown,
11428 test_3DES_chain_dpaa_sec_all),
11429 TEST_CASE_ST(ut_setup, ut_teardown,
11430 test_AES_cipheronly_dpaa_sec_all),
11431 TEST_CASE_ST(ut_setup, ut_teardown,
11432 test_3DES_cipheronly_dpaa_sec_all),
11433 TEST_CASE_ST(ut_setup, ut_teardown,
11434 test_authonly_dpaa_sec_all),
11436 /** AES GCM Authenticated Encryption */
11437 TEST_CASE_ST(ut_setup, ut_teardown,
11438 test_AES_GCM_authenticated_encryption_test_case_1),
11439 TEST_CASE_ST(ut_setup, ut_teardown,
11440 test_AES_GCM_authenticated_encryption_test_case_2),
11441 TEST_CASE_ST(ut_setup, ut_teardown,
11442 test_AES_GCM_authenticated_encryption_test_case_3),
11443 TEST_CASE_ST(ut_setup, ut_teardown,
11444 test_AES_GCM_authenticated_encryption_test_case_4),
11445 TEST_CASE_ST(ut_setup, ut_teardown,
11446 test_AES_GCM_authenticated_encryption_test_case_5),
11447 TEST_CASE_ST(ut_setup, ut_teardown,
11448 test_AES_GCM_authenticated_encryption_test_case_6),
11449 TEST_CASE_ST(ut_setup, ut_teardown,
11450 test_AES_GCM_authenticated_encryption_test_case_7),
11452 /** AES GCM Authenticated Decryption */
11453 TEST_CASE_ST(ut_setup, ut_teardown,
11454 test_AES_GCM_authenticated_decryption_test_case_1),
11455 TEST_CASE_ST(ut_setup, ut_teardown,
11456 test_AES_GCM_authenticated_decryption_test_case_2),
11457 TEST_CASE_ST(ut_setup, ut_teardown,
11458 test_AES_GCM_authenticated_decryption_test_case_3),
11459 TEST_CASE_ST(ut_setup, ut_teardown,
11460 test_AES_GCM_authenticated_decryption_test_case_4),
11461 TEST_CASE_ST(ut_setup, ut_teardown,
11462 test_AES_GCM_authenticated_decryption_test_case_5),
11463 TEST_CASE_ST(ut_setup, ut_teardown,
11464 test_AES_GCM_authenticated_decryption_test_case_6),
11465 TEST_CASE_ST(ut_setup, ut_teardown,
11466 test_AES_GCM_authenticated_decryption_test_case_7),
11468 /** AES GCM Authenticated Encryption 256 bits key */
11469 TEST_CASE_ST(ut_setup, ut_teardown,
11470 test_AES_GCM_auth_encryption_test_case_256_1),
11471 TEST_CASE_ST(ut_setup, ut_teardown,
11472 test_AES_GCM_auth_encryption_test_case_256_2),
11473 TEST_CASE_ST(ut_setup, ut_teardown,
11474 test_AES_GCM_auth_encryption_test_case_256_3),
11475 TEST_CASE_ST(ut_setup, ut_teardown,
11476 test_AES_GCM_auth_encryption_test_case_256_4),
11477 TEST_CASE_ST(ut_setup, ut_teardown,
11478 test_AES_GCM_auth_encryption_test_case_256_5),
11479 TEST_CASE_ST(ut_setup, ut_teardown,
11480 test_AES_GCM_auth_encryption_test_case_256_6),
11481 TEST_CASE_ST(ut_setup, ut_teardown,
11482 test_AES_GCM_auth_encryption_test_case_256_7),
11484 /** AES GCM Authenticated Decryption 256 bits key */
11485 TEST_CASE_ST(ut_setup, ut_teardown,
11486 test_AES_GCM_auth_decryption_test_case_256_1),
11487 TEST_CASE_ST(ut_setup, ut_teardown,
11488 test_AES_GCM_auth_decryption_test_case_256_2),
11489 TEST_CASE_ST(ut_setup, ut_teardown,
11490 test_AES_GCM_auth_decryption_test_case_256_3),
11491 TEST_CASE_ST(ut_setup, ut_teardown,
11492 test_AES_GCM_auth_decryption_test_case_256_4),
11493 TEST_CASE_ST(ut_setup, ut_teardown,
11494 test_AES_GCM_auth_decryption_test_case_256_5),
11495 TEST_CASE_ST(ut_setup, ut_teardown,
11496 test_AES_GCM_auth_decryption_test_case_256_6),
11497 TEST_CASE_ST(ut_setup, ut_teardown,
11498 test_AES_GCM_auth_decryption_test_case_256_7),
11500 /** Out of place tests */
11501 TEST_CASE_ST(ut_setup, ut_teardown,
11502 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11503 TEST_CASE_ST(ut_setup, ut_teardown,
11504 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11506 /** Scatter-Gather */
11507 TEST_CASE_ST(ut_setup, ut_teardown,
11508 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11509 TEST_CASE_ST(ut_setup, ut_teardown,
11510 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11511 TEST_CASE_ST(ut_setup, ut_teardown,
11512 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11513 TEST_CASE_ST(ut_setup, ut_teardown,
11514 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11516 TEST_CASES_END() /**< NULL terminate unit test array */
11520 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
11521 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
11522 .setup = testsuite_setup,
11523 .teardown = testsuite_teardown,
11524 .unit_test_cases = {
11525 TEST_CASE_ST(ut_setup, ut_teardown,
11526 test_device_configure_invalid_dev_id),
11527 TEST_CASE_ST(ut_setup, ut_teardown,
11528 test_multi_session),
11530 TEST_CASE_ST(ut_setup, ut_teardown,
11531 test_AES_chain_dpaa2_sec_all),
11532 TEST_CASE_ST(ut_setup, ut_teardown,
11533 test_3DES_chain_dpaa2_sec_all),
11534 TEST_CASE_ST(ut_setup, ut_teardown,
11535 test_AES_cipheronly_dpaa2_sec_all),
11536 TEST_CASE_ST(ut_setup, ut_teardown,
11537 test_3DES_cipheronly_dpaa2_sec_all),
11538 TEST_CASE_ST(ut_setup, ut_teardown,
11539 test_authonly_dpaa2_sec_all),
11541 /** AES GCM Authenticated Encryption */
11542 TEST_CASE_ST(ut_setup, ut_teardown,
11543 test_AES_GCM_authenticated_encryption_test_case_1),
11544 TEST_CASE_ST(ut_setup, ut_teardown,
11545 test_AES_GCM_authenticated_encryption_test_case_2),
11546 TEST_CASE_ST(ut_setup, ut_teardown,
11547 test_AES_GCM_authenticated_encryption_test_case_3),
11548 TEST_CASE_ST(ut_setup, ut_teardown,
11549 test_AES_GCM_authenticated_encryption_test_case_4),
11550 TEST_CASE_ST(ut_setup, ut_teardown,
11551 test_AES_GCM_authenticated_encryption_test_case_5),
11552 TEST_CASE_ST(ut_setup, ut_teardown,
11553 test_AES_GCM_authenticated_encryption_test_case_6),
11554 TEST_CASE_ST(ut_setup, ut_teardown,
11555 test_AES_GCM_authenticated_encryption_test_case_7),
11557 /** AES GCM Authenticated Decryption */
11558 TEST_CASE_ST(ut_setup, ut_teardown,
11559 test_AES_GCM_authenticated_decryption_test_case_1),
11560 TEST_CASE_ST(ut_setup, ut_teardown,
11561 test_AES_GCM_authenticated_decryption_test_case_2),
11562 TEST_CASE_ST(ut_setup, ut_teardown,
11563 test_AES_GCM_authenticated_decryption_test_case_3),
11564 TEST_CASE_ST(ut_setup, ut_teardown,
11565 test_AES_GCM_authenticated_decryption_test_case_4),
11566 TEST_CASE_ST(ut_setup, ut_teardown,
11567 test_AES_GCM_authenticated_decryption_test_case_5),
11568 TEST_CASE_ST(ut_setup, ut_teardown,
11569 test_AES_GCM_authenticated_decryption_test_case_6),
11570 TEST_CASE_ST(ut_setup, ut_teardown,
11571 test_AES_GCM_authenticated_decryption_test_case_7),
11573 /** AES GCM Authenticated Encryption 192 bits key */
11574 TEST_CASE_ST(ut_setup, ut_teardown,
11575 test_AES_GCM_auth_encryption_test_case_192_1),
11576 TEST_CASE_ST(ut_setup, ut_teardown,
11577 test_AES_GCM_auth_encryption_test_case_192_2),
11578 TEST_CASE_ST(ut_setup, ut_teardown,
11579 test_AES_GCM_auth_encryption_test_case_192_3),
11580 TEST_CASE_ST(ut_setup, ut_teardown,
11581 test_AES_GCM_auth_encryption_test_case_192_4),
11582 TEST_CASE_ST(ut_setup, ut_teardown,
11583 test_AES_GCM_auth_encryption_test_case_192_5),
11584 TEST_CASE_ST(ut_setup, ut_teardown,
11585 test_AES_GCM_auth_encryption_test_case_192_6),
11586 TEST_CASE_ST(ut_setup, ut_teardown,
11587 test_AES_GCM_auth_encryption_test_case_192_7),
11589 /** AES GCM Authenticated Decryption 192 bits key */
11590 TEST_CASE_ST(ut_setup, ut_teardown,
11591 test_AES_GCM_auth_decryption_test_case_192_1),
11592 TEST_CASE_ST(ut_setup, ut_teardown,
11593 test_AES_GCM_auth_decryption_test_case_192_2),
11594 TEST_CASE_ST(ut_setup, ut_teardown,
11595 test_AES_GCM_auth_decryption_test_case_192_3),
11596 TEST_CASE_ST(ut_setup, ut_teardown,
11597 test_AES_GCM_auth_decryption_test_case_192_4),
11598 TEST_CASE_ST(ut_setup, ut_teardown,
11599 test_AES_GCM_auth_decryption_test_case_192_5),
11600 TEST_CASE_ST(ut_setup, ut_teardown,
11601 test_AES_GCM_auth_decryption_test_case_192_6),
11602 TEST_CASE_ST(ut_setup, ut_teardown,
11603 test_AES_GCM_auth_decryption_test_case_192_7),
11605 /** AES GCM Authenticated Encryption 256 bits key */
11606 TEST_CASE_ST(ut_setup, ut_teardown,
11607 test_AES_GCM_auth_encryption_test_case_256_1),
11608 TEST_CASE_ST(ut_setup, ut_teardown,
11609 test_AES_GCM_auth_encryption_test_case_256_2),
11610 TEST_CASE_ST(ut_setup, ut_teardown,
11611 test_AES_GCM_auth_encryption_test_case_256_3),
11612 TEST_CASE_ST(ut_setup, ut_teardown,
11613 test_AES_GCM_auth_encryption_test_case_256_4),
11614 TEST_CASE_ST(ut_setup, ut_teardown,
11615 test_AES_GCM_auth_encryption_test_case_256_5),
11616 TEST_CASE_ST(ut_setup, ut_teardown,
11617 test_AES_GCM_auth_encryption_test_case_256_6),
11618 TEST_CASE_ST(ut_setup, ut_teardown,
11619 test_AES_GCM_auth_encryption_test_case_256_7),
11621 /** AES GCM Authenticated Decryption 256 bits key */
11622 TEST_CASE_ST(ut_setup, ut_teardown,
11623 test_AES_GCM_auth_decryption_test_case_256_1),
11624 TEST_CASE_ST(ut_setup, ut_teardown,
11625 test_AES_GCM_auth_decryption_test_case_256_2),
11626 TEST_CASE_ST(ut_setup, ut_teardown,
11627 test_AES_GCM_auth_decryption_test_case_256_3),
11628 TEST_CASE_ST(ut_setup, ut_teardown,
11629 test_AES_GCM_auth_decryption_test_case_256_4),
11630 TEST_CASE_ST(ut_setup, ut_teardown,
11631 test_AES_GCM_auth_decryption_test_case_256_5),
11632 TEST_CASE_ST(ut_setup, ut_teardown,
11633 test_AES_GCM_auth_decryption_test_case_256_6),
11634 TEST_CASE_ST(ut_setup, ut_teardown,
11635 test_AES_GCM_auth_decryption_test_case_256_7),
11637 /** Out of place tests */
11638 TEST_CASE_ST(ut_setup, ut_teardown,
11639 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11640 TEST_CASE_ST(ut_setup, ut_teardown,
11641 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11643 /** Scatter-Gather */
11644 TEST_CASE_ST(ut_setup, ut_teardown,
11645 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11646 TEST_CASE_ST(ut_setup, ut_teardown,
11647 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11648 TEST_CASE_ST(ut_setup, ut_teardown,
11649 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11650 TEST_CASE_ST(ut_setup, ut_teardown,
11651 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11653 TEST_CASES_END() /**< NULL terminate unit test array */
11657 static struct unit_test_suite cryptodev_null_testsuite = {
11658 .suite_name = "Crypto Device NULL Unit Test Suite",
11659 .setup = testsuite_setup,
11660 .teardown = testsuite_teardown,
11661 .unit_test_cases = {
11662 TEST_CASE_ST(ut_setup, ut_teardown,
11663 test_null_invalid_operation),
11664 TEST_CASE_ST(ut_setup, ut_teardown,
11665 test_null_burst_operation),
11666 TEST_CASE_ST(ut_setup, ut_teardown,
11667 test_AES_chain_null_all),
11668 TEST_CASE_ST(ut_setup, ut_teardown,
11669 test_AES_cipheronly_null_all),
11670 TEST_CASE_ST(ut_setup, ut_teardown,
11671 test_authonly_null_all),
11673 TEST_CASES_END() /**< NULL terminate unit test array */
11677 static struct unit_test_suite cryptodev_armv8_testsuite = {
11678 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
11679 .setup = testsuite_setup,
11680 .teardown = testsuite_teardown,
11681 .unit_test_cases = {
11682 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
11684 /** Negative tests */
11685 TEST_CASE_ST(ut_setup, ut_teardown,
11686 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11687 TEST_CASE_ST(ut_setup, ut_teardown,
11688 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11690 TEST_CASES_END() /**< NULL terminate unit test array */
11694 static struct unit_test_suite cryptodev_mrvl_testsuite = {
11695 .suite_name = "Crypto Device Marvell Component Test Suite",
11696 .setup = testsuite_setup,
11697 .teardown = testsuite_teardown,
11698 .unit_test_cases = {
11699 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11700 TEST_CASE_ST(ut_setup, ut_teardown,
11701 test_multi_session_random_usage),
11702 TEST_CASE_ST(ut_setup, ut_teardown,
11703 test_AES_chain_mrvl_all),
11704 TEST_CASE_ST(ut_setup, ut_teardown,
11705 test_AES_cipheronly_mrvl_all),
11706 TEST_CASE_ST(ut_setup, ut_teardown,
11707 test_authonly_mrvl_all),
11708 TEST_CASE_ST(ut_setup, ut_teardown,
11709 test_3DES_chain_mrvl_all),
11710 TEST_CASE_ST(ut_setup, ut_teardown,
11711 test_3DES_cipheronly_mrvl_all),
11713 /** Negative tests */
11714 TEST_CASE_ST(ut_setup, ut_teardown,
11715 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11716 TEST_CASE_ST(ut_setup, ut_teardown,
11717 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11718 TEST_CASE_ST(ut_setup, ut_teardown,
11719 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11720 TEST_CASE_ST(ut_setup, ut_teardown,
11721 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11723 TEST_CASES_END() /**< NULL terminate unit test array */
11727 static struct unit_test_suite cryptodev_ccp_testsuite = {
11728 .suite_name = "Crypto Device CCP Unit Test Suite",
11729 .setup = testsuite_setup,
11730 .teardown = testsuite_teardown,
11731 .unit_test_cases = {
11732 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11733 TEST_CASE_ST(ut_setup, ut_teardown,
11734 test_multi_session_random_usage),
11735 TEST_CASE_ST(ut_setup, ut_teardown,
11736 test_AES_chain_ccp_all),
11737 TEST_CASE_ST(ut_setup, ut_teardown,
11738 test_AES_cipheronly_ccp_all),
11739 TEST_CASE_ST(ut_setup, ut_teardown,
11740 test_3DES_chain_ccp_all),
11741 TEST_CASE_ST(ut_setup, ut_teardown,
11742 test_3DES_cipheronly_ccp_all),
11743 TEST_CASE_ST(ut_setup, ut_teardown,
11744 test_authonly_ccp_all),
11746 /** Negative tests */
11747 TEST_CASE_ST(ut_setup, ut_teardown,
11748 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11749 TEST_CASE_ST(ut_setup, ut_teardown,
11750 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11751 TEST_CASE_ST(ut_setup, ut_teardown,
11752 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11753 TEST_CASE_ST(ut_setup, ut_teardown,
11754 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11756 TEST_CASES_END() /**< NULL terminate unit test array */
11760 static struct unit_test_suite cryptodev_octeontx_testsuite = {
11761 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
11762 .setup = testsuite_setup,
11763 .teardown = testsuite_teardown,
11764 .unit_test_cases = {
11765 TEST_CASE_ST(ut_setup, ut_teardown,
11766 test_AES_chain_octeontx_all),
11767 TEST_CASE_ST(ut_setup, ut_teardown,
11768 test_AES_cipheronly_octeontx_all),
11769 TEST_CASE_ST(ut_setup, ut_teardown,
11770 test_3DES_chain_octeontx_all),
11771 TEST_CASE_ST(ut_setup, ut_teardown,
11772 test_3DES_cipheronly_octeontx_all),
11773 TEST_CASE_ST(ut_setup, ut_teardown,
11774 test_authonly_octeontx_all),
11776 /** AES GCM Authenticated Encryption */
11777 TEST_CASE_ST(ut_setup, ut_teardown,
11778 test_AES_GCM_authenticated_encryption_test_case_1),
11779 TEST_CASE_ST(ut_setup, ut_teardown,
11780 test_AES_GCM_authenticated_encryption_test_case_2),
11781 TEST_CASE_ST(ut_setup, ut_teardown,
11782 test_AES_GCM_authenticated_encryption_test_case_3),
11783 TEST_CASE_ST(ut_setup, ut_teardown,
11784 test_AES_GCM_authenticated_encryption_test_case_4),
11785 TEST_CASE_ST(ut_setup, ut_teardown,
11786 test_AES_GCM_authenticated_encryption_test_case_5),
11787 TEST_CASE_ST(ut_setup, ut_teardown,
11788 test_AES_GCM_authenticated_encryption_test_case_6),
11789 TEST_CASE_ST(ut_setup, ut_teardown,
11790 test_AES_GCM_authenticated_encryption_test_case_7),
11792 /** AES GCM Authenticated Decryption */
11793 TEST_CASE_ST(ut_setup, ut_teardown,
11794 test_AES_GCM_authenticated_decryption_test_case_1),
11795 TEST_CASE_ST(ut_setup, ut_teardown,
11796 test_AES_GCM_authenticated_decryption_test_case_2),
11797 TEST_CASE_ST(ut_setup, ut_teardown,
11798 test_AES_GCM_authenticated_decryption_test_case_3),
11799 TEST_CASE_ST(ut_setup, ut_teardown,
11800 test_AES_GCM_authenticated_decryption_test_case_4),
11801 TEST_CASE_ST(ut_setup, ut_teardown,
11802 test_AES_GCM_authenticated_decryption_test_case_5),
11803 TEST_CASE_ST(ut_setup, ut_teardown,
11804 test_AES_GCM_authenticated_decryption_test_case_6),
11805 TEST_CASE_ST(ut_setup, ut_teardown,
11806 test_AES_GCM_authenticated_decryption_test_case_7),
11807 /** AES GMAC Authentication */
11808 TEST_CASE_ST(ut_setup, ut_teardown,
11809 test_AES_GMAC_authentication_test_case_1),
11810 TEST_CASE_ST(ut_setup, ut_teardown,
11811 test_AES_GMAC_authentication_verify_test_case_1),
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_AES_GMAC_authentication_test_case_2),
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_AES_GMAC_authentication_verify_test_case_2),
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_AES_GMAC_authentication_test_case_3),
11818 TEST_CASE_ST(ut_setup, ut_teardown,
11819 test_AES_GMAC_authentication_verify_test_case_3),
11821 /** SNOW 3G encrypt only (UEA2) */
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_snow3g_encryption_test_case_1),
11824 TEST_CASE_ST(ut_setup, ut_teardown,
11825 test_snow3g_encryption_test_case_2),
11826 TEST_CASE_ST(ut_setup, ut_teardown,
11827 test_snow3g_encryption_test_case_3),
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_snow3g_encryption_test_case_4),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_snow3g_encryption_test_case_5),
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_snow3g_encryption_test_case_1_oop),
11835 TEST_CASE_ST(ut_setup, ut_teardown,
11836 test_snow3g_decryption_test_case_1_oop),
11837 TEST_CASE_ST(ut_setup, ut_teardown,
11838 test_snow3g_encryption_test_case_1_oop_sgl),
11840 /** SNOW 3G decrypt only (UEA2) */
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_snow3g_decryption_test_case_1),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_snow3g_decryption_test_case_2),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_snow3g_decryption_test_case_3),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_snow3g_decryption_test_case_4),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_snow3g_decryption_test_case_5),
11852 TEST_CASE_ST(ut_setup, ut_teardown,
11853 test_snow3g_hash_generate_test_case_1),
11854 TEST_CASE_ST(ut_setup, ut_teardown,
11855 test_snow3g_hash_generate_test_case_2),
11856 TEST_CASE_ST(ut_setup, ut_teardown,
11857 test_snow3g_hash_generate_test_case_3),
11858 TEST_CASE_ST(ut_setup, ut_teardown,
11859 test_snow3g_hash_verify_test_case_1),
11860 TEST_CASE_ST(ut_setup, ut_teardown,
11861 test_snow3g_hash_verify_test_case_2),
11862 TEST_CASE_ST(ut_setup, ut_teardown,
11863 test_snow3g_hash_verify_test_case_3),
11865 /** ZUC encrypt only (EEA3) */
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_zuc_encryption_test_case_1),
11868 TEST_CASE_ST(ut_setup, ut_teardown,
11869 test_zuc_encryption_test_case_2),
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_zuc_encryption_test_case_3),
11872 TEST_CASE_ST(ut_setup, ut_teardown,
11873 test_zuc_encryption_test_case_4),
11874 TEST_CASE_ST(ut_setup, ut_teardown,
11875 test_zuc_encryption_test_case_5),
11876 TEST_CASE_ST(ut_setup, ut_teardown,
11877 test_zuc_hash_generate_test_case_1),
11878 TEST_CASE_ST(ut_setup, ut_teardown,
11879 test_zuc_hash_generate_test_case_2),
11880 TEST_CASE_ST(ut_setup, ut_teardown,
11881 test_zuc_hash_generate_test_case_3),
11882 TEST_CASE_ST(ut_setup, ut_teardown,
11883 test_zuc_hash_generate_test_case_4),
11884 TEST_CASE_ST(ut_setup, ut_teardown,
11885 test_zuc_hash_generate_test_case_5),
11886 TEST_CASE_ST(ut_setup, ut_teardown,
11887 test_zuc_encryption_test_case_6_sgl),
11889 /** KASUMI encrypt only (UEA1) */
11890 TEST_CASE_ST(ut_setup, ut_teardown,
11891 test_kasumi_encryption_test_case_1),
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_kasumi_encryption_test_case_2),
11894 TEST_CASE_ST(ut_setup, ut_teardown,
11895 test_kasumi_encryption_test_case_3),
11896 TEST_CASE_ST(ut_setup, ut_teardown,
11897 test_kasumi_encryption_test_case_4),
11898 TEST_CASE_ST(ut_setup, ut_teardown,
11899 test_kasumi_encryption_test_case_5),
11900 TEST_CASE_ST(ut_setup, ut_teardown,
11901 test_kasumi_encryption_test_case_1_sgl),
11902 TEST_CASE_ST(ut_setup, ut_teardown,
11903 test_kasumi_encryption_test_case_1_oop_sgl),
11904 /** KASUMI decrypt only (UEA1) */
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_kasumi_decryption_test_case_1),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_kasumi_decryption_test_case_2),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_kasumi_decryption_test_case_3),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_kasumi_decryption_test_case_4),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_kasumi_decryption_test_case_5),
11916 TEST_CASE_ST(ut_setup, ut_teardown,
11917 test_kasumi_encryption_test_case_1_oop),
11918 TEST_CASE_ST(ut_setup, ut_teardown,
11919 test_kasumi_decryption_test_case_1_oop),
11921 /** KASUMI hash only (UIA1) */
11922 TEST_CASE_ST(ut_setup, ut_teardown,
11923 test_kasumi_hash_generate_test_case_1),
11924 TEST_CASE_ST(ut_setup, ut_teardown,
11925 test_kasumi_hash_generate_test_case_2),
11926 TEST_CASE_ST(ut_setup, ut_teardown,
11927 test_kasumi_hash_generate_test_case_3),
11928 TEST_CASE_ST(ut_setup, ut_teardown,
11929 test_kasumi_hash_generate_test_case_4),
11930 TEST_CASE_ST(ut_setup, ut_teardown,
11931 test_kasumi_hash_generate_test_case_5),
11932 TEST_CASE_ST(ut_setup, ut_teardown,
11933 test_kasumi_hash_generate_test_case_6),
11934 TEST_CASE_ST(ut_setup, ut_teardown,
11935 test_kasumi_hash_verify_test_case_1),
11936 TEST_CASE_ST(ut_setup, ut_teardown,
11937 test_kasumi_hash_verify_test_case_2),
11938 TEST_CASE_ST(ut_setup, ut_teardown,
11939 test_kasumi_hash_verify_test_case_3),
11940 TEST_CASE_ST(ut_setup, ut_teardown,
11941 test_kasumi_hash_verify_test_case_4),
11942 TEST_CASE_ST(ut_setup, ut_teardown,
11943 test_kasumi_hash_verify_test_case_5),
11946 TEST_CASE_ST(ut_setup, ut_teardown,
11947 test_null_cipher_only_operation),
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_null_auth_only_operation),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_null_cipher_auth_operation),
11952 TEST_CASE_ST(ut_setup, ut_teardown,
11953 test_null_auth_cipher_operation),
11955 /** Negative tests */
11956 TEST_CASE_ST(ut_setup, ut_teardown,
11957 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11960 TEST_CASE_ST(ut_setup, ut_teardown,
11961 authentication_verify_AES128_GMAC_fail_data_corrupt),
11962 TEST_CASE_ST(ut_setup, ut_teardown,
11963 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11968 TEST_CASES_END() /**< NULL terminate unit test array */
11973 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
11975 gbl_driver_id = rte_cryptodev_driver_id_get(
11976 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
11978 if (gbl_driver_id == -1) {
11979 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
11980 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
11981 "are enabled in config file to run this testsuite.\n");
11982 return TEST_SKIPPED;
11985 return unit_test_suite_runner(&cryptodev_qat_testsuite);
11989 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
11991 gbl_driver_id = rte_cryptodev_driver_id_get(
11992 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
11994 if (gbl_driver_id == -1) {
11995 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
11996 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
11997 "in config file to run this testsuite.\n");
11998 return TEST_FAILED;
12001 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12005 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12007 gbl_driver_id = rte_cryptodev_driver_id_get(
12008 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12010 if (gbl_driver_id == -1) {
12011 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12012 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12013 "in config file to run this testsuite.\n");
12014 return TEST_SKIPPED;
12017 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
12021 test_cryptodev_openssl(void)
12023 gbl_driver_id = rte_cryptodev_driver_id_get(
12024 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
12026 if (gbl_driver_id == -1) {
12027 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
12028 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
12029 "in config file to run this testsuite.\n");
12030 return TEST_SKIPPED;
12033 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
12037 test_cryptodev_aesni_gcm(void)
12039 gbl_driver_id = rte_cryptodev_driver_id_get(
12040 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12042 if (gbl_driver_id == -1) {
12043 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
12044 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
12045 "in config file to run this testsuite.\n");
12046 return TEST_SKIPPED;
12049 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
12053 test_cryptodev_null(void)
12055 gbl_driver_id = rte_cryptodev_driver_id_get(
12056 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
12058 if (gbl_driver_id == -1) {
12059 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
12060 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
12061 "in config file to run this testsuite.\n");
12062 return TEST_SKIPPED;
12065 return unit_test_suite_runner(&cryptodev_null_testsuite);
12069 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
12071 gbl_driver_id = rte_cryptodev_driver_id_get(
12072 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
12074 if (gbl_driver_id == -1) {
12075 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
12076 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
12077 "in config file to run this testsuite.\n");
12078 return TEST_SKIPPED;
12081 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
12085 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
12087 gbl_driver_id = rte_cryptodev_driver_id_get(
12088 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
12090 if (gbl_driver_id == -1) {
12091 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12092 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
12093 "in config file to run this testsuite.\n");
12094 return TEST_SKIPPED;
12097 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
12101 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
12103 gbl_driver_id = rte_cryptodev_driver_id_get(
12104 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
12106 if (gbl_driver_id == -1) {
12107 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12108 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
12109 "in config file to run this testsuite.\n");
12110 return TEST_SKIPPED;
12113 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
12117 test_cryptodev_armv8(void)
12119 gbl_driver_id = rte_cryptodev_driver_id_get(
12120 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
12122 if (gbl_driver_id == -1) {
12123 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
12124 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
12125 "in config file to run this testsuite.\n");
12126 return TEST_SKIPPED;
12129 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
12133 test_cryptodev_mrvl(void)
12135 gbl_driver_id = rte_cryptodev_driver_id_get(
12136 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
12138 if (gbl_driver_id == -1) {
12139 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
12140 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
12141 "in config file to run this testsuite.\n");
12142 return TEST_SKIPPED;
12145 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
12148 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12151 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
12153 gbl_driver_id = rte_cryptodev_driver_id_get(
12154 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
12156 if (gbl_driver_id == -1) {
12157 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
12158 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
12159 "in config file to run this testsuite.\n");
12160 return TEST_SKIPPED;
12163 if (rte_cryptodev_driver_id_get(
12164 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
12165 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
12166 " enabled in config file to run this testsuite.\n");
12167 return TEST_SKIPPED;
12169 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
12172 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
12177 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12179 gbl_driver_id = rte_cryptodev_driver_id_get(
12180 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
12182 if (gbl_driver_id == -1) {
12183 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
12184 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
12185 "in config file to run this testsuite.\n");
12186 return TEST_SKIPPED;
12189 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
12193 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12195 gbl_driver_id = rte_cryptodev_driver_id_get(
12196 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
12198 if (gbl_driver_id == -1) {
12199 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
12200 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
12201 "in config file to run this testsuite.\n");
12202 return TEST_SKIPPED;
12205 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
12209 test_cryptodev_ccp(void)
12211 gbl_driver_id = rte_cryptodev_driver_id_get(
12212 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
12214 if (gbl_driver_id == -1) {
12215 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
12216 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
12217 "in config file to run this testsuite.\n");
12218 return TEST_FAILED;
12221 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
12225 test_cryptodev_octeontx(void)
12227 gbl_driver_id = rte_cryptodev_driver_id_get(
12228 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
12229 if (gbl_driver_id == -1) {
12230 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
12231 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
12232 "enabled in config file to run this "
12234 return TEST_FAILED;
12236 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
12240 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
12242 gbl_driver_id = rte_cryptodev_driver_id_get(
12243 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
12245 if (gbl_driver_id == -1) {
12246 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
12247 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
12248 "in config file to run this testsuite.\n");
12249 return TEST_FAILED;
12252 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
12255 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
12256 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
12257 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
12258 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
12259 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
12260 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
12261 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
12262 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
12263 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
12264 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
12265 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
12266 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
12267 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
12268 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
12269 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
12270 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);